[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk>, =?utf-8?q?José?= L. Junior , =?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: https://github.com/taalhaataahir0102 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 1/7] [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 b19e694427546f8b..fac0ced910a11d48 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 44a2d560010fe403..0e41cd95e0ef17d2 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 b0f5ffead2a16569..9567c3f4384c1752 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 8f052d0a7b837e24..a83575ad82d69090 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, Addres
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk>, =?utf-8?q?José?= L. Junior , =?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: https://github.com/taalhaataahir0102 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 1/6] [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 b19e694427546f8b..fac0ced910a11d48 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 44a2d560010fe403..0e41cd95e0ef17d2 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 b0f5ffead2a16569..9567c3f4384c1752 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 8f052d0a7b837e24..a83575ad82d69090 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_ad
[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk>, =?utf-8?q?José?= L. Junior , =?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: https://github.com/taalhaataahir0102 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 1/7] [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 b19e694427546f8b..fac0ced910a11d48 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 44a2d560010fe403..0e41cd95e0ef17d2 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 b0f5ffead2a16569..9567c3f4384c1752 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 8f052d0a7b837e24..a83575ad82d69090 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, Addres
[Lldb-commits] [lldb] [lldb] correct inconsistent order of messages on process launch (PR #73173)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: DavidSpickett wrote: Opinions differ on what goes in a commit message but this seems fine to me, I'd just remove the sub-headings. My usual rule is that folks can choose not to read it if they don't want to, include as much information as you would want to see if you yourself had to come back to fix this change. (which happens to me more than I'd like to admit :) ) https://github.com/llvm/llvm-project/pull/73173 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] correct inconsistent order of messages on process launch (PR #73173)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: https://github.com/DavidSpickett approved this pull request. This LGTM just fixup the PR message and you can merge it. (if you don't have the permissions to do that, I can do it for you, let me know when you're ready) https://github.com/llvm/llvm-project/pull/73173 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Respect the DW_AT_alignment attribute. (PR #73307)
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/73307 Part of fixes for #72913. clang emits `DW_AT_alignment` attribute, however LLDB didn't respect it, resulting in incorrect RecordDecls built by lldb. This only fixes non-inheritance cases. The inheritance case will be handled in a follow-up patch. >From 5fb8fd532fe767feb2d361f9552ff31ea7770663 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 24 Nov 2023 10:46:03 +0100 Subject: [PATCH] [LLDB] Respect the DW_AT_alignment attribute. Part of fixes for #72913. clang emits the DW_AT_alignment attribute, however LLDB didn't respect it, resulting an incorrect the RecordDecl built by lldb. This only fixes non-inheritance cases. The inheritance case will be handled in a follow-up patch. --- .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 12 ++-- .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.h | 1 + .../cpp/alignas_base_class/TestAlignAsBaseClass.py | 4 lldb/test/API/lang/cpp/alignas_base_class/main.cpp | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index abe3c673e2cce69..a55ca0bf0f0fc1a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -355,6 +355,10 @@ ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes(const DWARFDIE &die) { byte_size = form_value.Unsigned(); break; +case DW_AT_alignment: + alignment = form_value.Unsigned(); + break; + case DW_AT_byte_stride: byte_stride = form_value.Unsigned(); break; @@ -1926,12 +1930,13 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, // TypeSystemClang is always in C++ mode, but some compilers such as // GCC and Clang give empty structs a size of 0 in C mode (in contrast to // the size of 1 for empty structs that would be computed in C++ mode). - if (attrs.byte_size) { + if (attrs.byte_size || attrs.alignment) { clang::RecordDecl *record_decl = TypeSystemClang::GetAsRecordDecl(clang_type); if (record_decl) { ClangASTImporter::LayoutInfo layout; - layout.bit_size = *attrs.byte_size * 8; + layout.bit_size = attrs.byte_size.value_or(0) * 8; + layout.alignment = attrs.alignment.value_or(0) * 8; GetClangASTImporter().SetRecordLayout(record_decl, layout); } } @@ -2270,6 +2275,9 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, if (layout_info.bit_size == 0) layout_info.bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8; +if (layout_info.alignment == 0) + layout_info.alignment = + die.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_alignment, 0) * 8; clang::CXXRecordDecl *record_decl = m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index 0247783217008e8..81b705a036189eb 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -456,6 +456,7 @@ struct ParsedDWARFTypeAttributes { lldb_private::plugin::dwarf::DWARFFormValue type; lldb::LanguageType class_language = lldb::eLanguageTypeUnknown; std::optional byte_size; + std::optional alignment; size_t calling_convention = llvm::dwarf::DW_CC_normal; uint32_t bit_stride = 0; uint32_t byte_stride = 0; diff --git a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py index c7a88987733e176..7d97b0c42b7e166 100644 --- a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py +++ b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py @@ -12,3 +12,7 @@ def test(self): # The offset of f2 should be 8 because of `alignas(8)`. self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", result_value="8") + +# Verify specified class alignments. +self.expect_expr("alignof(B2)", result_value="8") +self.expect_expr("alignof(EmptyClassAlign8)", result_value="8") diff --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp index 8dfced6c784e102..cf727e808017bcc 100644 --- a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp +++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp @@ -10,4 +10,6 @@ struct D : B1, B2 {}; D d3g; +struct alignas(8) EmptyClassAlign8 {} t; + int main() {} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Respect the DW_AT_alignment attribute. (PR #73307)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Haojian Wu (hokein) Changes Part of fixes for #72913. clang emits `DW_AT_alignment` attribute, however LLDB didn't respect it, resulting in incorrect RecordDecls built by lldb. This only fixes non-inheritance cases. The inheritance case will be handled in a follow-up patch. --- Full diff: https://github.com/llvm/llvm-project/pull/73307.diff 4 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+10-2) - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h (+1) - (modified) lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py (+4) - (modified) lldb/test/API/lang/cpp/alignas_base_class/main.cpp (+2) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index abe3c673e2cce69..a55ca0bf0f0fc1a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -355,6 +355,10 @@ ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes(const DWARFDIE &die) { byte_size = form_value.Unsigned(); break; +case DW_AT_alignment: + alignment = form_value.Unsigned(); + break; + case DW_AT_byte_stride: byte_stride = form_value.Unsigned(); break; @@ -1926,12 +1930,13 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, // TypeSystemClang is always in C++ mode, but some compilers such as // GCC and Clang give empty structs a size of 0 in C mode (in contrast to // the size of 1 for empty structs that would be computed in C++ mode). - if (attrs.byte_size) { + if (attrs.byte_size || attrs.alignment) { clang::RecordDecl *record_decl = TypeSystemClang::GetAsRecordDecl(clang_type); if (record_decl) { ClangASTImporter::LayoutInfo layout; - layout.bit_size = *attrs.byte_size * 8; + layout.bit_size = attrs.byte_size.value_or(0) * 8; + layout.alignment = attrs.alignment.value_or(0) * 8; GetClangASTImporter().SetRecordLayout(record_decl, layout); } } @@ -2270,6 +2275,9 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, if (layout_info.bit_size == 0) layout_info.bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8; +if (layout_info.alignment == 0) + layout_info.alignment = + die.GetAttributeValueAsUnsigned(llvm::dwarf::DW_AT_alignment, 0) * 8; clang::CXXRecordDecl *record_decl = m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index 0247783217008e8..81b705a036189eb 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -456,6 +456,7 @@ struct ParsedDWARFTypeAttributes { lldb_private::plugin::dwarf::DWARFFormValue type; lldb::LanguageType class_language = lldb::eLanguageTypeUnknown; std::optional byte_size; + std::optional alignment; size_t calling_convention = llvm::dwarf::DW_CC_normal; uint32_t bit_stride = 0; uint32_t byte_stride = 0; diff --git a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py index c7a88987733e176..7d97b0c42b7e166 100644 --- a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py +++ b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py @@ -12,3 +12,7 @@ def test(self): # The offset of f2 should be 8 because of `alignas(8)`. self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", result_value="8") + +# Verify specified class alignments. +self.expect_expr("alignof(B2)", result_value="8") +self.expect_expr("alignof(EmptyClassAlign8)", result_value="8") diff --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp index 8dfced6c784e102..cf727e808017bcc 100644 --- a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp +++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp @@ -10,4 +10,6 @@ struct D : B1, B2 {}; D d3g; +struct alignas(8) EmptyClassAlign8 {} t; + int main() {} `` https://github.com/llvm/llvm-project/pull/73307 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Respect the DW_AT_alignment attribute. (PR #73307)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 6b87d84ff45d03c244e7511fba9359776ce27977 5fb8fd532fe767feb2d361f9552ff31ea7770663 -- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h lldb/test/API/lang/cpp/alignas_base_class/main.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp index cf727e8080..9d37554957 100644 --- a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp +++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp @@ -10,6 +10,7 @@ struct D : B1, B2 {}; D d3g; -struct alignas(8) EmptyClassAlign8 {} t; +struct alignas(8) EmptyClassAlign8 { +} t; int main() {} `` https://github.com/llvm/llvm-project/pull/73307 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Respect the DW_AT_alignment attribute. (PR #73307)
@@ -1926,12 +1930,13 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, // TypeSystemClang is always in C++ mode, but some compilers such as // GCC and Clang give empty structs a size of 0 in C mode (in contrast to // the size of 1 for empty structs that would be computed in C++ mode). - if (attrs.byte_size) { + if (attrs.byte_size || attrs.alignment) { clang::RecordDecl *record_decl = TypeSystemClang::GetAsRecordDecl(clang_type); if (record_decl) { ClangASTImporter::LayoutInfo layout; - layout.bit_size = *attrs.byte_size * 8; + layout.bit_size = attrs.byte_size.value_or(0) * 8; + layout.alignment = attrs.alignment.value_or(0) * 8; Michael137 wrote: Why do we need this extra accounting for alignment here? This block used to be solely for cases where empty structs had special byte-size requirements. Is it because in your tests `alignof(EmptyStruct)` wouldn't trigger `CompleteRecordType`? https://github.com/llvm/llvm-project/pull/73307 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Improve error message for script commands when there's no inte… (PR #73321)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/73321 …rpreter It was: ``` error: there is no embedded script interpreter in this mode. ``` 1. What does "mode" mean? 2. It implies there might be an embedded script interpreter for some other "mode", whatever that would be. So I'm simplifying it and noting the most common reason for this which is that lldb wasn't built with a scripting language enabled in the first place. There are other tips for dealing with this, but I'm not sure this message is the best place for them. >From 6183547ff1481bd71f18f44f2083b58cd7084453 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Fri, 24 Nov 2023 12:05:41 + Subject: [PATCH] [lldb] Improve error message for script commands when there's no interpreter It was: ``` error: there is no embedded script interpreter in this mode. ``` 1. What does "mode" mean? 2. It implies there might be an embedded script interpreter for some other "mode", whatever that would be. So I'm simplifying it and noting the most common reason for this which is that lldb wasn't built with a scripting lanugage enabled in the first place. There are other tips for dealing with this, but I'm not sure this message is the best place for them. --- .../ScriptInterpreter/None/ScriptInterpreterNone.cpp | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp index 7df8b55fc7f55b1..9cc1d72eebf06cd 100644 --- a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp @@ -26,17 +26,19 @@ ScriptInterpreterNone::ScriptInterpreterNone(Debugger &debugger) ScriptInterpreterNone::~ScriptInterpreterNone() = default; +static const char *no_interpreter_err_msg = +"There is no embedded script interpreter. Check that LLDB was built with a " +"scripting language enabled.\n"; + bool ScriptInterpreterNone::ExecuteOneLine(llvm::StringRef command, CommandReturnObject *, const ExecuteScriptOptions &) { - m_debugger.GetErrorStream().PutCString( - "error: there is no embedded script interpreter in this mode.\n"); + m_debugger.GetErrorStream().PutCString(no_interpreter_err_msg); return false; } void ScriptInterpreterNone::ExecuteInterpreterLoop() { - m_debugger.GetErrorStream().PutCString( - "error: there is no embedded script interpreter in this mode.\n"); + m_debugger.GetErrorStream().PutCString(no_interpreter_err_msg); } void ScriptInterpreterNone::Initialize() { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Improve error message for script commands when there's no inte… (PR #73321)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes …rpreter It was: ``` error: there is no embedded script interpreter in this mode. ``` 1. What does "mode" mean? 2. It implies there might be an embedded script interpreter for some other "mode", whatever that would be. So I'm simplifying it and noting the most common reason for this which is that lldb wasn't built with a scripting language enabled in the first place. There are other tips for dealing with this, but I'm not sure this message is the best place for them. --- Full diff: https://github.com/llvm/llvm-project/pull/73321.diff 1 Files Affected: - (modified) lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp (+6-4) ``diff diff --git a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp index 7df8b55fc7f55b1..9cc1d72eebf06cd 100644 --- a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp @@ -26,17 +26,19 @@ ScriptInterpreterNone::ScriptInterpreterNone(Debugger &debugger) ScriptInterpreterNone::~ScriptInterpreterNone() = default; +static const char *no_interpreter_err_msg = +"There is no embedded script interpreter. Check that LLDB was built with a " +"scripting language enabled.\n"; + bool ScriptInterpreterNone::ExecuteOneLine(llvm::StringRef command, CommandReturnObject *, const ExecuteScriptOptions &) { - m_debugger.GetErrorStream().PutCString( - "error: there is no embedded script interpreter in this mode.\n"); + m_debugger.GetErrorStream().PutCString(no_interpreter_err_msg); return false; } void ScriptInterpreterNone::ExecuteInterpreterLoop() { - m_debugger.GetErrorStream().PutCString( - "error: there is no embedded script interpreter in this mode.\n"); + m_debugger.GetErrorStream().PutCString(no_interpreter_err_msg); } void ScriptInterpreterNone::Initialize() { `` https://github.com/llvm/llvm-project/pull/73321 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Respect the DW_AT_alignment attribute. (PR #73307)
@@ -1926,12 +1930,13 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, // TypeSystemClang is always in C++ mode, but some compilers such as // GCC and Clang give empty structs a size of 0 in C mode (in contrast to // the size of 1 for empty structs that would be computed in C++ mode). - if (attrs.byte_size) { + if (attrs.byte_size || attrs.alignment) { clang::RecordDecl *record_decl = TypeSystemClang::GetAsRecordDecl(clang_type); if (record_decl) { ClangASTImporter::LayoutInfo layout; - layout.bit_size = *attrs.byte_size * 8; + layout.bit_size = attrs.byte_size.value_or(0) * 8; + layout.alignment = attrs.alignment.value_or(0) * 8; hokein wrote: > Is it because in your tests alignof(EmptyStruct) wouldn't trigger > CompleteRecordType? Yes, exactly, this is the major reason. The codepath in `CompleteRecordType` has a conditional statement `if (!layout_info.field_offsets.empty() || !layout_info.base_offsets.empty() || !layout_info.vbase_offsets.empty())` where an empty structure will never hit. We could tweak the if condition there, but I'm less certain about it, my reading of code is that the location here seem to be responsible for empty structures (happy to change if this is not reasonable). https://github.com/llvm/llvm-project/pull/73307 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Improve error message for script commands when there's no inte… (PR #73321)
DavidSpickett wrote: I might be butchering the meaning of the message, but you see what I'm going for. https://github.com/llvm/llvm-project/pull/73321 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Improve error message for script commands when there's no interpreter (PR #73321)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/73321 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Improve error message for script commands when there's no interpreter (PR #73321)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/73321 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] correct inconsistent order of messages on process launch (PR #73173)
https://github.com/junior-jl edited https://github.com/llvm/llvm-project/pull/73173 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] correct inconsistent order of messages on process launch (PR #73173)
junior-jl wrote: > Opinions differ on what goes in a commit message but this seems fine to me, > I'd just remove the sub-headings. My usual rule is that folks can choose not > to read it if they don't want to, include as much information as you would > want to see if you yourself had to come back to fix this change. > (which happens to me more than I'd like to admit :) ) That's a good rule, thanks! Removed the sub-headings. > (if you don't have the permissions to do that, I can do it for you, let me > know when you're ready) I don't have write permissions here. Also, I tried using the `--fixup` flag on the second commit, does that mean the squashing is automatic or I need to squash the commits and push again? https://github.com/llvm/llvm-project/pull/73173 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] correct inconsistent order of messages on process launch (PR #73173)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: DavidSpickett wrote: > Also, I tried using the --fixup flag on the second commit, does that mean the > squashing is automatic or I need to squash the commits and push again? Honestly I've never used that flag. I'm not sure it matters with the way llvm is setup. I guess if llvm-project used one of the commit's messages as the final message, it wouldn't choose a fixup commit, but we squash before merging anyway so it doesn't matter. https://github.com/llvm/llvm-project/pull/73173 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] bd8f106 - [lldb] correct inconsistent order of messages on process launch (#73173)
Author: José Lira Junior Date: 2023-11-24T15:48:16Z New Revision: bd8f1068cad06b0f0342ac7ef351bf01c2e27322 URL: https://github.com/llvm/llvm-project/commit/bd8f1068cad06b0f0342ac7ef351bf01c2e27322 DIFF: https://github.com/llvm/llvm-project/commit/bd8f1068cad06b0f0342ac7ef351bf01c2e27322.diff LOG: [lldb] correct inconsistent order of messages on process launch (#73173) Fixes [#68035](https://github.com/llvm/llvm-project/issues/68035), where an inconsistency in the order of "Process launched" and "Process stopped" messages occurs during `process launch`. The fix involves adjusting the message output sequence in `CommandObjectProcessLaunch::DoExecute` within `source/Commands/CommandObjectProcess.cpp`. This ensures "Process launched" consistently precedes "Process stopped" when executing commands with the '-o' flag, i.e., non-interactive mode. Upon implementing this change, two tests failed: `lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test` and `lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test`. These failures were expected as they relied on the previous, now-corrected message order. Updating these tests to align with the new message sequence is part of this PR's scope. Added: Modified: lldb/source/Commands/CommandObjectProcess.cpp lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test Removed: diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index c7ce1b1258c196c..e42d637535eba47 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -264,9 +264,6 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach { // PushProcessIOHandler(). process_sp->SyncIOHandler(0, std::chrono::seconds(2)); -llvm::StringRef data = stream.GetString(); -if (!data.empty()) - result.AppendMessage(data); // If we didn't have a local executable, then we wouldn't have had an // executable module before launch. if (!exe_module_sp) @@ -282,6 +279,11 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach { exe_module_sp->GetFileSpec().GetPath().c_str(), archname); } result.SetStatus(eReturnStatusSuccessFinishResult); +// This message will refer to an event that happened after the process +// launched. +llvm::StringRef data = stream.GetString(); +if (!data.empty()) + result.AppendMessage(data); result.SetDidChangeProcessState(true); } else { result.AppendError( diff --git a/lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test b/lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test index bbb4830a416b5e5..52c86fa5530bf75 100644 --- a/lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test +++ b/lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test @@ -10,9 +10,9 @@ # CHECK: Breakpoint 1: no locations (pending). # CHECK: (lldb) run {{.*}} +# CHECK: Process {{.*}} launched: {{.*}} # CHECK: Process {{.*}} stopped # CHECK: JIT(0x{{.*}})`jitbp() at jitbp.cpp:1:15 # CHECK: -> 1int jitbp() { return 0; } # CHECK: ^ # CHECK:2int main() { return jitbp(); } -# CHECK: Process {{.*}} launched: {{.*}} diff --git a/lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test b/lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test index 8c289e2870ae6dd..b34a5673936f550 100644 --- a/lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test +++ b/lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test @@ -14,9 +14,9 @@ # CHECK: Breakpoint 1: no locations (pending). # CHECK: (lldb) run {{.*}} +# CHECK: Process {{.*}} launched: {{.*}} # CHECK: Process {{.*}} stopped # CHECK: JIT(0x{{.*}})`jitbp() at jitbp.cpp:1:15 # CHECK: -> 1int jitbp() { return 0; } # CHECK: ^ # CHECK:2int main() { return jitbp(); } -# CHECK: Process {{.*}} launched: {{.*}} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] correct inconsistent order of messages on process launch (PR #73173)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/73173 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits