[Lldb-commits] [lldb] [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo` (PR #124059)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/124059 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo` (PR #124059)
https://github.com/DavidSpickett commented: ABI details are someone else's job but on generic things this is the right idea. It needs tests, I suggest you find the tests that read general registers and add aliased name reads to those. Though it's unlikely to break for just one use case, I would add this to core file and live process tests, since it's simple and cheap to do. https://github.com/llvm/llvm-project/pull/124059 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo` (PR #124059)
@@ -644,32 +644,22 @@ void ABISysV_loongarch::AugmentRegisterInfo( std::vector ®s) { lldb_private::RegInfoBasedABI::AugmentRegisterInfo(regs); + static const std::unordered_map reg_aliases = { DavidSpickett wrote: There is `llvm/include/llvm/ADT/StringMap.h` for these sorts of purposes. We only do this once on process start but given it's the more "specific" type to LLVM you might as well use it. https://github.com/llvm/llvm-project/pull/124059 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters (PR #124096)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/124096 LLDB deduces the CV-qualifiers and storage class of a C++ method from the object parameter. Currently it assumes that parameter is implicit (and is a pointer type with the name "this"). This isn't true anymore in C++23 with explicit object parameters. To support those we can simply check the `DW_AT_object_pointer` of the subprogram DIE (works for both declarations and definitions) when searching for the object parameter. We can also remove the check for `eEncodingIsPointerUID`, because in C++ an artificial parameter called `this` is only ever the implicit object parameter (at least for all the major compilers). >From 8a95f08a8cd3747bdf823a8c158fe15590b9c831 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 22 Jan 2025 15:21:29 + Subject: [PATCH] [lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters LLDB deduces the CV-qualifiers and storage class of a C++ method from the object parameter. Currently it assumes that parameter is implicit (and is a pointer type with the name "this"). This isn't true anymore in C++23 with explicit object parameters. To support those we can simply check the `DW_AT_object_pointer` of the subprogram DIE (works for both declarations and definitions) when searching for the object parameter. We can also remove the check for `eEncodingIsPointerUID`, because in C++ an artificial parameter called `this` is only ever the implicit object parameter (at least for all the major compilers). --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 9 +- .../DWARF/DWARFASTParserClangTests.cpp| 178 ++ 2 files changed, 181 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index f54b7fc9cdad24..682ee6d287bf5c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -173,7 +173,9 @@ GetCXXObjectParameter(const DWARFDIE &subprogram, if (!DeclKindIsCXXClass(containing_decl_ctx.getDeclKind())) return {}; - // FIXME: if subprogram has a explicit DW_AT_object_pointer, use it. + if (DWARFDIE object_parameter = + subprogram.GetAttributeValueAsReferenceDIE(DW_AT_object_pointer)) +return object_parameter; // If no DW_AT_object_pointer was specified, assume the implicit object // parameter is the first parameter to the function, is called "this" and is @@ -215,11 +217,6 @@ static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram, return 0; uint32_t encoding_mask = this_type->GetEncodingMask(); - - // FIXME: explicit object parameters need not to be pointers - if (!(encoding_mask & (1u << Type::eEncodingIsPointerUID))) -return 0; - unsigned cv_quals = 0; if (encoding_mask & (1u << Type::eEncodingIsConstUID)) cv_quals |= clang::Qualifiers::Const; diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp index b31f56aa372d58..9c0300be08a78a 100644 --- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -902,3 +902,181 @@ TEST_F(DWARFASTParserClangTests, TestParseDWARFAttributes_ObjectPointer) { EXPECT_TRUE(attrs.object_pointer.IsValid()); EXPECT_EQ(attrs.object_pointer, param_die); } + +TEST_F(DWARFASTParserClangTests, TestParseSubroutine_ExplicitObjectParameter) { + // Tests parsing of a C++ non-static member function with an explicit object + // parameter that isn't called "this" and is not a pointer (but a CV-qualified + // rvalue reference instead). + + const char *yamldata = R"( +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data:ELFDATA2LSB + Type:ET_EXEC + Machine: EM_AARCH64 +DWARF: + debug_str: +- Context +- func +- mySelf + debug_abbrev: +- ID: 0 + Table: +- Code:0x1 + Tag: DW_TAG_compile_unit + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_language + Form:DW_FORM_data2 +- Code:0x2 + Tag: DW_TAG_structure_type + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Code:0x3 + Tag: DW_TAG_subprogram + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Attribute: DW_AT_declaration + Form:DW_FORM_flag_present +- Attribute: DW_AT_object_pointer + Form:DW_FORM_ref4
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters (PR #124096)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes LLDB deduces the CV-qualifiers and storage class of a C++ method from the object parameter. Currently it assumes that parameter is implicit (and is a pointer type with the name "this"). This isn't true anymore in C++23 with explicit object parameters. To support those we can simply check the `DW_AT_object_pointer` of the subprogram DIE (works for both declarations and definitions) when searching for the object parameter. We can also remove the check for `eEncodingIsPointerUID`, because in C++ an artificial parameter called `this` is only ever the implicit object parameter (at least for all the major compilers). --- Full diff: https://github.com/llvm/llvm-project/pull/124096.diff 2 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+3-6) - (modified) lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp (+178) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index f54b7fc9cdad24..682ee6d287bf5c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -173,7 +173,9 @@ GetCXXObjectParameter(const DWARFDIE &subprogram, if (!DeclKindIsCXXClass(containing_decl_ctx.getDeclKind())) return {}; - // FIXME: if subprogram has a explicit DW_AT_object_pointer, use it. + if (DWARFDIE object_parameter = + subprogram.GetAttributeValueAsReferenceDIE(DW_AT_object_pointer)) +return object_parameter; // If no DW_AT_object_pointer was specified, assume the implicit object // parameter is the first parameter to the function, is called "this" and is @@ -215,11 +217,6 @@ static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram, return 0; uint32_t encoding_mask = this_type->GetEncodingMask(); - - // FIXME: explicit object parameters need not to be pointers - if (!(encoding_mask & (1u << Type::eEncodingIsPointerUID))) -return 0; - unsigned cv_quals = 0; if (encoding_mask & (1u << Type::eEncodingIsConstUID)) cv_quals |= clang::Qualifiers::Const; diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp index b31f56aa372d58..9c0300be08a78a 100644 --- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -902,3 +902,181 @@ TEST_F(DWARFASTParserClangTests, TestParseDWARFAttributes_ObjectPointer) { EXPECT_TRUE(attrs.object_pointer.IsValid()); EXPECT_EQ(attrs.object_pointer, param_die); } + +TEST_F(DWARFASTParserClangTests, TestParseSubroutine_ExplicitObjectParameter) { + // Tests parsing of a C++ non-static member function with an explicit object + // parameter that isn't called "this" and is not a pointer (but a CV-qualified + // rvalue reference instead). + + const char *yamldata = R"( +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data:ELFDATA2LSB + Type:ET_EXEC + Machine: EM_AARCH64 +DWARF: + debug_str: +- Context +- func +- mySelf + debug_abbrev: +- ID: 0 + Table: +- Code:0x1 + Tag: DW_TAG_compile_unit + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_language + Form:DW_FORM_data2 +- Code:0x2 + Tag: DW_TAG_structure_type + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Code:0x3 + Tag: DW_TAG_subprogram + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Attribute: DW_AT_declaration + Form:DW_FORM_flag_present +- Attribute: DW_AT_object_pointer + Form:DW_FORM_ref4 +- Attribute: DW_AT_external + Form:DW_FORM_flag_present +- Code:0x4 + Tag: DW_TAG_formal_parameter + Children:DW_CHILDREN_no + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Attribute: DW_AT_type + Form:DW_FORM_ref4 +- Code:0x5 + Tag: DW_TAG_rvalue_reference_type + Children:DW_CHILDREN_no + Attributes: +- Attribute: DW_AT_type + Form:DW_FORM_ref4 +- Code:0x6 + Tag: DW_TAG_const_type + Children:
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
https://github.com/DavidSpickett updated https://github.com/llvm/llvm-project/pull/123945 >From ecb1b90e109df650ef1b50cc3d07b56fd302e274 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Wed, 22 Jan 2025 10:52:16 + Subject: [PATCH 1/4] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" This reverts commit 22561cfb443267905d4190f0e2a738e6b412457f and fixes b7b9ccf44988edf49886743ae5c3cf4184db211f (#112079). The problem is that x86_64 and Arm 32-bit have memory regions above the stack that are readable but not writeable. First Arm: ``` (lldb) memory region --all <...> [0xfffcf000-0x) rw- [stack] [0x-0x1000) r-x [vectors] [0x1000-0x) --- ``` Then x86_64: ``` $ cat /proc/self/maps <...> 7ffdcd148000-7ffdcd16a000 rw-p 00:00 0 [stack] 7ffdcd193000-7ffdcd196000 r--p 00:00 0 [vvar] 7ffdcd196000-7ffdcd197000 r-xp 00:00 0 [vdso] ff60-ff601000 --xp 00:00 0 [vsyscall] ``` Compare this to AArch64 where the test did pass: ``` $ cat /proc/self/maps <...> b87dc000-b87dd000 r--p 00:00 0 [vvar] b87dd000-b87de000 r-xp 00:00 0 [vdso] b87de000-b87e r--p 0002a000 00:3c 76927217 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 b87e-b87e2000 rw-p 0002c000 00:3c 76927217 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 f4216000-f4237000 rw-p 00:00 0 [stack] ``` To solve this, look up the memory region of the stack pointer and constrain the read to within that region. Since we know the stack is all readable and writeable. --- lldb/include/lldb/API/SBProcess.h | 1 + lldb/include/lldb/Target/Process.h| 28 +- lldb/include/lldb/Target/StopInfo.h | 7 + lldb/include/lldb/Target/Thread.h | 9 +- lldb/include/lldb/Target/ThreadList.h | 6 +- lldb/include/lldb/Target/ThreadPlan.h | 13 + lldb/include/lldb/Target/ThreadPlanBase.h | 2 + lldb/include/lldb/lldb-enumerations.h | 6 + .../Python/lldbsuite/test/gdbclientutils.py | 5 +- .../Python/lldbsuite/test/lldbgdbproxy.py | 175 ++ .../Python/lldbsuite/test/lldbreverse.py | 528 ++ .../Python/lldbsuite/test/lldbtest.py | 2 + .../tools/lldb-server/lldbgdbserverutils.py | 14 +- lldb/source/API/SBProcess.cpp | 12 + lldb/source/API/SBThread.cpp | 2 + .../source/Interpreter/CommandInterpreter.cpp | 3 +- .../Process/Linux/NativeThreadLinux.cpp | 3 + .../Process/MacOSX-Kernel/ProcessKDP.cpp | 8 +- .../Process/MacOSX-Kernel/ProcessKDP.h| 2 +- .../Process/Windows/Common/ProcessWindows.cpp | 9 +- .../Process/Windows/Common/ProcessWindows.h | 2 +- .../GDBRemoteCommunicationClient.cpp | 20 + .../gdb-remote/GDBRemoteCommunicationClient.h | 6 + .../GDBRemoteCommunicationServerLLGS.cpp | 1 + .../Process/gdb-remote/ProcessGDBRemote.cpp | 98 +++- .../Process/gdb-remote/ProcessGDBRemote.h | 4 +- .../Process/scripted/ScriptedProcess.cpp | 9 +- .../Process/scripted/ScriptedProcess.h| 2 +- lldb/source/Target/Process.cpp| 24 +- lldb/source/Target/StopInfo.cpp | 28 + lldb/source/Target/Thread.cpp | 9 +- lldb/source/Target/ThreadList.cpp | 32 +- lldb/source/Target/ThreadPlanBase.cpp | 4 + .../reverse-execution/Makefile| 3 + .../TestReverseContinueBreakpoints.py | 149 + .../TestReverseContinueNotSupported.py| 31 + .../TestReverseContinueWatchpoints.py | 130 + .../functionalities/reverse-execution/main.c | 25 + lldb/tools/lldb-dap/JSONUtils.cpp | 3 + lldb/tools/lldb-dap/LLDBUtils.cpp | 1 + 40 files changed, 1369 insertions(+), 47 deletions(-) create mode 100644 lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py create mode 100644 lldb/packages/Python/lldbsuite/test/lldbreverse.py create mode 100644 lldb/test/API/functionalities/reverse-execution/Makefile create mode 100644 lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py create mode 100644 lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py create mode 100644 lldb/test/API/functionalities/reverse-execution/TestReverseContinueWatchpoints.py create mode 100644 lldb/test/API/functionalities/reverse-execution/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 1624e02070b1b2..882b8bd837131d 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -15
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/123945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
DavidSpickett wrote: > can you add @skipIfRemote to the tests? Done > Another, simpler way to fix the memory read problem might be to just tolerate > failed memory writes --- log and continue. Log and continue is liable to be "triager forgets to look at logs, wastes days, disables the test and forgets". I think we're pretty safe to improve the error messages and raise them as soon as possible here. If we get a pile of reports about spurious failures then sure, let's log it, but stick to erroring as long as we can. I have improved the error messages for both memory and registers. https://github.com/llvm/llvm-project/pull/123945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "[lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters" (PR #124100)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/124100 Reverts llvm/llvm-project#124096 Broke linux CI: ``` Note: This is test shard 7 of 42. [==] Running 1 test from 1 test suite. [--] Global test environment set-up. [--] 1 test from DWARFASTParserClangTests [ RUN ] DWARFASTParserClangTests.TestParseSubroutine_ExplicitObjectParameter Expected must be checked before access or destruction. Expected value was in success state. (Note: Expected values in success mode must still be checked prior to being destroyed). Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 SymbolFileDWARFTests 0x560271ee5ba7 1 SymbolFileDWARFTests 0x560271ee3a2c 2 SymbolFileDWARFTests 0x560271ee63ea 3 libc.so.60x7f3e54e5b050 4 libc.so.60x7f3e54ea9e2c 5 libc.so.60x7f3e54e5afb2 gsignal + 18 6 libc.so.60x7f3e54e45472 abort + 211 7 SymbolFileDWARFTests 0x560271e79d51 8 SymbolFileDWARFTests 0x560271e724f7 9 SymbolFileDWARFTests 0x560271f39e2c 10 SymbolFileDWARFTests 0x560271f3b368 11 SymbolFileDWARFTests 0x560271f3c053 12 SymbolFileDWARFTests 0x560271f4cf67 13 SymbolFileDWARFTests 0x560271f4c18a 14 SymbolFileDWARFTests 0x560271f2561c 15 libc.so.60x7f3e54e4624a 16 libc.so.60x7f3e54e46305 __libc_start_main + 133 17 SymbolFileDWARFTests 0x560271e65161 ``` >From 21f62eaa7e28867b02d356a97a4fe134eb5d1f59 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 23 Jan 2025 11:19:37 + Subject: [PATCH] =?UTF-8?q?Revert=20"[lldb][DWARFASTParserClang]=20Make=20?= =?UTF-8?q?C++=20method=20parsing=20aware=20of=20explicit=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ad6d808906075c3386bbeada3c37d8d3e6afe248. --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 9 +- .../DWARF/DWARFASTParserClangTests.cpp| 178 -- 2 files changed, 6 insertions(+), 181 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 682ee6d287bf5c..f54b7fc9cdad24 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -173,9 +173,7 @@ GetCXXObjectParameter(const DWARFDIE &subprogram, if (!DeclKindIsCXXClass(containing_decl_ctx.getDeclKind())) return {}; - if (DWARFDIE object_parameter = - subprogram.GetAttributeValueAsReferenceDIE(DW_AT_object_pointer)) -return object_parameter; + // FIXME: if subprogram has a explicit DW_AT_object_pointer, use it. // If no DW_AT_object_pointer was specified, assume the implicit object // parameter is the first parameter to the function, is called "this" and is @@ -217,6 +215,11 @@ static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram, return 0; uint32_t encoding_mask = this_type->GetEncodingMask(); + + // FIXME: explicit object parameters need not to be pointers + if (!(encoding_mask & (1u << Type::eEncodingIsPointerUID))) +return 0; + unsigned cv_quals = 0; if (encoding_mask & (1u << Type::eEncodingIsConstUID)) cv_quals |= clang::Qualifiers::Const; diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp index 9c0300be08a78a..b31f56aa372d58 100644 --- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -902,181 +902,3 @@ TEST_F(DWARFASTParserClangTests, TestParseDWARFAttributes_ObjectPointer) { EXPECT_TRUE(attrs.object_pointer.IsValid()); EXPECT_EQ(attrs.object_pointer, param_die); } - -TEST_F(DWARFASTParserClangTests, TestParseSubroutine_ExplicitObjectParameter) { - // Tests parsing of a C++ non-static member function with an explicit object - // parameter that isn't called "this" and is not a pointer (but a CV-qualified - // rvalue reference instead). - - const char *yamldata = R"( !ELF -FileHeader: - Class: ELFCLASS64 - Data:ELFDATA2LSB - Type:ET_EXEC - Machine: EM_AARCH64 -DWARF: - debug_str: -- Context -- func -- mySelf - debug_abbrev: -- ID: 0 - Table: -- Code:0x1 - Tag: DW_TAG_compile_unit - Children:DW_CHILDREN_yes - Attributes: -- Attribute: DW_AT_language - Form:DW_FORM_data2 -- Code:0x2 - Tag: DW_TAG_structure_type - Children:DW_CHILDREN_yes - Attributes: -- Attribute: DW_AT_name - Form:DW_FORM_strp -- Code:
[Lldb-commits] [lldb] a802093 - Revert "[lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters" (#124100)
Author: Michael Buch Date: 2025-01-23T11:20:14Z New Revision: a8020930a8174d84da04fa91b6fef244207f42f5 URL: https://github.com/llvm/llvm-project/commit/a8020930a8174d84da04fa91b6fef244207f42f5 DIFF: https://github.com/llvm/llvm-project/commit/a8020930a8174d84da04fa91b6fef244207f42f5.diff LOG: Revert "[lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters" (#124100) Reverts llvm/llvm-project#124096 Broke linux CI: ``` Note: This is test shard 7 of 42. [==] Running 1 test from 1 test suite. [--] Global test environment set-up. [--] 1 test from DWARFASTParserClangTests [ RUN ] DWARFASTParserClangTests.TestParseSubroutine_ExplicitObjectParameter Expected must be checked before access or destruction. Expected value was in success state. (Note: Expected values in success mode must still be checked prior to being destroyed). Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 SymbolFileDWARFTests 0x560271ee5ba7 1 SymbolFileDWARFTests 0x560271ee3a2c 2 SymbolFileDWARFTests 0x560271ee63ea 3 libc.so.60x7f3e54e5b050 4 libc.so.60x7f3e54ea9e2c 5 libc.so.60x7f3e54e5afb2 gsignal + 18 6 libc.so.60x7f3e54e45472 abort + 211 7 SymbolFileDWARFTests 0x560271e79d51 8 SymbolFileDWARFTests 0x560271e724f7 9 SymbolFileDWARFTests 0x560271f39e2c 10 SymbolFileDWARFTests 0x560271f3b368 11 SymbolFileDWARFTests 0x560271f3c053 12 SymbolFileDWARFTests 0x560271f4cf67 13 SymbolFileDWARFTests 0x560271f4c18a 14 SymbolFileDWARFTests 0x560271f2561c 15 libc.so.60x7f3e54e4624a 16 libc.so.60x7f3e54e46305 __libc_start_main + 133 17 SymbolFileDWARFTests 0x560271e65161 ``` Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 682ee6d287bf5c..f54b7fc9cdad24 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -173,9 +173,7 @@ GetCXXObjectParameter(const DWARFDIE &subprogram, if (!DeclKindIsCXXClass(containing_decl_ctx.getDeclKind())) return {}; - if (DWARFDIE object_parameter = - subprogram.GetAttributeValueAsReferenceDIE(DW_AT_object_pointer)) -return object_parameter; + // FIXME: if subprogram has a explicit DW_AT_object_pointer, use it. // If no DW_AT_object_pointer was specified, assume the implicit object // parameter is the first parameter to the function, is called "this" and is @@ -217,6 +215,11 @@ static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram, return 0; uint32_t encoding_mask = this_type->GetEncodingMask(); + + // FIXME: explicit object parameters need not to be pointers + if (!(encoding_mask & (1u << Type::eEncodingIsPointerUID))) +return 0; + unsigned cv_quals = 0; if (encoding_mask & (1u << Type::eEncodingIsConstUID)) cv_quals |= clang::Qualifiers::Const; diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp index 9c0300be08a78a..b31f56aa372d58 100644 --- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -902,181 +902,3 @@ TEST_F(DWARFASTParserClangTests, TestParseDWARFAttributes_ObjectPointer) { EXPECT_TRUE(attrs.object_pointer.IsValid()); EXPECT_EQ(attrs.object_pointer, param_die); } - -TEST_F(DWARFASTParserClangTests, TestParseSubroutine_ExplicitObjectParameter) { - // Tests parsing of a C++ non-static member function with an explicit object - // parameter that isn't called "this" and is not a pointer (but a CV-qualified - // rvalue reference instead). - - const char *yamldata = R"( !ELF -FileHeader: - Class: ELFCLASS64 - Data:ELFDATA2LSB - Type:ET_EXEC - Machine: EM_AARCH64 -DWARF: - debug_str: -- Context -- func -- mySelf - debug_abbrev: -- ID: 0 - Table: -- Code:0x1 - Tag: DW_TAG_compile_unit - Children:DW_CHILDREN_yes - Attributes: -- Attribute: DW_AT_language - Form:DW_FORM_data2 -- Code:0x2 - Tag: DW_TAG_structure_type - Children:DW_CHILDREN_yes - Attributes: -- Attribute: DW_AT_name - Form:DW_FORM_strp -- Code:0x3 - Tag: D
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters (PR #124096)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `lldb-x86_64-debian` running on `lldb-x86_64-debian` while building `lldb` at step 6 "test". Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/14712 Here is the relevant piece of the build log for the reference ``` Step 6 (test) failure: build (failure) ... PASS: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/36/42 (2739 of 2757) PASS: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/38/42 (2740 of 2757) PASS: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/39/42 (2741 of 2757) PASS: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/37/42 (2742 of 2757) PASS: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/5/42 (2743 of 2757) PASS: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/9/42 (2744 of 2757) PASS: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/8/42 (2745 of 2757) PASS: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/4/42 (2746 of 2757) PASS: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/40/42 (2747 of 2757) PASS: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/41/42 (2748 of 2757) FAIL: lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/6/42 (2749 of 2757) TEST 'lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/6/42' FAILED Script(shard): -- GTEST_OUTPUT=json:/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/unittests/SymbolFile/DWARF/./SymbolFileDWARFTests-lldb-unit-1844284-6-42.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=42 GTEST_SHARD_INDEX=6 /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/unittests/SymbolFile/DWARF/./SymbolFileDWARFTests -- Note: This is test shard 7 of 42. [==] Running 1 test from 1 test suite. [--] Global test environment set-up. [--] 1 test from DWARFASTParserClangTests [ RUN ] DWARFASTParserClangTests.TestParseSubroutine_ExplicitObjectParameter Expected must be checked before access or destruction. Expected value was in success state. (Note: Expected values in success mode must still be checked prior to being destroyed). Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 SymbolFileDWARFTests 0x560271ee5ba7 1 SymbolFileDWARFTests 0x560271ee3a2c 2 SymbolFileDWARFTests 0x560271ee63ea 3 libc.so.60x7f3e54e5b050 4 libc.so.60x7f3e54ea9e2c 5 libc.so.60x7f3e54e5afb2 gsignal + 18 6 libc.so.60x7f3e54e45472 abort + 211 7 SymbolFileDWARFTests 0x560271e79d51 8 SymbolFileDWARFTests 0x560271e724f7 9 SymbolFileDWARFTests 0x560271f39e2c 10 SymbolFileDWARFTests 0x560271f3b368 11 SymbolFileDWARFTests 0x560271f3c053 12 SymbolFileDWARFTests 0x560271f4cf67 13 SymbolFileDWARFTests 0x560271f4c18a 14 SymbolFileDWARFTests 0x560271f2561c 15 libc.so.60x7f3e54e4624a 16 libc.so.60x7f3e54e46305 __libc_start_main + 133 17 SymbolFileDWARFTests 0x560271e65161 -- exit: -6 -- shard JSON output does not exist: /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/unittests/SymbolFile/DWARF/./SymbolFileDWARFTests-lldb-unit-1844284-6-42.json ``` https://github.com/llvm/llvm-project/pull/124096 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "[lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters" (PR #124100)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Reverts llvm/llvm-project#124096 Broke linux CI: ``` Note: This is test shard 7 of 42. [==] Running 1 test from 1 test suite. [--] Global test environment set-up. [--] 1 test from DWARFASTParserClangTests [ RUN ] DWARFASTParserClangTests.TestParseSubroutine_ExplicitObjectParameter Expectedmust be checked before access or destruction. Expected value was in success state. (Note: Expected values in success mode must still be checked prior to being destroyed). Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 SymbolFileDWARFTests 0x560271ee5ba7 1 SymbolFileDWARFTests 0x560271ee3a2c 2 SymbolFileDWARFTests 0x560271ee63ea 3 libc.so.60x7f3e54e5b050 4 libc.so.60x7f3e54ea9e2c 5 libc.so.60x7f3e54e5afb2 gsignal + 18 6 libc.so.60x7f3e54e45472 abort + 211 7 SymbolFileDWARFTests 0x560271e79d51 8 SymbolFileDWARFTests 0x560271e724f7 9 SymbolFileDWARFTests 0x560271f39e2c 10 SymbolFileDWARFTests 0x560271f3b368 11 SymbolFileDWARFTests 0x560271f3c053 12 SymbolFileDWARFTests 0x560271f4cf67 13 SymbolFileDWARFTests 0x560271f4c18a 14 SymbolFileDWARFTests 0x560271f2561c 15 libc.so.60x7f3e54e4624a 16 libc.so.60x7f3e54e46305 __libc_start_main + 133 17 SymbolFileDWARFTests 0x560271e65161 ``` --- Full diff: https://github.com/llvm/llvm-project/pull/124100.diff 2 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+6-3) - (modified) lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp (-178) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 682ee6d287bf5c..f54b7fc9cdad24 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -173,9 +173,7 @@ GetCXXObjectParameter(const DWARFDIE &subprogram, if (!DeclKindIsCXXClass(containing_decl_ctx.getDeclKind())) return {}; - if (DWARFDIE object_parameter = - subprogram.GetAttributeValueAsReferenceDIE(DW_AT_object_pointer)) -return object_parameter; + // FIXME: if subprogram has a explicit DW_AT_object_pointer, use it. // If no DW_AT_object_pointer was specified, assume the implicit object // parameter is the first parameter to the function, is called "this" and is @@ -217,6 +215,11 @@ static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram, return 0; uint32_t encoding_mask = this_type->GetEncodingMask(); + + // FIXME: explicit object parameters need not to be pointers + if (!(encoding_mask & (1u << Type::eEncodingIsPointerUID))) +return 0; + unsigned cv_quals = 0; if (encoding_mask & (1u << Type::eEncodingIsConstUID)) cv_quals |= clang::Qualifiers::Const; diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp index 9c0300be08a78a..b31f56aa372d58 100644 --- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -902,181 +902,3 @@ TEST_F(DWARFASTParserClangTests, TestParseDWARFAttributes_ObjectPointer) { EXPECT_TRUE(attrs.object_pointer.IsValid()); EXPECT_EQ(attrs.object_pointer, param_die); } - -TEST_F(DWARFASTParserClangTests, TestParseSubroutine_ExplicitObjectParameter) { - // Tests parsing of a C++ non-static member function with an explicit object - // parameter that isn't called "this" and is not a pointer (but a CV-qualified - // rvalue reference instead). - - const char *yamldata = R"( !ELF -FileHeader: - Class: ELFCLASS64 - Data:ELFDATA2LSB - Type:ET_EXEC - Machine: EM_AARCH64 -DWARF: - debug_str: -- Context -- func -- mySelf - debug_abbrev: -- ID: 0 - Table: -- Code:0x1 - Tag: DW_TAG_compile_unit - Children:DW_CHILDREN_yes - Attributes: -- Attribute: DW_AT_language - Form:DW_FORM_data2 -- Code:0x2 - Tag: DW_TAG_structure_type - Children:DW_CHILDREN_yes - Attributes: -- Attribute: DW_AT_name - Form:DW_FORM_strp -- Code:0x3 - Tag: DW_TAG_subprogram - Children:DW_CHILDREN_yes - Attributes: -- Attribute: DW_AT_name - Form:DW_FORM_strp -- Attribute: DW_AT_declaration - Form:DW_FORM_flag_present -- A
[Lldb-commits] [lldb] Revert "[lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters" (PR #124100)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/124100 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove compiler version check and use regex (PR #123393)
Michael137 wrote: Reverting for now to get CI green again https://github.com/llvm/llvm-project/pull/123393 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "[lldb][test] Remove compiler version check and use regex" (PR #124101)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/124101 Reverts llvm/llvm-project#123393 This is causing `TestVectorOfVectorsFromStdModule.py` to fail on the the macOS clang-15 matrix bot. >From bb21661782242f931f3d04eb8fed9be792bd4ef8 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 23 Jan 2025 11:27:19 + Subject: [PATCH] Revert "[lldb][test] Remove compiler version check and use regex (#123393)" This reverts commit b62e55803c52ca04093a0eea361407e849dc23e1. --- .../TestDbgInfoContentVectorFromStdModule.py | 22 + .../TestVectorOfVectorsFromStdModule.py | 46 +-- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py index 759077302bfca4..1c3e64f14c 100644 --- a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py @@ -23,6 +23,13 @@ def test(self): self.runCmd("settings set target.import-std-module true") +if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion( +[">", "16.0"] +): +vector_type = "std::vector" +else: +vector_type = "std::vector >" + size_type = "size_type" value_type = "value_type" iterator = "iterator" @@ -34,14 +41,13 @@ def test(self): ValueCheck(name="current"), ] -self.expect( -"expr a", -patterns=[ -"""\(std::vector )*>\) \$0 = size=3 \{ - \[0\] = \(a = 3\) - \[1\] = \(a = 1\) - \[2\] = \(a = 2\) -\}""" +self.expect_expr( +"a", +result_type=vector_type, +result_children=[ +ValueCheck(children=[ValueCheck(value="3")]), +ValueCheck(children=[ValueCheck(value="1")]), +ValueCheck(children=[ValueCheck(value="2")]), ], ) diff --git a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py index e18785ec1359cc..a1f33271f39d2f 100644 --- a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py @@ -17,26 +17,42 @@ def test(self): self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp") ) +if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion( +[">", "16.0"] +): +vector_type = "std::vector" +vector_of_vector_type = "std::vector >" +else: +vector_type = "std::vector" +vector_of_vector_type = ( +"std::vector, std::allocator > >" +) + size_type = "size_type" value_type = "value_type" self.runCmd("settings set target.import-std-module true") -self.expect( -"expr a", -patterns=[ -"""\(std::vector(, std::allocator )* >\) \$0 = size=2 \{ - \[0\] = size=3 \{ -\[0\] = 1 -\[1\] = 2 -\[2\] = 3 - \} - \[1\] = size=3 \{ -\[0\] = 3 -\[1\] = 2 -\[2\] = 1 - \} -\}""" +self.expect_expr( +"a", +result_type=vector_of_vector_type, +result_children=[ +ValueCheck( +type=vector_type, +children=[ +ValueCheck(value="1"), +ValueCheck(value="2"), +ValueCheck(value="3"), +], +), +ValueCheck( +type=vector_type, +children=[ +ValueCheck(value="3"), +ValueCheck(value="2"), +ValueCheck(value="1"), +], +), ], ) self.expect_expr("a.size()", result_type=size_type, result_value="2") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "[lldb][test] Remove compiler version check and use regex" (PR #124101)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Reverts llvm/llvm-project#123393 This is causing `TestVectorOfVectorsFromStdModule.py` to fail on the the macOS clang-15 matrix bot. --- Full diff: https://github.com/llvm/llvm-project/pull/124101.diff 2 Files Affected: - (modified) lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py (+14-8) - (modified) lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py (+31-15) ``diff diff --git a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py index 759077302bfca4..1c3e64f14c 100644 --- a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py @@ -23,6 +23,13 @@ def test(self): self.runCmd("settings set target.import-std-module true") +if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion( +[">", "16.0"] +): +vector_type = "std::vector" +else: +vector_type = "std::vector >" + size_type = "size_type" value_type = "value_type" iterator = "iterator" @@ -34,14 +41,13 @@ def test(self): ValueCheck(name="current"), ] -self.expect( -"expr a", -patterns=[ -"""\(std::vector )*>\) \$0 = size=3 \{ - \[0\] = \(a = 3\) - \[1\] = \(a = 1\) - \[2\] = \(a = 2\) -\}""" +self.expect_expr( +"a", +result_type=vector_type, +result_children=[ +ValueCheck(children=[ValueCheck(value="3")]), +ValueCheck(children=[ValueCheck(value="1")]), +ValueCheck(children=[ValueCheck(value="2")]), ], ) diff --git a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py index e18785ec1359cc..a1f33271f39d2f 100644 --- a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py @@ -17,26 +17,42 @@ def test(self): self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp") ) +if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion( +[">", "16.0"] +): +vector_type = "std::vector" +vector_of_vector_type = "std::vector >" +else: +vector_type = "std::vector" +vector_of_vector_type = ( +"std::vector, std::allocator > >" +) + size_type = "size_type" value_type = "value_type" self.runCmd("settings set target.import-std-module true") -self.expect( -"expr a", -patterns=[ -"""\(std::vector(, std::allocator )* >\) \$0 = size=2 \{ - \[0\] = size=3 \{ -\[0\] = 1 -\[1\] = 2 -\[2\] = 3 - \} - \[1\] = size=3 \{ -\[0\] = 3 -\[1\] = 2 -\[2\] = 1 - \} -\}""" +self.expect_expr( +"a", +result_type=vector_of_vector_type, +result_children=[ +ValueCheck( +type=vector_type, +children=[ +ValueCheck(value="1"), +ValueCheck(value="2"), +ValueCheck(value="3"), +], +), +ValueCheck( +type=vector_type, +children=[ +ValueCheck(value="3"), +ValueCheck(value="2"), +ValueCheck(value="1"), +], +), ], ) self.expect_expr("a.size()", result_type=size_type, result_value="2") `` https://github.com/llvm/llvm-project/pull/124101 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4bcdb26 - Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
Author: Michael Buch Date: 2025-01-23T11:29:06Z New Revision: 4bcdb26dac4cdadd7f8850a5f9b2e775b73aaf7f URL: https://github.com/llvm/llvm-project/commit/4bcdb26dac4cdadd7f8850a5f9b2e775b73aaf7f DIFF: https://github.com/llvm/llvm-project/commit/4bcdb26dac4cdadd7f8850a5f9b2e775b73aaf7f.diff LOG: Revert "[lldb][test] Remove compiler version check and use regex" (#124101) Reverts llvm/llvm-project#123393 This is causing `TestVectorOfVectorsFromStdModule.py` to fail on the the macOS clang-15 matrix bot. Added: Modified: lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py Removed: diff --git a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py index 759077302bfca4..1c3e64f14c 100644 --- a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py @@ -23,6 +23,13 @@ def test(self): self.runCmd("settings set target.import-std-module true") +if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion( +[">", "16.0"] +): +vector_type = "std::vector" +else: +vector_type = "std::vector >" + size_type = "size_type" value_type = "value_type" iterator = "iterator" @@ -34,14 +41,13 @@ def test(self): ValueCheck(name="current"), ] -self.expect( -"expr a", -patterns=[ -"""\(std::vector )*>\) \$0 = size=3 \{ - \[0\] = \(a = 3\) - \[1\] = \(a = 1\) - \[2\] = \(a = 2\) -\}""" +self.expect_expr( +"a", +result_type=vector_type, +result_children=[ +ValueCheck(children=[ValueCheck(value="3")]), +ValueCheck(children=[ValueCheck(value="1")]), +ValueCheck(children=[ValueCheck(value="2")]), ], ) diff --git a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py index e18785ec1359cc..a1f33271f39d2f 100644 --- a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py @@ -17,26 +17,42 @@ def test(self): self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp") ) +if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion( +[">", "16.0"] +): +vector_type = "std::vector" +vector_of_vector_type = "std::vector >" +else: +vector_type = "std::vector" +vector_of_vector_type = ( +"std::vector, std::allocator > >" +) + size_type = "size_type" value_type = "value_type" self.runCmd("settings set target.import-std-module true") -self.expect( -"expr a", -patterns=[ -"""\(std::vector(, std::allocator )* >\) \$0 = size=2 \{ - \[0\] = size=3 \{ -\[0\] = 1 -\[1\] = 2 -\[2\] = 3 - \} - \[1\] = size=3 \{ -\[0\] = 3 -\[1\] = 2 -\[2\] = 1 - \} -\}""" +self.expect_expr( +"a", +result_type=vector_of_vector_type, +result_children=[ +ValueCheck( +type=vector_type, +children=[ +ValueCheck(value="1"), +ValueCheck(value="2"), +ValueCheck(value="3"), +], +), +ValueCheck( +type=vector_type, +children=[ +ValueCheck(value="3"), +ValueCheck(value="2"), +ValueCheck(value="1"), +], +), ], ) self.expect_expr("a.size()", result_type=size_type, result_value="2") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "[lldb][test] Remove compiler version check and use regex" (PR #124101)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/124101 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo` (PR #124059)
@@ -644,32 +644,22 @@ void ABISysV_loongarch::AugmentRegisterInfo( std::vector ®s) { lldb_private::RegInfoBasedABI::AugmentRegisterInfo(regs); + static const std::unordered_map reg_aliases = { + {"r0", "zero"}, {"r1", "ra"}, {"r2", "tp"}, {"r3", "sp"}, + {"r4", "a0"}, {"r5", "a1"}, {"r6", "a2"}, {"r7", "a3"}, + {"r8", "a4"}, {"r9", "a5"}, {"r10", "a6"}, {"r11", "a7"}, + {"r12", "t0"}, {"r13", "t1"}, {"r14", "t2"}, {"r15", "t3"}, + {"r16", "t4"}, {"r17", "t5"}, {"r18", "t6"}, {"r19", "t7"}, + {"r20", "t8"}, {"r22", "fp"}, {"r23", "s0"}, {"r24", "s1"}, + {"r25", "s2"}, {"r26", "s3"}, {"r27", "s4"}, {"r28", "s5"}, + {"r29", "s6"}, {"r30", "s7"}, {"r31", "s8"}}; + for (auto it : llvm::enumerate(regs)) { // Set alt name for certain registers for convenience -if (it.value().name == "r0") - it.value().alt_name.SetCString("zero"); -else if (it.value().name == "r1") - it.value().alt_name.SetCString("ra"); -else if (it.value().name == "r3") - it.value().alt_name.SetCString("sp"); -else if (it.value().name == "r22") - it.value().alt_name.SetCString("fp"); -else if (it.value().name == "r4") - it.value().alt_name.SetCString("a0"); -else if (it.value().name == "r5") - it.value().alt_name.SetCString("a1"); -else if (it.value().name == "r6") - it.value().alt_name.SetCString("a2"); -else if (it.value().name == "r7") - it.value().alt_name.SetCString("a3"); -else if (it.value().name == "r8") - it.value().alt_name.SetCString("a4"); -else if (it.value().name == "r9") - it.value().alt_name.SetCString("a5"); -else if (it.value().name == "r10") - it.value().alt_name.SetCString("a6"); -else if (it.value().name == "r11") - it.value().alt_name.SetCString("a7"); +std::string reg_name = it.value().name.GetStringRef().str(); +if (auto alias = reg_aliases.find(reg_name); alias != reg_aliases.end()) { + it.value().alt_name.SetCString(alias->second.c_str()); +} DavidSpickett wrote: https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements https://github.com/llvm/llvm-project/pull/124059 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NFC] Calculate the region size of an in memory image if size isn't specified (PR #123148)
labath wrote: > > The reason this code looks the way it does is that we've had crashes when > > trying to read corrupted elf files from memory, where we load the size of > > the elf file from the process memory, find that out that it's size is > > 935872395 GB, try to allocate a host buffer of that size, and then explode > > when the allocation failed. > > How do you load the size of the ELF file from process memory? Are you saying > the memory region information was corrupted in such cases? You can't load the ELF file size from process memory -- but that didn't stop the code from trying. :P (I.e., it was wrong/buggy) IIRC (this was ~ten years ago), what happened was that the code looked at section header members in the ELF header (e_shoff, e_shentsize, e_shnum, which are present and filled in even when the headers themselves are not mapped in), and then tried to allocate enough memory to hold everything from the beginning of the file to the end. It didn't use the memory region information to validate this data (if it did, it would have found out that the memory is not there), it just took the data at face value. If those fields contained garbage, it would crash when attempting to allocate exabytes of memory. > They are not present in memory and never have been. Not entirely true (but I get the idea). Section headers *don't have to be* present in memory. They also *usually* not present there. The vdso pseudo-module, however, always has sections headers (technically I guess it also doesn't need them, but every vdso I've seen has them). ``` (lldb) image dump objfile [vdso] Dumping headers for 1 module(s). 0x5592a46ea680: ObjectFileELF, file = '', arch = x86_64 ELF Header e_ident[EI_MAG0 ] = 0x7f e_ident[EI_MAG1 ] = 0x45 'E' e_ident[EI_MAG2 ] = 0x4c 'L' e_ident[EI_MAG3 ] = 0x46 'F' Program Headers IDX p_type p_offset p_vaddr p_paddr p_filesz p_memsz p_flags p_align --- - [ 0] PT_LOAD 08df 08df 0005 (PF_X PF_R) 1000 [ 1] PT_DYNAMIC 03a0 03a0 03a0 0120 0120 0004 ( PF_R) 0008 [ 2] PT_NOTE 04c0 04c0 04c0 0054 0054 0004 ( PF_R) 0004 [ 3] PT_GNU_EH_FRAME 0514 0514 0514 0034 0034 0004 ( PF_R) 0004 Section Headers IDX name type flagsaddr offset size link info addralgn entsize Name [ 0] SHT_NULL ( ) [ 1] 000f SHT_HASH 0002 ( ALLOC ) 0120 0120 0044 0003 0008 0004 .hash [ 2] 000b 0x6ff6 0002 ( ALLOC ) 0168 0168 0050 0003 0008 .gnu.hash [ 3] 0015 SHT_DYNSYM 0002 ( ALLOC ) 01b8 01b8 0120 0004 0001 0008 0018 .dynsym etc. ``` > So I changed the ELF code to not rely on requiring sections when the > PT_DYNAMIC info or PT_NOTE info points to the same data without requiring > section info. :+1: > The first memory region is typically a page or two and contains all that we > want. That depends on how the file is linked. By changing the linker flags, I can easily make it so that the entire code section of the binary ends up in the first memory region. That means the region can be arbitrarily (~gigabytes) large. Also, there's really no reason why the program headers have to come directly after the elf header, or even be present in the first memory region. Producing this is harder, but [here's](https://github.com/user-attachments/files/18518554/a.zip) a perfectly valid elf file (it just prints "Hello world when executed), whose program headers are in the second memory region. (That said, you might not be always able to load this kind of a file from memory because you can't always find the program headers from the elf headers -- this is why the dynamic linker also stores a pointer to the dynamic section.) > But I am currently working with some Android folks and we do need to worry > about loading ELF headers from the middle of an APK file. I am not sure how > the memory regions look for shared libraries that are uncompressed inside of > the APK files. If the memory regions are ok, then this patch would work, but > if there is one memory region for the entire APK it wouldn't. Though I don't > see how this can work if there are not valid memory regions for each shared > library within the APK because they need different permissions. They will have multiple memory regions, exactl
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters (PR #124096)
https://github.com/labath approved this pull request. I like the unit test, but why don't we (also) have an end-to-end for the explicit object parameter feature? Is there something still missing for the full support? https://github.com/llvm/llvm-project/pull/124096 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)
DavidSpickett wrote: So this is ready for anyone who is able to test on Mac x86_64. https://github.com/llvm/llvm-project/pull/123945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters (PR #124096)
Michael137 wrote: > I like the unit test, but why don't we (also) have an end-to-end for the > explicit object parameter feature? Is there something still missing for the > full support? Yea there's still a couple of issues with it. Particularly, expression evaluation in such methods currently doesn't work. But I suspect that isn't DWARF parser related, but due to assumptions in other parts of the expression evaluator. One particularly nasty looking blocker is that `clang::ParmVarDecl::isExplicitObjectParameter` is only `true` if it has a valid source location. But we never attach valid source locations to decls from DWARF. Still need to investigate exactly what's going on though https://github.com/llvm/llvm-project/pull/124096 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ad6d808 - [lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters (#124096)
Author: Michael Buch Date: 2025-01-23T11:16:02Z New Revision: ad6d808906075c3386bbeada3c37d8d3e6afe248 URL: https://github.com/llvm/llvm-project/commit/ad6d808906075c3386bbeada3c37d8d3e6afe248 DIFF: https://github.com/llvm/llvm-project/commit/ad6d808906075c3386bbeada3c37d8d3e6afe248.diff LOG: [lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters (#124096) LLDB deduces the CV-qualifiers and storage class of a C++ method from the object parameter. Currently it assumes that parameter is implicit (and is a pointer type with the name "this"). This isn't true anymore in C++23 with explicit object parameters. To support those we can simply check the `DW_AT_object_pointer` of the subprogram DIE (works for both declarations and definitions) when searching for the object parameter. We can also remove the check for `eEncodingIsPointerUID`, because in C++ an artificial parameter called `this` is only ever the implicit object parameter (at least for all the major compilers). Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index f54b7fc9cdad24..682ee6d287bf5c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -173,7 +173,9 @@ GetCXXObjectParameter(const DWARFDIE &subprogram, if (!DeclKindIsCXXClass(containing_decl_ctx.getDeclKind())) return {}; - // FIXME: if subprogram has a explicit DW_AT_object_pointer, use it. + if (DWARFDIE object_parameter = + subprogram.GetAttributeValueAsReferenceDIE(DW_AT_object_pointer)) +return object_parameter; // If no DW_AT_object_pointer was specified, assume the implicit object // parameter is the first parameter to the function, is called "this" and is @@ -215,11 +217,6 @@ static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram, return 0; uint32_t encoding_mask = this_type->GetEncodingMask(); - - // FIXME: explicit object parameters need not to be pointers - if (!(encoding_mask & (1u << Type::eEncodingIsPointerUID))) -return 0; - unsigned cv_quals = 0; if (encoding_mask & (1u << Type::eEncodingIsConstUID)) cv_quals |= clang::Qualifiers::Const; diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp index b31f56aa372d58..9c0300be08a78a 100644 --- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -902,3 +902,181 @@ TEST_F(DWARFASTParserClangTests, TestParseDWARFAttributes_ObjectPointer) { EXPECT_TRUE(attrs.object_pointer.IsValid()); EXPECT_EQ(attrs.object_pointer, param_die); } + +TEST_F(DWARFASTParserClangTests, TestParseSubroutine_ExplicitObjectParameter) { + // Tests parsing of a C++ non-static member function with an explicit object + // parameter that isn't called "this" and is not a pointer (but a CV-qualified + // rvalue reference instead). + + const char *yamldata = R"( +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data:ELFDATA2LSB + Type:ET_EXEC + Machine: EM_AARCH64 +DWARF: + debug_str: +- Context +- func +- mySelf + debug_abbrev: +- ID: 0 + Table: +- Code:0x1 + Tag: DW_TAG_compile_unit + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_language + Form:DW_FORM_data2 +- Code:0x2 + Tag: DW_TAG_structure_type + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Code:0x3 + Tag: DW_TAG_subprogram + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Attribute: DW_AT_declaration + Form:DW_FORM_flag_present +- Attribute: DW_AT_object_pointer + Form:DW_FORM_ref4 +- Attribute: DW_AT_external + Form:DW_FORM_flag_present +- Code:0x4 + Tag: DW_TAG_formal_parameter + Children:DW_CHILDREN_no + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Attribute: DW_AT_type + Form:DW_FORM_ref4 +- Code:0x5 + Tag:
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters (PR #124096)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/124096 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 636bc72 - Reland "[lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters" (#124100)"
Author: Michael Buch Date: 2025-01-23T12:00:45Z New Revision: 636bc72f672712cb848729c0f130d8b42c86f1cb URL: https://github.com/llvm/llvm-project/commit/636bc72f672712cb848729c0f130d8b42c86f1cb DIFF: https://github.com/llvm/llvm-project/commit/636bc72f672712cb848729c0f130d8b42c86f1cb.diff LOG: Reland "[lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters" (#124100)" This reverts commit a8020930a8174d84da04fa91b6fef244207f42f5. Relands original commit but fixing the unit-test to consume the `llvm::Expected` error object. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index f54b7fc9cdad24..682ee6d287bf5c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -173,7 +173,9 @@ GetCXXObjectParameter(const DWARFDIE &subprogram, if (!DeclKindIsCXXClass(containing_decl_ctx.getDeclKind())) return {}; - // FIXME: if subprogram has a explicit DW_AT_object_pointer, use it. + if (DWARFDIE object_parameter = + subprogram.GetAttributeValueAsReferenceDIE(DW_AT_object_pointer)) +return object_parameter; // If no DW_AT_object_pointer was specified, assume the implicit object // parameter is the first parameter to the function, is called "this" and is @@ -215,11 +217,6 @@ static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram, return 0; uint32_t encoding_mask = this_type->GetEncodingMask(); - - // FIXME: explicit object parameters need not to be pointers - if (!(encoding_mask & (1u << Type::eEncodingIsPointerUID))) -return 0; - unsigned cv_quals = 0; if (encoding_mask & (1u << Type::eEncodingIsConstUID)) cv_quals |= clang::Qualifiers::Const; diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp index b31f56aa372d58..8adda6fba3a0b0 100644 --- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -902,3 +902,183 @@ TEST_F(DWARFASTParserClangTests, TestParseDWARFAttributes_ObjectPointer) { EXPECT_TRUE(attrs.object_pointer.IsValid()); EXPECT_EQ(attrs.object_pointer, param_die); } + +TEST_F(DWARFASTParserClangTests, TestParseSubroutine_ExplicitObjectParameter) { + // Tests parsing of a C++ non-static member function with an explicit object + // parameter that isn't called "this" and is not a pointer (but a CV-qualified + // rvalue reference instead). + + const char *yamldata = R"( +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data:ELFDATA2LSB + Type:ET_EXEC + Machine: EM_AARCH64 +DWARF: + debug_str: +- Context +- func +- mySelf + debug_abbrev: +- ID: 0 + Table: +- Code:0x1 + Tag: DW_TAG_compile_unit + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_language + Form:DW_FORM_data2 +- Code:0x2 + Tag: DW_TAG_structure_type + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Code:0x3 + Tag: DW_TAG_subprogram + Children:DW_CHILDREN_yes + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Attribute: DW_AT_declaration + Form:DW_FORM_flag_present +- Attribute: DW_AT_object_pointer + Form:DW_FORM_ref4 +- Attribute: DW_AT_external + Form:DW_FORM_flag_present +- Code:0x4 + Tag: DW_TAG_formal_parameter + Children:DW_CHILDREN_no + Attributes: +- Attribute: DW_AT_name + Form:DW_FORM_strp +- Attribute: DW_AT_type + Form:DW_FORM_ref4 +- Code:0x5 + Tag: DW_TAG_rvalue_reference_type + Children:DW_CHILDREN_no + Attributes: +- Attribute: DW_AT_type + Form:DW_FORM_ref4 +- Code:0x6 + Tag: DW_TAG_const_type + Children:DW_CHILDREN_no + Attributes: +- Attribute: DW_AT_type + Form:DW_FORM_ref4 +- Code:0x7 +
[Lldb-commits] [lldb] 3ea2b54 - [lldb/windows] Make "anonymous" pipe names more unique (#123905)
Author: Pavel Labath Date: 2025-01-23T13:03:29+01:00 New Revision: 3ea2b546a8d17014d3ecf05356ecfaadf26ed846 URL: https://github.com/llvm/llvm-project/commit/3ea2b546a8d17014d3ecf05356ecfaadf26ed846 DIFF: https://github.com/llvm/llvm-project/commit/3ea2b546a8d17014d3ecf05356ecfaadf26ed846.diff LOG: [lldb/windows] Make "anonymous" pipe names more unique (#123905) Using a "random" name for an "anonymous" pipe seems to be the state of the art on windows (according to stack overflow, new windows versions may have something better, but it involves calling kernel APIs directly and generally a lot of dark magic). The problem with the current method was that is does not produce unique names if one has two copies of the pipe code in the same process, which is what happened with #120457 (because liblldb only exposes the public api, and we've started using the pipe code in lldb-dap as well). This patch works around the problem by adding the address of the counter variable to the pipe name. Replicating the multiple-copies setup in a test would be very difficult, which is why I'm not adding a test for this scenario. Added: Modified: lldb/source/Host/windows/PipeWindows.cpp Removed: diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp index 21e30f0ae87384..e95007ae8fd163 100644 --- a/lldb/source/Host/windows/PipeWindows.cpp +++ b/lldb/source/Host/windows/PipeWindows.cpp @@ -71,9 +71,8 @@ Status PipeWindows::CreateNew(bool child_process_inherit) { // cannot get overlapped i/o on Windows without using a named pipe. So we // synthesize a unique name. uint32_t serial = g_pipe_serial.fetch_add(1); - std::string pipe_name; - llvm::raw_string_ostream pipe_name_stream(pipe_name); - pipe_name_stream << "lldb.pipe." << ::GetCurrentProcessId() << "." << serial; + std::string pipe_name = llvm::formatv( + "lldb.pipe.{0}.{1}.{2}", GetCurrentProcessId(), &g_pipe_serial, serial); return CreateNew(pipe_name.c_str(), child_process_inherit); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0236cb6 - [lldb] Enable "frame diagnose" on linux (#123217)
Author: Pavel Labath Date: 2025-01-23T13:04:36+01:00 New Revision: 0236cb689550ed2dac406443c652efb723cb2602 URL: https://github.com/llvm/llvm-project/commit/0236cb689550ed2dac406443c652efb723cb2602 DIFF: https://github.com/llvm/llvm-project/commit/0236cb689550ed2dac406443c652efb723cb2602.diff LOG: [lldb] Enable "frame diagnose" on linux (#123217) .. by changing the signal stop reason format :facepalm: The reason this did not work is because the code in `StopInfo::GetCrashingDereference` was looking for the string "address=" to extract the address of the crash. Macos stop reason strings have the form ``` EXC_BAD_ACCESS (code=1, address=0xdead) ``` while on linux they look like: ``` signal SIGSEGV: address not mapped to object (fault address: 0xdead) ``` Extracting the address from a string sounds like a bad idea, but I suppose there's some value in using a consistent format across platforms, so this patch changes the signal format to use the equals sign as well. All of the diagnose tests pass except one, which appears to fail due to something similar #115453 (disassembler reports unrelocated call targets). I've left the tests disabled on windows, as the stop reason reporting code works very differently there, and I suspect it won't work out of the box. If I'm wrong -- the XFAIL will let us know. Added: Modified: lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp lldb/source/Target/UnixSignals.cpp lldb/test/API/commands/frame/diagnose/array/TestArray.py lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py lldb/test/API/commands/frame/diagnose/dereference-this/TestDiagnoseDereferenceThis.py lldb/test/API/commands/frame/diagnose/inheritance/TestDiagnoseInheritance.py lldb/test/API/commands/frame/diagnose/local-variable/TestLocalVariable.py lldb/test/API/commands/frame/diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py lldb/test/API/linux/aarch64/mte_core_file/TestAArch64LinuxMTEMemoryTagCoreFile.py lldb/test/API/linux/aarch64/mte_tag_faults/TestAArch64LinuxMTEMemoryTagFaults.py lldb/test/API/linux/aarch64/non_address_bit_memory_access/TestAArch64LinuxNonAddressBitMemoryAccess.py lldb/test/Shell/Register/Core/x86-32-linux-multithread.test lldb/test/Shell/Register/Core/x86-64-linux-multithread.test lldb/unittests/Signals/UnixSignalsTest.cpp llvm/docs/ReleaseNotes.md Removed: diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp index de047ee214c11e4..a6d6a78357fe5c1 100644 --- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -326,14 +326,14 @@ void NativeThreadLinux::AnnotateSyncTagCheckFault(lldb::addr_t fault_addr) { } // We assume that the stop description is currently: - // signal SIGSEGV: sync tag check fault (fault address: ) + // signal SIGSEGV: sync tag check fault (fault address=) // Remove the closing ) m_stop_description.pop_back(); std::stringstream ss; std::unique_ptr manager(std::move(details->manager)); - ss << " logical tag: 0x" << std::hex << manager->GetLogicalTag(fault_addr); + ss << " logical tag=0x" << std::hex << manager->GetLogicalTag(fault_addr); std::vector allocation_tag_data; // The fault address may not be granule aligned. ReadMemoryTags will granule @@ -347,7 +347,7 @@ void NativeThreadLinux::AnnotateSyncTagCheckFault(lldb::addr_t fault_addr) { llvm::Expected> allocation_tag = manager->UnpackTagsData(allocation_tag_data, 1); if (allocation_tag) { - ss << " allocation tag: 0x" << std::hex << allocation_tag->front() << ")"; + ss << " allocation tag=0x" << std::hex << allocation_tag->front() << ")"; } else { llvm::consumeError(allocation_tag.takeError()); ss << ")"; diff --git a/lldb/source/Target/UnixSignals.cpp b/lldb/source/Target/UnixSignals.cpp index bee3a63818259ed..da661003925c79a 100644 --- a/lldb/source/Target/UnixSignals.cpp +++ b/lldb/source/Target/UnixSignals.cpp @@ -163,7 +163,7 @@ UnixSignals::GetSignalDescription(int32_t signo, std::optional code, break; case SignalCodePrintOption::Address: if (addr) -strm << " (fault address: 0x" << std::hex << *addr << ")"; +strm << " (fault address=0x" << std::hex << *addr << ")"; break; case SignalCodePrintOption::Bounds: if (lower && upper && addr) { @@ -172,9 +172,9 @@ UnixSignals::GetSignalDes
[Lldb-commits] [lldb] [llvm] [lldb] Enable "frame diagnose" on linux (PR #123217)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/123217 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/windows] Make "anonymous" pipe names more unique (PR #123905)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/123905 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use the first address range as the function address (PR #122440)
labath wrote: ping https://github.com/llvm/llvm-project/pull/122440 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Make C++ method parsing aware of explicit object parameters (PR #124096)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `lldb-remote-linux-ubuntu` running on `as-builder-9` while building `lldb` at step 15 "test-check-lldb-unit". Full details are available at: https://lab.llvm.org/buildbot/#/builders/195/builds/3894 Here is the relevant piece of the build log for the reference ``` Step 15 (test-check-lldb-unit) failure: Test just built components: check-lldb-unit completed (failure) TEST 'lldb-unit :: SymbolFile/DWARF/./SymbolFileDWARFTests/6/42' FAILED Script(shard): -- GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/unittests/SymbolFile/DWARF/./SymbolFileDWARFTests-lldb-unit-4043327-6-42.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=42 GTEST_SHARD_INDEX=6 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/unittests/SymbolFile/DWARF/./SymbolFileDWARFTests -- Note: This is test shard 7 of 42. [==] Running 1 test from 1 test suite. [--] Global test environment set-up. [--] 1 test from DWARFASTParserClangTests [ RUN ] DWARFASTParserClangTests.TestParseSubroutine_ExplicitObjectParameter Expected must be checked before access or destruction. Expected value was in success state. (Note: Expected values in success mode must still be checked prior to being destroyed). Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 SymbolFileDWARFTests 0x6446daf12702 1 SymbolFileDWARFTests 0x6446daf0f58f 2 SymbolFileDWARFTests 0x6446daf0f6d5 3 libc.so.60x71cf66645320 4 libc.so.60x71cf6669eb1c pthread_kill + 284 5 libc.so.60x71cf6664526e gsignal + 30 6 libc.so.60x71cf666288ff abort + 223 7 SymbolFileDWARFTests 0x6446dae86a8d 8 SymbolFileDWARFTests 0x6446dae8ac1a 9 SymbolFileDWARFTests 0x6446daf731bf 10 SymbolFileDWARFTests 0x6446daf7b6f2 11 SymbolFileDWARFTests 0x6446daf880c9 12 SymbolFileDWARFTests 0x6446daf88a02 13 SymbolFileDWARFTests 0x6446daf72ec0 14 SymbolFileDWARFTests 0x6446dad9dc3a 15 libc.so.60x71cf6662a1ca 16 libc.so.60x71cf6662a28b __libc_start_main + 139 17 SymbolFileDWARFTests 0x6446dae7e855 -- exit: -6 -- shard JSON output does not exist: /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/unittests/SymbolFile/DWARF/./SymbolFileDWARFTests-lldb-unit-4043327-6-42.json ``` https://github.com/llvm/llvm-project/pull/124096 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SymbolContext::GetAddress (PR #123340)
@@ -370,6 +370,31 @@ bool SymbolContext::GetAddressRange(uint32_t scope, uint32_t range_idx, return false; } +Address SymbolContext::GetAddress(uint32_t scope, + bool use_inline_block_range) const { + if ((scope & eSymbolContextLineEntry) && line_entry.IsValid()) +return line_entry.range.GetBaseAddress(); + + if (scope & eSymbolContextBlock) { +Block *block_to_use = (block && use_inline_block_range) + ? block->GetContainingInlinedBlock() + : block; +if (block_to_use) { + Address addr; + block_to_use->GetStartAddress(addr); + return addr; +} + } labath wrote: Okay, everything you've said now makes sense to me, including the part about the confusion between the function block and the function itself (it is as you described, for the block we would return the lowest address). I think we could fix that by changing Block::GetStartAddress for function blocks. Basically to change this: ``` if (function) { addr = function->GetAddress(); addr.Slide(m_ranges.GetEntryRef(0).GetRangeBase()); return true; } ``` into something like this: ``` if (function) { addr = function->GetAddress(); if (bool is_function_block = GetParent() == nullptr; !is_function_block) addr.Slide(m_ranges.GetEntryRef(0).GetRangeBase()); return true; } ``` Would that be acceptable? The other option I see is to ditch the SymbolContextItem flags and rename the function into something that makes it clear that it only considers functions and symbols. The implementation of that should be easy, we only need to figure out the name. I don't want it to be too obscure, as I think this is the thing that a lot of callers will actually want to use, but it should also be clear about what its doing. `GetFunctionOrSymbolAddress` is the best I can come up with right now. https://github.com/llvm/llvm-project/pull/123340 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add Lexer (with tests) for DIL (Data Inspection Language). (PR #123521)
@@ -0,0 +1,156 @@ +//===-- DILLexer.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_VALUEOBJECT_DILLEXER_H_ +#define LLDB_VALUEOBJECT_DILLEXER_H_ + +#include "llvm/ADT/StringRef.h" +#include +#include +#include +#include +#include + +namespace lldb_private { + +namespace dil { + +enum class TokenKind { + coloncolon, + eof, + identifier, + invalid, + kw_namespace, + l_paren, + none, + r_paren, + unknown, +}; + +/// Class defining the tokens generated by the DIL lexer and used by the +/// DIL parser. +class DILToken { +public: + DILToken(dil::TokenKind kind, std::string spelling, uint32_t start) + : m_kind(kind), m_spelling(spelling), m_start_pos(start) {} + + DILToken() : m_kind(dil::TokenKind::none), m_spelling(""), m_start_pos(0) {} + + void setKind(dil::TokenKind kind) { m_kind = kind; } + dil::TokenKind getKind() const { return m_kind; } + + std::string getSpelling() const { return m_spelling; } + + uint32_t getLength() const { return m_spelling.size(); } + + bool is(dil::TokenKind kind) const { return m_kind == kind; } + + bool isNot(dil::TokenKind kind) const { return m_kind != kind; } + + bool isOneOf(dil::TokenKind kind1, dil::TokenKind kind2) const { +return is(kind1) || is(kind2); + } + + template bool isOneOf(dil::TokenKind kind, Ts... Ks) const { +return is(kind) || isOneOf(Ks...); + } + + uint32_t getLocation() const { return m_start_pos; } + + void setValues(dil::TokenKind kind, std::string spelling, uint32_t start) { +m_kind = kind; +m_spelling = spelling; +m_start_pos = start; + } + + static const std::string getTokenName(dil::TokenKind kind); + +private: + dil::TokenKind m_kind; + std::string m_spelling; + uint32_t m_start_pos; // within entire expression string +}; + +/// Class for doing the simple lexing required by DIL. +class DILLexer { +public: + DILLexer(llvm::StringRef dil_expr) : m_expr(dil_expr.str()) { +m_cur_pos = m_expr.begin(); +// Use UINT_MAX to indicate invalid/uninitialized value. +m_tokens_idx = UINT_MAX; + } + + bool Lex(DILToken &result, bool look_ahead = false); + + bool Is_Word(std::string::iterator start, uint32_t &length); + + uint32_t GetLocation() { return m_cur_pos - m_expr.begin(); } + + /// Update 'result' with the other paremeter values, create a + /// duplicate token, and push the duplicate token onto the vector of + /// lexed tokens. + void UpdateLexedTokens(DILToken &result, dil::TokenKind tok_kind, + std::string tok_str, uint32_t tok_pos); + + /// Return the lexed token N+1 positions ahead of the 'current' token + /// being handled by the DIL parser. + const DILToken &LookAhead(uint32_t N); + + const DILToken &AcceptLookAhead(uint32_t N); labath wrote: That's good to hear, but it still makes the implementation complicated. Separating lexing from the traversal through the lexed tokens would make things much easier to follow. I understand traditional lexers can't do that, but hey are parsing megabytes of text. We're going to be parsing approximately one line of code here. https://github.com/llvm/llvm-project/pull/123521 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add Lexer (with tests) for DIL (Data Inspection Language). (PR #123521)
@@ -0,0 +1,205 @@ +//===-- DILLexer.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 +// +// This implements the recursive descent parser for the Data Inspection +// Language (DIL), and its helper functions, which will eventually underlie the +// 'frame variable' command. The language that this parser recognizes is +// described in lldb/docs/dil-expr-lang.ebnf +// +//===--===// + +#include "lldb/ValueObject/DILLexer.h" +#include "llvm/ADT/StringMap.h" + +namespace lldb_private { + +namespace dil { + +// For fast keyword lookup. More keywords will be added later. +const llvm::StringMap Keywords = { +{"namespace", dil::TokenKind::kw_namespace}, +}; labath wrote: Maybe, maybe not, but I doubt anyone will notice the extra few nanoseconds. I am also not convinced that we should have that many keywords, as every keyword is a variable name that's now impossible/hard to access. https://github.com/llvm/llvm-project/pull/123521 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add Lexer (with tests) for DIL (Data Inspection Language). (PR #123521)
@@ -0,0 +1,205 @@ +//===-- DILLexer.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 +// +// This implements the recursive descent parser for the Data Inspection +// Language (DIL), and its helper functions, which will eventually underlie the +// 'frame variable' command. The language that this parser recognizes is +// described in lldb/docs/dil-expr-lang.ebnf +// +//===--===// + +#include "lldb/ValueObject/DILLexer.h" +#include "llvm/ADT/StringMap.h" + +namespace lldb_private { + +namespace dil { + +// For fast keyword lookup. More keywords will be added later. +const llvm::StringMap Keywords = { +{"namespace", dil::TokenKind::kw_namespace}, +}; + +const std::string DILToken::getTokenName(dil::TokenKind kind) { + switch (kind) { + case dil::TokenKind::coloncolon: +return "coloncolon"; + case dil::TokenKind::eof: +return "eof"; + case dil::TokenKind::identifier: +return "identifier"; + case dil::TokenKind::kw_namespace: +return "namespace"; + case dil::TokenKind::l_paren: +return "l_paren"; + case dil::TokenKind::r_paren: +return "r_paren"; + case dil::TokenKind::unknown: +return "unknown"; + default: +return "token_name"; + } +} + +static bool Is_Letter(char c) { + if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) +return true; + return false; +} + +static bool Is_Digit(char c) { return ('0' <= c && c <= '9'); } + +// A word starts with a letter, underscore, or dollar sign, followed by +// letters ('a'..'z','A'..'Z'), digits ('0'..'9'), and/or underscores. +bool DILLexer::Is_Word(std::string::iterator start, uint32_t &length) { + bool done = false; labath wrote: Yes, but you break out of the loop as soon as you set it to true. (I don't think the meaning of the code would change if you just deleted all references to the variable. https://github.com/llvm/llvm-project/pull/123521 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
@@ -222,14 +223,15 @@ void FormatManager::GetPossibleMatches( if (compiler_type.IsPointerType()) { CompilerType non_ptr_type = compiler_type.GetPointeeType(); -GetPossibleMatches(valobj, non_ptr_type, use_dynamic, entries, - current_flags.WithStrippedPointer()); +if (dereference_ptr) + GetPossibleMatches(valobj, non_ptr_type, use_dynamic, entries, +current_flags.WithStrippedPointer(), false); labath wrote: Are you sure we need the extra flag? Could we use `current_flags.stripped_pointer` as an indicator of whether we've removed a level of pointers? https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
https://github.com/labath commented: This makes sense to me, but I'd like to hear what @jimingham thinks about this. > The current behaviour might cause crash on pretty printers. If the pretty > printer calls SBValue::GetChildMemberWithName when compute the synthetic > children or summary string and its type is T**, this might cause crash as it > will return nullptr or None in this case The code you linked to is problematic even with this fix. The returned value could be null due to bad/missing debug info or due to a new version of libstdc++ renaming the (private) member. That code should be using `GetChildAtNamePath`, which checks that all the intermediate nodes are present. https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
labath wrote: I'm fine (and very happy) with this if @enh-google (or whoever he nominates) is. I guess this means the whole "single step workaround" (lldb/source/Plugins/Process/Linux/SingleStepCheck.h) could go away as well (maybe make a separate patch for that). https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ brad0 wrote: The ptrace header issue and the bits from ar.h header I'll submit. SUN_LEN was only added 6 years ago so I figure keep it for a little bit longer. https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove more workrounds for Android that have been fixed upstream (PR #124176)
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/124176 >From 6753c51940bd947d1aac1b333f954daa80346a1c Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Thu, 23 Jan 2025 13:19:06 -0500 Subject: [PATCH] [lldb] Remove more workarounds for Android that have been fixed upstream Issues that were fixed 10+ years ago with Bionic libc. --- lldb/source/Host/posix/ProcessLauncherPosixFork.cpp | 4 .../ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 22bf698c71716e..7d856954684c49 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -24,10 +24,6 @@ #include #include -#ifdef __ANDROID__ -#define PT_TRACE_ME PTRACE_TRACEME -#endif - #if defined(__linux__) #include #endif diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index b202898ff438a6..6e5617664f7feb 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -8,7 +8,7 @@ #include "ObjectContainerBSDArchive.h" -#if defined(_WIN32) || defined(__ANDROID__) || defined(_AIX) +#if defined(_WIN32) || defined(_AIX) // Defines from ar, missing on Windows #define SARMAG 8 #define ARFMAG "`\n" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove more workrounds for Android that have been fixed upstream (PR #124176)
https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/124176 Issues that were fixed 10+ years ago with Bionic libc. >From 4e10a6b316a1562d96808db3d4447539b51e3179 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Thu, 23 Jan 2025 13:19:06 -0500 Subject: [PATCH] [lldb] Remove more workrounds for Android that have been fixed upstream Issues that were fixed 10+ years ago with Bionic libc. --- lldb/source/Host/posix/ProcessLauncherPosixFork.cpp | 4 .../ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 22bf698c71716e..7d856954684c49 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -24,10 +24,6 @@ #include #include -#ifdef __ANDROID__ -#define PT_TRACE_ME PTRACE_TRACEME -#endif - #if defined(__linux__) #include #endif diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index b202898ff438a6..6e5617664f7feb 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -8,7 +8,7 @@ #include "ObjectContainerBSDArchive.h" -#if defined(_WIN32) || defined(__ANDROID__) || defined(_AIX) +#if defined(_WIN32) || defined(_AIX) // Defines from ar, missing on Windows #define SARMAG 8 #define ARFMAG "`\n" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove more workrounds for Android that have been fixed upstream (PR #124176)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Brad Smith (brad0) Changes Issues that were fixed 10+ years ago with Bionic libc. --- Full diff: https://github.com/llvm/llvm-project/pull/124176.diff 2 Files Affected: - (modified) lldb/source/Host/posix/ProcessLauncherPosixFork.cpp (-4) - (modified) lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (+1-1) ``diff diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 22bf698c71716e..7d856954684c49 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -24,10 +24,6 @@ #include #include -#ifdef __ANDROID__ -#define PT_TRACE_ME PTRACE_TRACEME -#endif - #if defined(__linux__) #include #endif diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index b202898ff438a6..6e5617664f7feb 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -8,7 +8,7 @@ #include "ObjectContainerBSDArchive.h" -#if defined(_WIN32) || defined(__ANDROID__) || defined(_AIX) +#if defined(_WIN32) || defined(_AIX) // Defines from ar, missing on Windows #define SARMAG 8 #define ARFMAG "`\n" `` https://github.com/llvm/llvm-project/pull/124176 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
ZequanWu wrote: > How does this patch fit with the: > > ``` >-p ( --skip-pointers ) > Don't use this format for pointers-to-type objects. > >-r ( --skip-references ) > Don't use this format for references-to-type objects. > ``` > > settings in `type add`? It seems like we let the formatters > control whether they should also apply to pointers and references to those > types. Shouldn't that be what controls whether formatters also apply to > pointers? > > And if a formatter says it can handle pointers, it's up to the formatter to > do that right. This has no impact for reference. For pointers, if `-p` is set in `type add`, the new formatter will apply only the type T and this patch has no impact for that. This patch changes the behaviour when `-p` is not set. Currently, lldb apply the new formatter to `T`, `T*`, `T**` and so on if `-p` is not set. This change let lldb only apply the formatter to `T` and `T*`. https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4cf1fe2 - [lldb] Add missing operations to GetOpcodeDataSize (#120163)
Author: Jonas Devlieghere Date: 2025-01-23T10:37:11-08:00 New Revision: 4cf1fe240589d3f2a8a8332abf3f71a18bdba027 URL: https://github.com/llvm/llvm-project/commit/4cf1fe240589d3f2a8a8332abf3f71a18bdba027 DIFF: https://github.com/llvm/llvm-project/commit/4cf1fe240589d3f2a8a8332abf3f71a18bdba027.diff LOG: [lldb] Add missing operations to GetOpcodeDataSize (#120163) The improved error reporting in #120162 revealed that we were missing opcodes in GetOpcodeDataSize. I changed the function to remove the default case and switch over the enum type which will cause the compiler to emit a warning if there are unhandled operations in the future. rdar://139705570 Added: Modified: lldb/source/Expression/DWARFExpression.cpp Removed: diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 1d826e341e2c44..f48f3ab9307dd1 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -132,10 +132,35 @@ static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx, /// are made on the state of \p data after this call. static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, const lldb::offset_t data_offset, -const uint8_t op, +const LocationAtom op, const DWARFUnit *dwarf_cu) { lldb::offset_t offset = data_offset; switch (op) { + // Only used in LLVM metadata. + case DW_OP_LLVM_fragment: + case DW_OP_LLVM_convert: + case DW_OP_LLVM_tag_offset: + case DW_OP_LLVM_entry_value: + case DW_OP_LLVM_implicit_pointer: + case DW_OP_LLVM_arg: + case DW_OP_LLVM_extract_bits_sext: + case DW_OP_LLVM_extract_bits_zext: +break; + // Vendor extensions: + case DW_OP_HP_is_value: + case DW_OP_HP_fltconst4: + case DW_OP_HP_fltconst8: + case DW_OP_HP_mod_range: + case DW_OP_HP_unmod_range: + case DW_OP_HP_tls: + case DW_OP_INTEL_bit_piece: + case DW_OP_WASM_location: + case DW_OP_WASM_location_int: + case DW_OP_APPLE_uninit: + case DW_OP_PGI_omp_thread_num: + case DW_OP_hi_user: +break; + case DW_OP_addr: case DW_OP_call_ref: // 0x9a 1 address sized offset of DIE (DWARF3) return data.GetAddressByteSize(); @@ -246,6 +271,7 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, case DW_OP_pick:// 0x15 1 1-byte stack index case DW_OP_deref_size: // 0x94 1 1-byte size of data retrieved case DW_OP_xderef_size: // 0x95 1 1-byte size of data retrieved + case DW_OP_deref_type: // 0xa6 1 1-byte constant return 1; // Opcodes with a single 2 byte arguments @@ -268,7 +294,6 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, return 8; // All opcodes that have a single ULEB (signed or unsigned) argument - case DW_OP_addrx: // 0xa1 1 ULEB128 index case DW_OP_constu: // 0x10 1 ULEB128 constant case DW_OP_consts: // 0x11 1 SLEB128 constant case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend @@ -307,14 +332,20 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, case DW_OP_regx:// 0x90 1 ULEB128 register case DW_OP_fbreg: // 0x91 1 SLEB128 offset case DW_OP_piece: // 0x93 1 ULEB128 size of piece addressed + case DW_OP_convert: // 0xa8 1 ULEB128 offset + case DW_OP_reinterpret: // 0xa9 1 ULEB128 offset + case DW_OP_addrx: // 0xa1 1 ULEB128 index + case DW_OP_constx: // 0xa2 1 ULEB128 index + case DW_OP_xderef_type: // 0xa7 1 ULEB128 index case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index data.Skip_LEB128(&offset); return offset - data_offset; // All opcodes that have a 2 ULEB (signed or unsigned) arguments - case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset - case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3); + case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset + case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3); + case DW_OP_regval_type: // 0xa5 ULEB128 + ULEB128 data.Skip_LEB128(&offset); data.Skip_LEB128(&offset); return offset - data_offset; @@ -327,6 +358,13 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, return offset - data_offset; } + case DW_OP_implicit_pointer: // 0xa0 4-byte (or 8-byte for DWARF 64) constant + // + LEB128 + { +data.Skip_LEB128(&offset); +return DWARFUnit::GetAddressByteSize(dwarf_cu) + offset - data_offset; + } + case DW_OP_GNU_entry_value: case DW_OP_entry_value: // 0xa3 ULEB128 size + variable-length block { @@ -334
[Lldb-commits] [lldb] [lldb] Add missing operations to GetOpcodeDataSize (PR #120163)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/120163 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ enh-google wrote: > The ptrace header issue and the bits from ar.h header I'll submit. SUN_LEN > was only added 6 years ago so I figure keep it for a little bit longer. but it's just a macro in a header, so as long as you're building with an _ndk_ that's less than 6 years old (and no _supported_ ndk is more than 1 year old), "this is fine". (the ndk has a "unified headers" model where we use clang availability annotations _on functions_ so we can use the exact same headers regardless of what api level you're targeting. so any types/macros/etc "just work" even for OS releases where they weren't present.) https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
jimingham wrote: > > How does this patch fit with the: > > ``` > >-p ( --skip-pointers ) > > Don't use this format for pointers-to-type objects. > > > >-r ( --skip-references ) > > Don't use this format for references-to-type objects. > > ``` > > > > > > > > > > > > > > > > > > > > > > > > settings in `type add`? It seems like we let the formatters > > control whether they should also apply to pointers and references to those > > types. Shouldn't that be what controls whether formatters also apply to > > pointers? > > And if a formatter says it can handle pointers, it's up to the formatter to > > do that right. > > This has no impact for reference. For pointers, if `-p` is set in `type > add`, the new formatter will apply only the type T and this patch > has no impact for that. This patch changes the behaviour when `-p` is not > set. Currently, lldb apply the new formatter to `T`, `T*`, `T**` and so on if > `-p` is not set. This change let lldb only apply the formatter to `T` and > `T*`. If you write the formatter knowing that you've asked all for a match against all the pointers to this type, it's up to the formatter to not assume it's only being passed T or T*. I still don't see why we should be cutting this off in lldb. If I have a std::vector variable, I want to see its size in the local view, regardless of whether the handle to it is a pointer, or a pointer to a pointer. It seems artificial to cut that off for me. https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
jimingham wrote: If anything, we should allow `--skip-pointers 1` for formatter writers that only want to handle one level of pointer to the type. https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ brad0 wrote: > > The ptrace header issue and the bits from ar.h header I'll submit. SUN_LEN > > was only added 6 years ago so I figure keep it for a little bit longer. > > but it's just a macro in a header, so as long as you're building with an > _ndk_ that's less than 6 years old (and no _supported_ ndk is more than 1 > year old), "this is fine". > > (the ndk has a "unified headers" model where we use clang availability > annotations _on functions_ so we can use the exact same headers regardless of > what api level you're targeting. so any types/macros/etc "just work" even for > OS releases where they weren't present.) Ah, I was not aware of that. https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove more workrounds for Android that have been fixed upstream (PR #124176)
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/124176 >From 7c53e345b9264c9bd0ae16cddfb3c8066d43 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Thu, 23 Jan 2025 13:19:06 -0500 Subject: [PATCH] [lldb] Remove more workarounds for Android that have been fixed upstream Issues that were fixed 10+ years ago with Bionic libc. --- lldb/source/Host/posix/DomainSocket.cpp | 8 lldb/source/Host/posix/ProcessLauncherPosixFork.cpp | 4 .../BSD-Archive/ObjectContainerBSDArchive.cpp | 2 +- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp index be8fcdf2c8f2c8..6c490cdda47ed7 100644 --- a/lldb/source/Host/posix/DomainSocket.cpp +++ b/lldb/source/Host/posix/DomainSocket.cpp @@ -20,14 +20,6 @@ using namespace lldb; using namespace lldb_private; -#ifdef __ANDROID__ -// Android does not have SUN_LEN -#ifndef SUN_LEN -#define SUN_LEN(ptr) \ - (offsetof(struct sockaddr_un, sun_path) + strlen((ptr)->sun_path)) -#endif -#endif // #ifdef __ANDROID__ - static const int kDomain = AF_UNIX; static const int kType = SOCK_STREAM; diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 22bf698c71716e..7d856954684c49 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -24,10 +24,6 @@ #include #include -#ifdef __ANDROID__ -#define PT_TRACE_ME PTRACE_TRACEME -#endif - #if defined(__linux__) #include #endif diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index b202898ff438a6..6e5617664f7feb 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -8,7 +8,7 @@ #include "ObjectContainerBSDArchive.h" -#if defined(_WIN32) || defined(__ANDROID__) || defined(_AIX) +#if defined(_WIN32) || defined(_AIX) // Defines from ar, missing on Windows #define SARMAG 8 #define ARFMAG "`\n" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ brad0 wrote: ``` std::optional PosixUserIDResolver::DoGetGroupName(id_t gid) { #ifndef __ANDROID__ char group_buffer[PATH_MAX]; size_t group_buffer_size = sizeof(group_buffer); struct group group_info; struct group *group_info_ptr = &group_info; // Try the threadsafe version first if (::getgrgid_r(gid, &group_info, group_buffer, group_buffer_size, &group_info_ptr) == 0) { if (group_info_ptr) return std::string(group_info_ptr->gr_name); } else { // The threadsafe version isn't currently working for me on darwin, but the // non-threadsafe version is, so I am calling it below. group_info_ptr = ::getgrgid(gid); if (group_info_ptr) return std::string(group_info_ptr->gr_name); } #endif return std::nullopt; } ``` There is no comment and I do not immediately see what the issue is there. https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ enh-google wrote: looking at the bionic headers, getgrgid_r() wasn't available until API 24... https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Check Android API for existence of getgrgid_r() introduced in 24 (PR #124182)
https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/124182 None >From 394b06124cc49dfca54071ef6f19ec55914c0750 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Thu, 23 Jan 2025 15:15:50 -0500 Subject: [PATCH] [lldb] Check Android API for existence of getgrgid_r() introduced in 24 --- lldb/source/Host/posix/HostInfoPosix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp index 23ba3177de317a..879dccfd353be5 100644 --- a/lldb/source/Host/posix/HostInfoPosix.cpp +++ b/lldb/source/Host/posix/HostInfoPosix.cpp @@ -119,7 +119,7 @@ std::optional PosixUserIDResolver::DoGetUserName(id_t uid) { } std::optional PosixUserIDResolver::DoGetGroupName(id_t gid) { -#ifndef __ANDROID__ +#if !defined(__ANDROID__) || __ANDROID_API__ >= 24 char group_buffer[PATH_MAX]; size_t group_buffer_size = sizeof(group_buffer); struct group group_info; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Check Android API for existence of getgrgid_r() introduced in 24 (PR #124182)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Brad Smith (brad0) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/124182.diff 1 Files Affected: - (modified) lldb/source/Host/posix/HostInfoPosix.cpp (+1-1) ``diff diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp index 23ba3177de317a..879dccfd353be5 100644 --- a/lldb/source/Host/posix/HostInfoPosix.cpp +++ b/lldb/source/Host/posix/HostInfoPosix.cpp @@ -119,7 +119,7 @@ std::optional PosixUserIDResolver::DoGetUserName(id_t uid) { } std::optional PosixUserIDResolver::DoGetGroupName(id_t gid) { -#ifndef __ANDROID__ +#if !defined(__ANDROID__) || __ANDROID_API__ >= 24 char group_buffer[PATH_MAX]; size_t group_buffer_size = sizeof(group_buffer); struct group group_info; `` https://github.com/llvm/llvm-project/pull/124182 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ enh-google wrote: yeah, "if it confused you, it'll probably confuse the next person". either the comment or the more specific `#if` sgtm... https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove more workrounds for Android that have been fixed upstream (PR #124176)
https://github.com/enh-google approved this pull request. https://github.com/llvm/llvm-project/pull/124176 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ brad0 wrote: > looking at the bionic headers, getgrgid_r() wasn't available until API 24... Ok, thanks. https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ enh-google wrote: (getgrgid() has been around forever, though, so if anyone cared they could reduce the scope of this. but probably just `#if defined(__ANDROID__) && (__ANDROID_API__ >= 24)` is clearer, and groups aren't particularly meaningful on android anyway, so probably no-one cares in the meantime?) https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ brad0 wrote: > (getgrgid() has been around forever, though, so if anyone cared they could > reduce the scope of this. but probably just `#if defined(__ANDROID__) && > (__ANDROID_API__ >= 24)` is clearer, and groups aren't particularly > meaningful on android anyway, so probably no-one cares in the meantime?) I guess I was wondering if with another diff it would make sense to check the Android API or a comment making it clear when it would make sense to remove. Either way.. https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
https://github.com/enh-google approved this pull request. https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ enh-google wrote: fwiw, you shouldn't need this with any current NDK (and current NDKs support API >= 21). looks like i added this in 2015 to support building gdb/gdbserver out of the box and didn't realize lldb was carrying a workaround: https://android-review.googlesource.com/c/platform/bionic/+/155038 https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add missing operations to GetOpcodeDataSize (PR #120163)
https://github.com/adrian-prantl edited https://github.com/llvm/llvm-project/pull/120163 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add missing operations to GetOpcodeDataSize (PR #120163)
https://github.com/adrian-prantl commented: I found one bug, otherwise this looks good! https://github.com/llvm/llvm-project/pull/120163 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add missing operations to GetOpcodeDataSize (PR #120163)
@@ -327,27 +358,45 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, return offset - data_offset; } + case DW_OP_implicit_pointer: // 0xa0 4 + LEB128 + { +data.Skip_LEB128(&offset); +return 4 + offset - data_offset; adrian-prantl wrote: > The first operand is a 4-byte unsigned value in the 32-bit DWARF format, or > an 8-byte unsigned value in the 64-bit DWARF format https://github.com/llvm/llvm-project/pull/120163 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ enh-google wrote: looking around, i see a few others that aren't true either: ``` #ifdef __ANDROID__ // Android does not have SUN_LEN #ifndef SUN_LEN #define SUN_LEN(ptr) \ (offsetof(struct sockaddr_un, sun_path) + strlen((ptr)->sun_path)) #endif #endif // #ifdef __ANDROID__ ``` or ``` #if defined(_WIN32) || defined(__ANDROID__) || defined(_AIX) // Defines from ar, missing on Windows ``` for example. please let us know any time you find yourself needing to add a workaround like this, so we can try to make it "just work". anything like ``` #ifdef __ANDROID__ #include #include #include #include #include #include #include #endif // __ANDROID__ ``` is exceptionally weird. any time you're having to include stuff from `https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
https://github.com/ZequanWu updated https://github.com/llvm/llvm-project/pull/124048 >From 1948805894e006d84fbb78299574b3c7618959d8 Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Wed, 22 Jan 2025 18:32:11 -0800 Subject: [PATCH 1/2] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. --- lldb/include/lldb/DataFormatters/FormatManager.h | 3 ++- lldb/source/DataFormatters/FormatManager.cpp | 10 ++ .../ptr_ref_typedef/TestPtrRef2Typedef.py| 12 .../data-formatter/ptr_ref_typedef/main.cpp | 3 +++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h index db2fe99c44cafc..9329ee930125a6 100644 --- a/lldb/include/lldb/DataFormatters/FormatManager.h +++ b/lldb/include/lldb/DataFormatters/FormatManager.h @@ -163,7 +163,7 @@ class FormatManager : public IFormatChangeListener { GetPossibleMatches(ValueObject &valobj, lldb::DynamicValueType use_dynamic) { FormattersMatchVector matches; GetPossibleMatches(valobj, valobj.GetCompilerType(), use_dynamic, matches, - FormattersMatchCandidate::Flags(), true); + FormattersMatchCandidate::Flags(), true, true); return matches; } @@ -180,6 +180,7 @@ class FormatManager : public IFormatChangeListener { lldb::DynamicValueType use_dynamic, FormattersMatchVector &entries, FormattersMatchCandidate::Flags current_flags, + bool dereference_ptr = true, bool root_level = false); std::atomic m_last_revision; diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 3b891cecb1c8b9..d6d6935f3e002c 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -174,7 +174,8 @@ void FormatManager::DisableAllCategories() { void FormatManager::GetPossibleMatches( ValueObject &valobj, CompilerType compiler_type, lldb::DynamicValueType use_dynamic, FormattersMatchVector &entries, -FormattersMatchCandidate::Flags current_flags, bool root_level) { +FormattersMatchCandidate::Flags current_flags, bool dereference_ptr, +bool root_level) { compiler_type = compiler_type.GetTypeForFormatters(); ConstString type_name(compiler_type.GetTypeName()); // A ValueObject that couldn't be made correctly won't necessarily have a @@ -222,14 +223,15 @@ void FormatManager::GetPossibleMatches( if (compiler_type.IsPointerType()) { CompilerType non_ptr_type = compiler_type.GetPointeeType(); -GetPossibleMatches(valobj, non_ptr_type, use_dynamic, entries, - current_flags.WithStrippedPointer()); +if (dereference_ptr) + GetPossibleMatches(valobj, non_ptr_type, use_dynamic, entries, +current_flags.WithStrippedPointer(), false); if (non_ptr_type.IsTypedefType()) { CompilerType deffed_pointed_type = non_ptr_type.GetTypedefedType().GetPointerType(); // this is not exactly the usual meaning of stripping typedefs GetPossibleMatches(valobj, deffed_pointed_type, use_dynamic, entries, - current_flags.WithStrippedTypedef()); + current_flags.WithStrippedTypedef(), dereference_ptr); } } diff --git a/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py b/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py index f70162bf285839..fea40252a2a75c 100644 --- a/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py +++ b/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py @@ -53,3 +53,15 @@ def cleanup(): # the match. self.expect("frame variable y", substrs=["(Foo &", ") y = 0x", "IntLRef"]) self.expect("frame variable z", substrs=["(Foo &&", ") z = 0x", "IntRRef"]) + +# Test lldb doesn't dereference pointer more than once. +# xp has type Foo**, so it can only uses summary for Foo* or int*, not +# summary for Foo or int. +self.expect("frame variable xp", substrs=["(Foo **) xp = 0x", "IntPointer"]) + +self.runCmd('type summary delete "int *"') +self.runCmd('type summary add --cascade true -s "MyInt" "int"') +self.expect("frame variable xp", substrs=["(Foo **) xp = 0x"]) + +self.runCmd('type summary add --cascade true -s "FooPointer" "Foo *"') +self.expect("frame variable xp", substrs=["(Foo **) xp = 0x", "FooPointer"]) diff --git a/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/main.cpp b/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/mai
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
@@ -222,14 +223,15 @@ void FormatManager::GetPossibleMatches( if (compiler_type.IsPointerType()) { CompilerType non_ptr_type = compiler_type.GetPointeeType(); -GetPossibleMatches(valobj, non_ptr_type, use_dynamic, entries, - current_flags.WithStrippedPointer()); +if (dereference_ptr) + GetPossibleMatches(valobj, non_ptr_type, use_dynamic, entries, +current_flags.WithStrippedPointer(), false); ZequanWu wrote: It's unnecessary. Removed. https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support riscv32 corefiles (PR #115408)
JDevlieghere wrote: I'm in an awkward position where I'm not able to share the riscv32 core files I've been testing this against. @ita-sc & @AlexeyMerzlyakov, I know you two have worked on riscv64, is there any chance you could help me generate a riscv32 core file I can use to write a test for this? https://github.com/llvm/llvm-project/pull/115408 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add missing operations to GetOpcodeDataSize (PR #120163)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/120163 >From 21c9bbb7edab88caeb1b121dfe9090a6a3ef4404 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 22 Jan 2025 17:36:24 -0800 Subject: [PATCH 1/2] [lldb] Add missing operations to GetOpcodeDataSize The improved error reporting in #120162 revealed that we were missing opcodes in GetOpcodeDataSize. I changed the function to remove the default case and switch over the enum type which will cause the compiler to emit a warning if there are unhandled operations in the future. rdar://139705570 --- lldb/source/Expression/DWARFExpression.cpp | 75 ++ 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 1d826e341e2c44..072cc74bbaafea 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -132,10 +132,35 @@ static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx, /// are made on the state of \p data after this call. static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, const lldb::offset_t data_offset, -const uint8_t op, +const LocationAtom op, const DWARFUnit *dwarf_cu) { lldb::offset_t offset = data_offset; switch (op) { + // Only used in LLVM metadata. + case DW_OP_LLVM_fragment: + case DW_OP_LLVM_convert: + case DW_OP_LLVM_tag_offset: + case DW_OP_LLVM_entry_value: + case DW_OP_LLVM_implicit_pointer: + case DW_OP_LLVM_arg: + case DW_OP_LLVM_extract_bits_sext: + case DW_OP_LLVM_extract_bits_zext: +break; + // Vendor extensions: + case DW_OP_HP_is_value: + case DW_OP_HP_fltconst4: + case DW_OP_HP_fltconst8: + case DW_OP_HP_mod_range: + case DW_OP_HP_unmod_range: + case DW_OP_HP_tls: + case DW_OP_INTEL_bit_piece: + case DW_OP_WASM_location: + case DW_OP_WASM_location_int: + case DW_OP_APPLE_uninit: + case DW_OP_PGI_omp_thread_num: + case DW_OP_hi_user: +break; + case DW_OP_addr: case DW_OP_call_ref: // 0x9a 1 address sized offset of DIE (DWARF3) return data.GetAddressByteSize(); @@ -246,6 +271,7 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, case DW_OP_pick:// 0x15 1 1-byte stack index case DW_OP_deref_size: // 0x94 1 1-byte size of data retrieved case DW_OP_xderef_size: // 0x95 1 1-byte size of data retrieved + case DW_OP_deref_type: // 0xa6 1 1-byte constant return 1; // Opcodes with a single 2 byte arguments @@ -268,7 +294,6 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, return 8; // All opcodes that have a single ULEB (signed or unsigned) argument - case DW_OP_addrx: // 0xa1 1 ULEB128 index case DW_OP_constu: // 0x10 1 ULEB128 constant case DW_OP_consts: // 0x11 1 SLEB128 constant case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend @@ -307,14 +332,20 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, case DW_OP_regx:// 0x90 1 ULEB128 register case DW_OP_fbreg: // 0x91 1 SLEB128 offset case DW_OP_piece: // 0x93 1 ULEB128 size of piece addressed + case DW_OP_convert: // 0xa8 1 ULEB128 offset + case DW_OP_reinterpret: // 0xa9 1 ULEB128 offset + case DW_OP_addrx: // 0xa1 1 ULEB128 index + case DW_OP_constx: // 0xa2 1 ULEB128 index + case DW_OP_xderef_type: // 0xa7 1 ULEB128 index case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index data.Skip_LEB128(&offset); return offset - data_offset; // All opcodes that have a 2 ULEB (signed or unsigned) arguments - case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset - case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3); + case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset + case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3); + case DW_OP_regval_type: // 0xa5 ULEB128 + ULEB128 data.Skip_LEB128(&offset); data.Skip_LEB128(&offset); return offset - data_offset; @@ -327,6 +358,12 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, return offset - data_offset; } + case DW_OP_implicit_pointer: // 0xa0 4 + LEB128 + { +data.Skip_LEB128(&offset); +return 4 + offset - data_offset; + } + case DW_OP_GNU_entry_value: case DW_OP_entry_value: // 0xa3 ULEB128 size + variable-length block { @@ -334,20 +371,32 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, return (offset - data_offset) + subexpr_len; } - default: -if (!dwarf_cu) { - return LLDB_INVALID_OFFSET; -} + case DW_O
[Lldb-commits] [lldb] [lldb] Add SBThread.selected_frame property (PR #123981)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/123981 >From 3929895879a226bf8f0e407fead4524597a429af Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 22 Jan 2025 08:18:36 -0800 Subject: [PATCH 1/3] [lldb] Add SBThread.selected_frame property --- lldb/bindings/interface/SBThreadExtensions.i | 7 +++ .../commands/frame/recognizer/TestFrameRecognizer.py | 8 +++- .../location-list-lookup/TestLocationListLookup.py| 4 ++-- .../TestStdFunctionRecognizer.py | 11 --- lldb/test/API/lang/objc/print-obj/TestPrintObj.py | 9 +++-- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lldb/bindings/interface/SBThreadExtensions.i b/lldb/bindings/interface/SBThreadExtensions.i index 860a2d765a6695..926e5b1623c407 100644 --- a/lldb/bindings/interface/SBThreadExtensions.i +++ b/lldb/bindings/interface/SBThreadExtensions.i @@ -51,6 +51,12 @@ STRING_EXTENSION_OUTSIDE(SBThread) for idx in range(self.GetStopReasonDataCount()) ] +def set_selected_frame(self, frame): +if isinstance(frame, SBFrame): +self.SetSelectedFrame(frame.idx) +else: +self.SetSelectedFrame(frame) + id = property(GetThreadID, None, doc='''A read only property that returns the thread ID as an integer.''') idx = property(GetIndexID, None, doc='''A read only property that returns the thread index ID as an integer. Thread index ID values start at 1 and increment as threads come and go and can be used to uniquely identify threads.''') return_value = property(GetStopReturnValue, None, doc='''A read only property that returns an lldb object that represents the return value from the last stop (lldb.SBValue) if we just stopped due to stepping out of a function.''') @@ -65,6 +71,7 @@ STRING_EXTENSION_OUTSIDE(SBThread) stop_reason_data = property(get_stop_reason_data, None, doc='''A read only property that returns the stop reason data as a list.''') is_suspended = property(IsSuspended, None, doc='''A read only property that returns a boolean value that indicates if this thread is suspended.''') is_stopped = property(IsStopped, None, doc='''A read only property that returns a boolean value that indicates if this thread is stopped but not exited.''') +selected_frame = property(GetSelectedFrame, set_selected_frame, doc='''A read/write property that gets and sets the selected frame of this SBThread.''') %} #endif } diff --git a/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py b/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py index aa2a448087431e..3e9dbfe6d85552 100644 --- a/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py +++ b/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py @@ -20,7 +20,7 @@ def test_frame_recognizer_1(self): target, process, thread, _ = lldbutil.run_to_name_breakpoint( self, "foo", exe_name=exe ) -frame = thread.GetSelectedFrame() +frame = thread.selected_frame # Clear internal & plugins recognizers that get initialized at launch self.runCmd("frame recognizer clear") @@ -166,7 +166,7 @@ def test_frame_recognizer_hiding(self): self.build() target, process, thread, _ = lldbutil.run_to_name_breakpoint(self, "nested") -frame = thread.GetSelectedFrame() +frame = thread.selected_frame # Sanity check. self.expect( @@ -229,7 +229,6 @@ def test_frame_recognizer_multi_symbol(self): target, process, thread, _ = lldbutil.run_to_name_breakpoint( self, "foo", exe_name=exe ) -frame = thread.GetSelectedFrame() self.expect( "frame recognizer info 0", @@ -239,7 +238,6 @@ def test_frame_recognizer_multi_symbol(self): target, process, thread, _ = lldbutil.run_to_name_breakpoint( self, "bar", exe_name=exe ) -frame = thread.GetSelectedFrame() self.expect( "frame recognizer info 0", @@ -374,7 +372,7 @@ def test_frame_recognizer_not_only_first_instruction(self): opts = lldb.SBVariablesOptions() opts.SetIncludeRecognizedArguments(True) -frame = thread.GetSelectedFrame() +frame = thread.selected_frame variables = frame.GetVariables(opts) self.assertEqual(variables.GetSize(), 2) diff --git a/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py b/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py index 84033daff77308..a97f4fc5e3d799 100644 --- a/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py +++ b/lldb/test/API/functionalities/location-list-lookup/TestLocationListLookup.py @@ -25,7 +25,7 @@ def check_local_vars(self, process: lldb.SBProcess, check_e
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
jimingham wrote: How does this patch fit with the: -p ( --skip-pointers ) Don't use this format for pointers-to-type objects. -r ( --skip-references ) Don't use this format for references-to-type objects. settings in `type add`? It seems like we let the formatters control whether they should also apply to pointers and references to those types. Shouldn't that be what controls whether formatters also apply to pointers? And if a formatter says it can handle pointers, it's up to the formatter to do that right. https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SymbolContext::GetAddress (PR #123340)
@@ -370,6 +370,31 @@ bool SymbolContext::GetAddressRange(uint32_t scope, uint32_t range_idx, return false; } +Address SymbolContext::GetAddress(uint32_t scope, + bool use_inline_block_range) const { + if ((scope & eSymbolContextLineEntry) && line_entry.IsValid()) +return line_entry.range.GetBaseAddress(); + + if (scope & eSymbolContextBlock) { +Block *block_to_use = (block && use_inline_block_range) + ? block->GetContainingInlinedBlock() + : block; +if (block_to_use) { + Address addr; + block_to_use->GetStartAddress(addr); + return addr; +} + } jimingham wrote: I'm kind of leaning towards `GetFunctionOrSymbolAddress`, only doing what clearly makes sense seems best. I also can't think of a better name. https://github.com/llvm/llvm-project/pull/123340 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBThread.selected_frame property (PR #123981)
@@ -51,6 +51,12 @@ STRING_EXTENSION_OUTSIDE(SBThread) for idx in range(self.GetStopReasonDataCount()) ] +def set_selected_frame(self, frame): +if isinstance(frame, SBFrame): +self.SetSelectedFrame(frame.idx) kastiglione wrote: I've updated this helper method to check the `SBFrame` argument value belongs to the target instance of `SBThread`. If it doesn't, a `ValueError` is raised. Does that work for you @jimingham? https://github.com/llvm/llvm-project/pull/123981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBThread.selected_frame property (PR #123981)
@@ -51,6 +51,12 @@ STRING_EXTENSION_OUTSIDE(SBThread) for idx in range(self.GetStopReasonDataCount()) ] +def set_selected_frame(self, frame): +if isinstance(frame, SBFrame): +self.SetSelectedFrame(frame.idx) jimingham wrote: SetSelectedFrame returns the index of the selected frame. It should check the thread and if it doesn't match, return LLDB_INVALID_FRAME_ID. https://github.com/llvm/llvm-project/pull/123981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBThread.selected_frame property (PR #123981)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/123981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
enh-google wrote: > I guess this means the whole "single step workaround" > (lldb/source/Plugins/Process/Linux/SingleStepCheck.h) could go away as well > (maybe make a separate patch for that). from that file: ``` // The underlying issue has been fixed in android N and linux 4.4. This code can // be removed once these systems become obsolete. ``` i don't know what lldb's deprecation policy is (or Android Studio's, as "deliverers of the lldb"), but the _ndk_ at least still supports api >= 21, so if you're only asking me, technically i'd not consider that dead code (even if i am very skeptical that there are many developers still debugging on old devices/OS releases --- my anecdata is that most debugging happens on relatively current devices, even if _end users_ are still running apps on much older kit). https://apilevels.com/ claims about 4% of end users are still on an old enough release to have this problem[1]. 1. though tbh, i have questions about the "fixed in android N and linux 4.4" --- is there a _workaround_ in android n? because if it's actually only fixed in linux 4.4, and android n was the first release to have used a >= 4.4 kernel, it's definitely possible that there are devices out there running significantly more recent versions of android but still on an old kernel. afaik we didn't really have any requirements prior to the versions shown in https://source.android.com/docs/core/architecture/kernel/android-common#compatibility-matrix --- i think prior to those dates it was basically a free for all. https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBThread.selected_frame property (PR #123981)
jimingham wrote: I still think callers shouldn't have to do this, but to make the internal API good you'd really have to return a Status, so this is okay for now. https://github.com/llvm/llvm-project/pull/123981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/121860 >From b0cf540a08958ead1c7b9e38f30a2722fe780592 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 17 Jan 2025 17:10:36 -0800 Subject: [PATCH 1/3] [lldb] Implement a statusline in LLDB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a statusline to command-line LLDB to display progress events and other information related to the current state of the debugger. The statusline is a dedicated area displayed the bottom of the screen. The contents of the status line are configurable through a setting consisting of LLDB’s format strings. The statusline is configurable through the `statusline-format` setting. The default configuration shows the target name, the current file, the stop reason and the current progress event. ``` (lldb) settings show statusline-format statusline-format (format-string) = "${ansi.bg.cyan}${ansi.fg.black}{${target.file.basename}}{ | ${line.file.basename}:${line.number}:${line.column}}{ | ${thread.stop-reason}}{ | {${progress.count} }${progress.message}}" ``` The statusline is enabled by default, but can be disabled with the following setting: ``` (lldb) settings set show-statusline false ``` The statusline supersedes the current progress reporting implementation. Consequently, the following settings no longer have any effect (but continue to exist): ``` show-progress -- Whether to show progress or not if the debugger's output is an interactive color-enabled terminal. show-progress-ansi-prefix -- When displaying progress in a color-enabled terminal, use the ANSI terminal code specified in this format immediately before the progress message. show-progress-ansi-suffix -- When displaying progress in a color-enabled terminal, use the ANSI terminal code specified in this format immediately after the progress message. ``` RFC: https://discourse.llvm.org/t/rfc-lldb-statusline/83948 --- lldb/include/lldb/Core/Debugger.h| 21 ++- lldb/include/lldb/Core/FormatEntity.h| 4 +- lldb/include/lldb/Core/Statusline.h | 63 + lldb/include/lldb/Utility/AnsiTerminal.h | 1 + lldb/source/Core/CMakeLists.txt | 1 + lldb/source/Core/CoreProperties.td | 8 ++ lldb/source/Core/Debugger.cpp| 148 ++-- lldb/source/Core/FormatEntity.cpp| 46 ++- lldb/source/Core/Statusline.cpp | 165 +++ 9 files changed, 373 insertions(+), 84 deletions(-) create mode 100644 lldb/include/lldb/Core/Statusline.h create mode 100644 lldb/source/Core/Statusline.cpp diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 70f4c4216221c6..a4da5fd44c17fe 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -19,6 +19,7 @@ #include "lldb/Core/FormatEntity.h" #include "lldb/Core/IOHandler.h" #include "lldb/Core/SourceManager.h" +#include "lldb/Core/Statusline.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/StreamFile.h" @@ -308,6 +309,10 @@ class Debugger : public std::enable_shared_from_this, bool SetShowProgress(bool show_progress); + bool GetShowStatusline() const; + + const FormatEntity::Entry *GetStatuslineFormat() const; + llvm::StringRef GetShowProgressAnsiPrefix() const; llvm::StringRef GetShowProgressAnsiSuffix() const; @@ -604,6 +609,14 @@ class Debugger : public std::enable_shared_from_this, return m_source_file_cache; } + struct ProgressReport { +uint64_t id; +uint64_t completed; +uint64_t total; +std::string message; + }; + std::optional GetCurrentProgressReport() const; + protected: friend class CommandInterpreter; friend class REPL; @@ -728,7 +741,7 @@ class Debugger : public std::enable_shared_from_this, IOHandlerStack m_io_handler_stack; std::recursive_mutex m_io_handler_synchronous_mutex; - std::optional m_current_event_id; + std::optional m_statusline; llvm::StringMap> m_stream_handlers; std::shared_ptr m_callback_handler_sp; @@ -745,6 +758,12 @@ class Debugger : public std::enable_shared_from_this, lldb::TargetSP m_dummy_target_sp; Diagnostics::CallbackID m_diagnostics_callback_id; + /// Bookkeeping for command line progress events. + /// @{ + llvm::SmallVector m_progress_reports; + mutable std::mutex m_progress_reports_mutex; + /// @} + std::mutex m_destroy_callback_mutex; lldb::callback_token_t m_destroy_callback_next_token = 0; struct DestroyCallbackInfo { diff --git a/lldb/include/lldb/Core/FormatEntity.h b/lldb/include/lldb/Core/FormatEntity.h index c9d5af1f31673b..51e9ce37e54e79 100644 --- a/lldb/include/lldb/Core/FormatEntity.h +++ b/lldb/include/lldb/Core/FormatEntity.h @@ -100,7 +100,9 @@ struct Entry { LineEntryColumn, LineEntryStartAddress, LineEntryEndAddress, -CurrentPCArrow
[Lldb-commits] [lldb] [lldb] Remove support and workarounds for Android 4 and older (PR #124047)
@@ -25,13 +25,10 @@ #include #ifdef __ANDROID__ brad0 wrote: Ok, I will circle back with another set of diffs to clean up some of these other things too. Thanks. https://github.com/llvm/llvm-project/pull/124047 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ff17a41 - [lldb] Remove support and workarounds for Android 4 and older (#124047)
Author: Brad Smith Date: 2025-01-23T12:54:35-05:00 New Revision: ff17a4136dedba004d901a571c4fae501affd051 URL: https://github.com/llvm/llvm-project/commit/ff17a4136dedba004d901a571c4fae501affd051 DIFF: https://github.com/llvm/llvm-project/commit/ff17a4136dedba004d901a571c4fae501affd051.diff LOG: [lldb] Remove support and workarounds for Android 4 and older (#124047) Added: Modified: lldb/cmake/modules/LLDBConfig.cmake lldb/include/lldb/Host/Time.h lldb/source/Host/CMakeLists.txt lldb/source/Host/common/Socket.cpp lldb/source/Host/posix/HostInfoPosix.cpp lldb/source/Host/posix/ProcessLauncherPosixFork.cpp Removed: lldb/source/Host/android/LibcGlue.cpp diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake index 9bb37f5967d4f3..747f7e6038181c 100644 --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -306,9 +306,4 @@ else() set(LLDB_CAN_USE_DEBUGSERVER OFF) endif() -if ((CMAKE_SYSTEM_NAME MATCHES "Android") AND LLVM_BUILD_STATIC AND -((ANDROID_ABI MATCHES "armeabi") OR (ANDROID_ABI MATCHES "mips"))) - add_definitions(-DANDROID_USE_ACCEPT_WORKAROUND) -endif() - include(LLDBGenerateConfig) diff --git a/lldb/include/lldb/Host/Time.h b/lldb/include/lldb/Host/Time.h index aee4c43247c5a3..2ca5a4026884b7 100644 --- a/lldb/include/lldb/Host/Time.h +++ b/lldb/include/lldb/Host/Time.h @@ -11,15 +11,6 @@ #ifndef LLDB_HOST_TIME_H #define LLDB_HOST_TIME_H -#ifdef __ANDROID__ -#include -#endif - -#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 -#include -extern time_t timegm(struct tm *t); -#else #include -#endif #endif // LLDB_HOST_TIME_H diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt index e0cd8569bf9575..cdfb6184f2219e 100644 --- a/lldb/source/Host/CMakeLists.txt +++ b/lldb/source/Host/CMakeLists.txt @@ -113,7 +113,6 @@ else() if (CMAKE_SYSTEM_NAME MATCHES "Android") add_host_subdirectory(android android/HostInfoAndroid.cpp -android/LibcGlue.cpp ) endif() elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") diff --git a/lldb/source/Host/android/LibcGlue.cpp b/lldb/source/Host/android/LibcGlue.cpp deleted file mode 100644 index 877d735823feee..00 --- a/lldb/source/Host/android/LibcGlue.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===-- LibcGlue.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 -// -//===--===// - -// This files adds functions missing from libc on earlier versions of Android - -#include - -#include - -#if __ANDROID_API__ < 21 - -#include -#include -#include -#include - -#include "lldb/Host/Time.h" - -time_t timegm(struct tm *t) { return (time_t)timegm64(t); } - -int posix_openpt(int flags) { return open("/dev/ptmx", flags); } - -#endif diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 0ccff41a552068..296c2273ba419c 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -472,23 +472,7 @@ Status Socket::Accept(const Timeout &timeout, Socket *&socket) { NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, Status &error) { error.Clear(); -#if defined(ANDROID_USE_ACCEPT_WORKAROUND) - // Hack: - // This enables static linking lldb-server to an API 21 libc, but still - // having it run on older devices. It is necessary because API 21 libc's - // implementation of accept() uses the accept4 syscall(), which is not - // available in older kernels. Using an older libc would fix this issue, but - // introduce other ones, as the old libraries were quite buggy. - int fd = syscall(__NR_accept, sockfd, addr, addrlen); - if (fd >= 0) { -int flags = ::fcntl(fd, F_GETFD); -if (flags != -1 && ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) != -1) - return fd; -SetLastError(error); -close(fd); - } - return fd; -#elif defined(SOCK_CLOEXEC) && defined(HAVE_ACCEPT4) +#if defined(SOCK_CLOEXEC) && defined(HAVE_ACCEPT4) int flags = SOCK_CLOEXEC; NativeSocket fd = llvm::sys::RetryAfterSignal( static_cast(-1), ::accept4, sockfd, addr, addrlen, flags); diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp index 193f584900b632..23ba3177de317a 100644 --- a/lldb/source/Host/posix/HostInfoPosix.cpp +++ b/lldb/source/Host/posix/HostInfoPosix.cpp @@ -86,13 +86,6 @@ std::optional HostInfoPosix::GetOSBuildString() { return std::string(un.release); } -#ifdef __ANDROID__ -#include -#endif -#if def
[Lldb-commits] [lldb] [lldb] Avoid repeated map lookups (NFC) (PR #124077)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/124077 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d050083 - [lldb] Avoid repeated map lookups (NFC) (#124077)
Author: Kazu Hirata Date: 2025-01-23T08:45:59-08:00 New Revision: d05008363d4ed87b1350701831032ea5070d5b98 URL: https://github.com/llvm/llvm-project/commit/d05008363d4ed87b1350701831032ea5070d5b98 DIFF: https://github.com/llvm/llvm-project/commit/d05008363d4ed87b1350701831032ea5070d5b98.diff LOG: [lldb] Avoid repeated map lookups (NFC) (#124077) Added: Modified: lldb/source/Target/DynamicRegisterInfo.cpp Removed: diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp b/lldb/source/Target/DynamicRegisterInfo.cpp index 1a817449fa9589..9ad98a41c688c8 100644 --- a/lldb/source/Target/DynamicRegisterInfo.cpp +++ b/lldb/source/Target/DynamicRegisterInfo.cpp @@ -460,8 +460,8 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) { // Now update all value_regs with each register info as needed const size_t num_regs = m_regs.size(); for (size_t i = 0; i < num_regs; ++i) { -if (m_value_regs_map.find(i) != m_value_regs_map.end()) - m_regs[i].value_regs = m_value_regs_map[i].data(); +if (auto it = m_value_regs_map.find(i); it != m_value_regs_map.end()) + m_regs[i].value_regs = it->second.data(); else m_regs[i].value_regs = nullptr; } @@ -509,8 +509,9 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) { // Now update all invalidate_regs with each register info as needed for (size_t i = 0; i < num_regs; ++i) { -if (m_invalidate_regs_map.find(i) != m_invalidate_regs_map.end()) - m_regs[i].invalidate_regs = m_invalidate_regs_map[i].data(); +if (auto it = m_invalidate_regs_map.find(i); +it != m_invalidate_regs_map.end()) + m_regs[i].invalidate_regs = it->second.data(); else m_regs[i].invalidate_regs = nullptr; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBThread.selected_frame property (PR #123981)
@@ -51,6 +51,12 @@ STRING_EXTENSION_OUTSIDE(SBThread) for idx in range(self.GetStopReasonDataCount()) ] +def set_selected_frame(self, frame): +if isinstance(frame, SBFrame): +self.SetSelectedFrame(frame.idx) jimingham wrote: Callers shouldn't have to do that; StackFrames know their Threads, so SetSelectedFrame should really reject this (though in that case it ought to also return an error.) https://github.com/llvm/llvm-project/pull/123981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBThread.selected_frame property (PR #123981)
@@ -51,6 +51,12 @@ STRING_EXTENSION_OUTSIDE(SBThread) for idx in range(self.GetStopReasonDataCount()) ] +def set_selected_frame(self, frame): +if isinstance(frame, SBFrame): +self.SetSelectedFrame(frame.idx) kastiglione wrote: good call, done. https://github.com/llvm/llvm-project/pull/123981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBThread.selected_frame property (PR #123981)
@@ -51,6 +51,12 @@ STRING_EXTENSION_OUTSIDE(SBThread) for idx in range(self.GetStopReasonDataCount()) ] +def set_selected_frame(self, frame): +if isinstance(frame, SBFrame): +self.SetSelectedFrame(frame.idx) kastiglione wrote: oh my reply was to @labath, before I saw @jimingham's comments. https://github.com/llvm/llvm-project/pull/123981 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Handle improperly nested blocks differently (PR #117725)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/117725 >From db818448c238fe85f9bd3f322b620a4f4e171967 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 26 Nov 2024 16:12:40 +0100 Subject: [PATCH] [lldb] Handle improperly nested blocks differently In 6c7f56192fa6e689ef14d32e43a785de5692e9c0 (Sep 2011) we added code to extend the range of the parent block if the child block is not contained within it. Currently, this code doesn't work for (at least) two reasons: - we don't re-sort the ranges of the parent block, which means that the lookup may not find the range we added (and possibly other ranges as well) - The main address lookup mechanism (SymbolFileDWARF::ResolveSymbolContext(Address)) performs the lookup using DWARF DIE information, which doesn't contain this extra range. The motivation for the change was bad compiler output. The commit message does not go into details, so it's hard to say if this has been fixed, but given that was 13 years ago, I think we can assume that to be the case. In fact, as far as I can tell (I haven't tried building an lldb this old) this code stopped working in ea3e7d5ccf4f00741e4b106978bd8dab5cece3a1 (~two weeks later), when we added the requirement for the ranges to be sorted. Given that this isn't working, and that not changing the ranges of other blocks has other nice properties (the ranges can be immutable after construction), I'm removing the parent range changing code. I'm adding a test case that makes sure we don't do something egregious (e.g., crash) in this case. Having a child block not be a subset of the parent block doesn't seem to cause problems now, but if that ever turns out to be an issue, we can always intersect the child range with that of the parent. I'm also upgrading this message to a proper warning so we can see if this ever occurs in practice, and simplifying it so it doesn't get in the way of understanding the function. --- lldb/source/Symbol/Block.cpp | 37 +-- .../DWARF/x86/improperly_nested_blocks.s | 100 ++ 2 files changed, 105 insertions(+), 32 deletions(-) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/improperly_nested_blocks.s diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp index 139fa06d08fca5..f093e4f6182f46 100644 --- a/lldb/source/Symbol/Block.cpp +++ b/lldb/source/Symbol/Block.cpp @@ -344,38 +344,11 @@ void Block::FinalizeRanges() { void Block::AddRange(const Range &range) { Block *parent_block = GetParent(); if (parent_block && !parent_block->Contains(range)) { -Log *log = GetLog(LLDBLog::Symbols); -if (log) { - ModuleSP module_sp(m_parent_scope.CalculateSymbolContextModule()); - Function *function = m_parent_scope.CalculateSymbolContextFunction(); - const addr_t function_file_addr = function->GetAddress().GetFileAddress(); - const addr_t block_start_addr = function_file_addr + range.GetRangeBase(); - const addr_t block_end_addr = function_file_addr + range.GetRangeEnd(); - Type *func_type = function->GetType(); - - const Declaration &func_decl = func_type->GetDeclaration(); - if (func_decl.GetLine()) { -LLDB_LOGF(log, - "warning: %s:%u block {0x%8.8" PRIx64 - "} has range[%u] [0x%" PRIx64 " - 0x%" PRIx64 - ") which is not contained in parent block {0x%8.8" PRIx64 - "} in function {0x%8.8" PRIx64 "} from %s", - func_decl.GetFile().GetPath().c_str(), func_decl.GetLine(), - GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr, - block_end_addr, parent_block->GetID(), function->GetID(), - module_sp->GetFileSpec().GetPath().c_str()); - } else { -LLDB_LOGF(log, - "warning: block {0x%8.8" PRIx64 "} has range[%u] [0x%" PRIx64 - " - 0x%" PRIx64 - ") which is not contained in parent block {0x%8.8" PRIx64 - "} in function {0x%8.8" PRIx64 "} from %s", - GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr, - block_end_addr, parent_block->GetID(), function->GetID(), - module_sp->GetFileSpec().GetPath().c_str()); - } -} -parent_block->AddRange(range); +m_parent_scope.CalculateSymbolContextModule()->ReportWarning( +"block {0:x} has a range [{1:x}, {2:x}) which is not contained in the " +"parent block {3:x}", +GetID(), range.GetRangeBase(), range.GetRangeEnd(), +parent_block->GetID()); } m_ranges.Append(range); } diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/improperly_nested_blocks.s b/lldb/test/Shell/SymbolFile/DWARF/x86/improperly_nested_blocks.s new file mode 100644 index 00..af744385993f28 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/x86/improperly_nested_blocks.s @@ -0,0 +1,100 @@ +## This test checks tha
[Lldb-commits] [lldb] [lldb] Handle improperly nested blocks differently (PR #117725)
labath wrote: ping :) https://github.com/llvm/llvm-project/pull/117725 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove more workrounds for Android that have been fixed upstream (PR #124176)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/124176 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e289cb5 - [lldb] Remove more workrounds for Android that have been fixed upstream (#124176)
Author: Brad Smith Date: 2025-01-24T02:54:54-05:00 New Revision: e289cb545adabd8f7b72c0c4a023dcf640823767 URL: https://github.com/llvm/llvm-project/commit/e289cb545adabd8f7b72c0c4a023dcf640823767 DIFF: https://github.com/llvm/llvm-project/commit/e289cb545adabd8f7b72c0c4a023dcf640823767.diff LOG: [lldb] Remove more workrounds for Android that have been fixed upstream (#124176) Issues that were fixed 10+ years ago with Bionic libc. Added: Modified: lldb/source/Host/posix/DomainSocket.cpp lldb/source/Host/posix/ProcessLauncherPosixFork.cpp lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Removed: diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp index be8fcdf2c8f2c8..6c490cdda47ed7 100644 --- a/lldb/source/Host/posix/DomainSocket.cpp +++ b/lldb/source/Host/posix/DomainSocket.cpp @@ -20,14 +20,6 @@ using namespace lldb; using namespace lldb_private; -#ifdef __ANDROID__ -// Android does not have SUN_LEN -#ifndef SUN_LEN -#define SUN_LEN(ptr) \ - (offsetof(struct sockaddr_un, sun_path) + strlen((ptr)->sun_path)) -#endif -#endif // #ifdef __ANDROID__ - static const int kDomain = AF_UNIX; static const int kType = SOCK_STREAM; diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp index 22bf698c71716e..7d856954684c49 100644 --- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -24,10 +24,6 @@ #include #include -#ifdef __ANDROID__ -#define PT_TRACE_ME PTRACE_TRACEME -#endif - #if defined(__linux__) #include #endif diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index b202898ff438a6..6e5617664f7feb 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -8,7 +8,7 @@ #include "ObjectContainerBSDArchive.h" -#if defined(_WIN32) || defined(__ANDROID__) || defined(_AIX) +#if defined(_WIN32) || defined(_AIX) // Defines from ar, missing on Windows #define SARMAG 8 #define ARFMAG "`\n" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove more workrounds for Android that have been fixed upstream (PR #124176)
https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/124176 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add Lexer (with tests) for DIL (Data Inspection Language). (PR #123521)
@@ -0,0 +1,156 @@ +//===-- DILLexer.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_VALUEOBJECT_DILLEXER_H_ +#define LLDB_VALUEOBJECT_DILLEXER_H_ + +#include "llvm/ADT/StringRef.h" +#include +#include +#include +#include +#include + +namespace lldb_private { + +namespace dil { + +enum class TokenKind { + coloncolon, + eof, + identifier, + invalid, + kw_namespace, + l_paren, + none, + r_paren, + unknown, +}; + +/// Class defining the tokens generated by the DIL lexer and used by the +/// DIL parser. +class DILToken { +public: + DILToken(dil::TokenKind kind, std::string spelling, uint32_t start) + : m_kind(kind), m_spelling(spelling), m_start_pos(start) {} + + DILToken() : m_kind(dil::TokenKind::none), m_spelling(""), m_start_pos(0) {} + + void setKind(dil::TokenKind kind) { m_kind = kind; } + dil::TokenKind getKind() const { return m_kind; } + + std::string getSpelling() const { return m_spelling; } + + uint32_t getLength() const { return m_spelling.size(); } + + bool is(dil::TokenKind kind) const { return m_kind == kind; } + + bool isNot(dil::TokenKind kind) const { return m_kind != kind; } + + bool isOneOf(dil::TokenKind kind1, dil::TokenKind kind2) const { +return is(kind1) || is(kind2); + } + + template bool isOneOf(dil::TokenKind kind, Ts... Ks) const { +return is(kind) || isOneOf(Ks...); + } + + uint32_t getLocation() const { return m_start_pos; } + + void setValues(dil::TokenKind kind, std::string spelling, uint32_t start) { +m_kind = kind; +m_spelling = spelling; +m_start_pos = start; + } + + static const std::string getTokenName(dil::TokenKind kind); + +private: + dil::TokenKind m_kind; + std::string m_spelling; + uint32_t m_start_pos; // within entire expression string +}; + +/// Class for doing the simple lexing required by DIL. +class DILLexer { +public: + DILLexer(llvm::StringRef dil_expr) : m_expr(dil_expr.str()) { +m_cur_pos = m_expr.begin(); +// Use UINT_MAX to indicate invalid/uninitialized value. +m_tokens_idx = UINT_MAX; + } + + bool Lex(DILToken &result, bool look_ahead = false); + + bool Is_Word(std::string::iterator start, uint32_t &length); + + uint32_t GetLocation() { return m_cur_pos - m_expr.begin(); } + + /// Update 'result' with the other paremeter values, create a + /// duplicate token, and push the duplicate token onto the vector of + /// lexed tokens. + void UpdateLexedTokens(DILToken &result, dil::TokenKind tok_kind, cmtice wrote: A few of them can be private (I'll take care of that). Many of them could be protected (mostly just called from the parser, which I can designate as a friend), except that if I make them protected then my unittest, which needs to access them, can't access them. I've been trying and trying to find a way to allow my unit tests access these methods when they're protected, but I can't seem to make it work. Do you know the magic secret for this? https://github.com/llvm/llvm-project/pull/123521 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Enable the use of dladdr() on Android (PR #124187)
https://github.com/enh-google approved this pull request. https://github.com/llvm/llvm-project/pull/124187 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
jimingham wrote: I still feel like we should offer options here. If I as a formatter writer are interested in handling all the pointer types of the type I've registered my formatter for, I should be allowed to do that. If I say, my formatter is valid for all the pointer types as well as the type I've registered for, but I only want to write the formatter to handle Values of the original type, we could offer to do the dereferencing for them, and then pass the formatter in. And of course, if you only want to be asked about values of the type you registered your formatter for, you can do that already. https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] WIP: Stop using replicated variable ids (PR #124232)
https://github.com/Anthony-Eid created https://github.com/llvm/llvm-project/pull/124232 Closes #119784 This is still a work in progress, but I've technically fixed the bug where lldb-dap would reuse variable IDs within the same stopped state. However, I found another bug that is still prohibiting the Zed dap client from working correctly with lldb-dap. Whenever there's a scope request, lldb-dap resets their variable list to only variables from that scope. So variable requests fail when `request.variable_reference_id` represents a variable from a different scope than `dap.variables` has been reset to. I would be happy to fix the second bug in this issue or open a new PR that addresses that. >From e741fc75ccb6e2a725b3b26dd4c503cdea6c5fbb Mon Sep 17 00:00:00 2001 From: Anthony Eid Date: Fri, 24 Jan 2025 00:43:39 -0500 Subject: [PATCH] Stop using replicated variable ids --- lldb/tools/lldb-dap/DAP.cpp | 28 --- lldb/tools/lldb-dap/DAP.h | 15 ++-- lldb/tools/lldb-dap/JSONUtils.cpp | 6 ++-- lldb/tools/lldb-dap/JSONUtils.h | 3 +- lldb/tools/lldb-dap/ProgressEvent.h | 5 +++ lldb/tools/lldb-dap/lldb-dap.cpp| 54 ++--- 6 files changed, 80 insertions(+), 31 deletions(-) diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index 35250d9eef608a..0836fbf9f32dd6 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -137,6 +138,15 @@ void DAP::PopulateExceptionBreakpoints() { }); } +std::optional DAP::ScopeKind(const int64_t variablesReference) { + auto iter = scope_kinds.find(variablesReference); + if (iter != scope_kinds.end()) { +return iter->second; + } + + return std::nullopt; +} + ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const std::string &filter) { // PopulateExceptionBreakpoints() is called after g_dap.debugger is created // in a request-initialize. @@ -476,12 +486,22 @@ lldb::SBFrame DAP::GetLLDBFrame(const llvm::json::Object &arguments) { llvm::json::Value DAP::CreateTopLevelScopes() { llvm::json::Array scopes; - scopes.emplace_back( - CreateScope("Locals", VARREF_LOCALS, variables.locals.GetSize(), false)); - scopes.emplace_back(CreateScope("Globals", VARREF_GLOBALS, + + scopes.emplace_back(CreateScope("Locals", variables.next_temporary_var_ref, + ScopeKind::Locals, variables.locals.GetSize(), + false)); + scope_kinds[variables.next_temporary_var_ref++] = ScopeKind::Locals; + + scopes.emplace_back(CreateScope("Globals", variables.next_temporary_var_ref, + ScopeKind::Globals, variables.globals.GetSize(), false)); - scopes.emplace_back(CreateScope("Registers", VARREF_REGS, + scope_kinds[variables.next_temporary_var_ref++] = ScopeKind::Globals; + + scopes.emplace_back(CreateScope("Registers", variables.next_temporary_var_ref, + ScopeKind::Registers, variables.registers.GetSize(), false)); + scope_kinds[variables.next_temporary_var_ref++] = ScopeKind::Registers; + return llvm::json::Value(std::move(scopes)); } diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h index ae496236f13369..68399e2e0410c7 100644 --- a/lldb/tools/lldb-dap/DAP.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "llvm/ADT/DenseMap.h" @@ -39,6 +40,7 @@ #include "InstructionBreakpoint.h" #include "ProgressEvent.h" #include "SourceBreakpoint.h" +#include "lldb/API/SBValueList.h" #define VARREF_LOCALS (int64_t)1 #define VARREF_GLOBALS (int64_t)2 @@ -86,6 +88,8 @@ struct Variables { int64_t next_temporary_var_ref{VARREF_FIRST_VAR_IDX}; int64_t next_permanent_var_ref{PermanentVariableStartIndex}; + std::set added_frames; + /// Variables that are alive in this stop state. /// Will be cleared when debuggee resumes. llvm::DenseMap referenced_variables; @@ -117,25 +121,27 @@ struct Variables { struct StartDebuggingRequestHandler : public lldb::SBCommandPluginInterface { DAP &dap; - explicit StartDebuggingRequestHandler(DAP &d) : dap(d) {}; + explicit StartDebuggingRequestHandler(DAP &d) : dap(d){}; bool DoExecute(lldb::SBDebugger debugger, char **command, lldb::SBCommandReturnObject &result) override; }; struct ReplModeRequestHandler : public lldb::SBCommandPluginInterface { DAP &dap; - explicit ReplModeRequestHandler(DAP &d) : dap(d) {}; + explicit ReplModeRequestHandler(DAP &d) : dap(d){}; bool DoExecute(lldb::SBDebugger debugger, char **command, lldb::SBCommandReturnObject &result) override; }; struct SendEventRequestHandler : public lldb::SBCommandPluginInterface { DAP &dap; - explicit SendEventRequestHandler(DAP
[Lldb-commits] [lldb] [lldb] Enable the use of dladdr() on Android (PR #124187)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Brad Smith (brad0) Changes dladdr() was introduced 15 years ago. --- Full diff: https://github.com/llvm/llvm-project/pull/124187.diff 1 Files Affected: - (modified) lldb/source/Host/common/Host.cpp (-2) ``diff diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 7b2bae74e196fe..fdb623667bc251 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -352,7 +352,6 @@ bool Host::ResolveExecutableInBundle(FileSpec &file) { return false; } FileSpec Host::GetModuleFileSpecForHostAddress(const void *host_addr) { FileSpec module_filespec; -#if !defined(__ANDROID__) Dl_info info; if (::dladdr(host_addr, &info)) { if (info.dli_fname) { @@ -360,7 +359,6 @@ FileSpec Host::GetModuleFileSpecForHostAddress(const void *host_addr) { FileSystem::Instance().Resolve(module_filespec); } } -#endif return module_filespec; } `` https://github.com/llvm/llvm-project/pull/124187 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
jimingham wrote: It still sounds like this is a change to accommodate formatters that aren't correctly written. Regex formatters are slower than name match ones and more fallible to write, so I'm not sure "you can write a regex instead" is a good substitute. https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Do not recursively dereference pointer type when creating formatter candicates list. (PR #124048)
jimingham wrote: It isn't that hard to have your formatter dereference the ValueObject it was provided till it's of the form that it wants to deal with (type or pointer) and then pass that to the main formatter. If the objection is that's a pain to do for every formatter, we could have the type matcher do the dereferencing and always pass the formatter the ValueObject that is the type they registered the formatter for. This just seems like a really arbitrary restriction, not particularly user-friendly, and is being imposed just to work around formatter bugs, which doesn't strike me as a good motivation. https://github.com/llvm/llvm-project/pull/124048 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits