[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #136121)
anjenner wrote: I'm away for the long weekend but can revert on Wednesday if nobody does so before then. However, I'm not sure how we can track down such lurking issues other than by leaving this unreverted and fixing issues as they pop up, since neither code review nor testcases caught https://github.com/llvm/llvm-project/issues/138194 . Do you have any recommendations other than just not making this API change and leaving the localCache API without proper error handling? https://github.com/llvm/llvm-project/pull/136121 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)
eronnen wrote: @felipepiovezan Thanks for noticing, I'll try to fix it soon https://github.com/llvm/llvm-project/pull/137512 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)
eronnen wrote: Aperrantly I missed that searching unnamed symbols is dependant on the symbol index at https://github.com/llvm/llvm-project/blob/main/lldb/source/Symbol/Symtab.cpp#L668, so changing it will require a deeper change https://github.com/llvm/llvm-project/pull/137512 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)
eronnen wrote: Aperrantly I missed that searching unnamed symbols is dependant on the symbol index at https://github.com/llvm/llvm-project/blob/main/lldb/source/Symbol/Symtab.cpp#L668, so changing it will require a deeper change https://github.com/llvm/llvm-project/pull/137512 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #136121)
teresajohnson wrote: > I'm away for the long weekend but can revert on Wednesday if nobody does so > before then. However, I'm not sure how we can track down such lurking issues > other than by leaving this unreverted and fixing issues as they pop up, since > neither code review nor testcases caught #138194 . Do you have any > recommendations other than just not making this API change and leaving the > localCache API without proper error handling? I've added some questions on that PR, after looking closely at the 2 changes I'm not really sure how this change produced or is related to the crash being fixed there. https://github.com/llvm/llvm-project/pull/136121 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #138416)
eronnen wrote: @felipepiovezan Hopefully this should fix the problem in the macOS tests (https://github.com/llvm/llvm-project/pull/137512#issuecomment-2846104161) though I don't know how to trigger these tests from the PR :| https://github.com/llvm/llvm-project/pull/138416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [clang] Add `__ptrauth_restricted_intptr` qualifier (PR #137580)
ojhunt wrote: @AaronBallman have you made a decision? (if the keyword has to go away I need to replace all the tests and work out how to integrate with other libraries downstream in a way that works in both modes) https://github.com/llvm/llvm-project/pull/137580 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #138416)
https://github.com/eronnen created https://github.com/llvm/llvm-project/pull/138416 * Changes the default synthetic symbol names to contain their file address This is a new PR after the first PR (#137512) was reverted because it didn't update the way unnamed symbols were searched in the symbol table, which relied on the index being in the name. This time also added extra test to make sure the symbol is found as expected >From 3ec9e1962940799ab291aaa8455e6f76da02af0f Mon Sep 17 00:00:00 2001 From: Ely Ronnen Date: Sun, 27 Apr 2025 13:48:45 +0200 Subject: [PATCH 1/3] Change ___lldb_unnamed_symbol generated names to have the file address --- lldb/source/Symbol/Symbol.cpp | 4 +++- lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml | 4 ++-- .../test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test | 2 +- lldb/test/Shell/SymbolFile/Breakpad/symtab.test | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 4828de4fdfa37..da74707c75e13 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -639,7 +639,9 @@ void Symbol::SynthesizeNameIfNeeded() const { // breakpoints on them. llvm::SmallString<256> name; llvm::raw_svector_ostream os(name); -os << GetSyntheticSymbolPrefix() << GetID(); +os << GetSyntheticSymbolPrefix() << "_" + << llvm::format_hex_no_prefix( + m_addr_range.GetBaseAddress().GetFileAddress(), 0); m_mangled.SetDemangledName(ConstString(os.str())); } } diff --git a/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml b/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml index 0dcc9fb76bd4f..709c37e79d878 100644 --- a/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml +++ b/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml @@ -3,8 +3,8 @@ # CHECK: Index UserID DSX TypeFile Address/Value Load Address Size Flags Name # CHECK: [0] 1 SourceFile 0x 0x 0x0004 - -# CHECK: [1] 2 SX Code0x00201180 0x0010 0x ___lldb_unnamed_symbol{{[0-9]*}} -# CHECK: [2] 3 SX Code0x00201190 0x0006 0x ___lldb_unnamed_symbol{{[0-9]*}} +# CHECK: [1] 2 SX Code0x00201180 0x0010 0x ___lldb_unnamed_symbol_{{[0-9a-f]*}} +# CHECK: [2] 3 SX Code0x00201190 0x0006 0x ___lldb_unnamed_symbol_{{[0-9a-f]*}} --- !ELF FileHeader: diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test b/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test index 98052ea20bedd..00e04eb39a98e 100644 --- a/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test +++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test @@ -3,7 +3,7 @@ # RUN: -s %s | FileCheck %s # CHECK: num_symbols = 4 (sorted by size): -# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol0 +# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol_40 # CHECK: [1] 0 X Code0x004000d0 0x0022 0x _start # CHECK: [2] 0 X Code0x004000b0 0x0010 0x f1 # CHECK: [3] 0 X Code0x004000c0 0x0010 0x f2 diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test index ef41bb3bea955..a32eb5808426f 100644 --- a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test +++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test @@ -5,7 +5,7 @@ # CHECK-LABEL: (lldb) image dump symtab symtab.out # CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 4: # CHECK: Index UserID DSX TypeFile Address/Value Load Address Size Flags Name -# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}} +# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol_{{[0-9a-f]*}} # CHECK: [1] 0 X Code0x004000b0 0x0010 0x f1 # CHECK: [2] 0 X Code0x004000c0 0x0010 0x f2 # CHECK: [3] 0 X Code0x004000d0 0x0022 0x _start >From 3798a
[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #138416)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Ely Ronnen (eronnen) Changes * Changes the default synthetic symbol names to contain their file address This is a new PR after the first PR (#137512) was reverted because it didn't update the way unnamed symbols were searched in the symbol table, which relied on the index being in the name. This time also added extra test to make sure the symbol is found as expected --- Full diff: https://github.com/llvm/llvm-project/pull/138416.diff 9 Files Affected: - (modified) lldb/include/lldb/Symbol/Symbol.h (+1-1) - (modified) lldb/source/Symbol/Symbol.cpp (+3-1) - (modified) lldb/source/Symbol/Symtab.cpp (+6-5) - (added) lldb/test/API/python_api/unnamed_symbol_lookup/Makefile (+12) - (added) lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py (+40) - (added) lldb/test/API/python_api/unnamed_symbol_lookup/main.c (+10) - (modified) lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml (+2-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test (+1-1) - (modified) lldb/test/Shell/SymbolFile/Breakpad/symtab.test (+1-1) ``diff diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h index e05c845a69f3e..688c8a5931feb 100644 --- a/lldb/include/lldb/Symbol/Symbol.h +++ b/lldb/include/lldb/Symbol/Symbol.h @@ -258,7 +258,7 @@ class Symbol : public SymbolContextScope { bool ContainsFileAddress(lldb::addr_t file_addr) const; static llvm::StringRef GetSyntheticSymbolPrefix() { -return "___lldb_unnamed_symbol"; +return "___lldb_unnamed_symbol_"; } /// Decode a serialized version of this object from data. diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 4828de4fdfa37..d6689a647062a 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -639,7 +639,9 @@ void Symbol::SynthesizeNameIfNeeded() const { // breakpoints on them. llvm::SmallString<256> name; llvm::raw_svector_ostream os(name); -os << GetSyntheticSymbolPrefix() << GetID(); +os << GetSyntheticSymbolPrefix() + << llvm::format_hex_no_prefix( + m_addr_range.GetBaseAddress().GetFileAddress(), 0); m_mangled.SetDemangledName(ConstString(os.str())); } } diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 9aee5d3e813d8..52545f22322d2 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -654,7 +654,7 @@ uint32_t Symtab::GetNameIndexes(ConstString symbol_name, if (count) return count; // Synthetic symbol names are not added to the name indexes, but they start - // with a prefix and end with a the symbol UserID. This allows users to find + // with a prefix and end with the symbol file address. This allows users to find // these symbols without having to add them to the name indexes. These // queries will not happen very often since the names don't mean anything, so // performance is not paramount in this case. @@ -663,11 +663,12 @@ uint32_t Symtab::GetNameIndexes(ConstString symbol_name, if (!name.consume_front(Symbol::GetSyntheticSymbolPrefix())) return 0; // Not a synthetic symbol name - // Extract the user ID from the symbol name - unsigned long long uid = 0; - if (getAsUnsignedInteger(name, /*Radix=*/10, uid)) + // Extract the file address from the symbol name + unsigned long long file_address = 0; + if (getAsUnsignedInteger(name, /*Radix=*/16, file_address)) return 0; // Failed to extract the user ID as an integer - Symbol *symbol = FindSymbolByID(uid); + + Symbol *symbol = FindSymbolAtFileAddress(static_cast(file_address)); if (symbol == nullptr) return 0; const uint32_t symbol_idx = GetIndexForSymbol(symbol); diff --git a/lldb/test/API/python_api/unnamed_symbol_lookup/Makefile b/lldb/test/API/python_api/unnamed_symbol_lookup/Makefile new file mode 100644 index 0..9ba76898b61ba --- /dev/null +++ b/lldb/test/API/python_api/unnamed_symbol_lookup/Makefile @@ -0,0 +1,12 @@ +C_SOURCES := main.c + +include Makefile.rules + +all: a.out.stripped + +a.out.stripped: + $(STRIP) --keep-symbol=main -o a.out.stripped a.out + +ifneq "$(CODESIGN)" "" + $(CODESIGN) -fs - a.out.stripped +endif diff --git a/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py b/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py new file mode 100644 index 0..09d43a34c7e30 --- /dev/null +++ b/lldb/test/API/python_api/unnamed_symbol_lookup/TestUnnamedSymbolLookup.py @@ -0,0 +1,40 @@ +""" +Test lookup unnamed symbols. +""" + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestUnnamedSymbolLookup(TestBase): +def test_unnamed_symbol_lookup(self): +"""Test looking up unnamed symbol synthetic name""" +self.build() +(tar
[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #138416)
https://github.com/eronnen updated https://github.com/llvm/llvm-project/pull/138416 >From 3ec9e1962940799ab291aaa8455e6f76da02af0f Mon Sep 17 00:00:00 2001 From: Ely Ronnen Date: Sun, 27 Apr 2025 13:48:45 +0200 Subject: [PATCH 1/4] Change ___lldb_unnamed_symbol generated names to have the file address --- lldb/source/Symbol/Symbol.cpp | 4 +++- lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml | 4 ++-- .../test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test | 2 +- lldb/test/Shell/SymbolFile/Breakpad/symtab.test | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 4828de4fdfa37..da74707c75e13 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -639,7 +639,9 @@ void Symbol::SynthesizeNameIfNeeded() const { // breakpoints on them. llvm::SmallString<256> name; llvm::raw_svector_ostream os(name); -os << GetSyntheticSymbolPrefix() << GetID(); +os << GetSyntheticSymbolPrefix() << "_" + << llvm::format_hex_no_prefix( + m_addr_range.GetBaseAddress().GetFileAddress(), 0); m_mangled.SetDemangledName(ConstString(os.str())); } } diff --git a/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml b/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml index 0dcc9fb76bd4f..709c37e79d878 100644 --- a/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml +++ b/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml @@ -3,8 +3,8 @@ # CHECK: Index UserID DSX TypeFile Address/Value Load Address Size Flags Name # CHECK: [0] 1 SourceFile 0x 0x 0x0004 - -# CHECK: [1] 2 SX Code0x00201180 0x0010 0x ___lldb_unnamed_symbol{{[0-9]*}} -# CHECK: [2] 3 SX Code0x00201190 0x0006 0x ___lldb_unnamed_symbol{{[0-9]*}} +# CHECK: [1] 2 SX Code0x00201180 0x0010 0x ___lldb_unnamed_symbol_{{[0-9a-f]*}} +# CHECK: [2] 3 SX Code0x00201190 0x0006 0x ___lldb_unnamed_symbol_{{[0-9a-f]*}} --- !ELF FileHeader: diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test b/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test index 98052ea20bedd..00e04eb39a98e 100644 --- a/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test +++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test @@ -3,7 +3,7 @@ # RUN: -s %s | FileCheck %s # CHECK: num_symbols = 4 (sorted by size): -# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol0 +# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol_40 # CHECK: [1] 0 X Code0x004000d0 0x0022 0x _start # CHECK: [2] 0 X Code0x004000b0 0x0010 0x f1 # CHECK: [3] 0 X Code0x004000c0 0x0010 0x f2 diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test index ef41bb3bea955..a32eb5808426f 100644 --- a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test +++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test @@ -5,7 +5,7 @@ # CHECK-LABEL: (lldb) image dump symtab symtab.out # CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 4: # CHECK: Index UserID DSX TypeFile Address/Value Load Address Size Flags Name -# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}} +# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol_{{[0-9a-f]*}} # CHECK: [1] 0 X Code0x004000b0 0x0010 0x f1 # CHECK: [2] 0 X Code0x004000c0 0x0010 0x f2 # CHECK: [3] 0 X Code0x004000d0 0x0022 0x _start >From 3798aff067f8facbb386a3b3282975b23680447f Mon Sep 17 00:00:00 2001 From: Ely Ronnen Date: Sat, 3 May 2025 18:55:50 +0200 Subject: [PATCH 2/4] add test for looking up unnamed symbols --- .../python_api/unnamed_symbol_lookup/Makefile | 12 ++ .../TestUnnamedSymbolLookup.py| 40 +++ .../python_api/unnamed_symbol_l
[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #138416)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions c,cpp,h -- lldb/test/API/python_api/unnamed_symbol_lookup/main.c lldb/include/lldb/Symbol/Symbol.h lldb/source/Symbol/Symbol.cpp lldb/source/Symbol/Symtab.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 52545f223..9a3e8476f 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -654,8 +654,8 @@ uint32_t Symtab::GetNameIndexes(ConstString symbol_name, if (count) return count; // Synthetic symbol names are not added to the name indexes, but they start - // with a prefix and end with the symbol file address. This allows users to find - // these symbols without having to add them to the name indexes. These + // with a prefix and end with the symbol file address. This allows users to + // find these symbols without having to add them to the name indexes. These // queries will not happen very often since the names don't mean anything, so // performance is not paramount in this case. llvm::StringRef name = symbol_name.GetStringRef(); diff --git a/lldb/test/API/python_api/unnamed_symbol_lookup/main.c b/lldb/test/API/python_api/unnamed_symbol_lookup/main.c index 1c9ce8e0e..ec8350706 100644 --- a/lldb/test/API/python_api/unnamed_symbol_lookup/main.c +++ b/lldb/test/API/python_api/unnamed_symbol_lookup/main.c @@ -1,10 +1,6 @@ -__attribute__((nodebug)) int stripped_function(int val) -{ -return val * val; -} +__attribute__((nodebug)) int stripped_function(int val) { return val * val; } -int main (void) -{ +int main(void) { stripped_function(10); return 0; } `` https://github.com/llvm/llvm-project/pull/138416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Handle step-in over a Darwin "branch island". (PR #138330)
https://github.com/JDevlieghere approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/138330 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Give attach test binaries unique names (PR #138435)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/138435 Give the test binaries used for attaching unique names to avoid accidentally attaching to the wrong binary. Fixes #138197 >From fabb7d6951d124292b3fd333f5bd64499242f6ea Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 2 Apr 2025 00:47:44 -0700 Subject: [PATCH] [lldb-dap] Give attach test binaries unique names Give the test binaries used for attaching unique names to avoid accidentally attaching to the wrong binary. Fixes #138197 --- .../test/tools/lldb-dap/lldbdap_testcase.py | 4 +- .../tools/lldb-dap/attach/TestDAP_attach.py | 46 +++ .../attach/TestDAP_attachByPortNum.py | 22 + 3 files changed, 32 insertions(+), 40 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index ee5272850b9a8..8d407b8e1a17e 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -28,8 +28,8 @@ def create_debug_adapter(self, lldbDAPEnv=None, connection=None): env=lldbDAPEnv, ) -def build_and_create_debug_adapter(self, lldbDAPEnv=None): -self.build() +def build_and_create_debug_adapter(self, lldbDAPEnv=None, dictionary=None): +self.build(dictionary=dictionary) self.create_debug_adapter(lldbDAPEnv) def set_source_breakpoints(self, source_path, lines, data=None): diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py index 6f70316821c8c..17885ef953ea3 100644 --- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py +++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py @@ -2,13 +2,13 @@ Test lldb-dap attach request """ - import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil import lldbdap_testcase import os +import uuid import shutil import subprocess import tempfile @@ -25,7 +25,7 @@ def spawn_and_wait(program, delay): process.wait() -@skipIf +@skip class TestDAP_attach(lldbdap_testcase.DAPTestCaseBase): def set_and_hit_breakpoint(self, continueToExit=True): source = "main.c" @@ -45,8 +45,9 @@ def test_by_pid(self): """ Tests attaching to a process by process ID. """ -self.build_and_create_debug_adapter() -program = self.getBuildArtifact("a.out") +unique_name = str(uuid.uuid4()) +self.build_and_create_debug_adapter(dictionary={"EXE": unique_name}) +program = self.getBuildArtifact(unique_name) self.process = subprocess.Popen( [program], stdin=subprocess.PIPE, @@ -61,34 +62,17 @@ def test_by_name(self): """ Tests attaching to a process by process name. """ -self.build_and_create_debug_adapter() -orig_program = self.getBuildArtifact("a.out") -# Since we are going to attach by process name, we need a unique -# process name that has minimal chance to match a process that is -# already running. To do this we use tempfile.mktemp() to give us a -# full path to a location where we can copy our executable. We then -# run this copy to ensure we don't get the error "more that one -# process matches 'a.out'". -program = tempfile.mktemp() -shutil.copyfile(orig_program, program) -shutil.copymode(orig_program, program) +unique_name = str(uuid.uuid4()) +self.build_and_create_debug_adapter(dictionary={"EXE": unique_name}) +program = self.getBuildArtifact(unique_name) # Use a file as a synchronization point between test and inferior. pid_file_path = lldbutil.append_to_process_working_directory( self, "pid_file_%d" % (int(time.time())) ) -def cleanup(): -if os.path.exists(program): -os.unlink(program) -self.run_platform_command("rm %s" % (pid_file_path)) - -# Execute the cleanup function during test case tear down. -self.addTearDownHook(cleanup) - popen = self.spawnSubprocess(program, [pid_file_path]) - -pid = lldbutil.wait_for_file_on_target(self, pid_file_path) +lldbutil.wait_for_file_on_target(self, pid_file_path) self.attach(program=program) self.set_and_hit_breakpoint(continueToExit=True) @@ -136,8 +120,10 @@ def test_commands(self): "terminateCommands" are a list of LLDB commands that get executed when the debugger session terminates. """ -self.build_and_create_debug_adapter() -program = self.getBuildArtifact("a.out") +unique_name = str(uuid.uuid4()) +self.build_and_create_debug
[Lldb-commits] [lldb] [lldb-dap] Give attach test binaries unique names (PR #138435)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Give the test binaries used for attaching unique names to avoid accidentally attaching to the wrong binary. Fixes #138197 --- Full diff: https://github.com/llvm/llvm-project/pull/138435.diff 3 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py (+2-2) - (modified) lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py (+17-29) - (modified) lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py (+13-9) ``diff diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index ee5272850b9a8..8d407b8e1a17e 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -28,8 +28,8 @@ def create_debug_adapter(self, lldbDAPEnv=None, connection=None): env=lldbDAPEnv, ) -def build_and_create_debug_adapter(self, lldbDAPEnv=None): -self.build() +def build_and_create_debug_adapter(self, lldbDAPEnv=None, dictionary=None): +self.build(dictionary=dictionary) self.create_debug_adapter(lldbDAPEnv) def set_source_breakpoints(self, source_path, lines, data=None): diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py index 6f70316821c8c..17885ef953ea3 100644 --- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py +++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py @@ -2,13 +2,13 @@ Test lldb-dap attach request """ - import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil import lldbdap_testcase import os +import uuid import shutil import subprocess import tempfile @@ -25,7 +25,7 @@ def spawn_and_wait(program, delay): process.wait() -@skipIf +@skip class TestDAP_attach(lldbdap_testcase.DAPTestCaseBase): def set_and_hit_breakpoint(self, continueToExit=True): source = "main.c" @@ -45,8 +45,9 @@ def test_by_pid(self): """ Tests attaching to a process by process ID. """ -self.build_and_create_debug_adapter() -program = self.getBuildArtifact("a.out") +unique_name = str(uuid.uuid4()) +self.build_and_create_debug_adapter(dictionary={"EXE": unique_name}) +program = self.getBuildArtifact(unique_name) self.process = subprocess.Popen( [program], stdin=subprocess.PIPE, @@ -61,34 +62,17 @@ def test_by_name(self): """ Tests attaching to a process by process name. """ -self.build_and_create_debug_adapter() -orig_program = self.getBuildArtifact("a.out") -# Since we are going to attach by process name, we need a unique -# process name that has minimal chance to match a process that is -# already running. To do this we use tempfile.mktemp() to give us a -# full path to a location where we can copy our executable. We then -# run this copy to ensure we don't get the error "more that one -# process matches 'a.out'". -program = tempfile.mktemp() -shutil.copyfile(orig_program, program) -shutil.copymode(orig_program, program) +unique_name = str(uuid.uuid4()) +self.build_and_create_debug_adapter(dictionary={"EXE": unique_name}) +program = self.getBuildArtifact(unique_name) # Use a file as a synchronization point between test and inferior. pid_file_path = lldbutil.append_to_process_working_directory( self, "pid_file_%d" % (int(time.time())) ) -def cleanup(): -if os.path.exists(program): -os.unlink(program) -self.run_platform_command("rm %s" % (pid_file_path)) - -# Execute the cleanup function during test case tear down. -self.addTearDownHook(cleanup) - popen = self.spawnSubprocess(program, [pid_file_path]) - -pid = lldbutil.wait_for_file_on_target(self, pid_file_path) +lldbutil.wait_for_file_on_target(self, pid_file_path) self.attach(program=program) self.set_and_hit_breakpoint(continueToExit=True) @@ -136,8 +120,10 @@ def test_commands(self): "terminateCommands" are a list of LLDB commands that get executed when the debugger session terminates. """ -self.build_and_create_debug_adapter() -program = self.getBuildArtifact("a.out") +unique_name = str(uuid.uuid4()) +self.build_and_create_debug_adapter(dictionary={"EXE": unique_name}) +program = self.getBuildArtifact(unique_name) + # Here we just create a target and launch the process as a way to test # if we are ab