[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)

2023-11-13 Thread Haojian Wu via lldb-commits

https://github.com/hokein updated 
https://github.com/llvm/llvm-project/pull/71928

>From 08c3b1a40b508d360f47bed6d7d42050c18b01a0 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Fri, 10 Nov 2023 12:35:10 +0100
Subject: [PATCH 1/3] [LLDB] Display artificial __promise and __coro_frame
 variables.

See the discussion in #69309.
---
 .../CPlusPlus/CPPLanguageRuntime.cpp|  6 +-
 .../generic/coroutine_handle/TestCoroutineHandle.py | 13 -
 .../generic/coroutine_handle/main.cpp   |  2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c2488eaa9f5b50d..b5dfd07bdff2453 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -41,7 +41,11 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
 : LanguageRuntime(process) {}
 
 bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
-  return name == g_this;
+  // FIXME: use a list when the list grows more.
+  return name == g_this ||
+  // Artificial coroutine-related variables emitted by clang.
+ name == ConstString("__promise") ||
+ name == ConstString("__coro_frame");
 }
 
 bool CPPLanguageRuntime::GetObjectDescription(Stream &str,
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
index 42ee32f9ccca58d..bcb1da6dc3838c8 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
@@ -78,8 +78,19 @@ def do_test(self, stdlib_type):
 ],
 )
 
-# Run until after the `co_yield`
 process = self.process()
+
+# Break at a coroutine body
+lldbutil.continue_to_source_breakpoint(
+  self, process, "// Break at co_yield", lldb.SBFileSpec("main.cpp", 
False)
+)
+# Expect artificial variables to be displayed
+self.expect(
+  "frame variable",
+  substrs=['__promise', '__coro_frame']
+)
+
+# Run until after the `co_yield`
 lldbutil.continue_to_source_breakpoint(
 self, process, "// Break after co_yield", 
lldb.SBFileSpec("main.cpp", False)
 )
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
index 8cb81c3bc9f4c4e..4523b7c7baf80aa 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
@@ -33,7 +33,7 @@ struct int_generator {
   ~int_generator() { hdl.destroy(); }
 };
 
-int_generator my_generator_func() { co_yield 42; }
+int_generator my_generator_func() { co_yield 42; } // Break at co_yield
 
 // This is an empty function which we call just so the debugger has
 // a place to reliably set a breakpoint on.

>From f684e1972eb3dc600603c67bf4a755d07971d7d2 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Fri, 10 Nov 2023 15:16:08 +0100
Subject: [PATCH 2/3] Remove an unneeded FIXME.

---
 .../Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp   | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index b5dfd07bdff2453..2d14cf0d7a62add 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -41,9 +41,8 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
 : LanguageRuntime(process) {}
 
 bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
-  // FIXME: use a list when the list grows more.
   return name == g_this ||
-  // Artificial coroutine-related variables emitted by clang.
+ // Artificial coroutine-related variables emitted by clang.
  name == ConstString("__promise") ||
  name == ConstString("__coro_frame");
 }

>From 43ab6022f2a63a57d8195dcdd83b0c54ae66b1f6 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Mon, 13 Nov 2023 09:29:59 +0100
Subject: [PATCH 3/3] Use static constants for builtin variables.

---
 .../LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp  | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPL

[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)

2023-11-13 Thread Haojian Wu via lldb-commits


@@ -78,8 +78,19 @@ def do_test(self, stdlib_type):
 ],
 )
 
-# Run until after the `co_yield`
 process = self.process()
+
+# Break at a coroutine body
+lldbutil.continue_to_source_breakpoint(
+  self, process, "// Break at co_yield", lldb.SBFileSpec("main.cpp", 
False)

hokein wrote:

Do you mean we run the lldb command like `self.runCmd("break 
my_generator_func")` to stop at a break point?

BTW, this file is using this `continue_to_source_breakpoint ` pattern in other 
places, I was following this pattern.  





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


[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)

2023-11-13 Thread Haojian Wu via lldb-commits


@@ -41,7 +41,10 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
 : LanguageRuntime(process) {}
 
 bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
-  return name == g_this;
+  return name == g_this ||
+ // Artificial coroutine-related variables emitted by clang.
+ name == ConstString("__promise") ||
+ name == ConstString("__coro_frame");

hokein wrote:

Good point, thanks!

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


[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)

2023-11-13 Thread Haojian Wu via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)

2023-11-13 Thread Haojian Wu via lldb-commits

https://github.com/hokein commented:

Thanks for the comments.

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


[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)

2023-11-13 Thread Michael Buch via lldb-commits


@@ -78,8 +78,19 @@ def do_test(self, stdlib_type):
 ],
 )
 
-# Run until after the `co_yield`
 process = self.process()
+
+# Break at a coroutine body
+lldbutil.continue_to_source_breakpoint(
+  self, process, "// Break at co_yield", lldb.SBFileSpec("main.cpp", 
False)

Michael137 wrote:

I meant you can just do
```
 lldbutil.continue_to_source_breakpoint(
  self, process, "int_generator my_generator_func", 
lldb.SBFileSpec("main.cpp", False)
```
Or sometimes we put something like `std::puts("Break here");` into the source, 
instead of relying on comments.

> BTW, this file is using this continue_to_source_breakpoint  pattern in other 
> places, I was following this pattern.

Yup, it isn't very strictly enforced. Also it isn't part of the LLDB testing 
guidelines. Maybe it should be

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


[Lldb-commits] [lldb] Remove hardware index from watchpoints and breakpoints (PR #72012)

2023-11-13 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> The Linux MIPS support has been ripped out and the remaining support for MIPS 
> probably gets no real testing

Don't know the status but the BSD's still have some MIPS support.

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


[Lldb-commits] [lldb] 0515ccc - [lldb] Fix a typo in the comment, NFC

2023-11-13 Thread Haojian Wu via lldb-commits

Author: Haojian Wu
Date: 2023-11-13T10:12:55+01:00
New Revision: 0515ccc0c48b919dae03edc391304e66cdb75d66

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

LOG: [lldb] Fix a typo in the comment, NFC

Added: 


Modified: 

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

Removed: 




diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
index 42ee32f9ccca58d..2dbbf969dfcdae2 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
@@ -83,7 +83,7 @@ def do_test(self, stdlib_type):
 lldbutil.continue_to_source_breakpoint(
 self, process, "// Break after co_yield", 
lldb.SBFileSpec("main.cpp", False)
 )
-# We correctly show the updated value inside `prommise.current_value`.
+# We correctly show the updated value inside `promise.current_value`.
 self.expect_expr(
 "gen.hdl",
 result_children=[



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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Extract static data member decl creation into helper (PR #72109)

2023-11-13 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/72109

This patch extracts the logic to create a static variable member decl into a 
helper. We will use this in an upcoming patch which will need to call exactly 
the same logic from a separate part of the DWARF parser.

>From 3513963ac45aff2296f687e6c7b315e0f25b8586 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 7 Nov 2023 10:57:08 +
Subject: [PATCH] [lldb][DWARFASTParserClang][NFC] Extract static data member
 decl creation into helper

This patch extracts the logic to parse static
variable member declarations into a helper. We
will use this in an upcoming patch which will
need to call exactly the same logic from a separate
part of the DWARF parser.
---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 121 --
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  40 ++
 2 files changed, 94 insertions(+), 67 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index eb894328547ea5e..2039608bc8f1e1b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2534,28 +2534,6 @@ DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit 
&comp_unit,
 }
 
 namespace {
-/// Parsed form of all attributes that are relevant for parsing type members.
-struct MemberAttributes {
-  explicit MemberAttributes(const DWARFDIE &die, const DWARFDIE &parent_die,
-ModuleSP module_sp);
-  const char *name = nullptr;
-  /// Indicates how many bits into the word (according to the host endianness)
-  /// the low-order bit of the field starts. Can be negative.
-  int64_t bit_offset = 0;
-  /// Indicates the size of the field in bits.
-  size_t bit_size = 0;
-  uint64_t data_bit_offset = UINT64_MAX;
-  AccessType accessibility = eAccessNone;
-  std::optional byte_size;
-  std::optional const_value_form;
-  DWARFFormValue encoding_form;
-  /// Indicates the byte offset of the word from the base address of the
-  /// structure.
-  uint32_t member_byte_offset = UINT32_MAX;
-  bool is_artificial = false;
-  bool is_declaration = false;
-};
-
 /// Parsed form of all attributes that are relevant for parsing Objective-C
 /// properties.
 struct PropertyAttributes {
@@ -2684,9 +2662,8 @@ std::vector &VariantPart::members() { 
return this->_members; }
 
 DiscriminantValue &VariantPart::discriminant() { return this->_discriminant; }
 
-MemberAttributes::MemberAttributes(const DWARFDIE &die,
-   const DWARFDIE &parent_die,
-   ModuleSP module_sp) {
+DWARFASTParserClang::MemberAttributes::MemberAttributes(
+const DWARFDIE &die, const DWARFDIE &parent_die, ModuleSP module_sp) {
   DWARFAttributes attributes = die.GetAttributes();
   for (size_t i = 0; i < attributes.Size(); ++i) {
 const dw_attr_t attr = attributes.AttributeAtIndex(i);
@@ -2908,13 +2885,63 @@ llvm::Expected 
DWARFASTParserClang::ExtractIntFromFormValue(
   return result;
 }
 
+void DWARFASTParserClang::CreateStaticMemberVariable(
+const DWARFDIE &die, const MemberAttributes &attrs,
+const lldb_private::CompilerType &class_clang_type) {
+  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+  assert(die.Tag() == DW_TAG_member);
+
+  Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
+
+  if (!var_type)
+return;
+
+  auto accessibility =
+  attrs.accessibility == eAccessNone ? eAccessPublic : attrs.accessibility;
+
+  CompilerType ct = var_type->GetForwardCompilerType();
+  clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType(
+  class_clang_type, attrs.name, ct, accessibility);
+  if (!v) {
+LLDB_LOG(log, "Failed to add variable to the record type");
+return;
+  }
+
+  bool unused;
+  // TODO: Support float/double static members as well.
+  if (!ct.IsIntegerOrEnumerationType(unused))
+return;
+
+  auto maybe_const_form_value = attrs.const_value_form;
+
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of an inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!maybe_const_form_value) {
+maybe_const_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_const_form_value)
+  return;
+  }
+
+  llvm::Expected const_value_or_err =
+  ExtractIntFromFormValue(ct, *attrs.const_value_form);
+  if (!const_value_or_err) {
+LLDB_LOG_ERROR(log, const_value_or_err.takeError(),
+   "Failed to add const value to variable {1}: {0}",
+   v->getQualifiedNameAsString());
+return;
+  }
+
+  TypeSystemClang::SetIntegerInitializerForVariable(v, *const_value_or_err);
+}
+
 void DWARFASTParserClang::ParseSingleMember(
 const DWARFDIE &die, const DWARFDIE &parent_die,

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Extract static data member decl creation into helper (PR #72109)

2023-11-13 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This patch extracts the logic to create a static variable member decl into a 
helper. We will use this in an upcoming patch which will need to call exactly 
the same logic from a separate part of the DWARF parser.

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


2 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(+54-67) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h (+40) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index eb894328547ea5e..2039608bc8f1e1b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2534,28 +2534,6 @@ DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit 
&comp_unit,
 }
 
 namespace {
-/// Parsed form of all attributes that are relevant for parsing type members.
-struct MemberAttributes {
-  explicit MemberAttributes(const DWARFDIE &die, const DWARFDIE &parent_die,
-ModuleSP module_sp);
-  const char *name = nullptr;
-  /// Indicates how many bits into the word (according to the host endianness)
-  /// the low-order bit of the field starts. Can be negative.
-  int64_t bit_offset = 0;
-  /// Indicates the size of the field in bits.
-  size_t bit_size = 0;
-  uint64_t data_bit_offset = UINT64_MAX;
-  AccessType accessibility = eAccessNone;
-  std::optional byte_size;
-  std::optional const_value_form;
-  DWARFFormValue encoding_form;
-  /// Indicates the byte offset of the word from the base address of the
-  /// structure.
-  uint32_t member_byte_offset = UINT32_MAX;
-  bool is_artificial = false;
-  bool is_declaration = false;
-};
-
 /// Parsed form of all attributes that are relevant for parsing Objective-C
 /// properties.
 struct PropertyAttributes {
@@ -2684,9 +2662,8 @@ std::vector &VariantPart::members() { 
return this->_members; }
 
 DiscriminantValue &VariantPart::discriminant() { return this->_discriminant; }
 
-MemberAttributes::MemberAttributes(const DWARFDIE &die,
-   const DWARFDIE &parent_die,
-   ModuleSP module_sp) {
+DWARFASTParserClang::MemberAttributes::MemberAttributes(
+const DWARFDIE &die, const DWARFDIE &parent_die, ModuleSP module_sp) {
   DWARFAttributes attributes = die.GetAttributes();
   for (size_t i = 0; i < attributes.Size(); ++i) {
 const dw_attr_t attr = attributes.AttributeAtIndex(i);
@@ -2908,13 +2885,63 @@ llvm::Expected 
DWARFASTParserClang::ExtractIntFromFormValue(
   return result;
 }
 
+void DWARFASTParserClang::CreateStaticMemberVariable(
+const DWARFDIE &die, const MemberAttributes &attrs,
+const lldb_private::CompilerType &class_clang_type) {
+  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+  assert(die.Tag() == DW_TAG_member);
+
+  Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
+
+  if (!var_type)
+return;
+
+  auto accessibility =
+  attrs.accessibility == eAccessNone ? eAccessPublic : attrs.accessibility;
+
+  CompilerType ct = var_type->GetForwardCompilerType();
+  clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType(
+  class_clang_type, attrs.name, ct, accessibility);
+  if (!v) {
+LLDB_LOG(log, "Failed to add variable to the record type");
+return;
+  }
+
+  bool unused;
+  // TODO: Support float/double static members as well.
+  if (!ct.IsIntegerOrEnumerationType(unused))
+return;
+
+  auto maybe_const_form_value = attrs.const_value_form;
+
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of an inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!maybe_const_form_value) {
+maybe_const_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_const_form_value)
+  return;
+  }
+
+  llvm::Expected const_value_or_err =
+  ExtractIntFromFormValue(ct, *attrs.const_value_form);
+  if (!const_value_or_err) {
+LLDB_LOG_ERROR(log, const_value_or_err.takeError(),
+   "Failed to add const value to variable {1}: {0}",
+   v->getQualifiedNameAsString());
+return;
+  }
+
+  TypeSystemClang::SetIntegerInitializerForVariable(v, *const_value_or_err);
+}
+
 void DWARFASTParserClang::ParseSingleMember(
 const DWARFDIE &die, const DWARFDIE &parent_die,
 const lldb_private::CompilerType &class_clang_type,
 lldb::AccessType default_accessibility,
 lldb_private::ClangASTImporter::LayoutInfo &layout_info,
 FieldInfo &last_field_info) {
-  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
   // This function can only parse DW_TAG_member.
   assert(die.Tag() == DW_TAG_member);
 
@@ -2940,

[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

> For all 3 API command test, the error is same i.e.,
>
> AssertionError: 'error: Couldn't look up symbols:
>  std::deque>::size() const
> ' is not success

This feels like a version problem. Perhaps the libstdc++ on your system isn't 
the same version as the `-dev` package you installed?

Beyond that, it's hard to say without having a machine in front of me, and is 
probably not worth the time to figure out. I hate to say it, but I'd just make 
a note of these failing tests and make sure there aren't more failing tests 
when your changes are present.

> error: Failed to save core file for process: no ObjectFile plugins were able 
> to save a core for this process
' did not return successfully

I can't see any reason this should fail, so again, make note of it for later.

> Not sure if we are missing some other dependencies to pass these tests (plus 
> isn't there any file which mention these required dependencies? Would have 
> been much more easier 🙂).

You might have needed `build-essential`. This is listed in 
https://lldb.llvm.org/resources/build.html#optional-dependencies but also we 
call it optional which isn't great.

More broadly the llvm project has been thinking about docker images to tackle 
this sort of thing. If you had an Arm64 machine, you could use Linaro's, but we 
don't run builders on x86 unfortunately.

> Also there are a lot of unsupported tests as well on our system. Is this an 
> issue as well?

Unsupported is stuff like must be running BSD, must have this program 
installed, etc, so this is not a problem unless every single test was being 
marked unsupported. Like on Windows, it's normal to have a few 100 unsupported.

So yeah, it's not ideal, but make a note of what failed and then compare with 
your changes. If it's the same failures, you're fine (I don't think that what 
you're changing could break those tests anyway).

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


[Lldb-commits] [lldb] Centralize the code that figures out which memory ranges to save into core files (PR #71772)

2023-11-13 Thread antoine moynault via lldb-commits

antmox wrote:

Hello @clayborg ! Looks like this patch broke lldb-aarch64-windows bot:  
https://lab.llvm.org/buildbot/#/builders/219/builds/6868
Could you please look at this ?

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


[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)

2023-11-13 Thread Haojian Wu via lldb-commits

https://github.com/hokein updated 
https://github.com/llvm/llvm-project/pull/71928

>From 08c3b1a40b508d360f47bed6d7d42050c18b01a0 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Fri, 10 Nov 2023 12:35:10 +0100
Subject: [PATCH 1/4] [LLDB] Display artificial __promise and __coro_frame
 variables.

See the discussion in #69309.
---
 .../CPlusPlus/CPPLanguageRuntime.cpp|  6 +-
 .../generic/coroutine_handle/TestCoroutineHandle.py | 13 -
 .../generic/coroutine_handle/main.cpp   |  2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index c2488eaa9f5b50d..b5dfd07bdff2453 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -41,7 +41,11 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
 : LanguageRuntime(process) {}
 
 bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
-  return name == g_this;
+  // FIXME: use a list when the list grows more.
+  return name == g_this ||
+  // Artificial coroutine-related variables emitted by clang.
+ name == ConstString("__promise") ||
+ name == ConstString("__coro_frame");
 }
 
 bool CPPLanguageRuntime::GetObjectDescription(Stream &str,
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
index 42ee32f9ccca58d..bcb1da6dc3838c8 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py
@@ -78,8 +78,19 @@ def do_test(self, stdlib_type):
 ],
 )
 
-# Run until after the `co_yield`
 process = self.process()
+
+# Break at a coroutine body
+lldbutil.continue_to_source_breakpoint(
+  self, process, "// Break at co_yield", lldb.SBFileSpec("main.cpp", 
False)
+)
+# Expect artificial variables to be displayed
+self.expect(
+  "frame variable",
+  substrs=['__promise', '__coro_frame']
+)
+
+# Run until after the `co_yield`
 lldbutil.continue_to_source_breakpoint(
 self, process, "// Break after co_yield", 
lldb.SBFileSpec("main.cpp", False)
 )
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
index 8cb81c3bc9f4c4e..4523b7c7baf80aa 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/main.cpp
@@ -33,7 +33,7 @@ struct int_generator {
   ~int_generator() { hdl.destroy(); }
 };
 
-int_generator my_generator_func() { co_yield 42; }
+int_generator my_generator_func() { co_yield 42; } // Break at co_yield
 
 // This is an empty function which we call just so the debugger has
 // a place to reliably set a breakpoint on.

>From f684e1972eb3dc600603c67bf4a755d07971d7d2 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Fri, 10 Nov 2023 15:16:08 +0100
Subject: [PATCH 2/4] Remove an unneeded FIXME.

---
 .../Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp   | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index b5dfd07bdff2453..2d14cf0d7a62add 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -41,9 +41,8 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
 : LanguageRuntime(process) {}
 
 bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
-  // FIXME: use a list when the list grows more.
   return name == g_this ||
-  // Artificial coroutine-related variables emitted by clang.
+ // Artificial coroutine-related variables emitted by clang.
  name == ConstString("__promise") ||
  name == ConstString("__coro_frame");
 }

>From 43ab6022f2a63a57d8195dcdd83b0c54ae66b1f6 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Mon, 13 Nov 2023 09:29:59 +0100
Subject: [PATCH 3/4] Use static constants for builtin variables.

---
 .../LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp  | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPL

[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)

2023-11-13 Thread Haojian Wu via lldb-commits


@@ -78,8 +78,19 @@ def do_test(self, stdlib_type):
 ],
 )
 
-# Run until after the `co_yield`
 process = self.process()
+
+# Break at a coroutine body
+lldbutil.continue_to_source_breakpoint(
+  self, process, "// Break at co_yield", lldb.SBFileSpec("main.cpp", 
False)

hokein wrote:

I see, thanks for the explanation. Fixed now.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits

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

From 7f228a5c2ef65ba595ca9b7c0d7227cd82f63b3f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 7 Nov 2023 16:57:18 -0300
Subject: [PATCH] [lldb] colorize symbols in image lookup

---
 lldb/include/lldb/Core/Address.h  |  5 +-
 lldb/include/lldb/Symbol/Symbol.h |  3 +-
 lldb/include/lldb/Symbol/SymbolContext.h  |  6 ++-
 lldb/source/Commands/CommandObjectTarget.cpp  | 14 --
 lldb/source/Core/Address.cpp  | 49 ---
 lldb/source/Symbol/Symbol.cpp | 16 --
 lldb/source/Symbol/SymbolContext.cpp  | 15 --
 .../Commands/command-image-lookup-color.test  | 25 ++
 8 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test

diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index b19e694427546f8..63cf68a3a99e2b9 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -247,7 +247,10 @@ class Address {
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
 uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+bool all_ranges = false, const char *pattern = nullptr) const;
+
+  static void DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern = nullptr);
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index 44a2d560010fe40..fb2da73ecb0a857 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -175,7 +175,8 @@ class Symbol : public SymbolContextScope {
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
   void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  Target *target,
+  const char *pattern = nullptr) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index b0f5ffead2a1656..5633bac88b54217 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -151,7 +151,8 @@ class SymbolContext {
const Address &so_addr, bool show_fullpaths,
bool show_module, bool show_inlined_frames,
bool show_function_arguments,
-   bool show_function_name) const;
+   bool show_function_name,
+   const char *pattern = nullptr) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -218,7 +219,8 @@ class SymbolContext {
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error);
 
   void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  Target *target,
+  const char *pattern = nullptr) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 8f052d0a7b837e2..1513730e95da280 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -8,6 +8,7 @@
 
 #include "CommandObjectTarget.h"
 
+#include "lldb/Core/Address.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/Module.h"
@@ -1534,7 +1535,7 @@ static void DumpOsoFilesTable(Stream &strm,
 
 static void DumpAddress(ExecutionContextScope *exe_scope,
 const Address &so_addr, bool verbose, bool all_ranges,
-Stream &strm) {
+Stream &strm, const char *pattern = nullptr) {
   strm.IndentMore();
   strm.Indent("Address: ");
   so_addr.Dump(&strm, exe_scope, Address::DumpStyleModuleWithFileAddress);
@@ -1544,13 +1545,13 @@ static void DumpAddress(ExecutionContextScope 
*exe_scope,
   strm.Indent("Summary: ");
   const uint32_t save_indent = strm.GetIndentLevel();
   strm.SetIndentLevel(save_indent + 13);
-  so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription);
+  so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription, 
Address::DumpStyleInvalid, UINT32_MAX, false, pattern);
   strm.SetIndentLevel(save_indent);
   // Print out detailed address information when verbose is enabled
   if (verbose) {
 strm.EOL();
 so_addr.Dump(&strm, exe_scope, Address::DumpStyleDetailedSymbolContext,
- Address::DumpStyleInvalid, UINT32_MAX, all_ranges);
+ Address::DumpStyleInvalid, UINT32_MAX, all_ranges, pattern);
   }
   strm.IndentLess(

[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits

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

From a857d725625ea0d094da1860316f5204f11c9ba1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 7 Nov 2023 16:57:18 -0300
Subject: [PATCH] [lldb] colorize symbols in image lookup

---
 lldb/include/lldb/Core/Address.h  |  5 +-
 lldb/include/lldb/Symbol/Symbol.h |  3 +-
 lldb/include/lldb/Symbol/SymbolContext.h  |  6 ++-
 lldb/source/Commands/CommandObjectTarget.cpp  | 14 --
 lldb/source/Core/Address.cpp  | 49 ---
 lldb/source/Symbol/Symbol.cpp | 16 --
 lldb/source/Symbol/SymbolContext.cpp  | 15 --
 .../Commands/command-image-lookup-color.test  | 25 ++
 8 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test

diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index b19e694427546f8..63cf68a3a99e2b9 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -247,7 +247,10 @@ class Address {
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
 uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+bool all_ranges = false, const char *pattern = nullptr) const;
+
+  static void DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern = nullptr);
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index 44a2d560010fe40..fb2da73ecb0a857 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -175,7 +175,8 @@ class Symbol : public SymbolContextScope {
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
   void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  Target *target,
+  const char *pattern = nullptr) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index b0f5ffead2a1656..5633bac88b54217 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -151,7 +151,8 @@ class SymbolContext {
const Address &so_addr, bool show_fullpaths,
bool show_module, bool show_inlined_frames,
bool show_function_arguments,
-   bool show_function_name) const;
+   bool show_function_name,
+   const char *pattern = nullptr) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -218,7 +219,8 @@ class SymbolContext {
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error);
 
   void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  Target *target,
+  const char *pattern = nullptr) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 8f052d0a7b837e2..1513730e95da280 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -8,6 +8,7 @@
 
 #include "CommandObjectTarget.h"
 
+#include "lldb/Core/Address.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/Module.h"
@@ -1534,7 +1535,7 @@ static void DumpOsoFilesTable(Stream &strm,
 
 static void DumpAddress(ExecutionContextScope *exe_scope,
 const Address &so_addr, bool verbose, bool all_ranges,
-Stream &strm) {
+Stream &strm, const char *pattern = nullptr) {
   strm.IndentMore();
   strm.Indent("Address: ");
   so_addr.Dump(&strm, exe_scope, Address::DumpStyleModuleWithFileAddress);
@@ -1544,13 +1545,13 @@ static void DumpAddress(ExecutionContextScope 
*exe_scope,
   strm.Indent("Summary: ");
   const uint32_t save_indent = strm.GetIndentLevel();
   strm.SetIndentLevel(save_indent + 13);
-  so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription);
+  so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription, 
Address::DumpStyleInvalid, UINT32_MAX, false, pattern);
   strm.SetIndentLevel(save_indent);
   // Print out detailed address information when verbose is enabled
   if (verbose) {
 strm.EOL();
 so_addr.Dump(&strm, exe_scope, Address::DumpStyleDetailedSymbolContext,
- Address::DumpStyleInvalid, UINT32_MAX, all_ranges);
+ Address::DumpStyleInvalid, UINT32_MAX, all_ranges, pattern);
   }
   strm.IndentLess(

[Lldb-commits] [llvm] [lld] [clang] [lldb] [flang] [libcxx] [clang-tools-extra] [libc] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Erich Keane via lldb-commits


@@ -229,6 +230,9 @@ class Parser : public CodeCompletionHandler {
   /// Parsing OpenMP directive mode.
   bool OpenMPDirectiveParsing = false;
 
+  /// Parsing OpenACC directive mode.
+  bool OpenACCDirectiveParsing = false;

erichkeane wrote:

Its currently being used here: 
https://github.com/llvm/llvm-project/pull/70234/files#diff-5c51bae1966e0b475927bfa75751eb83db5d90f828aa825cb24f40dea653c408R322
 (Line 322 in Parser.cpp).

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


[Lldb-commits] [llvm] [lld] [clang] [lldb] [flang] [libcxx] [clang-tools-extra] [libc] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Erich Keane via lldb-commits


@@ -0,0 +1,14 @@
+// RUN: %clang -S -### -fopenacc %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DRIVER
+// CHECK-DRIVER: "-cc1" {{.*}} "-fopenacc"
+
+// RUN: %clang -S -### -fopenacc -fexperimental-openacc-macro-override=202211 
%s 2>&1 | FileCheck %s --check-prefix=CHECK-MACRO-OVERRIDE
+// RUN: %clang -S -### -fopenacc -fexperimental-openacc-macro-override 202211 
%s 2>&1 | FileCheck %s --check-prefix=CHECK-MACRO-OVERRIDE

erichkeane wrote:

We cannot, because this is a 'builtin' macro, overriding it on the command line 
is essentially UB.  Additionally, this clarifies that it is an experimental 
patch, which is less likely to be a concern when we remove it in the future.  
That is, the intent is to prevent folks from coming to depend on this in the 
future.

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Extract static data member decl creation into helper (PR #72109)

2023-11-13 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/72109

>From 3513963ac45aff2296f687e6c7b315e0f25b8586 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Tue, 7 Nov 2023 10:57:08 +
Subject: [PATCH 1/2] [lldb][DWARFASTParserClang][NFC] Extract static data
 member decl creation into helper

This patch extracts the logic to parse static
variable member declarations into a helper. We
will use this in an upcoming patch which will
need to call exactly the same logic from a separate
part of the DWARF parser.
---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 121 --
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  40 ++
 2 files changed, 94 insertions(+), 67 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index eb894328547ea5e..2039608bc8f1e1b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2534,28 +2534,6 @@ DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit 
&comp_unit,
 }
 
 namespace {
-/// Parsed form of all attributes that are relevant for parsing type members.
-struct MemberAttributes {
-  explicit MemberAttributes(const DWARFDIE &die, const DWARFDIE &parent_die,
-ModuleSP module_sp);
-  const char *name = nullptr;
-  /// Indicates how many bits into the word (according to the host endianness)
-  /// the low-order bit of the field starts. Can be negative.
-  int64_t bit_offset = 0;
-  /// Indicates the size of the field in bits.
-  size_t bit_size = 0;
-  uint64_t data_bit_offset = UINT64_MAX;
-  AccessType accessibility = eAccessNone;
-  std::optional byte_size;
-  std::optional const_value_form;
-  DWARFFormValue encoding_form;
-  /// Indicates the byte offset of the word from the base address of the
-  /// structure.
-  uint32_t member_byte_offset = UINT32_MAX;
-  bool is_artificial = false;
-  bool is_declaration = false;
-};
-
 /// Parsed form of all attributes that are relevant for parsing Objective-C
 /// properties.
 struct PropertyAttributes {
@@ -2684,9 +2662,8 @@ std::vector &VariantPart::members() { 
return this->_members; }
 
 DiscriminantValue &VariantPart::discriminant() { return this->_discriminant; }
 
-MemberAttributes::MemberAttributes(const DWARFDIE &die,
-   const DWARFDIE &parent_die,
-   ModuleSP module_sp) {
+DWARFASTParserClang::MemberAttributes::MemberAttributes(
+const DWARFDIE &die, const DWARFDIE &parent_die, ModuleSP module_sp) {
   DWARFAttributes attributes = die.GetAttributes();
   for (size_t i = 0; i < attributes.Size(); ++i) {
 const dw_attr_t attr = attributes.AttributeAtIndex(i);
@@ -2908,13 +2885,63 @@ llvm::Expected 
DWARFASTParserClang::ExtractIntFromFormValue(
   return result;
 }
 
+void DWARFASTParserClang::CreateStaticMemberVariable(
+const DWARFDIE &die, const MemberAttributes &attrs,
+const lldb_private::CompilerType &class_clang_type) {
+  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+  assert(die.Tag() == DW_TAG_member);
+
+  Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
+
+  if (!var_type)
+return;
+
+  auto accessibility =
+  attrs.accessibility == eAccessNone ? eAccessPublic : attrs.accessibility;
+
+  CompilerType ct = var_type->GetForwardCompilerType();
+  clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType(
+  class_clang_type, attrs.name, ct, accessibility);
+  if (!v) {
+LLDB_LOG(log, "Failed to add variable to the record type");
+return;
+  }
+
+  bool unused;
+  // TODO: Support float/double static members as well.
+  if (!ct.IsIntegerOrEnumerationType(unused))
+return;
+
+  auto maybe_const_form_value = attrs.const_value_form;
+
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of an inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!maybe_const_form_value) {
+maybe_const_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_const_form_value)
+  return;
+  }
+
+  llvm::Expected const_value_or_err =
+  ExtractIntFromFormValue(ct, *attrs.const_value_form);
+  if (!const_value_or_err) {
+LLDB_LOG_ERROR(log, const_value_or_err.takeError(),
+   "Failed to add const value to variable {1}: {0}",
+   v->getQualifiedNameAsString());
+return;
+  }
+
+  TypeSystemClang::SetIntegerInitializerForVariable(v, *const_value_or_err);
+}
+
 void DWARFASTParserClang::ParseSingleMember(
 const DWARFDIE &die, const DWARFDIE &parent_die,
 const lldb_private::CompilerType &class_clang_type,
 lldb::AccessType default_accessibility,
 lldb_private::ClangASTImporter::LayoutInfo &layout_info,
 FieldInfo &last_field_info) {
-  Log *log 

[Lldb-commits] [flang] [llvm] [clang] [lld] [libcxx] [lldb] [clang-tools-extra] [libc] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Alexey Bataev via lldb-commits


@@ -229,6 +230,9 @@ class Parser : public CodeCompletionHandler {
   /// Parsing OpenMP directive mode.
   bool OpenMPDirectiveParsing = false;
 
+  /// Parsing OpenACC directive mode.
+  bool OpenACCDirectiveParsing = false;

alexey-bataev wrote:

I mean, it has value false only and is not changed anywhere

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


[Lldb-commits] [flang] [llvm] [clang] [lld] [libcxx] [lldb] [clang-tools-extra] [libc] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Erich Keane via lldb-commits


@@ -229,6 +230,9 @@ class Parser : public CodeCompletionHandler {
   /// Parsing OpenMP directive mode.
   bool OpenMPDirectiveParsing = false;
 
+  /// Parsing OpenACC directive mode.
+  bool OpenACCDirectiveParsing = false;

erichkeane wrote:

Ah, I see.  As it is likely to be used within another patch or two, I see value 
in leaving it (if only to not have to edit hte Parser.cpp lines again), but can 
remove it if you insist.  

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


[Lldb-commits] [flang] [llvm] [clang] [lld] [libcxx] [lldb] [clang-tools-extra] [libc] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Alexey Bataev via lldb-commits


@@ -229,6 +230,9 @@ class Parser : public CodeCompletionHandler {
   /// Parsing OpenMP directive mode.
   bool OpenMPDirectiveParsing = false;
 
+  /// Parsing OpenACC directive mode.
+  bool OpenACCDirectiveParsing = false;

alexey-bataev wrote:

I think better to introduce it with the patch that actually relies on it, 
currently better to remove it.

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


[Lldb-commits] [clang] [libc] [flang] [clang-tools-extra] [llvm] [libcxx] [lld] [lldb] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Alexey Bataev via lldb-commits


@@ -1349,6 +1349,19 @@ def fno_hip_emit_relocatable : Flag<["-"], 
"fno-hip-emit-relocatable">,
   HelpText<"Do not override toolchain to compile HIP source to relocatable">;
 }
 
+// Clang specific/exclusive options for OpenACC.
+def openacc_macro_override

alexey-bataev wrote:

Why do you need this form? Is not EQ form is enough?

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


[Lldb-commits] [clang] [libc] [flang] [clang-tools-extra] [llvm] [libcxx] [lld] [lldb] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Erich Keane via lldb-commits


@@ -1349,6 +1349,19 @@ def fno_hip_emit_relocatable : Flag<["-"], 
"fno-hip-emit-relocatable">,
   HelpText<"Do not override toolchain to compile HIP source to relocatable">;
 }
 
+// Clang specific/exclusive options for OpenACC.
+def openacc_macro_override

erichkeane wrote:

It is for general consistency here, we typically provide both for many similar 
options.  We typically don't use the 'EQ' form for CC1 at all (since it 
requires driver string-appending), and users are often more comfortable with 
the EQ version.  I'm not attached to either, but it seems that it is sensible 
to provide both.

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


[Lldb-commits] [flang] [llvm] [clang] [lld] [libcxx] [lldb] [clang-tools-extra] [libc] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Erich Keane via lldb-commits

https://github.com/erichkeane updated 
https://github.com/llvm/llvm-project/pull/70234

>From b3d64b3f744ccb37e334e3aae8d6874cd8391c56 Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Mon, 23 Oct 2023 11:09:11 -0700
Subject: [PATCH 1/7] [OpenACC] Initial commit for OpenACC Support

This is the initial commit to support OpenACC in Clang, which adds a
clang-command line argument '-fopenacc', and starts to define _OPENACC,
albeit to '1' instead of the standardized value (since we don't
properly implement OpenACC yet).
---
 clang/docs/ReleaseNotes.rst   | 12 
 clang/include/clang/Basic/LangOptions.def |  2 ++
 clang/include/clang/Driver/Options.td | 10 --
 clang/lib/Driver/ToolChains/Clang.cpp | 11 +++
 clang/lib/Frontend/CompilerInvocation.cpp |  7 +++
 clang/lib/Frontend/InitPreprocessor.cpp   |  6 ++
 clang/test/Driver/openacc.c   |  2 ++
 clang/test/Preprocessor/openacc.c |  4 
 8 files changed, 52 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/openacc.c
 create mode 100644 clang/test/Preprocessor/openacc.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f94e4e10b805911..8f40872b539322a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -211,6 +211,11 @@ New Compiler Flags
   the preprocessed text to the output. This can greatly reduce the size of the
   preprocessed output, which can be helpful when trying to reduce a test case.
 
+* ``-Wbitfield-conversion`` was added to detect assignments of integral
+  types to a bitfield that may change the value.
+
+* ``-fopenacc`` was added as a part of the effort to support OpenACC in clang.
+
 Deprecated Compiler Flags
 -
 
@@ -665,6 +670,13 @@ Miscellaneous Clang Crashes Fixed
 - Fixed a crash when an ObjC ivar has an invalid type. See
   (`#68001 `_)
 
+OpenACC Specific Changes
+
+- OpenACC Implementation effort is beginning with semantic analysis and parsing
+  of OpenACC pragmas. The ``-fopenacc`` flag was added to enable these new,
+  albeit incomplete changes. The ``_OPENACC`` macro is currently defined to
+  ``1``, as support is too incomplete to update to a standards-required value.
+
 Target Specific Changes
 ---
 
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index c0ea4ecb9806a5b..872d693cc3ebbff 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -283,6 +283,8 @@ LANGOPT(OffloadUniformBlock, 1, 0, "Assume that kernels are 
launched with unifor
 LANGOPT(HIPStdPar, 1, 0, "Enable Standard Parallel Algorithm Acceleration for 
HIP (experimental)")
 LANGOPT(HIPStdParInterposeAlloc, 1, 0, "Replace allocations / deallocations 
with HIP RT calls when Standard Parallel Algorithm Acceleration for HIP is 
enabled (Experimental)")
 
+LANGOPT(OpenACC   , 1, 0, "OpenACC Enabled")
+
 LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are 
unavailable")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c6b1903a32a0621..ab28c3e394afe93 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3340,6 +3340,14 @@ def fno_openmp_target_debug : Flag<["-"], 
"fno-openmp-target-debug">;
 } // let Visibility = [ClangOption, CC1Option, FC1Option]
 } // let Flags = [NoArgumentUnused]
 
+//===--===//
+// FlangOption + FC1 + ClangOption + CC1Option
+//===--===//
+let Visibility = [FC1Option, FlangOption, CC1Option, ClangOption] in {
+def fopenacc : Flag<["-"], "fopenacc">, Group,
+  HelpText<"Enable OpenACC">;
+} // let Visibility = [FC1Option, FlangOption, CC1Option, ClangOption]
+
 
//===--===//
 // Optimisation remark options
 
//===--===//
@@ -6256,8 +6264,6 @@ file}]>;
 def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, 
Group, Alias;
 def fconvert_EQ : Joined<["-"], "fconvert=">, Group,
   HelpText<"Set endian conversion of data for unformatted files">;
-def fopenacc : Flag<["-"], "fopenacc">, Group,
-  HelpText<"Enable OpenACC">;
 def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group,
   HelpText<"Set the default double precision kind to an 8 byte wide type">;
 def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 601bbfb927746fc..cf65773de0d010d 100644
--- a/clang/l

[Lldb-commits] [flang] [llvm] [clang] [lld] [libcxx] [lldb] [clang-tools-extra] [libc] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Alexey Bataev via lldb-commits


@@ -4001,6 +4008,14 @@ bool CompilerInvocation::ParseLangArgs(LangOptions 
&Opts, ArgList &Args,
 (T.isNVPTX() || T.isAMDGCN()) &&
 Args.hasArg(options::OPT_fopenmp_cuda_mode);
 
+  // OpenACC Configuration.
+  if (Args.hasArg(options::OPT_fopenacc)) {
+Opts.OpenACC = true;

alexey-bataev wrote:

Maybe keep the version of the ACC in this value instead of having a separate 
string field, just like OpenMP does? 0 means th support is disabled, non-zero - 
supported version number.

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


[Lldb-commits] [flang] [lld] [libcxx] [clang] [libc] [lldb] [llvm] [clang-tools-extra] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Alexey Bataev via lldb-commits


@@ -3633,6 +3633,22 @@ static void RenderHLSLOptions(const ArgList &Args, 
ArgStringList &CmdArgs,
 CmdArgs.push_back("-finclude-default-header");
 }
 
+static void RenderOpenACCOptions(const Driver &D, const ArgList &Args,
+ ArgStringList &CmdArgs, types::ID InputType) {
+  if (!Args.hasArg(options::OPT_fopenacc))
+return;
+
+  CmdArgs.push_back("-fopenacc");
+
+  if (Arg *A = Args.getLastArg(options::OPT_openacc_macro_override)) {
+StringRef Value = A->getValue();
+if (llvm::find_if_not(Value, isdigit) == Value.end())
+  A->renderAsInput(Args, CmdArgs);
+else
+  D.Diag(diag::err_drv_clang_unsupported) << Value;

alexey-bataev wrote:

```suggestion
if (Value.getAsInteger(10, Version))
  A->renderAsInput(Args, CmdArgs);
else
  D.Diag(diag::err_drv_clang_unsupported) << Value;
```

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


[Lldb-commits] [libc] [clang] [lld] [libcxx] [lldb] [llvm] [clang-tools-extra] [flang] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Erich Keane via lldb-commits


@@ -4001,6 +4008,14 @@ bool CompilerInvocation::ParseLangArgs(LangOptions 
&Opts, ArgList &Args,
 (T.isNVPTX() || T.isAMDGCN()) &&
 Args.hasArg(options::OPT_fopenmp_cuda_mode);
 
+  // OpenACC Configuration.
+  if (Args.hasArg(options::OPT_fopenacc)) {
+Opts.OpenACC = true;

erichkeane wrote:

I likely will in the future, however as we currently don't have support for 
multiple versions of OpenACC, we only need 'true' or 'false'.  So for now, it 
seems prudent to not do that yet (as it won't be used).

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


[Lldb-commits] [lldb] [libc] [llvm] [clang-tools-extra] [lld] [clang] [flang] [libcxx] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Erich Keane via lldb-commits


@@ -3633,6 +3633,22 @@ static void RenderHLSLOptions(const ArgList &Args, 
ArgStringList &CmdArgs,
 CmdArgs.push_back("-finclude-default-header");
 }
 
+static void RenderOpenACCOptions(const Driver &D, const ArgList &Args,
+ ArgStringList &CmdArgs, types::ID InputType) {
+  if (!Args.hasArg(options::OPT_fopenacc))
+return;
+
+  CmdArgs.push_back("-fopenacc");
+
+  if (Arg *A = Args.getLastArg(options::OPT_openacc_macro_override)) {
+StringRef Value = A->getValue();
+if (llvm::find_if_not(Value, isdigit) == Value.end())
+  A->renderAsInput(Args, CmdArgs);
+else
+  D.Diag(diag::err_drv_clang_unsupported) << Value;

erichkeane wrote:

Done!  `getAsInteger` returns `false` on success, so I inverted the condition 
(patch coming).

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


[Lldb-commits] [libc] [clang] [lld] [libcxx] [lldb] [llvm] [clang-tools-extra] [flang] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Erich Keane via lldb-commits

https://github.com/erichkeane updated 
https://github.com/llvm/llvm-project/pull/70234

>From b3d64b3f744ccb37e334e3aae8d6874cd8391c56 Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Mon, 23 Oct 2023 11:09:11 -0700
Subject: [PATCH 1/8] [OpenACC] Initial commit for OpenACC Support

This is the initial commit to support OpenACC in Clang, which adds a
clang-command line argument '-fopenacc', and starts to define _OPENACC,
albeit to '1' instead of the standardized value (since we don't
properly implement OpenACC yet).
---
 clang/docs/ReleaseNotes.rst   | 12 
 clang/include/clang/Basic/LangOptions.def |  2 ++
 clang/include/clang/Driver/Options.td | 10 --
 clang/lib/Driver/ToolChains/Clang.cpp | 11 +++
 clang/lib/Frontend/CompilerInvocation.cpp |  7 +++
 clang/lib/Frontend/InitPreprocessor.cpp   |  6 ++
 clang/test/Driver/openacc.c   |  2 ++
 clang/test/Preprocessor/openacc.c |  4 
 8 files changed, 52 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/openacc.c
 create mode 100644 clang/test/Preprocessor/openacc.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f94e4e10b805911..8f40872b539322a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -211,6 +211,11 @@ New Compiler Flags
   the preprocessed text to the output. This can greatly reduce the size of the
   preprocessed output, which can be helpful when trying to reduce a test case.
 
+* ``-Wbitfield-conversion`` was added to detect assignments of integral
+  types to a bitfield that may change the value.
+
+* ``-fopenacc`` was added as a part of the effort to support OpenACC in clang.
+
 Deprecated Compiler Flags
 -
 
@@ -665,6 +670,13 @@ Miscellaneous Clang Crashes Fixed
 - Fixed a crash when an ObjC ivar has an invalid type. See
   (`#68001 `_)
 
+OpenACC Specific Changes
+
+- OpenACC Implementation effort is beginning with semantic analysis and parsing
+  of OpenACC pragmas. The ``-fopenacc`` flag was added to enable these new,
+  albeit incomplete changes. The ``_OPENACC`` macro is currently defined to
+  ``1``, as support is too incomplete to update to a standards-required value.
+
 Target Specific Changes
 ---
 
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index c0ea4ecb9806a5b..872d693cc3ebbff 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -283,6 +283,8 @@ LANGOPT(OffloadUniformBlock, 1, 0, "Assume that kernels are 
launched with unifor
 LANGOPT(HIPStdPar, 1, 0, "Enable Standard Parallel Algorithm Acceleration for 
HIP (experimental)")
 LANGOPT(HIPStdParInterposeAlloc, 1, 0, "Replace allocations / deallocations 
with HIP RT calls when Standard Parallel Algorithm Acceleration for HIP is 
enabled (Experimental)")
 
+LANGOPT(OpenACC   , 1, 0, "OpenACC Enabled")
+
 LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are 
unavailable")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c6b1903a32a0621..ab28c3e394afe93 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3340,6 +3340,14 @@ def fno_openmp_target_debug : Flag<["-"], 
"fno-openmp-target-debug">;
 } // let Visibility = [ClangOption, CC1Option, FC1Option]
 } // let Flags = [NoArgumentUnused]
 
+//===--===//
+// FlangOption + FC1 + ClangOption + CC1Option
+//===--===//
+let Visibility = [FC1Option, FlangOption, CC1Option, ClangOption] in {
+def fopenacc : Flag<["-"], "fopenacc">, Group,
+  HelpText<"Enable OpenACC">;
+} // let Visibility = [FC1Option, FlangOption, CC1Option, ClangOption]
+
 
//===--===//
 // Optimisation remark options
 
//===--===//
@@ -6256,8 +6264,6 @@ file}]>;
 def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, 
Group, Alias;
 def fconvert_EQ : Joined<["-"], "fconvert=">, Group,
   HelpText<"Set endian conversion of data for unformatted files">;
-def fopenacc : Flag<["-"], "fopenacc">, Group,
-  HelpText<"Enable OpenACC">;
 def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group,
   HelpText<"Set the default double precision kind to an 8 byte wide type">;
 def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 601bbfb927746fc..cf65773de0d010d 100644
--- a/clang/l

[Lldb-commits] [flang] [lld] [libcxx] [clang] [libc] [lldb] [llvm] [clang-tools-extra] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-13 Thread Alexey Bataev via lldb-commits

https://github.com/alexey-bataev approved this pull request.


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


[Lldb-commits] [lldb] Remove hardware index from watchpoints and breakpoints (PR #72012)

2023-11-13 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

> > The Linux MIPS support has been ripped out and the remaining support for 
> > MIPS probably gets no real testing
> 
> Don't know the status but the BSD's still have some MIPS support.

Yeah I've been trying to keep the MIPS watchpoint code in the sources as I've 
been updating it (it doesn't distinguish the low nibble of addresses iirc and 
there's code to decode the load/store instruction to find the exact address 
accessed), even if it's not currently maintained I'd rather not remove it, it's 
not a lot of code.  Someone may want to re-support this exciting architecture 
again in the future.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits

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

From 620ce688faba76bee7deb1429e7499f473d7509c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 7 Nov 2023 16:57:18 -0300
Subject: [PATCH] [lldb] colorize symbols in image lookup

---
 lldb/include/lldb/Core/Address.h  |  7 ++-
 lldb/include/lldb/Symbol/Symbol.h |  4 +-
 lldb/include/lldb/Symbol/SymbolContext.h  |  8 +--
 lldb/source/Commands/CommandObjectTarget.cpp  | 15 --
 lldb/source/Core/Address.cpp  | 53 ---
 lldb/source/Symbol/Symbol.cpp | 16 --
 lldb/source/Symbol/SymbolContext.cpp  | 16 --
 .../Commands/command-image-lookup-color.test  | 25 +
 8 files changed, 114 insertions(+), 30 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test

diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index b19e694427546f8..fac0ced910a11d4 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -246,8 +246,11 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;
+
+  static void DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern = nullptr);
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index 44a2d560010fe40..0e41cd95e0ef17d 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -174,8 +174,8 @@ class Symbol : public SymbolContextScope {
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index b0f5ffead2a1656..9567c3f4384c175 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -150,8 +150,8 @@ class SymbolContext {
   bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
const Address &so_addr, bool show_fullpaths,
bool show_module, bool show_inlined_frames,
-   bool show_function_arguments,
-   bool show_function_name) const;
+   bool show_function_arguments, bool show_function_name,
+   const char *pattern = nullptr) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -217,8 +217,8 @@ class SymbolContext {
   /// The symbol that was found, or \b nullptr if none was found.
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error);
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 8f052d0a7b837e2..a83575ad82d6909 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -8,6 +8,7 @@
 
 #include "CommandObjectTarget.h"
 
+#include "lldb/Core/Address.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/Module.h"
@@ -1534,7 +1535,7 @@ static void DumpOsoFilesTable(Stream &strm,
 
 static void DumpAddress(ExecutionContextScope *exe_scope,
 const Address &so_addr, bool verbose, bool all_ranges,
-Stream &strm) {
+Stream &strm, const char *pattern = nullptr) {
   strm.IndentMore();
   strm.Indent("Address: ");
   so_addr.Dump(&strm, exe_scope, Address::DumpStyleModuleWithFileAddress);
@@ -1544,13 +1545,14 @@ static void DumpAddress(ExecutionContextScope 
*exe_scope,
   strm.Indent("Summary: ");
   const uint32_t save_indent = strm.GetIndentLevel();
   strm.SetIndentLevel(save_indent + 13);
-  so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription);
+  so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription,
+   Address::DumpStyleInvalid, UINT32_MAX, false, pattern);
   strm.SetIndentLevel(save_indent);
   

[Lldb-commits] [llvm] [lldb] Remove hardware index from watchpoints and breakpoints (PR #72012)

2023-11-13 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/72012

>From 1d22db051b0115e622208802cede47de6bdf507c Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Fri, 10 Nov 2023 17:38:59 -0800
Subject: [PATCH 1/2] Remove hardware index from watchpoints and breakpoints

The Watchpoint and Breakpoint objects try to track the hardware
index that was used for them, if they are hardware wp/bp's.
The majority of our debugging goes over the gdb remote serial
protocol, and when we set the watchpoint/breakpoint, there is no
(standard) way for the remote stub to communicate to lldb which
hardware index was used.  We have an lldb-extension packet to
query the total number of watchpoint registers.

When a watchpoint is hit, there is an lldb extension to the
stop reply packet (documented in lldb-gdb-remote.txt) to
describe the watchpoint including its actual hardware index,

  

(the third field is specifically needed for MIPS).  At this point,
if the stub reported these three fields (the stub is only required
to provide the first), we can know the actual hardware index for
this watchpoint.

Breakpoints are worse; there's never any way for us to be notified
about which hardware index was used.  Breakpoints got this as a
side effect of inherting from StoppointSite with Watchpoints.

We expose the watchpoint hardware index through "watchpoint list -v"
and through SBWatchpoint::GetHardwareIndex.

With my large watchpoint support, there is no *single* hardware
index that may be used for a watchpoint, it may need multiple
resources.  Also I don't see what a user is supposed to do with
this information, or an IDE.  Knowing the total number of watchpoint
registers on the target, and knowing how many Watchpoint Resources
are currently in use, is helpful.  Knowing how many Watchpoint
Resources
a single user-specified watchpoint needed to be implemented is useful.
But knowing which registers were used is an implementation detail
and not available until we hit the watchpoint when using gdb remote
serial protocol.

So given all that, I'm removing watchpoint hardware index numbers.
I'm changing the SB API to always return -1.
---
 lldb/bindings/interface/SBTargetDocstrings.i   |  2 +-
 .../interface/SBWatchpointDocstrings.i |  3 ++-
 lldb/docs/use/tutorial.rst |  2 +-
 lldb/include/lldb/API/SBWatchpoint.h   |  2 +-
 lldb/include/lldb/Breakpoint/StoppointSite.h   |  7 ---
 lldb/source/API/SBWatchpoint.cpp   | 15 +--
 lldb/source/Breakpoint/BreakpointLocation.cpp  |  7 ++-
 lldb/source/Breakpoint/BreakpointSite.cpp  |  4 ++--
 lldb/source/Breakpoint/StoppointSite.cpp   | 11 +--
 lldb/source/Breakpoint/Watchpoint.cpp  |  8 +++-
 .../Process/Utility/StopInfoMachException.cpp  | 18 --
 .../Process/Windows/Common/ProcessWindows.cpp  |  4 
 .../Process/gdb-remote/ProcessGDBRemote.cpp| 13 ++---
 lldb/source/Target/StopInfo.cpp|  3 ---
 .../default-constructor/sb_watchpoint.py   |  1 -
 .../watchpoint/TestWatchpointIter.py   |  8 
 16 files changed, 28 insertions(+), 80 deletions(-)

diff --git a/lldb/bindings/interface/SBTargetDocstrings.i 
b/lldb/bindings/interface/SBTargetDocstrings.i
index f586552c99108c0..ce4992aade3a694 100644
--- a/lldb/bindings/interface/SBTargetDocstrings.i
+++ b/lldb/bindings/interface/SBTargetDocstrings.i
@@ -34,7 +34,7 @@ produces: ::
 
 Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw
 declare @ 
'/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12'
-hw_index = 0  hit_count = 2 ignore_count = 0"
+hit_count = 2 ignore_count = 0"
 ) lldb::SBTarget;
 
 %feature("docstring", "
diff --git a/lldb/bindings/interface/SBWatchpointDocstrings.i 
b/lldb/bindings/interface/SBWatchpointDocstrings.i
index 4eb7b136282dc30..892a82e6d0519f2 100644
--- a/lldb/bindings/interface/SBWatchpointDocstrings.i
+++ b/lldb/bindings/interface/SBWatchpointDocstrings.i
@@ -9,7 +9,8 @@ watchpoints of the target."
 ) lldb::SBWatchpoint;
 
 %feature("docstring", "
-With -1 representing an invalid hardware index."
+Deprecated.  Previously: Return the hardware index of the 
+watchpoint register.  Now: -1 is always returned."
 ) lldb::SBWatchpoint::GetHardwareIndex;
 
 %feature("docstring", "
diff --git a/lldb/docs/use/tutorial.rst b/lldb/docs/use/tutorial.rst
index 85dc173fa37cd33..ff956d750c29f23 100644
--- a/lldb/docs/use/tutorial.rst
+++ b/lldb/docs/use/tutorial.rst
@@ -431,7 +431,7 @@ a variable called 'global' for write operation, but only 
stop if the condition
Watchpoint 1: addr = 0x11018 size = 4 state = enabled type = w
   declare @ 
'/Volumes/data/lldb/svn/ToT/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp:12'
   condition = '(global==5)'
-  hw_index = 0  hit_count = 5 ignore_count = 0
+  hit_count = 5 ignore_coun

[Lldb-commits] [llvm] [lldb] Remove hardware index from watchpoints and breakpoints (PR #72012)

2023-11-13 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

> Oh, one more thing: Can you document the deprecation of this method into the 
> release notes? The file is `llvm-project/llvm/docs/ReleaseNotes.rst` and 
> there is an LLDB section.

Thanks for the tip, did that.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits

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

From 2c23aaf231beef11d3e0db6506fe82323a0be6a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 7 Nov 2023 16:57:18 -0300
Subject: [PATCH] [lldb] colorize symbols in image lookup

---
 lldb/include/lldb/Core/Address.h  |  7 ++-
 lldb/include/lldb/Symbol/Symbol.h |  4 +-
 lldb/include/lldb/Symbol/SymbolContext.h  |  8 +--
 lldb/source/Commands/CommandObjectTarget.cpp  | 15 --
 lldb/source/Core/Address.cpp  | 53 ---
 lldb/source/Symbol/Symbol.cpp | 18 ---
 lldb/source/Symbol/SymbolContext.cpp  | 16 --
 .../Commands/command-image-lookup-color.test  | 25 +
 8 files changed, 114 insertions(+), 32 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test

diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index b19e694427546f8..fac0ced910a11d4 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -246,8 +246,11 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;
+
+  static void DumpName(Stream *strm, llvm::StringRef text,
+   const char *pattern = nullptr);
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index 44a2d560010fe40..0e41cd95e0ef17d 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -174,8 +174,8 @@ class Symbol : public SymbolContextScope {
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index b0f5ffead2a1656..9567c3f4384c175 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -150,8 +150,8 @@ class SymbolContext {
   bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
const Address &so_addr, bool show_fullpaths,
bool show_module, bool show_inlined_frames,
-   bool show_function_arguments,
-   bool show_function_name) const;
+   bool show_function_arguments, bool show_function_name,
+   const char *pattern = nullptr) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -217,8 +217,8 @@ class SymbolContext {
   /// The symbol that was found, or \b nullptr if none was found.
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error);
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 8f052d0a7b837e2..a83575ad82d6909 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -8,6 +8,7 @@
 
 #include "CommandObjectTarget.h"
 
+#include "lldb/Core/Address.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/Module.h"
@@ -1534,7 +1535,7 @@ static void DumpOsoFilesTable(Stream &strm,
 
 static void DumpAddress(ExecutionContextScope *exe_scope,
 const Address &so_addr, bool verbose, bool all_ranges,
-Stream &strm) {
+Stream &strm, const char *pattern = nullptr) {
   strm.IndentMore();
   strm.Indent("Address: ");
   so_addr.Dump(&strm, exe_scope, Address::DumpStyleModuleWithFileAddress);
@@ -1544,13 +1545,14 @@ static void DumpAddress(ExecutionContextScope 
*exe_scope,
   strm.Indent("Summary: ");
   const uint32_t save_indent = strm.GetIndentLevel();
   strm.SetIndentLevel(save_indent + 13);
-  so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription);
+  so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription,
+   Address::DumpStyleInvalid, UINT32_MAX, false, pattern);
   strm.SetIndentLevel(save_indent);
  

[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits


@@ -252,11 +263,24 @@ void Symbol::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   s->Printf(", value = 0x%16.16" PRIx64,
 m_addr_range.GetBaseAddress().GetOffset());
   }
-  ConstString demangled = GetMangled().GetDemangledName();
-  if (demangled)
-s->Printf(", name=\"%s\"", demangled.AsCString());
-  if (m_mangled.GetMangledName())
-s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
+

junior-jl wrote:

Corrected this.

![image](https://github.com/llvm/llvm-project/assets/69206952/17dcb9f5-2171-4f6d-a3b5-41d92278fa2f)


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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits


@@ -252,11 +263,24 @@ void Symbol::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   s->Printf(", value = 0x%16.16" PRIx64,
 m_addr_range.GetBaseAddress().GetOffset());
   }
-  ConstString demangled = GetMangled().GetDemangledName();
-  if (demangled)
-s->Printf(", name=\"%s\"", demangled.AsCString());
-  if (m_mangled.GetMangledName())
-s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
+
+  // Checking if the name (i.e., searched symbol is passed as an argument to 
the
+  // function) In that case, we use the DumpName function to colorize the
+  // symbol.
+  if (auto mangled_name = m_mangled.GetMangledName()) {
+s->Printf(", mangled=");
+if (name)
+  Address::DumpName(s, mangled_name.GetStringRef(), name);
+else
+  s->Printf("\"%s\"", mangled_name.AsCString());
+  } else {
+ConstString demangled = GetMangled().GetDemangledName();
+s->Printf(", name=");
+if (name)
+  Address::DumpName(s, demangled.AsCString(), name);
+else
+  s->Printf("\"%s\"", demangled.AsCString());

junior-jl wrote:

Corrected this as well. Also, since the beginning of `DumpName` has the 
following condition, I removed the redundant `if`:

```cpp
if (!pattern) {
strm->PutCString(text.data());
return;
  }
```

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits


@@ -89,13 +97,18 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   s->Printf("<");
   dumped_something = true;
 } else {
-  ConstString name;
+  ConstString name_func;

junior-jl wrote:

Since the argument is now named `pattern`, I think this confusion is cleared.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits


@@ -0,0 +1,25 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t

junior-jl wrote:

Yes, I believe that was the case. Removed the other test.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits


@@ -163,6 +176,14 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   dumped_something = true;
   if (symbol->GetType() == eSymbolTypeTrampoline)
 s->PutCString("symbol stub for: ");
+
+  // Similar here, Using DumpName if the function is called by regex symbol

junior-jl wrote:

Removed the comments.

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


[Lldb-commits] [lldb] ad20a9e - [lldb] Remove StructuredData::Array::GetItemAtIndexAsArray (#71994)

2023-11-13 Thread via lldb-commits

Author: Alex Langford
Date: 2023-11-13T10:12:36-08:00
New Revision: ad20a9e1a15d1694f7ab3d878bcfaab3d52c5abf

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

LOG: [lldb] Remove StructuredData::Array::GetItemAtIndexAsArray (#71994)

This method is completely unused.

Added: 


Modified: 
lldb/include/lldb/Utility/StructuredData.h

Removed: 




diff  --git a/lldb/include/lldb/Utility/StructuredData.h 
b/lldb/include/lldb/Utility/StructuredData.h
index 8d0ae372f43c6bf..e7ee12868512f4a 100644
--- a/lldb/include/lldb/Utility/StructuredData.h
+++ b/lldb/include/lldb/Utility/StructuredData.h
@@ -276,16 +276,6 @@ class StructuredData {
   return {};
 }
 
-bool GetItemAtIndexAsArray(size_t idx, Array *&result) const {
-  result = nullptr;
-  ObjectSP value_sp = GetItemAtIndex(idx);
-  if (value_sp.get()) {
-result = value_sp->GetAsArray();
-return (result != nullptr);
-  }
-  return false;
-}
-
 void Push(const ObjectSP &item) { m_items.push_back(item); }
 
 void AddItem(const ObjectSP &item) { m_items.push_back(item); }



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


[Lldb-commits] [lldb] [lldb] Remove StructuredData::Array::GetItemAtIndexAsArray (PR #71994)

2023-11-13 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits

junior-jl wrote:

>> 
- Please remove any commented out code, comments that are now obvious from 
reading the code, etc.
- Rename name to pattern, it will be a 1000% less confusing for all of us :)
- Make sure that ninja check-lldb has no failures.
- clang-format your changes (https://clang.llvm.org/docs/ClangFormat.html)
 
Hello again, David. We've done these. When I fetched the most recent changes in 
LLVM project today, the `ninja check-lldb` was okay again. Just FYI, I did not 
update any dependency.

```
$ ninja check-lldb
[259/260] Running lldb lit test suite
llvm-lit: /home/jose/lldb/llvm-project/llvm/utils/lit/lit/llvm/config.py:488: 
note: using clang: /home/jose/lldb/llvm-project/bin/clang

Testing Time: 208.89s

Total Discovered Tests: 2849
  Skipped  :1 (0.04%)
  Unsupported  : 1327 (46.58%)
  Passed   : 1520 (53.35%)
  Expectedly Failed:1 (0.04%)
```

I tried commenting on the more recent suggestions you made that were addressed.

Also, we have a few questions:

1. Should we add some tests to the file with `settings set use-color false`?
2. Right now, the colorize only works for symbols, i.e., the `-s` flag. Should 
this also work for the `-F` and `-n` flags? If so, is it better that we add 
this on this PR or in another patch?

Thanks in advance!

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits


@@ -253,9 +264,20 @@ void Symbol::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
 m_addr_range.GetBaseAddress().GetOffset());
   }
   ConstString demangled = GetMangled().GetDemangledName();
-  if (demangled)
+
+  // Checking if the name (i.e., searched symbol is passed as an argument to 
the function)
+  // In that case, we use the re_pattern function to colorize the symbol.
+  if (demangled && name){
+s->Printf(", name=");
+Address::re_pattern(s, demangled.AsCString(), name);
+  }
+  else if(demangled && name == nullptr)
 s->Printf(", name=\"%s\"", demangled.AsCString());
-  if (m_mangled.GetMangledName())
+  if (m_mangled.GetMangledName() && name){
+s->Printf(", mangled=");
+Address::re_pattern(s, m_mangled.GetMangledName().AsCString(), name);
+  }
+  else if(m_mangled.GetMangledName() && name == nullptr)

junior-jl wrote:

I realize now I might have misinterpreted this suggestion. The mangled name is 
now shown before the demangled one. Is that what you were meaning here? This is 
how the code is now.

```cpp
if (ConstString mangled_name = m_mangled.GetMangledName()) {
s->Printf(", mangled=\"");
Address::DumpName(s, mangled_name.GetStringRef(), pattern);
s->Printf("\"");
  }
  if (ConstString demangled = m_mangled.GetDemangledName()) {
s->Printf(", name=\"");
Address::DumpName(s, demangled.GetStringRef(), pattern);
s->Printf("\"");
  }
```

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-13 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] Centralize the code that figures out which memory ranges to save into core files (PR #71772)

2023-11-13 Thread Greg Clayton via lldb-commits

clayborg wrote:

> Hello @clayborg ! Looks like this patch broke lldb-aarch64-windows bot: 
> https://lab.llvm.org/buildbot/#/builders/219/builds/6868 Could you please 
> look at this ?

@antmox 

I looked at this and I didn't touch anything related to native windows core 
file saving. If this is a native windows build on arm64 for lldb, and we are 
debugging with COFF files, then this code will get run:
```
bool ObjectFilePECOFF::SaveCore(const lldb::ProcessSP &process_sp,
const lldb_private::FileSpec &outfile,
lldb::SaveCoreStyle &core_style,
lldb_private::Status &error) {
  core_style = eSaveCoreFull;
  return SaveMiniDump(process_sp, outfile, error);
}
```
The `SaveMinidump` calls native windows APIs to create the minidump file in 
`lldb/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp`. Then this file 
gets loaded by the ProcessMinidump.cpp and I didn't touch anything inside of 
the process plug-in that loads the minidumps. So I am not sure how to proceed 
other than disabling this test for arm64 windows? Does anyone have access to an 
arm64 windows machine to see what is going on? In theory none of the code I 
changed should touch this, and I didn't modify 
`lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py` at all with 
this patch.

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Extract static data member decl creation into helper (PR #72109)

2023-11-13 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] Centralize the code that figures out which memory ranges to save into core files (PR #71772)

2023-11-13 Thread Greg Clayton via lldb-commits

clayborg wrote:

Does anyone have access to a native windows arm64 build of LLDB that could help 
look at this?

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


[Lldb-commits] [lldb] [lldb] DRAFT - Remove 2nd "error: " and print caret (^) below last input line from the developer. (PR #72150)

2023-11-13 Thread Pete Lawrence via lldb-commits

https://github.com/PortalPete created 
https://github.com/llvm/llvm-project/pull/72150

This patch serves 2 goals:
- Remove a second "error: " substring in error messages from debugging Swift.
- Print caret (^) line with optional leading/trailing tildes (~) below the line 
the developer last entered.

Here' an example from a Swift app:
```
(lldb) p abc
error: :3:1: error: cannot find 'abc' in scope
abc
^~~
```

And here's what that same error message is after the patch
```
(lldb) p abc
 ^~~
error: :3:1: cannot find 'abc' in scope
abc
^~~
```

To make this work, the patch passes the diagnostics up the call stack to 
`CommandInterpreter::IOHandlerInputComplete(...)` because the deepest call 
frame that knows what the developer entered at the prompt. This is important 
for commands like DWIM print (and its aliases 'p' and 'po') where the length of 
the actual command they typed in gets us the correct spacing to pad before the 
line with the caret.

To get the diagnostics up to that level, I added a vector of `Diagnostic` 
instances into `Status` and `CommandReturnObject`. I originally prototyped this 
by hoisting a `DiagnosticManager` manager instance but it's a bit heavy handed 
for what we need to accomplish the goal.

>From 0b25a5adb9579f162cc64a3e8c2aa8ebb94bc74c Mon Sep 17 00:00:00 2001
From: Pete Lawrence 
Date: Mon, 6 Nov 2023 17:16:28 -1000
Subject: [PATCH] Remove secondary "error: " and print diagnostic line with
 caret (^) just below the developer's last command.

---
 .../lldb/Interpreter/CommandReturnObject.h|  6 ++
 lldb/include/lldb/Utility/Status.h|  2 +
 lldb/source/Expression/UserExpression.cpp | 14 +
 .../source/Interpreter/CommandInterpreter.cpp | 59 ++-
 .../Interpreter/CommandReturnObject.cpp   | 10 
 5 files changed, 89 insertions(+), 2 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h 
b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index 8c4dcb54d708f08..41afcd654928287 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -9,6 +9,7 @@
 #ifndef LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
 #define LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
 
+#include "lldb/Expression/DiagnosticManager.h"
 #include "lldb/Host/StreamFile.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/StreamTee.h"
@@ -139,6 +140,10 @@ class CommandReturnObject {
 
   void SetStatus(lldb::ReturnStatus status);
 
+  std::vector GetDiagnostics() const;
+
+  void SetDiagnostics(std::vector diagnostics);
+
   bool Succeeded() const;
 
   bool HasResult() const;
@@ -162,6 +167,7 @@ class CommandReturnObject {
   StreamTee m_err_stream;
 
   lldb::ReturnStatus m_status = lldb::eReturnStatusStarted;
+  std::vector m_diagnostics;
 
   bool m_did_change_process_state = false;
   bool m_suppress_immediate_output = false;
diff --git a/lldb/include/lldb/Utility/Status.h 
b/lldb/include/lldb/Utility/Status.h
index ac410552438e0c6..7df3436b6c4b8ed 100644
--- a/lldb/include/lldb/Utility/Status.h
+++ b/lldb/include/lldb/Utility/Status.h
@@ -9,6 +9,7 @@
 #ifndef LLDB_UTILITY_STATUS_H
 #define LLDB_UTILITY_STATUS_H
 
+#include "lldb/Expression/DiagnosticManager.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-enumerations.h"
 #include "llvm/ADT/StringRef.h"
@@ -188,6 +189,7 @@ class Status {
   /// \b true if this object contains an value that describes
   /// success (non-erro), \b false otherwise.
   bool Success() const;
+  mutable std::vector m_diagnostics;
 
 protected:
   /// Member variables
diff --git a/lldb/source/Expression/UserExpression.cpp 
b/lldb/source/Expression/UserExpression.cpp
index c181712a2f0b243..98da9de91a2b8b6 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -278,6 +278,20 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
   user_expression_sp->Parse(diagnostic_manager, exe_ctx, execution_policy,
 keep_expression_in_memory, 
generate_debug_info);
 
+  // Copy diagnostics from the manager to the error (`Status`) instance's
+  // diagnostic vector.
+  {
+const DiagnosticList &source = diagnostic_manager.Diagnostics();
+
+if (source.size() >= 1) {
+  std::vector &destination = error.m_diagnostics;
+  destination.clear();
+
+  for (auto &entry : source)
+destination.push_back(*entry);
+}
+  }
+
   // Calculate the fixed expression always, since we need it for errors.
   std::string tmp_fixed_expression;
   if (fixed_expression == nullptr)
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index e1275ce711fc172..5b29ad32b3365ca 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3071,6 +3071,44 @@ bool CommandInterpreter::EchoCommandNonInteractive(
 
   return true;
 }
+// MARK: - Diag

[Lldb-commits] [lldb] [compiler-rt] [mlir] [llvm] Changes to support running tests for Windows arm64 asan (PR #66973)

2023-11-13 Thread Farzon Lotfi via lldb-commits

https://github.com/farzonl updated 
https://github.com/llvm/llvm-project/pull/66973

>From 85e5f76f0e9ccf4c3ed77eac0aaa3de944091c2c Mon Sep 17 00:00:00 2001
From: Farzon Lotfi 
Date: Wed, 20 Sep 2023 22:58:08 -0400
Subject: [PATCH 01/13] Changes to support running tests for Windows arm64 asan
 1. Differentiate SANITIZER_WINDOWS64 for x64 and arm64 2. fix A Warning where
 asserts needs messages 3. turn of interception tests that expect x86 assembly

---
 compiler-rt/lib/interception/interception_win.cpp | 6 +++---
 .../lib/interception/tests/interception_win_test.cpp  | 4 +++-
 compiler-rt/lib/sanitizer_common/sanitizer_platform.h | 8 
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/lib/interception/interception_win.cpp 
b/compiler-rt/lib/interception/interception_win.cpp
index 1b681ada37b170d..0a0e03ba63e5b59 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -1,4 +1,4 @@
-//===-- interception_win.cpp *- C++ 
-*-===//
+//===-- interception_win.cpp *- C++ 
-*-===// 
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -462,7 +462,7 @@ static size_t GetInstructionSize(uptr address, size_t* 
rel_offset = nullptr) {
   return 4;
 #endif
 
-#if SANITIZER_WINDOWS64
+#if SANITIZER_WINDOWS_x64
   if (memcmp((u8*)address, kPrologueWithShortJump1,
  sizeof(kPrologueWithShortJump1)) == 0 ||
   memcmp((u8*)address, kPrologueWithShortJump2,
@@ -544,7 +544,7 @@ static size_t GetInstructionSize(uptr address, size_t* 
rel_offset = nullptr) {
   return 7;
   }
 
-#if SANITIZER_WINDOWS64
+#if SANITIZER_WINDOWS_x64
   switch (*(u8*)address) {
 case 0xA1:  // A1 XX XX XX XX XX XX XX XX :
 //   movabs eax, dword ptr ds:[]
diff --git a/compiler-rt/lib/interception/tests/interception_win_test.cpp 
b/compiler-rt/lib/interception/tests/interception_win_test.cpp
index 9159ce405f2dc49..7dca93556527e7b 100644
--- a/compiler-rt/lib/interception/tests/interception_win_test.cpp
+++ b/compiler-rt/lib/interception/tests/interception_win_test.cpp
@@ -1,4 +1,4 @@
-//===-- interception_win_test.cpp 
-===//
+//===-- interception_win_test.cpp 
-===// 
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -17,6 +17,7 @@
 // Too slow for debug build
 #if !SANITIZER_DEBUG
 #if SANITIZER_WINDOWS
+#if !SANITIZER_WINDOWS_ARM64
 
 #include 
 
@@ -793,5 +794,6 @@ TEST(Interception, EmptyExportTable) {
 
 }  // namespace __interception
 
+#endif   // !SANITIZER_WINDOWS_ARM64
 #endif  // SANITIZER_WINDOWS
 #endif  // #if !SANITIZER_DEBUG
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
index 3e1b078a0212f5e..6af3051ac5aff3f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
@@ -260,6 +260,14 @@
 #  define SANITIZER_ARM64 0
 #endif
 
+#if SANITIZER_WINDOWS64 && SANITIZER_ARM64 
+#  define SANITIZER_WINDOWS_ARM64 1
+#  define SANITIZER_WINDOWS_x64 0
+#else
+#  define SANITIZER_WINDOWS_ARM64 0
+#  define SANITIZER_WINDOWS_x64 1
+#endif
+
 #if SANITIZER_SOLARIS && SANITIZER_WORDSIZE == 32
 #  define SANITIZER_SOLARIS32 1
 #else

>From fee3661104d31f4ff426397f1cb183b7aeaa1f27 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi 
Date: Mon, 13 Nov 2023 12:38:39 -0500
Subject: [PATCH 02/13] add comments, run git clang-format.

---
 compiler-rt/lib/interception/interception_win.cpp| 9 +++--
 .../lib/interception/tests/interception_win_test.cpp | 4 +++-
 compiler-rt/lib/sanitizer_common/sanitizer_platform.h| 2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/lib/interception/interception_win.cpp 
b/compiler-rt/lib/interception/interception_win.cpp
index 0a0e03ba63e5b59..8c002c06539b7f1 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -1,4 +1,4 @@
-//===-- interception_win.cpp *- C++ 
-*-===// 
+//===-- interception_win.cpp *- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -431,7 +431,8 @@ static uptr AllocateMemoryForTrampoline(uptr image_address, 
size_t size) {
 // The following prologues cannot be patched because of the short jump
 // jumping to the patching region.
 
-#if SANITIZER_WINDOWS64
+// Note: The jump byte array below is x86 assembly
+#if SANITIZER_WINDOWS_x64
 // ntdll!wcslen in Win11
 //

[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)

2023-11-13 Thread Michael Buch via lldb-commits

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

LGTM (once bots are happy)

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


[Lldb-commits] [lldb] [LLDB] Display artificial __promise and __coro_frame variables. (PR #71928)

2023-11-13 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Extract static data member decl creation into helper (PR #72109)

2023-11-13 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] 743c4fe - [lldb][DWARFASTParserClang][NFC] Extract static data member decl creation into helper (#72109)

2023-11-13 Thread via lldb-commits

Author: Michael Buch
Date: 2023-11-13T19:30:28Z
New Revision: 743c4fe43cad05dad422c1c64fd855fc506bb209

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

LOG: [lldb][DWARFASTParserClang][NFC] Extract static data member decl creation 
into helper (#72109)

This patch extracts the logic to create a static variable member decl
into a helper. We will use this in an upcoming patch which will need to
call exactly the same logic from a separate part of the DWARF parser.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index eb894328547ea5e..f5628b2753da2a7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2534,28 +2534,6 @@ DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit 
&comp_unit,
 }
 
 namespace {
-/// Parsed form of all attributes that are relevant for parsing type members.
-struct MemberAttributes {
-  explicit MemberAttributes(const DWARFDIE &die, const DWARFDIE &parent_die,
-ModuleSP module_sp);
-  const char *name = nullptr;
-  /// Indicates how many bits into the word (according to the host endianness)
-  /// the low-order bit of the field starts. Can be negative.
-  int64_t bit_offset = 0;
-  /// Indicates the size of the field in bits.
-  size_t bit_size = 0;
-  uint64_t data_bit_offset = UINT64_MAX;
-  AccessType accessibility = eAccessNone;
-  std::optional byte_size;
-  std::optional const_value_form;
-  DWARFFormValue encoding_form;
-  /// Indicates the byte offset of the word from the base address of the
-  /// structure.
-  uint32_t member_byte_offset = UINT32_MAX;
-  bool is_artificial = false;
-  bool is_declaration = false;
-};
-
 /// Parsed form of all attributes that are relevant for parsing Objective-C
 /// properties.
 struct PropertyAttributes {
@@ -2684,9 +2662,8 @@ std::vector &VariantPart::members() { 
return this->_members; }
 
 DiscriminantValue &VariantPart::discriminant() { return this->_discriminant; }
 
-MemberAttributes::MemberAttributes(const DWARFDIE &die,
-   const DWARFDIE &parent_die,
-   ModuleSP module_sp) {
+DWARFASTParserClang::MemberAttributes::MemberAttributes(
+const DWARFDIE &die, const DWARFDIE &parent_die, ModuleSP module_sp) {
   DWARFAttributes attributes = die.GetAttributes();
   for (size_t i = 0; i < attributes.Size(); ++i) {
 const dw_attr_t attr = attributes.AttributeAtIndex(i);
@@ -2908,13 +2885,63 @@ llvm::Expected 
DWARFASTParserClang::ExtractIntFromFormValue(
   return result;
 }
 
+void DWARFASTParserClang::CreateStaticMemberVariable(
+const DWARFDIE &die, const MemberAttributes &attrs,
+const lldb_private::CompilerType &class_clang_type) {
+  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
+  assert(die.Tag() == DW_TAG_member);
+
+  Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
+
+  if (!var_type)
+return;
+
+  auto accessibility =
+  attrs.accessibility == eAccessNone ? eAccessPublic : attrs.accessibility;
+
+  CompilerType ct = var_type->GetForwardCompilerType();
+  clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType(
+  class_clang_type, attrs.name, ct, accessibility);
+  if (!v) {
+LLDB_LOG(log, "Failed to add variable to the record type");
+return;
+  }
+
+  bool unused;
+  // TODO: Support float/double static members as well.
+  if (!ct.IsIntegerOrEnumerationType(unused))
+return;
+
+  auto maybe_const_form_value = attrs.const_value_form;
+
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of an inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!maybe_const_form_value) {
+maybe_const_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_const_form_value)
+  return;
+  }
+
+  llvm::Expected const_value_or_err =
+  ExtractIntFromFormValue(ct, *maybe_const_form_value);
+  if (!const_value_or_err) {
+LLDB_LOG_ERROR(log, const_value_or_err.takeError(),
+   "Failed to add const value to variable {1}: {0}",
+   v->getQualifiedNameAsString());
+return;
+  }
+
+  TypeSystemClang::SetIntegerInitializerForVariable(v, *const_value_or_err);
+}
+
 void DWARFASTParserClang::ParseSingleMember(
 const DWARFDIE &die, const DWARFDIE &parent_die,
 const lldb_private::CompilerType &class_clang_type,
 lldb::AccessType def

[Lldb-commits] [libcxxabi] [llvm] [lldb] [libc] [libcxx] [lld] [flang] [libunwind] [mlir] [compiler-rt] [clang-tools-extra] [clang] Have fir::unwrapSeqOrBoxedSeqType work with BaseBoxType (PR #72160)

2023-11-13 Thread Renaud Kauffmann via lldb-commits

https://github.com/Renaud-K created 
https://github.com/llvm/llvm-project/pull/72160

Fixing  fir::unwrapSeqOrBoxedSeqType so it also works with the fir::ClassType

>From af6200e4466066f92a67d69e6f49c8baa28bf62f Mon Sep 17 00:00:00 2001
From: Renaud-K 
Date: Wed, 8 Mar 2023 18:39:40 -0800
Subject: [PATCH] Break circular dependency between FIR dialect and utilities
 Differential revision: https://reviews.llvm.org/D145640

---
 flang/include/flang/Lower/Bridge.h   |  2 +-
 flang/include/flang/Optimizer/Builder/FIRBuilder.h   |  2 +-
 .../Optimizer/{ => Dialect}/Support/FIRContext.h |  0
 .../Optimizer/{ => Dialect}/Support/KindMapping.h|  0
 flang/lib/Frontend/CMakeLists.txt|  3 +--
 flang/lib/Frontend/FrontendActions.cpp   |  4 ++--
 flang/lib/Lower/Bridge.cpp   |  2 +-
 flang/lib/Lower/CMakeLists.txt   |  5 ++---
 flang/lib/Lower/ConvertVariable.cpp  |  2 +-
 flang/lib/Lower/IO.cpp   |  2 +-
 flang/lib/Optimizer/Analysis/CMakeLists.txt  |  3 +--
 flang/lib/Optimizer/Builder/CMakeLists.txt   |  2 +-
 flang/lib/Optimizer/Builder/IntrinsicCall.cpp|  2 +-
 flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp   |  2 +-
 flang/lib/Optimizer/CodeGen/CMakeLists.txt   |  3 +--
 flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp |  2 +-
 flang/lib/Optimizer/CodeGen/Target.cpp   |  2 +-
 flang/lib/Optimizer/CodeGen/Target.h |  2 +-
 flang/lib/Optimizer/CodeGen/TargetRewrite.cpp|  2 +-
 flang/lib/Optimizer/CodeGen/TypeConverter.h  |  4 ++--
 flang/lib/Optimizer/Dialect/CMakeLists.txt   |  6 --
 flang/lib/Optimizer/Dialect/FIRAttr.cpp  |  2 +-
 flang/lib/Optimizer/Dialect/FIROps.cpp   |  4 ++--
 flang/lib/Optimizer/Dialect/FIRType.cpp  |  2 +-
 flang/lib/Optimizer/Dialect/Support/CMakeLists.txt   | 12 
 .../Optimizer/{ => Dialect}/Support/FIRContext.cpp   |  4 ++--
 .../Optimizer/{ => Dialect}/Support/KindMapping.cpp  |  2 +-
 .../Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp|  2 +-
 flang/lib/Optimizer/HLFIR/Transforms/CMakeLists.txt  |  1 +
 .../lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp  |  2 +-
 flang/lib/Optimizer/Support/CMakeLists.txt   |  2 --
 flang/lib/Optimizer/Transforms/AbstractResult.cpp|  2 +-
 .../lib/Optimizer/Transforms/AddDebugFoundation.cpp  |  2 +-
 flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp|  2 +-
 flang/lib/Optimizer/Transforms/CMakeLists.txt|  3 +--
 .../lib/Optimizer/Transforms/CharacterConversion.cpp |  4 ++--
 .../Optimizer/Transforms/ControlFlowConverter.cpp|  4 ++--
 .../Optimizer/Transforms/PolymorphicOpConversion.cpp |  4 ++--
 .../lib/Optimizer/Transforms/SimplifyIntrinsics.cpp  |  2 +-
 flang/lib/Optimizer/Transforms/StackArrays.cpp   |  2 +-
 flang/tools/bbc/CMakeLists.txt   |  1 +
 flang/tools/bbc/bbc.cpp  |  4 ++--
 flang/tools/tco/CMakeLists.txt   |  1 +
 flang/tools/tco/tco.cpp  |  4 ++--
 flang/unittests/Optimizer/Builder/CharacterTest.cpp  |  2 +-
 flang/unittests/Optimizer/Builder/ComplexTest.cpp|  2 +-
 .../unittests/Optimizer/Builder/DoLoopHelperTest.cpp |  2 +-
 flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp |  2 +-
 flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp |  2 +-
 .../Optimizer/Builder/Runtime/RuntimeCallTestBase.h  |  2 +-
 flang/unittests/Optimizer/CMakeLists.txt |  1 +
 flang/unittests/Optimizer/FIRContextTest.cpp |  4 ++--
 flang/unittests/Optimizer/KindMappingTest.cpp|  2 +-
 53 files changed, 75 insertions(+), 64 deletions(-)
 rename flang/include/flang/Optimizer/{ => Dialect}/Support/FIRContext.h (100%)
 rename flang/include/flang/Optimizer/{ => Dialect}/Support/KindMapping.h (100%)
 create mode 100644 flang/lib/Optimizer/Dialect/Support/CMakeLists.txt
 rename flang/lib/Optimizer/{ => Dialect}/Support/FIRContext.cpp (95%)
 rename flang/lib/Optimizer/{ => Dialect}/Support/KindMapping.cpp (99%)

diff --git a/flang/include/flang/Lower/Bridge.h 
b/flang/include/flang/Lower/Bridge.h
index 6766613ebc27dba..b4ee77a0b166ec9 100644
--- a/flang/include/flang/Lower/Bridge.h
+++ b/flang/include/flang/Lower/Bridge.h
@@ -19,7 +19,7 @@
 #include "flang/Lower/LoweringOptions.h"
 #include "flang/Lower/StatementContext.h"
 #include "flang/Optimizer/Builder/FIRBuilder.h"
-#include "flang/Optimizer/Support/KindMapping.h"
+#include "flang/Optimizer/Dialect/Support/KindMapping.h"
 #include "mlir/IR/BuiltinOps.h"
 
 namespace Fortran {
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h 
b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index 085e91f0c6fa61d..0dbd77823d8f859 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -20,7 +20,7 

[Lldb-commits] [libcxxabi] [llvm] [lldb] [libc] [libcxx] [lld] [flang] [libunwind] [mlir] [compiler-rt] [clang-tools-extra] [clang] Have fir::unwrapSeqOrBoxedSeqType work with BaseBoxType (PR #72160)

2023-11-13 Thread Renaud Kauffmann via lldb-commits

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -2755,6 +2755,58 @@ bool ScriptInterpreterPythonImpl::RunScriptBasedCommand(
   return ret_val;
 }
 
+bool ScriptInterpreterPythonImpl::RunScriptBasedParsedCommand(
+StructuredData::GenericSP impl_obj_sp, Args &args,
+ScriptedCommandSynchronicity synchronicity,
+lldb_private::CommandReturnObject &cmd_retobj, Status &error,

jimingham wrote:

In this patch, I was just adding the Parsed command to the Raw one that was 
already there, without changing more than I needed to.  If we want to go back 
and clean up little things like this in both interfaces, I'd rather do that as 
a separate piece of work.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -447,6 +447,22 @@ bool CommandObject::IsPairType(ArgumentRepetitionType 
arg_repeat_type) {
  (arg_repeat_type == eArgRepeatPairRangeOptional);
 }
 
+std::optional 
+CommandObject::ArgRepetitionFromString(llvm::StringRef string) {
+  if (string == "plain") return eArgRepeatPlain ;   
+  if (string ==  "optional") return eArgRepeatOptional;
+  if (string ==  "plus") return eArgRepeatPlus;
+  if (string ==  "star") return eArgRepeatStar; 
+  if (string ==  "range") return eArgRepeatRange;
+  if (string ==  "pair-plain") return eArgRepeatPairPlain;
+  if (string ==  "pair-optional") return eArgRepeatPairOptional;
+  if (string ==  "pair-plus") return eArgRepeatPairPlus;
+  if (string ==  "pair-star") return eArgRepeatPairStar;
+  if (string ==  "pair-range") return eArgRepeatPairRange;
+  if (string ==  "pair-range-optional") return eArgRepeatPairRangeOptional;
+  return {};

jimingham wrote:

Sure

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -1255,6 +1258,676 @@ class CommandObjectScriptingObject : public 
CommandObjectRaw {
   CompletionType m_completion_type = eNoCompletion;
 };
 
+
+/// This command implements a lldb parsed scripted command.  The command
+/// provides a definition of the options and arguments, and a option value
+/// setting callback, and then the command's execution function gets passed
+/// just the parsed arguments.
+/// Note, implementing a command in Python using these base interfaces is a bit
+/// of a pain, but it is much easier to export this low level interface, and
+/// then make it nicer on the Python side, than to try to do that in a
+/// script language neutral way.
+/// So I've also added a base class in Python that provides a table-driven
+/// way of defining the options and arguments, which automatically fills the
+/// option values, making them available as properties in Python.
+/// 
+class CommandObjectScriptingObjectParsed : public CommandObjectParsed {
+private: 
+  class CommandOptions : public Options {
+  public:
+CommandOptions(CommandInterpreter &interpreter, 
+StructuredData::GenericSP cmd_obj_sp) : m_interpreter(interpreter), 
+m_cmd_obj_sp(cmd_obj_sp) {}
+
+~CommandOptions() override = default;
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  Status error;
+  ScriptInterpreter *scripter = 
+m_interpreter.GetDebugger().GetScriptInterpreter();
+  if (!scripter) {
+error.SetErrorString("No script interpreter for SetOptionValue.");
+return error;
+  }
+  if (!m_cmd_obj_sp) {
+error.SetErrorString("SetOptionValue called with empty cmd_obj.");
+return error;
+  }
+  if (!m_options_definition_up) {
+error.SetErrorString("SetOptionValue called before options definitions 
"
+ "were created.");
+return error;
+  }
+  // Pass the long option, since you aren't actually required to have a
+  // short_option, and for those options the index or short option 
character
+  // aren't meaningful on the python side.
+  const char * long_option = 
+m_options_definition_up.get()[option_idx].long_option;
+  bool success = scripter->SetOptionValueForCommandObject(m_cmd_obj_sp, 
+execution_context, long_option, option_arg);
+  if (!success)
+error.SetErrorStringWithFormatv("Error setting option: {0} to {1}",
+long_option, option_arg);
+  return error;
+}
+
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  ScriptInterpreter *scripter = 
+m_interpreter.GetDebugger().GetScriptInterpreter();
+  if (!scripter) {
+return;
+  }
+  if (!m_cmd_obj_sp) {
+return;
+  }
+  scripter->OptionParsingStartedForCommandObject(m_cmd_obj_sp);
+};
+
+llvm::ArrayRef GetDefinitions() override {
+  if (!m_options_definition_up)
+return {};
+  return llvm::ArrayRef(m_options_definition_up.get(), m_num_options);
+}
+
+static bool ParseUsageMaskFromArray(StructuredData::ObjectSP obj_sp, 
+size_t counter, uint32_t &usage_mask, Status &error) {
+  // If the usage entry is not provided, we use LLDB_OPT_SET_ALL.
+  // If the usage mask is a UINT, the option belongs to that group.
+  // If the usage mask is a vector of UINT's, the option belongs to all the
+  // groups listed.
+  // If a subelement of the vector is a vector of two ints, then the option
+  // belongs to the inclusive range from the first to the second element.
+  if (!obj_sp) {
+usage_mask = LLDB_OPT_SET_ALL;
+return true;
+  }
+  
+  usage_mask = 0;
+  
+  StructuredData::UnsignedInteger *uint_val = 
+  obj_sp->GetAsUnsignedInteger();
+  if (uint_val) {
+// If this is an integer, then this specifies a single group:
+uint32_t value = uint_val->GetValue();
+if (value == 0) {
+  error.SetErrorStringWithFormatv(
+  "0 is not a valid group for option {0}", counter);
+  return false;
+}
+usage_mask = (1 << (value - 1));
+return true;
+  }
+  // Otherwise it has to be an array:
+  StructuredData::Array *array_val = obj_sp->GetAsArray();
+  if (!array_val) {
+error.SetErrorStringWithFormatv(
+"required field is not a array for option {0}", counter);
+return false;
+  }
+  // This is the array ForEach for accumulating a group usage mask from
+  // an array of string descriptions of groups.
+  auto groups_accumulator 
+  = [counter, &usage_mask, &error] 
+(StructuredData::Object *obj) -> bool {
+StructuredData::UnsignedInteger *int_val = obj->GetAsUnsignedInteger();
+i

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -2873,6 +2925,204 @@ uint32_t 
ScriptInterpreterPythonImpl::GetFlagsForCommandObject(
   return result;
 }
 
+StructuredData::ObjectSP 
+ScriptInterpreterPythonImpl::GetOptionsForCommandObject(
+StructuredData::GenericSP cmd_obj_sp) {
+  StructuredData::ObjectSP result = {};
+
+  Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, 
Locker::FreeLock);
+
+  static char callee_name[] = "get_options_definition";
+
+  if (!cmd_obj_sp)
+return result;
+
+  PythonObject implementor(PyRefType::Borrowed,
+   (PyObject *)cmd_obj_sp->GetValue());
+
+  if (!implementor.IsAllocated())
+return result;
+
+  PythonObject pmeth(PyRefType::Owned,
+ PyObject_GetAttrString(implementor.get(), callee_name));
+
+  if (PyErr_Occurred())
+PyErr_Clear();
+
+  if (!pmeth.IsAllocated())
+return result;
+
+  if (PyCallable_Check(pmeth.get()) == 0) {
+if (PyErr_Occurred())
+  PyErr_Clear();
+return result;
+  }
+
+  if (PyErr_Occurred())
+PyErr_Clear();
+
+  PythonList py_return = unwrapOrSetPythonException(
+  As(implementor.CallMethod(callee_name)));
+
+  // if it fails, print the error but otherwise go on
+  if (PyErr_Occurred()) {
+PyErr_Print();
+PyErr_Clear();
+return {};
+  }
+return py_return.CreateStructuredObject();
+}
+
+StructuredData::ObjectSP 
+ScriptInterpreterPythonImpl::GetArgumentsForCommandObject(
+StructuredData::GenericSP cmd_obj_sp) {
+  StructuredData::ObjectSP result = {};
+
+  Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, 
Locker::FreeLock);
+
+  static char callee_name[] = "get_args_definition";
+
+  if (!cmd_obj_sp)
+return result;
+
+  PythonObject implementor(PyRefType::Borrowed,
+   (PyObject *)cmd_obj_sp->GetValue());
+
+  if (!implementor.IsAllocated())
+return result;
+
+  PythonObject pmeth(PyRefType::Owned,
+ PyObject_GetAttrString(implementor.get(), callee_name));
+
+  if (PyErr_Occurred())
+PyErr_Clear();
+
+  if (!pmeth.IsAllocated())
+return result;
+
+  if (PyCallable_Check(pmeth.get()) == 0) {
+if (PyErr_Occurred())
+  PyErr_Clear();
+return result;
+  }
+
+  if (PyErr_Occurred())
+PyErr_Clear();
+
+  PythonList py_return = unwrapOrSetPythonException(
+  As(implementor.CallMethod(callee_name)));
+
+  // if it fails, print the error but otherwise go on
+  if (PyErr_Occurred()) {
+PyErr_Print();
+PyErr_Clear();
+return {};
+  }
+return py_return.CreateStructuredObject();
+}
+
+void 
+ScriptInterpreterPythonImpl::OptionParsingStartedForCommandObject(
+StructuredData::GenericSP cmd_obj_sp) {
+
+  Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, 
Locker::FreeLock);
+
+  static char callee_name[] = "option_parsing_started";
+
+  if (!cmd_obj_sp)
+return ;
+
+  PythonObject implementor(PyRefType::Borrowed,
+   (PyObject *)cmd_obj_sp->GetValue());
+
+  if (!implementor.IsAllocated())
+return;
+
+  PythonObject pmeth(PyRefType::Owned,
+ PyObject_GetAttrString(implementor.get(), callee_name));
+
+  if (PyErr_Occurred())
+PyErr_Clear();
+
+  if (!pmeth.IsAllocated())
+return;
+
+  if (PyCallable_Check(pmeth.get()) == 0) {
+if (PyErr_Occurred())
+  PyErr_Clear();
+return;
+  }
+
+  if (PyErr_Occurred())
+PyErr_Clear();
+
+  // FIXME: this should really be a void function

jimingham wrote:

The function being called is a void return, but I didn't see a way to call 
that.  I was explaining why I ignored the return, but I made the comment clearer

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)
+
+# FIXME: would this be better done on the C++ side?
+# The common completers are missing some useful ones.
+# For instance there really should be a common Type completer
+# And an "lldb command name" completer.
+completion_table = {
+lldb.eArgTypeAddressOrExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeArchitecture : lldb.eArchitectureCompletion,
+lldb.eArgTypeBreakpointID : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointIDRange : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointName : lldb.eBreakpointNameCompletion,
+lldb.eArgTypeClassName : lldb.eSymbolCompletion,
+lldb.eArgTypeDirectoryName : lldb.eDiskDirectoryCompletion,
+lldb.eArgTypeExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeExpressionPath : lldb.eVariablePathCompletion,
+lldb.eArgTypeFilename : lldb.eDiskFileCompletion,
+lldb.eArgTypeFrameIndex : lldb.eFrameIndexCompletion,
+lldb.eArgTypeFunctionName : lldb.eSymbolCompletion,
+lldb.eArgTypeFunctionOrSymbol : lldb.eSymbolCompletion,

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.

jimingham wrote:

Do we raise Python exceptions anywhere else in our API's.  It is a pythonic way 
to do things, but we don't tend to do it that way.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 

jimingham wrote:

Comment got displaced, it goes with the "was_set" discussion.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)

jimingham wrote:

The translator methods return `(Value, Error)` if there's no translator then 
there's no error, so I have to return False here as well.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)
+
+# FIXME: would this be better done on the C++ side?
+# The common completers are missing some useful ones.
+# For instance there really should be a common Type completer
+# And an "lldb command name" completer.
+completion_table = {

jimingham wrote:

I agree as well, but I don't want to do that sort of change in this patch.

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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/71843

>From 8ad22d82fb987c1f32446220d96760e71b9f5130 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 9 Nov 2023 13:15:55 -0500
Subject: [PATCH] [lldb-dap] Add an option to show function args in stack
 frames

When this option is enabled, display names of stack frames are generated using 
the `${function.name-with-args}` formatter instead of simply calling 
`SBFrame::GetDisplayFunctionName`. This makes lldb-dap show an output similar 
to the one in the CLI.

This option is disabled by default because of its performance cost. It's a good 
option for non-gigantic programs.
---
 lldb/include/lldb/API/SBDefines.h |   1 +
 lldb/include/lldb/API/SBError.h   |   1 +
 lldb/include/lldb/API/SBFormat.h  |  69 +++
 lldb/include/lldb/API/SBFrame.h   |  17 +-
 lldb/include/lldb/Core/FormatEntity.h | 404 +-
 lldb/include/lldb/Target/StackFrame.h |  18 +-
 lldb/include/lldb/lldb-forward.h  |   4 +
 .../test/tools/lldb-dap/dap_server.py |   4 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   4 +
 lldb/source/API/CMakeLists.txt|   1 +
 lldb/source/API/SBFormat.cpp  |  47 ++
 lldb/source/API/SBFrame.cpp   |  35 ++
 lldb/source/Core/FormatEntity.cpp |  20 +-
 lldb/source/Target/StackFrame.cpp |  25 +-
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |  23 +-
 lldb/tools/lldb-dap/DAP.cpp   |  11 +
 lldb/tools/lldb-dap/DAP.h |   4 +
 lldb/tools/lldb-dap/JSONUtils.cpp |  17 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 lldb/tools/lldb-dap/package.json  |  10 +
 20 files changed, 482 insertions(+), 235 deletions(-)
 create mode 100644 lldb/include/lldb/API/SBFormat.h
 create mode 100644 lldb/source/API/SBFormat.cpp

diff --git a/lldb/include/lldb/API/SBDefines.h 
b/lldb/include/lldb/API/SBDefines.h
index c6f01cc03f263c8..2630a82df0e7135 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -71,6 +71,7 @@ class LLDB_API SBExpressionOptions;
 class LLDB_API SBFile;
 class LLDB_API SBFileSpec;
 class LLDB_API SBFileSpecList;
+class LLDB_API SBFormat;
 class LLDB_API SBFrame;
 class LLDB_API SBFunction;
 class LLDB_API SBHostOS;
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index b241052ed9cc2a2..1a720a479d9a689 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -80,6 +80,7 @@ class LLDB_API SBError {
   friend class SBData;
   friend class SBDebugger;
   friend class SBFile;
+  friend class SBFormat;
   friend class SBHostOS;
   friend class SBPlatform;
   friend class SBProcess;
diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
new file mode 100644
index 000..acc9467b4e2babb
--- /dev/null
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -0,0 +1,69 @@
+
+//===-- SBFormat.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_API_SBFORMAT_H
+#define LLDB_API_SBFORMAT_H
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb_private {
+namespace python {
+class SWIGBridge;
+} // namespace python
+namespace lua {
+class SWIGBridge;
+} // namespace lua
+} // namespace lldb_private
+
+namespace lldb {
+
+/// Class that represents a format string that can be used to generate
+/// descriptions of objects like frames and threads. See
+/// https://lldb.llvm.org/use/formatting.html for more information.
+class LLDB_API SBFormat {
+public:
+  SBFormat();
+
+  SBFormat(const lldb::SBFormat &rhs);
+
+  lldb::SBFormat &operator=(const lldb::SBFormat &rhs);
+
+  ~SBFormat();
+
+  /// \return
+  ///   \b true if and only if this object is valid and can be used for
+  ///   formatting.
+  explicit operator bool() const;
+
+  /// Parse the given format string.
+  ///
+  /// \param[in] format
+  ///   The format string to parse.
+  ///
+  /// \param[out] error
+  ///   An object where error messages will be written to if parsing fails.
+  ///
+  /// \return
+  ///   An \a SBFormat object with the parsing result, which might be an 
invalid
+  ///   object if parsing fails.
+  static lldb::SBFormat Parse(const char *format, lldb::SBError &error);
+
+protected:
+  friend class SBFrame;
+
+  /// \return
+  ///   The underlying shared pointer storage for this object.
+  lldb::FormatEntrySP GetFormatEntrySP() const;
+
+  /// The storage for this object.
+  lldb::FormatEntrySP m_opaque_sp;
+};
+
+} // namespace lldb
+#endif // LLDB_API_SBFORMAT_H
diff --git a/lldb/incl

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)
+
+# FIXME: would this be better done on the C++ side?
+# The common completers are missing some useful ones.
+# For instance there really should be a common Type completer
+# And an "lldb command name" completer.
+completion_table = {
+lldb.eArgTypeAddressOrExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeArchitecture : lldb.eArchitectureCompletion,
+lldb.eArgTypeBreakpointID : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointIDRange : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointName : lldb.eBreakpointNameCompletion,
+lldb.eArgTypeClassName : lldb.eSymbolCompletion,
+lldb.eArgTypeDirectoryName : lldb.eDiskDirectoryCompletion,
+lldb.eArgTypeExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeExpressionPath : lldb.eVariablePathCompletion,
+lldb.eArgTypeFilename : lldb.eDiskFileCompletion,
+lldb.eArgTypeFrameIndex : lldb.eFrameIndexCompletion,
+lldb.eArgTypeFunctionName : lldb.eSymbolCompletion,
+lldb.eArgTypeFunctionOrSymbol : lldb.eSymbolCompletion,

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)
+
+# FIXME: would this be better done on the C++ side?
+# The common completers are missing some useful ones.
+# For instance there really should be a common Type completer
+# And an "lldb command name" completer.
+completion_table = {
+lldb.eArgTypeAddressOrExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeArchitecture : lldb.eArchitectureCompletion,
+lldb.eArgTypeBreakpointID : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointIDRange : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointName : lldb.eBreakpointNameCompletion,
+lldb.eArgTypeClassName : lldb.eSymbolCompletion,
+lldb.eArgTypeDirectoryName : lldb.eDiskDirectoryCompletion,
+lldb.eArgTypeExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeExpressionPath : lldb.eVariablePathCompletion,
+lldb.eArgTypeFilename : lldb.eDiskFileCompletion,
+lldb.eArgTypeFrameIndex : lldb.eFrameIndexCompletion,
+lldb.eArgTypeFunctionName : lldb.eSymbolCompletion,
+lldb.eArgTypeFunctionOrSymbol : lldb.eSymbolCompletion,

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get passed 
arguments.
+
+Then implement the execute function for your command as:
+
+def __call__(self, debugger, args_array, exe_ctx, result):
+
+The arguments will be in a python array as strings.  
+
+You can access the option values using varname you passed in when defining the 
option.  
+If you need to know whether a given option was set by the user or not, you can 
retrieve 
+the option definition array with:
+
+  self.get_options_definition()
+
+look up your element by varname and check the "_value_set" element.
+
+There are example commands in the lldb testsuite at:
+
+llvm-project/lldb/test/API/commands/command/script/add/test_commands.py
+
+FIXME: I should make a convenient wrapper for that. 
+"""
+import inspect
+import lldb
+import sys
+
+class LLDBOVParser:
+def __init__(self):
+self.options_array = []
+self.args_array = []
+
+# Some methods to translate common value types.  Should return a
+# tuple of the value and an error value (True => error) if the
+# type can't be converted.
+# FIXME: Need a way to push the conversion error string back to lldb.
+@staticmethod
+def to_bool(in_value):
+error = True
+value = False
+low_in = in_value.lower()
+if low_in == "yes" or low_in == "true" or low_in == "1":
+value = True
+error = False
+
+if not value and low_in == "no" or low_in == "false" or low_in == "0":
+value = False
+error = False
+
+return (value, error)
+
+@staticmethod
+def to_int(in_value):
+#FIXME: Not doing errors yet...
+return (int(in_value), False)
+
+def to_unsigned(in_value):
+# FIXME: find an unsigned converter...
+# And handle errors.
+return (int(in_value), False)
+
+translators = {
+lldb.eArgTypeBoolean : to_bool,
+lldb.eArgTypeBreakpointID : to_unsigned,
+lldb.eArgTypeByteSize : to_unsigned,
+lldb.eArgTypeCount : to_unsigned,
+lldb.eArgTypeFrameIndex : to_unsigned,
+lldb.eArgTypeIndex : to_unsigned,
+lldb.eArgTypeLineNum : to_unsigned,
+lldb.eArgTypeNumLines : to_unsigned,
+lldb.eArgTypeNumberPerLine : to_unsigned,
+lldb.eArgTypeOffset : to_int,
+lldb.eArgTypeThreadIndex : to_unsigned,
+lldb.eArgTypeUnsignedInteger : to_unsigned,
+lldb.eArgTypeWatchpointID : to_unsigned,
+lldb.eArgTypeColumnNum : to_unsigned,
+lldb.eArgTypeRecognizerID : to_unsigned,
+lldb.eArgTypeTargetID : to_unsigned,
+lldb.eArgTypeStopHookID : to_unsigned
+}
+
+@classmethod
+def translate_value(cls, value_type, value):
+error = False
+try:
+return cls.translators[value_type](value)
+except KeyError:
+# If we don't have a translator, return the string value.
+return (value, False)
+
+# FIXME: would this be better done on the C++ side?
+# The common completers are missing some useful ones.
+# For instance there really should be a common Type completer
+# And an "lldb command name" completer.
+completion_table = {
+lldb.eArgTypeAddressOrExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeArchitecture : lldb.eArchitectureCompletion,
+lldb.eArgTypeBreakpointID : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointIDRange : lldb.eBreakpointCompletion,
+lldb.eArgTypeBreakpointName : lldb.eBreakpointNameCompletion,
+lldb.eArgTypeClassName : lldb.eSymbolCompletion,
+lldb.eArgTypeDirectoryName : lldb.eDiskDirectoryCompletion,
+lldb.eArgTypeExpression : lldb.eVariablePathCompletion,
+lldb.eArgTypeExpressionPath : lldb.eVariablePathCompletion,
+lldb.eArgTypeFilename : lldb.eDiskFileCompletion,
+lldb.eArgTypeFrameIndex : lldb.eFrameIndexCompletion,
+lldb.eArgTypeFunctionName : lldb.eSymbolCompletion,
+lldb.eArgTypeFunctionOrSymbol : lldb.eSymbolCompletion,

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -476,6 +476,14 @@ class ScriptInterpreter : public PluginInterface {
 return false;
   }
 
+  virtual bool RunScriptBasedParsedCommand(
+  StructuredData::GenericSP impl_obj_sp, Args& args,
+  ScriptedCommandSynchronicity synchronicity,
+  lldb_private::CommandReturnObject &cmd_retobj, Status &error,

jimingham wrote:

This is another place where I'm just following what the Raw command form did.  
We can go clean up both, and probably should, but that seems like a separate 
pass over the code.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits


@@ -1255,6 +1258,676 @@ class CommandObjectScriptingObject : public 
CommandObjectRaw {
   CompletionType m_completion_type = eNoCompletion;
 };
 
+
+/// This command implements a lldb parsed scripted command.  The command
+/// provides a definition of the options and arguments, and a option value
+/// setting callback, and then the command's execution function gets passed
+/// just the parsed arguments.
+/// Note, implementing a command in Python using these base interfaces is a bit
+/// of a pain, but it is much easier to export this low level interface, and
+/// then make it nicer on the Python side, than to try to do that in a
+/// script language neutral way.
+/// So I've also added a base class in Python that provides a table-driven
+/// way of defining the options and arguments, which automatically fills the
+/// option values, making them available as properties in Python.
+/// 
+class CommandObjectScriptingObjectParsed : public CommandObjectParsed {
+private: 
+  class CommandOptions : public Options {
+  public:
+CommandOptions(CommandInterpreter &interpreter, 
+StructuredData::GenericSP cmd_obj_sp) : m_interpreter(interpreter), 
+m_cmd_obj_sp(cmd_obj_sp) {}
+
+~CommandOptions() override = default;
+
+Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+  ExecutionContext *execution_context) override {
+  Status error;
+  ScriptInterpreter *scripter = 
+m_interpreter.GetDebugger().GetScriptInterpreter();
+  if (!scripter) {
+error.SetErrorString("No script interpreter for SetOptionValue.");
+return error;
+  }
+  if (!m_cmd_obj_sp) {
+error.SetErrorString("SetOptionValue called with empty cmd_obj.");
+return error;
+  }
+  if (!m_options_definition_up) {
+error.SetErrorString("SetOptionValue called before options definitions 
"
+ "were created.");
+return error;
+  }
+  // Pass the long option, since you aren't actually required to have a
+  // short_option, and for those options the index or short option 
character
+  // aren't meaningful on the python side.
+  const char * long_option = 
+m_options_definition_up.get()[option_idx].long_option;
+  bool success = scripter->SetOptionValueForCommandObject(m_cmd_obj_sp, 
+execution_context, long_option, option_arg);
+  if (!success)
+error.SetErrorStringWithFormatv("Error setting option: {0} to {1}",
+long_option, option_arg);
+  return error;
+}
+
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  ScriptInterpreter *scripter = 
+m_interpreter.GetDebugger().GetScriptInterpreter();
+  if (!scripter) {
+return;
+  }
+  if (!m_cmd_obj_sp) {
+return;
+  }
+  scripter->OptionParsingStartedForCommandObject(m_cmd_obj_sp);
+};
+
+llvm::ArrayRef GetDefinitions() override {
+  if (!m_options_definition_up)
+return {};
+  return llvm::ArrayRef(m_options_definition_up.get(), m_num_options);
+}
+
+static bool ParseUsageMaskFromArray(StructuredData::ObjectSP obj_sp, 
+size_t counter, uint32_t &usage_mask, Status &error) {

jimingham wrote:

Old habits

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


[Lldb-commits] [mlir] [lldb] [llvm] [clang] [compiler-rt] Enable Custom Lowering for fabs.v8f16 on AVX (PR #71730)

2023-11-13 Thread David Li via lldb-commits

https://github.com/david-xl updated 
https://github.com/llvm/llvm-project/pull/71730

>From 6032b965f85482b39e841bd95842f4e17c92fefd Mon Sep 17 00:00:00 2001
From: David Li 
Date: Tue, 7 Nov 2023 23:29:44 -0800
Subject: [PATCH 1/6] Enable Custom Lowering for fabs.v8f16 on AVX

---
 llvm/lib/Target/X86/X86ISelLowering.cpp |  3 ++
 llvm/test/CodeGen/X86/vec_fabs.ll   | 41 +
 2 files changed, 44 insertions(+)

diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 22fba5601ccfd38..8d9519b9f8c6b10 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2238,6 +2238,9 @@ X86TargetLowering::X86TargetLowering(const 
X86TargetMachine &TM,
 }
   }
 
+  if (Subtarget.hasAVX())
+setOperationAction(ISD::FABS, MVT::v8f16, Custom);
+
   if (!Subtarget.useSoftFloat() &&
   (Subtarget.hasAVXNECONVERT() || Subtarget.hasBF16())) {
 addRegisterClass(MVT::v8bf16, Subtarget.hasAVX512() ? &X86::VR128XRegClass
diff --git a/llvm/test/CodeGen/X86/vec_fabs.ll 
b/llvm/test/CodeGen/X86/vec_fabs.ll
index 982062d8907542a..08364449ab1a378 100644
--- a/llvm/test/CodeGen/X86/vec_fabs.ll
+++ b/llvm/test/CodeGen/X86/vec_fabs.ll
@@ -1,8 +1,10 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx | FileCheck %s 
--check-prefix=X86 --check-prefix=X86-AVX
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx2 | FileCheck %s 
--check-prefix=X86 --check-prefix=X86-AVX2
 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx512vl | FileCheck %s 
--check-prefix=X86 --check-prefix=X86-AVX512VL
 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx512dq,+avx512vl | 
FileCheck %s --check-prefix=X86 --check-prefix=X86-AVX512VLDQ
 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s 
--check-prefix=X64 --check-prefix=X64-AVX
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s 
--check-prefix=X64 --check-prefix=X64-AVX2
 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl | FileCheck 
%s --check-prefix=X64 --check-prefix=X64-AVX512VL
 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512dq,+avx512vl | 
FileCheck %s --check-prefix=X64 --check-prefix=X64-AVX512VLDQ
 
@@ -111,6 +113,45 @@ define <4 x double> @fabs_v4f64(<4 x double> %p) {
 }
 declare <4 x double> @llvm.fabs.v4f64(<4 x double> %p)
 
+define <8 x half> @fabs_v8f16(ptr %p) {
+; X86-AVX-LABEL: fabs_v8f16:
+; X86-AVX:   # %bb.0:
+; X86-AVX-NEXT:movl 4(%esp), [[ADDRREG:%.*]]
+; X86-AVX-NEXT:vmovaps ([[ADDRREG]]), %xmm0
+; X86-AVX-NEXT:vandps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
+; X86-AVX-NEXT:retl
+
+; X86-AVX2-LABEL: fabs_v8f16:
+; X86-AVX2:   # %bb.0:
+; X86-AVX2-NEXT:movl 4(%esp), [[REG:%.*]]
+; X86-AVX2-NEXT:vpbroadcastw {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-AVX2-NEXT:vpand ([[REG]]), %xmm0, %xmm0
+; X86-AVX2-NEXT:retl
+
+; X64-AVX512VL-LABEL: fabs_v8f16:
+; X64-AVX512VL:   # %bb.0:
+; X64-AVX512VL-NEXT:vpbroadcastw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-AVX512VL-NEXT:vpand (%rdi), %xmm0, %xmm0
+; X64-AVX512VL-NEXT:retq
+
+; X64-AVX-LABEL: fabs_v8f16:
+; X64-AVX:   # %bb.0:
+; X64-AVX-NEXT:vmovaps (%rdi), %xmm0
+; X64-AVX-NEXT:vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
+; X64-AVX-NEXT:retq
+
+; X64-AVX2-LABEL: fabs_v8f16:
+; X64-AVX2:   # %bb.0:
+; X64-AVX2-NEXT:vpbroadcastw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-AVX2-NEXT:vpand (%rdi), %xmm0, %xmm0
+; X64-AVX2-NEXT:retq
+
+  %v = load <8 x half>, ptr %p, align 16
+  %nnv = call <8 x half> @llvm.fabs.v8f16(<8 x half> %v)
+  ret <8 x half> %nnv
+}
+declare <8 x half> @llvm.fabs.v8f16(<8 x half> %p)
+
 define <8 x float> @fabs_v8f32(<8 x float> %p) {
 ; X86-AVX-LABEL: fabs_v8f32:
 ; X86-AVX:   # %bb.0:

>From f2f3136667805cc7202ccba45e01393afe34ccc5 Mon Sep 17 00:00:00 2001
From: David Li 
Date: Tue, 7 Nov 2023 23:29:44 -0800
Subject: [PATCH 2/6] Enable Custom Lowering for fabs.v8f16 on AVX

---
 llvm/lib/Target/X86/X86ISelLowering.cpp |  3 ++
 llvm/test/CodeGen/X86/vec_fabs.ll   | 41 +
 2 files changed, 44 insertions(+)

diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 22fba5601ccfd38..8d9519b9f8c6b10 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2238,6 +2238,9 @@ X86TargetLowering::X86TargetLowering(const 
X86TargetMachine &TM,
 }
   }
 
+  if (Subtarget.hasAVX())
+setOperationAction(ISD::FABS, MVT::v8f16, Custom);
+
   if (!Subtarget.useSoftFloat() &&
   (Subtarget.hasAVXNECONVERT() || Subtarget.hasBF16())) {
 addRegisterClass(MVT::v8bf16, Subtarget.hasAVX512() ? &X86::VR128XRegClass
diff --git a/llvm/test/CodeGen/X86/vec_fabs.ll 
b/llvm/test/CodeGen/X86/vec_fabs.ll
index 98

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/71843

>From f7e9a2a9e206062f187ae4cc74038bd31ba32d26 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 9 Nov 2023 13:15:55 -0500
Subject: [PATCH] [lldb-dap] Add an option to show function args in stack
 frames

When this option is enabled, display names of stack frames are generated using 
the `${function.name-with-args}` formatter instead of simply calling 
`SBFrame::GetDisplayFunctionName`. This makes lldb-dap show an output similar 
to the one in the CLI.

This option is disabled by default because of its performance cost. It's a good 
option for non-gigantic programs.
---
 lldb/include/lldb/API/SBDefines.h |   1 +
 lldb/include/lldb/API/SBError.h   |   1 +
 lldb/include/lldb/API/SBFormat.h  |  69 +++
 lldb/include/lldb/API/SBFrame.h   |  17 +-
 lldb/include/lldb/Core/FormatEntity.h | 404 +-
 lldb/include/lldb/Target/StackFrame.h |  18 +-
 lldb/include/lldb/lldb-forward.h  |   4 +
 .../test/tools/lldb-dap/dap_server.py |   4 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   4 +
 lldb/source/API/CMakeLists.txt|   1 +
 lldb/source/API/SBFormat.cpp  |  47 ++
 lldb/source/API/SBFrame.cpp   |  35 ++
 lldb/source/Core/FormatEntity.cpp |  20 +-
 lldb/source/Target/StackFrame.cpp |  25 +-
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |  23 +-
 lldb/tools/lldb-dap/DAP.cpp   |  11 +
 lldb/tools/lldb-dap/DAP.h |   4 +
 lldb/tools/lldb-dap/JSONUtils.cpp |  17 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 lldb/tools/lldb-dap/package.json  |  10 +
 20 files changed, 482 insertions(+), 235 deletions(-)
 create mode 100644 lldb/include/lldb/API/SBFormat.h
 create mode 100644 lldb/source/API/SBFormat.cpp

diff --git a/lldb/include/lldb/API/SBDefines.h 
b/lldb/include/lldb/API/SBDefines.h
index c6f01cc03f263c8..2630a82df0e7135 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -71,6 +71,7 @@ class LLDB_API SBExpressionOptions;
 class LLDB_API SBFile;
 class LLDB_API SBFileSpec;
 class LLDB_API SBFileSpecList;
+class LLDB_API SBFormat;
 class LLDB_API SBFrame;
 class LLDB_API SBFunction;
 class LLDB_API SBHostOS;
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index b241052ed9cc2a2..1a720a479d9a689 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -80,6 +80,7 @@ class LLDB_API SBError {
   friend class SBData;
   friend class SBDebugger;
   friend class SBFile;
+  friend class SBFormat;
   friend class SBHostOS;
   friend class SBPlatform;
   friend class SBProcess;
diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
new file mode 100644
index 000..acc9467b4e2babb
--- /dev/null
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -0,0 +1,69 @@
+
+//===-- SBFormat.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_API_SBFORMAT_H
+#define LLDB_API_SBFORMAT_H
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb_private {
+namespace python {
+class SWIGBridge;
+} // namespace python
+namespace lua {
+class SWIGBridge;
+} // namespace lua
+} // namespace lldb_private
+
+namespace lldb {
+
+/// Class that represents a format string that can be used to generate
+/// descriptions of objects like frames and threads. See
+/// https://lldb.llvm.org/use/formatting.html for more information.
+class LLDB_API SBFormat {
+public:
+  SBFormat();
+
+  SBFormat(const lldb::SBFormat &rhs);
+
+  lldb::SBFormat &operator=(const lldb::SBFormat &rhs);
+
+  ~SBFormat();
+
+  /// \return
+  ///   \b true if and only if this object is valid and can be used for
+  ///   formatting.
+  explicit operator bool() const;
+
+  /// Parse the given format string.
+  ///
+  /// \param[in] format
+  ///   The format string to parse.
+  ///
+  /// \param[out] error
+  ///   An object where error messages will be written to if parsing fails.
+  ///
+  /// \return
+  ///   An \a SBFormat object with the parsing result, which might be an 
invalid
+  ///   object if parsing fails.
+  static lldb::SBFormat Parse(const char *format, lldb::SBError &error);
+
+protected:
+  friend class SBFrame;
+
+  /// \return
+  ///   The underlying shared pointer storage for this object.
+  lldb::FormatEntrySP GetFormatEntrySP() const;
+
+  /// The storage for this object.
+  lldb::FormatEntrySP m_opaque_sp;
+};
+
+} // namespace lldb
+#endif // LLDB_API_SBFORMAT_H
diff --git a/lldb/incl

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/71843

>From 650690b3c8333b6ce54359508519c881f23cf4c4 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 9 Nov 2023 13:15:55 -0500
Subject: [PATCH] [lldb-dap] Add an option to show function args in stack
 frames

When this option is enabled, display names of stack frames are generated using 
the `${function.name-with-args}` formatter instead of simply calling 
`SBFrame::GetDisplayFunctionName`. This makes lldb-dap show an output similar 
to the one in the CLI.

This option is disabled by default because of its performance cost. It's a good 
option for non-gigantic programs.
---
 lldb/include/lldb/API/SBDefines.h |   1 +
 lldb/include/lldb/API/SBError.h   |   1 +
 lldb/include/lldb/API/SBFormat.h  |  68 +++
 lldb/include/lldb/API/SBFrame.h   |  17 +-
 lldb/include/lldb/Core/FormatEntity.h | 404 +-
 lldb/include/lldb/Target/StackFrame.h |  18 +-
 lldb/include/lldb/lldb-forward.h  |   4 +
 .../test/tools/lldb-dap/dap_server.py |   4 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   4 +
 lldb/source/API/CMakeLists.txt|   1 +
 lldb/source/API/SBFormat.cpp  |  47 ++
 lldb/source/API/SBFrame.cpp   |  35 ++
 lldb/source/Core/FormatEntity.cpp |  20 +-
 lldb/source/Target/StackFrame.cpp |  25 +-
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |  23 +-
 lldb/tools/lldb-dap/DAP.cpp   |  11 +
 lldb/tools/lldb-dap/DAP.h |   4 +
 lldb/tools/lldb-dap/JSONUtils.cpp |  17 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 lldb/tools/lldb-dap/package.json  |  10 +
 20 files changed, 481 insertions(+), 235 deletions(-)
 create mode 100644 lldb/include/lldb/API/SBFormat.h
 create mode 100644 lldb/source/API/SBFormat.cpp

diff --git a/lldb/include/lldb/API/SBDefines.h 
b/lldb/include/lldb/API/SBDefines.h
index c6f01cc03f263c8..2630a82df0e7135 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -71,6 +71,7 @@ class LLDB_API SBExpressionOptions;
 class LLDB_API SBFile;
 class LLDB_API SBFileSpec;
 class LLDB_API SBFileSpecList;
+class LLDB_API SBFormat;
 class LLDB_API SBFrame;
 class LLDB_API SBFunction;
 class LLDB_API SBHostOS;
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index b241052ed9cc2a2..1a720a479d9a689 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -80,6 +80,7 @@ class LLDB_API SBError {
   friend class SBData;
   friend class SBDebugger;
   friend class SBFile;
+  friend class SBFormat;
   friend class SBHostOS;
   friend class SBPlatform;
   friend class SBProcess;
diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
new file mode 100644
index 000..ddf38e2991788b1
--- /dev/null
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -0,0 +1,68 @@
+//===-- SBFormat.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_API_SBFORMAT_H
+#define LLDB_API_SBFORMAT_H
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb_private {
+namespace python {
+class SWIGBridge;
+} // namespace python
+namespace lua {
+class SWIGBridge;
+} // namespace lua
+} // namespace lldb_private
+
+namespace lldb {
+
+/// Class that represents a format string that can be used to generate
+/// descriptions of objects like frames and threads. See
+/// https://lldb.llvm.org/use/formatting.html for more information.
+class LLDB_API SBFormat {
+public:
+  SBFormat();
+
+  SBFormat(const lldb::SBFormat &rhs);
+
+  lldb::SBFormat &operator=(const lldb::SBFormat &rhs);
+
+  ~SBFormat();
+
+  /// \return
+  ///   \b true if and only if this object is valid and can be used for
+  ///   formatting.
+  explicit operator bool() const;
+
+  /// Parse the given format string.
+  ///
+  /// \param[in] format
+  ///   The format string to parse.
+  ///
+  /// \param[out] error
+  ///   An object where error messages will be written to if parsing fails.
+  ///
+  /// \return
+  ///   An \a SBFormat object with the parsing result, which might be an 
invalid
+  ///   object if parsing fails.
+  static lldb::SBFormat Parse(const char *format, lldb::SBError &error);
+
+protected:
+  friend class SBFrame;
+
+  /// \return
+  ///   The underlying shared pointer storage for this object.
+  lldb::FormatEntrySP GetFormatEntrySP() const;
+
+  /// The storage for this object.
+  lldb::FormatEntrySP m_opaque_sp;
+};
+
+} // namespace lldb
+#endif // LLDB_API_SBFORMAT_H
diff --git a/lldb/includ

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Greg Clayton via lldb-commits

https://github.com/clayborg requested changes to this pull request.

Just need to not use `llvm::errs()` or `llvm::outs()` in lldb DAP, use 
DAP::SendOutput(OutputType::Console, ...)` to ensure that the users sees this.


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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Greg Clayton via lldb-commits


@@ -824,4 +824,15 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger 
debugger,
   return true;
 }
 
+void DAP::SetFrameFormat(llvm::StringRef format) {
+  if (format.empty())
+return;
+  lldb::SBError error;
+  g_dap.frame_format = lldb::SBFormat::Parse(format.data(), error);
+  if (error.Fail()) {
+llvm::errs() << "The provided frame format '" << format
+ << "' couldn't be parsed. " << error.GetCString() << "\n";

clayborg wrote:

Dump to the console instead of `lldb::errs()` or `llvm::outs()` as 
stdout/stderr go to `/dev/null` as the stdin/stdout is used for packets. When 
we start lldb-dap, we dup the stdin/out/err file descriptors so they don't use 
FD 0, 1 and 2, and then we close stdin/out/err and redirect to /dev/null. Dump 
to the console with:
```
g_dap.SendOutput(OutputType::Console, llvm::StringRef(...));
```


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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,69 @@
+
+//===-- SBFormat.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_API_SBFORMAT_H
+#define LLDB_API_SBFORMAT_H
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb_private {
+namespace python {
+class SWIGBridge;
+} // namespace python
+namespace lua {
+class SWIGBridge;
+} // namespace lua
+} // namespace lldb_private
+
+namespace lldb {
+
+/// Class that represents a format string that can be used to generate
+/// descriptions of objects like frames and threads. See
+/// https://lldb.llvm.org/use/formatting.html for more information.
+class LLDB_API SBFormat {
+public:
+  SBFormat();
+
+  SBFormat(const lldb::SBFormat &rhs);
+
+  lldb::SBFormat &operator=(const lldb::SBFormat &rhs);
+
+  ~SBFormat();
+
+  /// \return
+  ///   \b true if and only if this object is valid and can be used for
+  ///   formatting.
+  explicit operator bool() const;

clayborg wrote:

Does thius work correctly with SWIG and python? It it doesn't, then we might 
need to override a python operator manually to call this operator bool? Not 
sure if that is why we have all of the "IsValid()" stuff around

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


[Lldb-commits] [flang] [mlir] [clang] [clang-tools-extra] [llvm] [lldb] [compiler-rt] [CodeGen][DebugInfo] Add missing debug info for jump table BB (PR #71021)

2023-11-13 Thread via lldb-commits

https://github.com/HaohaiWen updated 
https://github.com/llvm/llvm-project/pull/71021

>From 1be56cf6541d34e4e2ead3f4b3d3ce482d69f68f Mon Sep 17 00:00:00 2001
From: Haohai Wen 
Date: Thu, 2 Nov 2023 12:14:15 +0800
Subject: [PATCH 1/4] [DebugInfo] Add debug info test for jump table

Test whether jump table BB has debug info after ISel.
---
 .../Generic/debug-info-jump-table.ll  | 176 ++
 1 file changed, 176 insertions(+)
 create mode 100644 llvm/test/DebugInfo/Generic/debug-info-jump-table.ll

diff --git a/llvm/test/DebugInfo/Generic/debug-info-jump-table.ll 
b/llvm/test/DebugInfo/Generic/debug-info-jump-table.ll
new file mode 100644
index 000..b73d05441f654bb
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/debug-info-jump-table.ll
@@ -0,0 +1,176 @@
+; RUN: llc -debug-only=isel %s -o /dev/null 2>&1 | FileCheck 
--match-full-lines %s
+
+source_filename = "jump_table.c"
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@str = private unnamed_addr constant [2 x i8] c"1\00", align 1
+@str.12 = private unnamed_addr constant [2 x i8] c"2\00", align 1
+@str.13 = private unnamed_addr constant [2 x i8] c"3\00", align 1
+@str.14 = private unnamed_addr constant [2 x i8] c"4\00", align 1
+@str.15 = private unnamed_addr constant [2 x i8] c"5\00", align 1
+@str.16 = private unnamed_addr constant [2 x i8] c"6\00", align 1
+@str.17 = private unnamed_addr constant [2 x i8] c"7\00", align 1
+@str.18 = private unnamed_addr constant [2 x i8] c"8\00", align 1
+@str.19 = private unnamed_addr constant [2 x i8] c"9\00", align 1
+@str.20 = private unnamed_addr constant [3 x i8] c"10\00", align 1
+@str.21 = private unnamed_addr constant [3 x i8] c"11\00", align 1
+@str.22 = private unnamed_addr constant [3 x i8] c"12\00", align 1
+
+
+
+; Function Attrs: nofree nounwind uwtable
+define dso_local void @foo(i32 noundef %cond) local_unnamed_addr #0 !dbg !42 {
+;CHECK: Initial selection DAG: %bb.{{[0-9]+}} 'foo:entry'
+;CHECK: SelectionDAG has 5 nodes:
+;CHECK: [[TMP1:t.*]]: ch,glue = EntryToken
+;CHECK:   [[TMP2:t.*]]: i64,ch = CopyFromReg [[TMP1]], Register:i64 %{{[0-9]+}}
+;CHECK:   t{{[0-9]+}}: ch = br_jt [[TMP2]]:1, JumpTable:i64<0>, [[TMP2]]
+
+entry:
+  call void @llvm.dbg.value(metadata i32 %cond, metadata !47, metadata 
!DIExpression()), !dbg !48
+  switch i32 %cond, label %sw.epilog [
+i32 1, label %sw.bb
+i32 2, label %sw.bb1
+i32 3, label %sw.bb3
+i32 4, label %sw.bb5
+i32 5, label %sw.bb7
+i32 6, label %sw.bb9
+i32 7, label %sw.bb11
+i32 8, label %sw.bb13
+i32 9, label %sw.bb15
+i32 10, label %sw.bb17
+i32 11, label %sw.bb19
+i32 12, label %sw.bb21
+  ], !dbg !49
+
+sw.bb:; preds = %entry
+  %puts = tail call i32 @puts(ptr nonnull dereferenceable(1) @str), !dbg !50
+  br label %sw.bb1, !dbg !50
+
+sw.bb1:   ; preds = %entry, %sw.bb
+  %puts23 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.12), !dbg 
!52
+  br label %sw.bb3, !dbg !52
+
+sw.bb3:   ; preds = %entry, %sw.bb1
+  %puts24 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.13), !dbg 
!53
+  br label %sw.bb5, !dbg !53
+
+sw.bb5:   ; preds = %entry, %sw.bb3
+  %puts25 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.14), !dbg 
!54
+  br label %sw.bb7, !dbg !54
+
+sw.bb7:   ; preds = %entry, %sw.bb5
+  %puts26 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.15), !dbg 
!55
+  br label %sw.bb9, !dbg !55
+
+sw.bb9:   ; preds = %entry, %sw.bb7
+  %puts27 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.16), !dbg 
!56
+  br label %sw.bb11, !dbg !56
+
+sw.bb11:  ; preds = %entry, %sw.bb9
+  %puts28 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.17), !dbg 
!57
+  br label %sw.bb13, !dbg !57
+
+sw.bb13:  ; preds = %entry, %sw.bb11
+  %puts29 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.18), !dbg 
!58
+  br label %sw.bb15, !dbg !58
+
+sw.bb15:  ; preds = %entry, %sw.bb13
+  %puts30 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.19), !dbg 
!59
+  br label %sw.bb17, !dbg !59
+
+sw.bb17:  ; preds = %entry, %sw.bb15
+  %puts31 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.20), !dbg 
!60
+  br label %sw.bb19, !dbg !60
+
+sw.bb19:  ; preds = %entry, %sw.bb17
+  %puts32 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.21), !dbg 
!61
+  br label %sw.bb21, !dbg !61
+
+sw.bb21:  ; preds = %entry, %sw.bb19
+  %puts33 = tail ca

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,47 @@
+//===-- SBFormat.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/API/SBFormat.h"
+#include "Utils.h"
+#include "lldb/Core/FormatEntity.h"
+#include "lldb/lldb-types.h"
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+SBFormat::SBFormat() : m_opaque_sp() {}

clayborg wrote:

Do we want a constructor like:
```
Also do we want an actual constructor for SBFormat like:
```
SBFormat(const char *format, lldb::SBError &error);
```
Seems a pain to always have to write:
```
SBError error;
SBFormat format = SBFormat::Parse(, error);
```
Versus:
```
SBFormat format(, error);
```


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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Walter Erquinigo via lldb-commits


@@ -0,0 +1,47 @@
+//===-- SBFormat.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/API/SBFormat.h"
+#include "Utils.h"
+#include "lldb/Core/FormatEntity.h"
+#include "lldb/lldb-types.h"
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+SBFormat::SBFormat() : m_opaque_sp() {}

walter-erquinigo wrote:

good idea!

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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/71843

>From 96d3b9e61dde88bc5d7b6dbad7c35932054b8981 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 9 Nov 2023 13:15:55 -0500
Subject: [PATCH] [lldb-dap] Add an option to show function args in stack
 frames

When this option is enabled, display names of stack frames are generated using 
the `${function.name-with-args}` formatter instead of simply calling 
`SBFrame::GetDisplayFunctionName`. This makes lldb-dap show an output similar 
to the one in the CLI.

This option is disabled by default because of its performance cost. It's a good 
option for non-gigantic programs.
---
 lldb/bindings/headers.swig|   1 +
 lldb/bindings/interface/SBFormatDocstrings.i  |   5 +
 lldb/bindings/interfaces.swig |   2 +
 lldb/include/lldb/API/SBDefines.h |   1 +
 lldb/include/lldb/API/SBError.h   |   1 +
 lldb/include/lldb/API/SBFormat.h  |  65 +++
 lldb/include/lldb/API/SBFrame.h   |  17 +-
 lldb/include/lldb/Core/FormatEntity.h | 404 +-
 lldb/include/lldb/Target/StackFrame.h |  18 +-
 lldb/include/lldb/lldb-forward.h  |   4 +
 .../test/tools/lldb-dap/dap_server.py |   4 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   4 +
 lldb/source/API/CMakeLists.txt|   1 +
 lldb/source/API/SBFormat.cpp  |  44 ++
 lldb/source/API/SBFrame.cpp   |  35 ++
 lldb/source/Core/FormatEntity.cpp |  20 +-
 lldb/source/Target/StackFrame.cpp |  25 +-
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |  23 +-
 lldb/tools/lldb-dap/DAP.cpp   |  15 +
 lldb/tools/lldb-dap/DAP.h |   4 +
 lldb/tools/lldb-dap/JSONUtils.cpp |  17 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 lldb/tools/lldb-dap/package.json  |  10 +
 23 files changed, 487 insertions(+), 235 deletions(-)
 create mode 100644 lldb/bindings/interface/SBFormatDocstrings.i
 create mode 100644 lldb/include/lldb/API/SBFormat.h
 create mode 100644 lldb/source/API/SBFormat.cpp

diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index b1d88726f754354..408db90b925f15e 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -30,6 +30,7 @@
 #include "lldb/API/SBFile.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBFileSpecList.h"
+#include "lldb/API/SBFormat.h"
 #include "lldb/API/SBFrame.h"
 #include "lldb/API/SBFunction.h"
 #include "lldb/API/SBHostOS.h"
diff --git a/lldb/bindings/interface/SBFormatDocstrings.i 
b/lldb/bindings/interface/SBFormatDocstrings.i
new file mode 100644
index 000..a7304f5f6a84837
--- /dev/null
+++ b/lldb/bindings/interface/SBFormatDocstrings.i
@@ -0,0 +1,5 @@
+%feature("docstring",
+"Class that represents a format string that can be used to generate "
+"descriptions of objects like frames and threads. See "
+"https://lldb.llvm.org/use/formatting.html for more information."
+) lldb::SBFormat;
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 373c2f6cf545cfb..9ca479218f621c5 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -34,6 +34,7 @@
 %include "./interface/SBFileDocstrings.i"
 %include "./interface/SBFileSpecDocstrings.i"
 %include "./interface/SBFileSpecListDocstrings.i"
+%include "./interface/SBFormatDocstrings.i"
 %include "./interface/SBFrameDocstrings.i"
 %include "./interface/SBFunctionDocstrings.i"
 %include "./interface/SBHostOSDocstrings.i"
@@ -106,6 +107,7 @@
 %include "lldb/API/SBFile.h"
 %include "lldb/API/SBFileSpec.h"
 %include "lldb/API/SBFileSpecList.h"
+%include "lldb/API/SBFormat.h"
 %include "lldb/API/SBFrame.h"
 %include "lldb/API/SBFunction.h"
 %include "lldb/API/SBHostOS.h"
diff --git a/lldb/include/lldb/API/SBDefines.h 
b/lldb/include/lldb/API/SBDefines.h
index c6f01cc03f263c8..2630a82df0e7135 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -71,6 +71,7 @@ class LLDB_API SBExpressionOptions;
 class LLDB_API SBFile;
 class LLDB_API SBFileSpec;
 class LLDB_API SBFileSpecList;
+class LLDB_API SBFormat;
 class LLDB_API SBFrame;
 class LLDB_API SBFunction;
 class LLDB_API SBHostOS;
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index b241052ed9cc2a2..1a720a479d9a689 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -80,6 +80,7 @@ class LLDB_API SBError {
   friend class SBData;
   friend class SBDebugger;
   friend class SBFile;
+  friend class SBFormat;
   friend class SBHostOS;
   friend class SBPlatform;
   friend class SBProcess;
diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
new file mode 100644
index 000..1bbaad18cafafab
--- /dev/null
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -0,0 +1,65 @@
+//===-- SBFo

[Lldb-commits] [lldb] [llvm] Emit DIE's size in bits when size is not a multiple of 8 (PR #69741)

2023-11-13 Thread David Blaikie via lldb-commits

dwblaikie wrote:

> @dwblaikie I talked with Adrian, his idea is to emit the size in bits 
> whenever it does not cleanly fit in a byte. His point (and I agree) is that 
> there may be tools that can use this bit size, and if we always round up when 
> emitting the DWARF we will lose this information, with no way to recover it. 
> I updated the patch to implement this behavior.

Yeah - ultimately it's pretty much up to you folks how you encode Swift and 
ObjC things - so take anything I'm saying as advice but not requirement.

But it feels a bit at-odds with precedent in the way other things that seem 
similar to me are encoded in DWARF already, and precedent is pretty much 
most/all we have to go with in DWARF.

I guess one question that might be relevant - does Swift have something like 
`sizeof` and what result does it give for these sort of types with bits to 
spare?

But like I said - it seems like structs with tail padding are similar to this 
situation - we still describe the whole size of the struct, because that's used 
for creating arrays of instances, ABI passing, etc. But the tail padding can 
still be used, in certain circumstances, when laying out a derived class. We 
encode this as the POD-ness of the type, and so if you wanted to create a class 
that derived from one described in DWARF you could do so & would know whether 
or not to put the derived class's members into the tail padding of the base or 
not.

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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Greg Clayton via lldb-commits

https://github.com/clayborg requested changes to this pull request.

One last request: test the SBFormat API in a stand alone test in 
`lldb/test/api/sbformat` so we can see if the errors work and the "operator 
bool" works as expected:
```
format = lldb.SBFormat()
self.assertFalse(format)
err = lldb.SBError()
format = lldb.SBFormat("${bad}", error)
self.assertFalse(format) # We expect an invalid object back if we have an error
self.assertTrue(error.Fail())
format = lldb.SBFormat("${frame.index}", error)
# Check the error string here as well
self.assertTrue(format)
self.assertTrue(error.Success())
```


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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits

jimingham wrote:

I addressed most of the review comments - a few I had questions about - and 
also did the clang-format & python-deformatting.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2023-11-13 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
a41b149f481e2bcba24e81f208a1938247f040e0..aaeb653198f32386f8f7d38e4607fdd274f285d5
 lldb/examples/python/parsed_cmd.py 
lldb/test/API/commands/command/script/add/TestAddParsedCommand.py 
lldb/test/API/commands/command/script/add/test_commands.py
``





View the diff from darker here.


``diff
--- test/API/commands/command/script/add/TestAddParsedCommand.py
2023-10-30 21:48:37.00 +
+++ test/API/commands/command/script/add/TestAddParsedCommand.py
2023-11-14 01:40:47.807666 +
@@ -14,11 +14,11 @@
 NO_DEBUG_INFO_TESTCASE = True
 
 def test(self):
 self.pycmd_tests()
 
-def check_help_options(self, cmd_name, opt_list, substrs = []):
+def check_help_options(self, cmd_name, opt_list, substrs=[]):
 """
 Pass the command name in cmd_name and a vector of the short option, 
type & long option.
 This will append the checks for all the options and test "help 
command".
 Any strings already in substrs will also be checked.
 Any element in opt list that begin with "+" will be added to the 
checked strings as is.
@@ -28,119 +28,172 @@
 substrs.append(elem[1:])
 else:
 (short_opt, type, long_opt) = elem
 substrs.append(f"-{short_opt} <{type}> ( --{long_opt} <{type}> 
)")
 print(f"Opt Vec\n{substrs}")
-self.expect("help " + cmd_name, substrs = substrs)
+self.expect("help " + cmd_name, substrs=substrs)
 
 def pycmd_tests(self):
 source_dir = self.getSourceDir()
 test_file_path = os.path.join(source_dir, "test_commands.py")
 self.runCmd("command script import " + test_file_path)
-self.expect("help", substrs = ["no-args", "one-arg-no-opt", 
"two-args"])
+self.expect("help", substrs=["no-args", "one-arg-no-opt", "two-args"])
 
 # Test that we did indeed add these commands as user commands:
 
 # This is the function to remove the custom commands in order to have a
 # clean slate for the next test case.
 def cleanup():
-self.runCmd("command script delete no-args one-arg-no-opt 
two-args", check=False)
+self.runCmd(
+"command script delete no-args one-arg-no-opt two-args", 
check=False
+)
 
 # Execute the cleanup function during test case tear down.
 self.addTearDownHook(cleanup)
 
 # First test the no arguments command.  Make sure the help is right:
-no_arg_opts = [["b", "boolean", "bool-arg"],
-   "+a boolean arg, defaults to True",
-   ["d", "filename", "disk-file-name"],
-   "+An on disk filename",
-   ["e", "none", "enum-option"],
-   "+An enum, doesn't actually do anything",
-   "+Values: foo | bar | baz",
-   ["l", "linenum", "line-num"],
-   "+A line number",
-   ["s", "shlib-name", "shlib-name"],
-   "+A shared library name"]
-substrs = ["Example command for use in debugging",
-   "Syntax: no-args "]
-
+no_arg_opts = [
+["b", "boolean", "bool-arg"],
+"+a boolean arg, defaults to True",
+["d", "filename", "disk-file-name"],
+"+An on disk filename",
+["e", "none", "enum-option"],
+"+An enum, doesn't actually do anything",
+"+Values: foo | bar | baz",
+["l", "linenum", "line-num"],
+"+A line number",
+["s", "shlib-name", "shlib-name"],
+"+A shared library name",
+]
+substrs = [
+"Example command for use in debugging",
+"Syntax: no-args ",
+]
+
 self.check_help_options("no-args", no_arg_opts, substrs)
 
 # Make sure the command doesn't accept arguments:
-self.expect("no-args an-arg", substrs=["'no-args' doesn't take any 
arguments."],
-error=True)
+self.expect(
+"no-args an-arg",
+substrs=["'no-args' doesn't take any arguments."],
+error=True,
+)
 
 # Try setting the bool with the wrong value:
-self.expect("no-args -b Something",
-substrs=["Error setting option: bool-arg to Something"],
-error=True)
+self.expect(
+"no-args -b Something",
+substrs=["Error setting option: bool-arg to Something"],
+error=True,
+)
 # Try setting the enum to an illegal value as well:
-self.expect("no-args --enum-option Something",
-substrs=["error: E

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/71843

>From 9dab558339346e15149bb59da4dc2d58070dafa2 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 9 Nov 2023 13:15:55 -0500
Subject: [PATCH] [lldb-dap] Add an option to show function args in stack
 frames

When this option is enabled, display names of stack frames are generated using 
the `${function.name-with-args}` formatter instead of simply calling 
`SBFrame::GetDisplayFunctionName`. This makes lldb-dap show an output similar 
to the one in the CLI.

This option is disabled by default because of its performance cost. It's a good 
option for non-gigantic programs.
---
 lldb/bindings/headers.swig|   1 +
 lldb/bindings/interface/SBFormatDocstrings.i  |   5 +
 lldb/bindings/interfaces.swig |   2 +
 lldb/include/lldb/API/SBDefines.h |   1 +
 lldb/include/lldb/API/SBError.h   |   1 +
 lldb/include/lldb/API/SBFormat.h  |  65 +++
 lldb/include/lldb/API/SBFrame.h   |  17 +-
 lldb/include/lldb/Core/FormatEntity.h | 404 +-
 lldb/include/lldb/Target/StackFrame.h |  18 +-
 lldb/include/lldb/lldb-forward.h  |   4 +
 .../test/tools/lldb-dap/dap_server.py |   4 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   4 +
 lldb/source/API/CMakeLists.txt|   1 +
 lldb/source/API/SBFormat.cpp  |  44 ++
 lldb/source/API/SBFrame.cpp   |  35 ++
 lldb/source/Core/FormatEntity.cpp |  20 +-
 lldb/source/Target/StackFrame.cpp |  25 +-
 lldb/test/API/python_api/format/TestFormat.py |  24 ++
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |  23 +-
 lldb/tools/lldb-dap/DAP.cpp   |  15 +
 lldb/tools/lldb-dap/DAP.h |   4 +
 lldb/tools/lldb-dap/JSONUtils.cpp |  17 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 lldb/tools/lldb-dap/package.json  |  10 +
 24 files changed, 511 insertions(+), 235 deletions(-)
 create mode 100644 lldb/bindings/interface/SBFormatDocstrings.i
 create mode 100644 lldb/include/lldb/API/SBFormat.h
 create mode 100644 lldb/source/API/SBFormat.cpp
 create mode 100644 lldb/test/API/python_api/format/TestFormat.py

diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index b1d88726f754354..408db90b925f15e 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -30,6 +30,7 @@
 #include "lldb/API/SBFile.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBFileSpecList.h"
+#include "lldb/API/SBFormat.h"
 #include "lldb/API/SBFrame.h"
 #include "lldb/API/SBFunction.h"
 #include "lldb/API/SBHostOS.h"
diff --git a/lldb/bindings/interface/SBFormatDocstrings.i 
b/lldb/bindings/interface/SBFormatDocstrings.i
new file mode 100644
index 000..a7304f5f6a84837
--- /dev/null
+++ b/lldb/bindings/interface/SBFormatDocstrings.i
@@ -0,0 +1,5 @@
+%feature("docstring",
+"Class that represents a format string that can be used to generate "
+"descriptions of objects like frames and threads. See "
+"https://lldb.llvm.org/use/formatting.html for more information."
+) lldb::SBFormat;
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 373c2f6cf545cfb..9ca479218f621c5 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -34,6 +34,7 @@
 %include "./interface/SBFileDocstrings.i"
 %include "./interface/SBFileSpecDocstrings.i"
 %include "./interface/SBFileSpecListDocstrings.i"
+%include "./interface/SBFormatDocstrings.i"
 %include "./interface/SBFrameDocstrings.i"
 %include "./interface/SBFunctionDocstrings.i"
 %include "./interface/SBHostOSDocstrings.i"
@@ -106,6 +107,7 @@
 %include "lldb/API/SBFile.h"
 %include "lldb/API/SBFileSpec.h"
 %include "lldb/API/SBFileSpecList.h"
+%include "lldb/API/SBFormat.h"
 %include "lldb/API/SBFrame.h"
 %include "lldb/API/SBFunction.h"
 %include "lldb/API/SBHostOS.h"
diff --git a/lldb/include/lldb/API/SBDefines.h 
b/lldb/include/lldb/API/SBDefines.h
index c6f01cc03f263c8..2630a82df0e7135 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -71,6 +71,7 @@ class LLDB_API SBExpressionOptions;
 class LLDB_API SBFile;
 class LLDB_API SBFileSpec;
 class LLDB_API SBFileSpecList;
+class LLDB_API SBFormat;
 class LLDB_API SBFrame;
 class LLDB_API SBFunction;
 class LLDB_API SBHostOS;
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index b241052ed9cc2a2..1a720a479d9a689 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -80,6 +80,7 @@ class LLDB_API SBError {
   friend class SBData;
   friend class SBDebugger;
   friend class SBFile;
+  friend class SBFormat;
   friend class SBHostOS;
   friend class SBPlatform;
   friend class SBProcess;
diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
new file mode 100644

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
0e1a52f556a90cc7b7ce7666fc476c99cf7bfb02..9dab558339346e15149bb59da4dc2d58070dafa2
 lldb/test/API/python_api/format/TestFormat.py 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
``





View the diff from darker here.


``diff
--- test/API/python_api/format/TestFormat.py2023-11-14 01:50:00.00 +
+++ test/API/python_api/format/TestFormat.py2023-11-14 01:52:37.635813 +
@@ -13,11 +13,11 @@
 self.assertFalse(format)
 
 error = lldb.SBError()
 format = lldb.SBFormat("${bad}", error)
 self.assertIn("invalid top level item 'bad'", error.GetCString())
-self.assertFalse(format) # We expect an invalid object back if we have 
an error
+self.assertFalse(format)  # We expect an invalid object back if we 
have an error
 self.assertTrue(error.Fail())
 
 format = lldb.SBFormat("${frame.index}", error)
 self.assertIs(error.GetCString(), None)
 self.assertTrue(format)

``




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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Greg Clayton via lldb-commits

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

Thanks for all of the changes. Looks great!

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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/71843

>From 9dab558339346e15149bb59da4dc2d58070dafa2 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 9 Nov 2023 13:15:55 -0500
Subject: [PATCH 1/2] [lldb-dap] Add an option to show function args in stack
 frames

When this option is enabled, display names of stack frames are generated using 
the `${function.name-with-args}` formatter instead of simply calling 
`SBFrame::GetDisplayFunctionName`. This makes lldb-dap show an output similar 
to the one in the CLI.

This option is disabled by default because of its performance cost. It's a good 
option for non-gigantic programs.
---
 lldb/bindings/headers.swig|   1 +
 lldb/bindings/interface/SBFormatDocstrings.i  |   5 +
 lldb/bindings/interfaces.swig |   2 +
 lldb/include/lldb/API/SBDefines.h |   1 +
 lldb/include/lldb/API/SBError.h   |   1 +
 lldb/include/lldb/API/SBFormat.h  |  65 +++
 lldb/include/lldb/API/SBFrame.h   |  17 +-
 lldb/include/lldb/Core/FormatEntity.h | 404 +-
 lldb/include/lldb/Target/StackFrame.h |  18 +-
 lldb/include/lldb/lldb-forward.h  |   4 +
 .../test/tools/lldb-dap/dap_server.py |   4 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |   4 +
 lldb/source/API/CMakeLists.txt|   1 +
 lldb/source/API/SBFormat.cpp  |  44 ++
 lldb/source/API/SBFrame.cpp   |  35 ++
 lldb/source/Core/FormatEntity.cpp |  20 +-
 lldb/source/Target/StackFrame.cpp |  25 +-
 lldb/test/API/python_api/format/TestFormat.py |  24 ++
 .../lldb-dap/stackTrace/TestDAP_stackTrace.py |  23 +-
 lldb/tools/lldb-dap/DAP.cpp   |  15 +
 lldb/tools/lldb-dap/DAP.h |   4 +
 lldb/tools/lldb-dap/JSONUtils.cpp |  17 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 lldb/tools/lldb-dap/package.json  |  10 +
 24 files changed, 511 insertions(+), 235 deletions(-)
 create mode 100644 lldb/bindings/interface/SBFormatDocstrings.i
 create mode 100644 lldb/include/lldb/API/SBFormat.h
 create mode 100644 lldb/source/API/SBFormat.cpp
 create mode 100644 lldb/test/API/python_api/format/TestFormat.py

diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index b1d88726f754354..408db90b925f15e 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -30,6 +30,7 @@
 #include "lldb/API/SBFile.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBFileSpecList.h"
+#include "lldb/API/SBFormat.h"
 #include "lldb/API/SBFrame.h"
 #include "lldb/API/SBFunction.h"
 #include "lldb/API/SBHostOS.h"
diff --git a/lldb/bindings/interface/SBFormatDocstrings.i 
b/lldb/bindings/interface/SBFormatDocstrings.i
new file mode 100644
index 000..a7304f5f6a84837
--- /dev/null
+++ b/lldb/bindings/interface/SBFormatDocstrings.i
@@ -0,0 +1,5 @@
+%feature("docstring",
+"Class that represents a format string that can be used to generate "
+"descriptions of objects like frames and threads. See "
+"https://lldb.llvm.org/use/formatting.html for more information."
+) lldb::SBFormat;
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 373c2f6cf545cfb..9ca479218f621c5 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -34,6 +34,7 @@
 %include "./interface/SBFileDocstrings.i"
 %include "./interface/SBFileSpecDocstrings.i"
 %include "./interface/SBFileSpecListDocstrings.i"
+%include "./interface/SBFormatDocstrings.i"
 %include "./interface/SBFrameDocstrings.i"
 %include "./interface/SBFunctionDocstrings.i"
 %include "./interface/SBHostOSDocstrings.i"
@@ -106,6 +107,7 @@
 %include "lldb/API/SBFile.h"
 %include "lldb/API/SBFileSpec.h"
 %include "lldb/API/SBFileSpecList.h"
+%include "lldb/API/SBFormat.h"
 %include "lldb/API/SBFrame.h"
 %include "lldb/API/SBFunction.h"
 %include "lldb/API/SBHostOS.h"
diff --git a/lldb/include/lldb/API/SBDefines.h 
b/lldb/include/lldb/API/SBDefines.h
index c6f01cc03f263c8..2630a82df0e7135 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -71,6 +71,7 @@ class LLDB_API SBExpressionOptions;
 class LLDB_API SBFile;
 class LLDB_API SBFileSpec;
 class LLDB_API SBFileSpecList;
+class LLDB_API SBFormat;
 class LLDB_API SBFrame;
 class LLDB_API SBFunction;
 class LLDB_API SBHostOS;
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index b241052ed9cc2a2..1a720a479d9a689 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -80,6 +80,7 @@ class LLDB_API SBError {
   friend class SBData;
   friend class SBDebugger;
   friend class SBFile;
+  friend class SBFormat;
   friend class SBHostOS;
   friend class SBPlatform;
   friend class SBProcess;
diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
new file mode 100

[Lldb-commits] [lldb] d9ec4b2 - [lldb-dap] Add an option to provide a format for stack frames (#71843)

2023-11-13 Thread via lldb-commits

Author: Walter Erquinigo
Date: 2023-11-13T21:10:16-05:00
New Revision: d9ec4b24a84addb8bd77b5d9dd990181351cf84c

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

LOG: [lldb-dap] Add an option to provide a format for stack frames (#71843)

When this option gets enabled, descriptions of stack frames will be
generated using the format provided in the launch configuration instead
of simply calling `SBFrame::GetDisplayFunctionName`. This allows
lldb-dap to show an output similar to the one in the CLI.

Added: 
lldb/bindings/interface/SBFormatDocstrings.i
lldb/include/lldb/API/SBFormat.h
lldb/source/API/SBFormat.cpp
lldb/test/API/python_api/format/TestFormat.py

Modified: 
lldb/bindings/headers.swig
lldb/bindings/interfaces.swig
lldb/include/lldb/API/SBDefines.h
lldb/include/lldb/API/SBError.h
lldb/include/lldb/API/SBFrame.h
lldb/include/lldb/Core/FormatEntity.h
lldb/include/lldb/Target/StackFrame.h
lldb/include/lldb/lldb-forward.h
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
lldb/source/API/CMakeLists.txt
lldb/source/API/SBFrame.cpp
lldb/source/Core/FormatEntity.cpp
lldb/source/Target/StackFrame.cpp
lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/JSONUtils.cpp
lldb/tools/lldb-dap/lldb-dap.cpp
lldb/tools/lldb-dap/package.json

Removed: 




diff  --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index b1d88726f754354..408db90b925f15e 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -30,6 +30,7 @@
 #include "lldb/API/SBFile.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBFileSpecList.h"
+#include "lldb/API/SBFormat.h"
 #include "lldb/API/SBFrame.h"
 #include "lldb/API/SBFunction.h"
 #include "lldb/API/SBHostOS.h"

diff  --git a/lldb/bindings/interface/SBFormatDocstrings.i 
b/lldb/bindings/interface/SBFormatDocstrings.i
new file mode 100644
index 000..a7304f5f6a84837
--- /dev/null
+++ b/lldb/bindings/interface/SBFormatDocstrings.i
@@ -0,0 +1,5 @@
+%feature("docstring",
+"Class that represents a format string that can be used to generate "
+"descriptions of objects like frames and threads. See "
+"https://lldb.llvm.org/use/formatting.html for more information."
+) lldb::SBFormat;

diff  --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 373c2f6cf545cfb..9ca479218f621c5 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -34,6 +34,7 @@
 %include "./interface/SBFileDocstrings.i"
 %include "./interface/SBFileSpecDocstrings.i"
 %include "./interface/SBFileSpecListDocstrings.i"
+%include "./interface/SBFormatDocstrings.i"
 %include "./interface/SBFrameDocstrings.i"
 %include "./interface/SBFunctionDocstrings.i"
 %include "./interface/SBHostOSDocstrings.i"
@@ -106,6 +107,7 @@
 %include "lldb/API/SBFile.h"
 %include "lldb/API/SBFileSpec.h"
 %include "lldb/API/SBFileSpecList.h"
+%include "lldb/API/SBFormat.h"
 %include "lldb/API/SBFrame.h"
 %include "lldb/API/SBFunction.h"
 %include "lldb/API/SBHostOS.h"

diff  --git a/lldb/include/lldb/API/SBDefines.h 
b/lldb/include/lldb/API/SBDefines.h
index c6f01cc03f263c8..2630a82df0e7135 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -71,6 +71,7 @@ class LLDB_API SBExpressionOptions;
 class LLDB_API SBFile;
 class LLDB_API SBFileSpec;
 class LLDB_API SBFileSpecList;
+class LLDB_API SBFormat;
 class LLDB_API SBFrame;
 class LLDB_API SBFunction;
 class LLDB_API SBHostOS;

diff  --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index b241052ed9cc2a2..1a720a479d9a689 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -80,6 +80,7 @@ class LLDB_API SBError {
   friend class SBData;
   friend class SBDebugger;
   friend class SBFile;
+  friend class SBFormat;
   friend class SBHostOS;
   friend class SBPlatform;
   friend class SBProcess;

diff  --git a/lldb/include/lldb/API/SBFormat.h 
b/lldb/include/lldb/API/SBFormat.h
new file mode 100644
index 000..1bbaad18cafafab
--- /dev/null
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -0,0 +1,65 @@
+//===-- SBFormat.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_API_SBFORMAT_H
+#define LLDB_API_SBFORMAT_H
+
+#i

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for stack frames (PR #71843)

2023-11-13 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for threads (PR #72196)

2023-11-13 Thread Walter Erquinigo via lldb-commits

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

When this option gets enabled, descriptions of threads will be generated using 
the format provided in the launch configuration instead of generating it 
manually in the dap code. This allows lldb-dap to show an output similar to the 
one in the CLI.
This is very similar to https://github.com/llvm/llvm-project/pull/71843


>From 5b5ec92b655e390e652fafbe3f56628ff822ee51 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 13 Nov 2023 21:42:26 -0500
Subject: [PATCH] [lldb-dap] Add an option to provide a format for threads

When this option gets enabled, descriptions of threads will be generated using 
the format provided in the launch configuration instead of generating it 
manually in the dap code. This allows lldb-dap to show an output similar to the 
one in the CLI.
This is very similar to https://github.com/llvm/llvm-project/pull/71843
---
 lldb/include/lldb/API/SBFormat.h  |  1 +
 lldb/include/lldb/API/SBThread.h  | 15 +++
 lldb/include/lldb/Target/Thread.h | 27 +---
 .../test/tools/lldb-dap/dap_server.py |  3 ++
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  4 ++
 lldb/source/API/SBThread.cpp  | 35 ---
 lldb/source/Target/Thread.cpp | 19 +---
 .../{correct-thread => threads}/Makefile  |  0
 .../TestDAP_threads.py}   | 25 ++-
 .../{correct-thread => threads}/main.c|  0
 lldb/tools/lldb-dap/DAP.cpp   | 15 +++
 lldb/tools/lldb-dap/DAP.h |  3 ++
 lldb/tools/lldb-dap/JSONUtils.cpp | 43 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  2 +
 lldb/tools/lldb-dap/package.json  | 10 +
 15 files changed, 166 insertions(+), 36 deletions(-)
 rename lldb/test/API/tools/lldb-dap/{correct-thread => threads}/Makefile (100%)
 rename lldb/test/API/tools/lldb-dap/{correct-thread/TestDAP_correct_thread.py 
=> threads/TestDAP_threads.py} (63%)
 rename lldb/test/API/tools/lldb-dap/{correct-thread => threads}/main.c (100%)

diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
index 1bbaad18cafafab..757340ab2b5c2a4 100644
--- a/lldb/include/lldb/API/SBFormat.h
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -52,6 +52,7 @@ class LLDB_API SBFormat {
 
 protected:
   friend class SBFrame;
+  friend class SBThread;
 
   /// \return
   ///   The underlying shared pointer storage for this object.
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h
index 49c3d954fa93329..dcf6aa9d5424e85 100644
--- a/lldb/include/lldb/API/SBThread.h
+++ b/lldb/include/lldb/API/SBThread.h
@@ -200,6 +200,21 @@ class LLDB_API SBThread {
 
   bool GetDescription(lldb::SBStream &description, bool stop_format) const;
 
+  /// Similar to \a GetDescription() but the format of the description can be
+  /// configured via the \p format parameter. See
+  /// https://lldb.llvm.org/use/formatting.html for more information on format
+  /// strings.
+  ///
+  /// \param[in] format
+  ///   The format to use for generating the description.
+  ///
+  /// \param[out] output
+  ///   The stream where the description will be written to.
+  ///
+  /// \return
+  ///   An error object with an error message in case of failures.
+  SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output);
+
   bool GetStatus(lldb::SBStream &status) const;
 
   SBThread GetExtendedBacktraceThread(const char *type);
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index dabdbb8d455021a..2c47b66d8b54d95 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -490,6 +490,23 @@ class Thread : public std::enable_shared_from_this,
   void DumpTraceInstructions(Stream &s, size_t count,
  size_t start_position = 0) const;
 
+  /// Print a description of this thread using the provided thread format.
+  ///
+  /// \param[out] strm
+  ///   The Stream to print the description to.
+  ///
+  /// \param[in] frame_idx
+  ///   If not \b LLDB_INVALID_FRAME_ID, then use this frame index as context 
to
+  ///   generate the description.
+  ///
+  /// \param[in] format
+  ///   The input format.
+  ///
+  /// \return
+  ///   \b true if and only if dumping with the given \p format worked.
+  bool DumpUsingFormat(Stream &strm, uint32_t frame_idx,
+   const FormatEntity::Entry *format);
+
   // If stop_format is true, this will be the form used when we print stop
   // info. If false, it will be the form we use for thread list and co.
   void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx,
@@ -1169,11 +1186,11 @@ class Thread : public 
std::enable_shared_from_this,
   void ResetStopInfo();
 
   void SetShouldReportStop(Vote vote);
-  
-  void SetShouldRunBeforePublicStop(bool newval) { 
-  

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for threads (PR #72196)

2023-11-13 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Walter Erquinigo (walter-erquinigo)


Changes

When this option gets enabled, descriptions of threads will be generated using 
the format provided in the launch configuration instead of generating it 
manually in the dap code. This allows lldb-dap to show an output similar to the 
one in the CLI.
This is very similar to https://github.com/llvm/llvm-project/pull/71843


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


15 Files Affected:

- (modified) lldb/include/lldb/API/SBFormat.h (+1) 
- (modified) lldb/include/lldb/API/SBThread.h (+15) 
- (modified) lldb/include/lldb/Target/Thread.h (+22-5) 
- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
(+3) 
- (modified) 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py (+4) 
- (modified) lldb/source/API/SBThread.cpp (+30-5) 
- (modified) lldb/source/Target/Thread.cpp (+13-6) 
- (renamed) lldb/test/API/tools/lldb-dap/threads/Makefile () 
- (renamed) lldb/test/API/tools/lldb-dap/threads/TestDAP_threads.py (+23-2) 
- (renamed) lldb/test/API/tools/lldb-dap/threads/main.c () 
- (modified) lldb/tools/lldb-dap/DAP.cpp (+15) 
- (modified) lldb/tools/lldb-dap/DAP.h (+3) 
- (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+25-18) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+2) 
- (modified) lldb/tools/lldb-dap/package.json (+10) 


``diff
diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
index 1bbaad18cafafab..757340ab2b5c2a4 100644
--- a/lldb/include/lldb/API/SBFormat.h
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -52,6 +52,7 @@ class LLDB_API SBFormat {
 
 protected:
   friend class SBFrame;
+  friend class SBThread;
 
   /// \return
   ///   The underlying shared pointer storage for this object.
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h
index 49c3d954fa93329..dcf6aa9d5424e85 100644
--- a/lldb/include/lldb/API/SBThread.h
+++ b/lldb/include/lldb/API/SBThread.h
@@ -200,6 +200,21 @@ class LLDB_API SBThread {
 
   bool GetDescription(lldb::SBStream &description, bool stop_format) const;
 
+  /// Similar to \a GetDescription() but the format of the description can be
+  /// configured via the \p format parameter. See
+  /// https://lldb.llvm.org/use/formatting.html for more information on format
+  /// strings.
+  ///
+  /// \param[in] format
+  ///   The format to use for generating the description.
+  ///
+  /// \param[out] output
+  ///   The stream where the description will be written to.
+  ///
+  /// \return
+  ///   An error object with an error message in case of failures.
+  SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output);
+
   bool GetStatus(lldb::SBStream &status) const;
 
   SBThread GetExtendedBacktraceThread(const char *type);
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index dabdbb8d455021a..2c47b66d8b54d95 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -490,6 +490,23 @@ class Thread : public std::enable_shared_from_this,
   void DumpTraceInstructions(Stream &s, size_t count,
  size_t start_position = 0) const;
 
+  /// Print a description of this thread using the provided thread format.
+  ///
+  /// \param[out] strm
+  ///   The Stream to print the description to.
+  ///
+  /// \param[in] frame_idx
+  ///   If not \b LLDB_INVALID_FRAME_ID, then use this frame index as context 
to
+  ///   generate the description.
+  ///
+  /// \param[in] format
+  ///   The input format.
+  ///
+  /// \return
+  ///   \b true if and only if dumping with the given \p format worked.
+  bool DumpUsingFormat(Stream &strm, uint32_t frame_idx,
+   const FormatEntity::Entry *format);
+
   // If stop_format is true, this will be the form used when we print stop
   // info. If false, it will be the form we use for thread list and co.
   void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx,
@@ -1169,11 +1186,11 @@ class Thread : public 
std::enable_shared_from_this,
   void ResetStopInfo();
 
   void SetShouldReportStop(Vote vote);
-  
-  void SetShouldRunBeforePublicStop(bool newval) { 
-  m_should_run_before_public_stop = newval; 
+
+  void SetShouldRunBeforePublicStop(bool newval) {
+m_should_run_before_public_stop = newval;
   }
-  
+
   bool ShouldRunBeforePublicStop() {
   return m_should_run_before_public_stop;
   }
@@ -1266,7 +1283,7 @@ class Thread : public 
std::enable_shared_from_this,
   uint32_t m_stop_info_override_stop_id; // The stop ID containing the last 
time
  // the stop info was checked against
  // the stop info override
-  bool m_should_run_before_public_stop;  // If this thread has "stop others" 
+  bool m_should_run_before_public_stop;  // If this thread has "stop others"
  

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for threads (PR #72196)

2023-11-13 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
e9453f3c3c7e682e39952c9e18e6b1f8152b0ffa..5b5ec92b655e390e652fafbe3f56628ff822ee51
 lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
lldb/test/API/tools/lldb-dap/threads/TestDAP_threads.py
``





View the diff from darker here.


``diff
--- test/API/tools/lldb-dap/threads/TestDAP_threads.py  2023-11-14 
02:43:30.00 +
+++ test/API/tools/lldb-dap/threads/TestDAP_threads.py  2023-11-14 
02:48:15.446523 +
@@ -49,11 +49,13 @@
 def test_thread_format(self):
 """
 Tests the support for custom thread formats.
 """
 program = self.getBuildArtifact("a.out")
-self.build_and_launch(program, customThreadFormat="This is thread 
index #${thread.index}")
+self.build_and_launch(
+program, customThreadFormat="This is thread index #${thread.index}"
+)
 source = "main.c"
 breakpoint_line = line_number(source, "// break here")
 lines = [breakpoint_line]
 # Set breakpoint in the thread function
 breakpoint_ids = self.set_source_breakpoints(source, lines)

``




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


[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for threads (PR #72196)

2023-11-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/72196

>From 00c258dd5c90cd920e5771ac89c0a8d2e97be937 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 13 Nov 2023 21:42:26 -0500
Subject: [PATCH] thread format

---
 lldb/include/lldb/API/SBFormat.h  |  1 +
 lldb/include/lldb/API/SBThread.h  | 15 +++
 lldb/include/lldb/Target/Thread.h | 17 
 .../test/tools/lldb-dap/dap_server.py |  3 ++
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  4 ++
 lldb/source/API/SBThread.cpp  | 35 ---
 lldb/source/Target/Thread.cpp | 19 +---
 .../{correct-thread => threads}/Makefile  |  0
 .../TestDAP_threads.py}   | 25 ++-
 .../{correct-thread => threads}/main.c|  0
 lldb/tools/lldb-dap/DAP.cpp   | 15 +++
 lldb/tools/lldb-dap/DAP.h |  3 ++
 lldb/tools/lldb-dap/JSONUtils.cpp | 43 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  2 +
 lldb/tools/lldb-dap/package.json  | 10 +
 15 files changed, 161 insertions(+), 31 deletions(-)
 rename lldb/test/API/tools/lldb-dap/{correct-thread => threads}/Makefile (100%)
 rename lldb/test/API/tools/lldb-dap/{correct-thread/TestDAP_correct_thread.py 
=> threads/TestDAP_threads.py} (63%)
 rename lldb/test/API/tools/lldb-dap/{correct-thread => threads}/main.c (100%)

diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
index 1bbaad18cafafab..757340ab2b5c2a4 100644
--- a/lldb/include/lldb/API/SBFormat.h
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -52,6 +52,7 @@ class LLDB_API SBFormat {
 
 protected:
   friend class SBFrame;
+  friend class SBThread;
 
   /// \return
   ///   The underlying shared pointer storage for this object.
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h
index 49c3d954fa93329..dcf6aa9d5424e85 100644
--- a/lldb/include/lldb/API/SBThread.h
+++ b/lldb/include/lldb/API/SBThread.h
@@ -200,6 +200,21 @@ class LLDB_API SBThread {
 
   bool GetDescription(lldb::SBStream &description, bool stop_format) const;
 
+  /// Similar to \a GetDescription() but the format of the description can be
+  /// configured via the \p format parameter. See
+  /// https://lldb.llvm.org/use/formatting.html for more information on format
+  /// strings.
+  ///
+  /// \param[in] format
+  ///   The format to use for generating the description.
+  ///
+  /// \param[out] output
+  ///   The stream where the description will be written to.
+  ///
+  /// \return
+  ///   An error object with an error message in case of failures.
+  SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output);
+
   bool GetStatus(lldb::SBStream &status) const;
 
   SBThread GetExtendedBacktraceThread(const char *type);
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index dabdbb8d455021a..e423dd4a6d2baa7 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -490,6 +490,23 @@ class Thread : public std::enable_shared_from_this,
   void DumpTraceInstructions(Stream &s, size_t count,
  size_t start_position = 0) const;
 
+  /// Print a description of this thread using the provided thread format.
+  ///
+  /// \param[out] strm
+  ///   The Stream to print the description to.
+  ///
+  /// \param[in] frame_idx
+  ///   If not \b LLDB_INVALID_FRAME_ID, then use this frame index as context 
to
+  ///   generate the description.
+  ///
+  /// \param[in] format
+  ///   The input format.
+  ///
+  /// \return
+  ///   \b true if and only if dumping with the given \p format worked.
+  bool DumpUsingFormat(Stream &strm, uint32_t frame_idx,
+   const FormatEntity::Entry *format);
+
   // If stop_format is true, this will be the form used when we print stop
   // info. If false, it will be the form we use for thread list and co.
   void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx,
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index a41861c59d2875a..518e3b9cf5bab33 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -733,6 +733,7 @@ def request_launch(
 enableSyntheticChildDebugging=False,
 commandEscapePrefix="`",
 customFrameFormat=None,
+customThreadFormat=None,
 ):
 args_dict = {"program": program}
 if args:
@@ -776,6 +777,8 @@ def request_launch(
 args_dict["postRunCommands"] = postRunCommands
 if customFrameFormat:
 args_dict["customFrameFormat"] = customFrameFormat
+if customThreadFormat:
+args_dict["customThreadFormat"] = customThreadFormat
 
 args_d

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for threads (PR #72196)

2023-11-13 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/72196

>From bedae95f3c3f9d719b3677ef59c262283b813284 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 13 Nov 2023 21:42:26 -0500
Subject: [PATCH] thread format

---
 lldb/include/lldb/API/SBFormat.h  |  1 +
 lldb/include/lldb/API/SBThread.h  | 15 +++
 lldb/include/lldb/Target/Thread.h | 17 
 .../test/tools/lldb-dap/dap_server.py |  3 ++
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  4 ++
 lldb/source/API/SBThread.cpp  | 35 ---
 lldb/source/Target/Thread.cpp | 19 +---
 .../{correct-thread => threads}/Makefile  |  0
 .../TestDAP_threads.py}   | 27 +++-
 .../{correct-thread => threads}/main.c|  0
 lldb/tools/lldb-dap/DAP.cpp   | 15 +++
 lldb/tools/lldb-dap/DAP.h |  3 ++
 lldb/tools/lldb-dap/JSONUtils.cpp | 43 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  2 +
 lldb/tools/lldb-dap/package.json  | 10 +
 15 files changed, 163 insertions(+), 31 deletions(-)
 rename lldb/test/API/tools/lldb-dap/{correct-thread => threads}/Makefile (100%)
 rename lldb/test/API/tools/lldb-dap/{correct-thread/TestDAP_correct_thread.py 
=> threads/TestDAP_threads.py} (63%)
 rename lldb/test/API/tools/lldb-dap/{correct-thread => threads}/main.c (100%)

diff --git a/lldb/include/lldb/API/SBFormat.h b/lldb/include/lldb/API/SBFormat.h
index 1bbaad18cafafab..757340ab2b5c2a4 100644
--- a/lldb/include/lldb/API/SBFormat.h
+++ b/lldb/include/lldb/API/SBFormat.h
@@ -52,6 +52,7 @@ class LLDB_API SBFormat {
 
 protected:
   friend class SBFrame;
+  friend class SBThread;
 
   /// \return
   ///   The underlying shared pointer storage for this object.
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h
index 49c3d954fa93329..dcf6aa9d5424e85 100644
--- a/lldb/include/lldb/API/SBThread.h
+++ b/lldb/include/lldb/API/SBThread.h
@@ -200,6 +200,21 @@ class LLDB_API SBThread {
 
   bool GetDescription(lldb::SBStream &description, bool stop_format) const;
 
+  /// Similar to \a GetDescription() but the format of the description can be
+  /// configured via the \p format parameter. See
+  /// https://lldb.llvm.org/use/formatting.html for more information on format
+  /// strings.
+  ///
+  /// \param[in] format
+  ///   The format to use for generating the description.
+  ///
+  /// \param[out] output
+  ///   The stream where the description will be written to.
+  ///
+  /// \return
+  ///   An error object with an error message in case of failures.
+  SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output);
+
   bool GetStatus(lldb::SBStream &status) const;
 
   SBThread GetExtendedBacktraceThread(const char *type);
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index dabdbb8d455021a..e423dd4a6d2baa7 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -490,6 +490,23 @@ class Thread : public std::enable_shared_from_this,
   void DumpTraceInstructions(Stream &s, size_t count,
  size_t start_position = 0) const;
 
+  /// Print a description of this thread using the provided thread format.
+  ///
+  /// \param[out] strm
+  ///   The Stream to print the description to.
+  ///
+  /// \param[in] frame_idx
+  ///   If not \b LLDB_INVALID_FRAME_ID, then use this frame index as context 
to
+  ///   generate the description.
+  ///
+  /// \param[in] format
+  ///   The input format.
+  ///
+  /// \return
+  ///   \b true if and only if dumping with the given \p format worked.
+  bool DumpUsingFormat(Stream &strm, uint32_t frame_idx,
+   const FormatEntity::Entry *format);
+
   // If stop_format is true, this will be the form used when we print stop
   // info. If false, it will be the form we use for thread list and co.
   void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx,
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index a41861c59d2875a..518e3b9cf5bab33 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -733,6 +733,7 @@ def request_launch(
 enableSyntheticChildDebugging=False,
 commandEscapePrefix="`",
 customFrameFormat=None,
+customThreadFormat=None,
 ):
 args_dict = {"program": program}
 if args:
@@ -776,6 +777,8 @@ def request_launch(
 args_dict["postRunCommands"] = postRunCommands
 if customFrameFormat:
 args_dict["customFrameFormat"] = customFrameFormat
+if customThreadFormat:
+args_dict["customThreadFormat"] = customThreadFormat
 
 args_

[Lldb-commits] [lldb] [lldb-dap] Add an option to provide a format for threads (PR #72196)

2023-11-13 Thread Greg Clayton via lldb-commits


@@ -839,4 +839,19 @@ void DAP::SetFrameFormat(llvm::StringRef format) {
   }
 }
 
+void DAP::SetThreadFormat(llvm::StringRef format) {
+  if (format.empty())
+return;
+  lldb::SBError error;
+  g_dap.thread_format = lldb::SBFormat(format.data(), error);

clayborg wrote:

if `format` isn't null terminated this can cause problems. You will want to use 
the following to ensure this is NULL terminated:
```
g_dap.thread_format = lldb::SBFormat(format.str().c_str(), error);
```
If the same thing was being done for the `g_dap.frame_format` lets fix that too.

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


  1   2   >