[Lldb-commits] [lldb] [lld] [openmp] [libcxx] [mlir] [clang] [compiler-rt] [flang] [llvm] [clang-format] SpacesInSquareBrackets not working for Java (PR #77833)
https://github.com/mydeveloperday closed https://github.com/llvm/llvm-project/pull/77833 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [lldb] [libc] [lld] [flang] [clang-tools-extra] [libcxx] [clang] [llvm] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)
@@ -1183,9 +1228,21 @@ bool SIInsertWaitcnts::generateWaitcntInstBefore(MachineInstr &MI, // No need to wait before load from VMEM to LDS. if (TII->mayWriteLDSThroughDMA(MI)) continue; -unsigned RegNo = SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS; + // VM_CNT is only relevant to vgpr or LDS. -ScoreBrackets.determineWait(VM_CNT, RegNo, Wait); +unsigned RegNo = SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS; +bool FoundAliasingStore = false; +if (Ptr && Memop->getAAInfo() && Memop->getAAInfo().Scope) { arsenm wrote: I still don't understand the usage of scope; scope isn't special, isn't common and I do at all like specially treating it. I think you should just let the AA query figure out what to do with it https://github.com/llvm/llvm-project/pull/74537 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [libc] [lld] [libcxx] [clang] [compiler-rt] [flang] [clang-tools-extra] [llvm] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)
@@ -130,6 +130,8 @@ ; GCN-O0-NEXT:MachineDominator Tree Construction ; GCN-O0-NEXT:Machine Natural Loop Construction ; GCN-O0-NEXT:MachinePostDominator Tree Construction +; GCN-O0-NEXT:Basic Alias Analysis (stateless AA impl) +; GCN-O0-NEXT:Function Alias Analysis Results arsenm wrote: Can you skip querying for AA at -O0? https://github.com/llvm/llvm-project/pull/74537 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libc] [clang] [libcxx] [llvm] [clang-tools-extra] [flang] [compiler-rt] [lldb] [lld] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)
@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII, setRegScore(RegNo, T, CurrScore); } } -if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) { - setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore); +if (Inst.mayStore() && +(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) { + // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS + // written can be accessed. A load from LDS to VMEM does not need a wait. + unsigned Slot = 0; + for (const auto *MemOp : Inst.memoperands()) { +if (!MemOp->isStore() || +MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS) + continue; +// Comparing just AA info does not guarantee memoperands are equal arsenm wrote: But there's no PseudoSourceValue in this example, it should be a straightforward Value-to-Value comparison https://github.com/llvm/llvm-project/pull/74537 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ValueObject][NFC] Remove unused parameter to ReadPointedString (PR #77919)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/77919 The need for it was removed in `2206b48d6ddabad61979fa69ba09e6b6fb19b0b2`. >From c1ee450df703a4026923b501e8228c16ff019527 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 12 Jan 2024 12:32:02 + Subject: [PATCH] [lldb][ValueObject][NFC] Remove unused parameter to ReadPointedString --- lldb/include/lldb/Core/ValueObject.h | 3 +-- lldb/source/Core/ValueObject.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 3f8005ba696ce8..dec1c7b237ac27 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -670,8 +670,7 @@ class ValueObject { std::pair ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, -uint32_t max_length = 0, bool honor_array = true, -lldb::Format item_format = lldb::eFormatCharArray); +uint32_t max_length = 0, bool honor_array = true); virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0, uint32_t item_count = 1); diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index b2a6d9412ab40b..a5d155d3c6675f 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -814,7 +814,7 @@ static bool CopyStringDataToBufferSP(const StreamString &source, std::pair ValueObject::ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, uint32_t max_length, - bool honor_array, Format item_format) { + bool honor_array) { bool was_capped = false; StreamString s; ExecutionContext exe_ctx(GetExecutionContextRef()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ValueObject][NFC] Remove unused parameter to ReadPointedString (PR #77919)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/77919 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ValueObject][NFC] Remove unused parameter to ReadPointedString (PR #77919)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes All its usages were removed in `2206b48d6ddabad61979fa69ba09e6b6fb19b0b2`. --- Full diff: https://github.com/llvm/llvm-project/pull/77919.diff 2 Files Affected: - (modified) lldb/include/lldb/Core/ValueObject.h (+1-2) - (modified) lldb/source/Core/ValueObject.cpp (+1-1) ``diff diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 3f8005ba696ce8..dec1c7b237ac27 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -670,8 +670,7 @@ class ValueObject { std::pair ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, -uint32_t max_length = 0, bool honor_array = true, -lldb::Format item_format = lldb::eFormatCharArray); +uint32_t max_length = 0, bool honor_array = true); virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0, uint32_t item_count = 1); diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index b2a6d9412ab40b..a5d155d3c6675f 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -814,7 +814,7 @@ static bool CopyStringDataToBufferSP(const StreamString &source, std::pair ValueObject::ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, uint32_t max_length, - bool honor_array, Format item_format) { + bool honor_array) { bool was_capped = false; StreamString s; ExecutionContext exe_ctx(GetExecutionContextRef()); `` https://github.com/llvm/llvm-project/pull/77919 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add tests for target.max-string-summary-length setting (PR #77920)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/77920 This adds API tests for the `target.max-string-summary-length`, which was recently fixed in https://github.com/llvm/llvm-project/pull/72233 >From 4de3716b55a22dc8b7dda621889089f390026739 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 12 Jan 2024 12:34:16 + Subject: [PATCH] [lldb][test] Add tests for target.max-string-summary-length setting --- .../TestDataFormatterAdv.py | 17 + .../data-formatter-advanced/main.cpp| 14 ++ 2 files changed, 31 insertions(+) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index e7c517a90134f3..fb22256e6fa1a8 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -295,6 +295,23 @@ def cleanup(): substrs=["e_2", "n_2", "r_2", "i_2", "k_2", "o_2"], ) +self.runCmd("settings set target.max-string-summary-length 5") +some_string = self.frame().FindVariable('some_string') +some_string_summary = some_string.GetSummary() +self.assertEqual(some_string_summary, '"01234"...') + +some_carr = self.frame().FindVariable('some_carr') +some_carr_summary = some_carr.GetSummary() +self.assertEqual(some_carr_summary, '"01234"...') + +# FIXME: c-strings should honor the target.max-string-summary-length +# setting. Currently a C-string will be truncated at 64 (an internal +# implementation detail) instead of the value specified in the setting. +some_cstring = self.frame().FindVariable('some_cstring') +some_cstring_summary = some_cstring.GetSummary() +self.assertEqual(len(some_cstring_summary), 66) # 64 + 2 (for quotation marks) +self.assertFalse(some_cstring_summary.endswith('...')) + # override the cap self.expect( "frame variable a_long_guy --show-all-children", diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp index e7a52fe73bd4c5..c78f381b8ebe9f 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include struct i_am_cool { @@ -164,6 +165,19 @@ int main (int argc, const char * argv[]) Simple a_simple_object(3,0.14,'E'); VeryLong a_long_guy; + +std::string some_string = +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789"; +char const* some_cstring = some_string.c_str(); + +char const some_carr[] = +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789"; return 0; // Set break point at this line. } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix MaxSummaryLength target property type (PR #72233)
Michael137 wrote: Added tests in: https://github.com/llvm/llvm-project/pull/77920 https://github.com/llvm/llvm-project/pull/72233 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add tests for target.max-string-summary-length setting (PR #77920)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This adds API tests for the `target.max-string-summary-length`, which was recently fixed in https://github.com/llvm/llvm-project/pull/72233 --- Full diff: https://github.com/llvm/llvm-project/pull/77920.diff 2 Files Affected: - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py (+17) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp (+14) ``diff diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index e7c517a90134f3..fb22256e6fa1a8 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -295,6 +295,23 @@ def cleanup(): substrs=["e_2", "n_2", "r_2", "i_2", "k_2", "o_2"], ) +self.runCmd("settings set target.max-string-summary-length 5") +some_string = self.frame().FindVariable('some_string') +some_string_summary = some_string.GetSummary() +self.assertEqual(some_string_summary, '"01234"...') + +some_carr = self.frame().FindVariable('some_carr') +some_carr_summary = some_carr.GetSummary() +self.assertEqual(some_carr_summary, '"01234"...') + +# FIXME: c-strings should honor the target.max-string-summary-length +# setting. Currently a C-string will be truncated at 64 (an internal +# implementation detail) instead of the value specified in the setting. +some_cstring = self.frame().FindVariable('some_cstring') +some_cstring_summary = some_cstring.GetSummary() +self.assertEqual(len(some_cstring_summary), 66) # 64 + 2 (for quotation marks) +self.assertFalse(some_cstring_summary.endswith('...')) + # override the cap self.expect( "frame variable a_long_guy --show-all-children", diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp index e7a52fe73bd4c5..c78f381b8ebe9f 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include struct i_am_cool { @@ -164,6 +165,19 @@ int main (int argc, const char * argv[]) Simple a_simple_object(3,0.14,'E'); VeryLong a_long_guy; + +std::string some_string = +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789"; +char const* some_cstring = some_string.c_str(); + +char const some_carr[] = +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789"; return 0; // Set break point at this line. } `` https://github.com/llvm/llvm-project/pull/77920 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add tests for target.max-string-summary-length setting (PR #77920)
@@ -295,6 +295,23 @@ def cleanup(): substrs=["e_2", "n_2", "r_2", "i_2", "k_2", "o_2"], ) +self.runCmd("settings set target.max-string-summary-length 5") +some_string = self.frame().FindVariable('some_string') +some_string_summary = some_string.GetSummary() +self.assertEqual(some_string_summary, '"01234"...') + +some_carr = self.frame().FindVariable('some_carr') +some_carr_summary = some_carr.GetSummary() +self.assertEqual(some_carr_summary, '"01234"...') + +# FIXME: c-strings should honor the target.max-string-summary-length Michael137 wrote: @JDevlieghere @DavidSpickett @jasonmolenda Not 100% this is expected or not. Added a fixme for now https://github.com/llvm/llvm-project/pull/77920 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add tests for target.max-string-summary-length setting (PR #77920)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r 786cf76f434d2691878067dedb8b1eb99472810b...4de3716b55a22dc8b7dda621889089f390026739 lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py `` View the diff from darker here. ``diff --- TestDataFormatterAdv.py 2024-01-12 12:34:29.00 + +++ TestDataFormatterAdv.py 2024-01-12 12:54:01.521293 + @@ -294,25 +294,25 @@ matching=False, substrs=["e_2", "n_2", "r_2", "i_2", "k_2", "o_2"], ) self.runCmd("settings set target.max-string-summary-length 5") -some_string = self.frame().FindVariable('some_string') +some_string = self.frame().FindVariable("some_string") some_string_summary = some_string.GetSummary() self.assertEqual(some_string_summary, '"01234"...') -some_carr = self.frame().FindVariable('some_carr') +some_carr = self.frame().FindVariable("some_carr") some_carr_summary = some_carr.GetSummary() self.assertEqual(some_carr_summary, '"01234"...') # FIXME: c-strings should honor the target.max-string-summary-length # setting. Currently a C-string will be truncated at 64 (an internal # implementation detail) instead of the value specified in the setting. -some_cstring = self.frame().FindVariable('some_cstring') +some_cstring = self.frame().FindVariable("some_cstring") some_cstring_summary = some_cstring.GetSummary() -self.assertEqual(len(some_cstring_summary), 66) # 64 + 2 (for quotation marks) -self.assertFalse(some_cstring_summary.endswith('...')) +self.assertEqual(len(some_cstring_summary), 66) # 64 + 2 (for quotation marks) +self.assertFalse(some_cstring_summary.endswith("...")) # override the cap self.expect( "frame variable a_long_guy --show-all-children", matching=True, `` https://github.com/llvm/llvm-project/pull/77920 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add tests for target.max-string-summary-length setting (PR #77920)
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 786cf76f434d2691878067dedb8b1eb99472810b 4de3716b55a22dc8b7dda621889089f390026739 -- lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp index c78f381b8e..9d12ca30f9 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp @@ -1,6 +1,6 @@ +#include #include #include -#include #include struct i_am_cool @@ -166,18 +166,16 @@ int main (int argc, const char * argv[]) VeryLong a_long_guy; -std::string some_string = -"012345678901234567890123456789" -"012345678901234567890123456789" -"012345678901234567890123456789" -"012345678901234567890123456789"; -char const* some_cstring = some_string.c_str(); +std::string some_string = "012345678901234567890123456789" + "012345678901234567890123456789" + "012345678901234567890123456789" + "012345678901234567890123456789"; +char const *some_cstring = some_string.c_str(); + +char const some_carr[] = "012345678901234567890123456789" + "012345678901234567890123456789" + "012345678901234567890123456789" + "012345678901234567890123456789"; -char const some_carr[] = -"012345678901234567890123456789" -"012345678901234567890123456789" -"012345678901234567890123456789" -"012345678901234567890123456789"; - return 0; // Set break point at this line. } `` https://github.com/llvm/llvm-project/pull/77920 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add tests for target.max-string-summary-length setting (PR #77920)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/77920 >From 4de3716b55a22dc8b7dda621889089f390026739 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 12 Jan 2024 12:34:16 + Subject: [PATCH 1/2] [lldb][test] Add tests for target.max-string-summary-length setting --- .../TestDataFormatterAdv.py | 17 + .../data-formatter-advanced/main.cpp| 14 ++ 2 files changed, 31 insertions(+) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index e7c517a90134f3..fb22256e6fa1a8 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -295,6 +295,23 @@ def cleanup(): substrs=["e_2", "n_2", "r_2", "i_2", "k_2", "o_2"], ) +self.runCmd("settings set target.max-string-summary-length 5") +some_string = self.frame().FindVariable('some_string') +some_string_summary = some_string.GetSummary() +self.assertEqual(some_string_summary, '"01234"...') + +some_carr = self.frame().FindVariable('some_carr') +some_carr_summary = some_carr.GetSummary() +self.assertEqual(some_carr_summary, '"01234"...') + +# FIXME: c-strings should honor the target.max-string-summary-length +# setting. Currently a C-string will be truncated at 64 (an internal +# implementation detail) instead of the value specified in the setting. +some_cstring = self.frame().FindVariable('some_cstring') +some_cstring_summary = some_cstring.GetSummary() +self.assertEqual(len(some_cstring_summary), 66) # 64 + 2 (for quotation marks) +self.assertFalse(some_cstring_summary.endswith('...')) + # override the cap self.expect( "frame variable a_long_guy --show-all-children", diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp index e7a52fe73bd4c5..c78f381b8ebe9f 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include struct i_am_cool { @@ -164,6 +165,19 @@ int main (int argc, const char * argv[]) Simple a_simple_object(3,0.14,'E'); VeryLong a_long_guy; + +std::string some_string = +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789"; +char const* some_cstring = some_string.c_str(); + +char const some_carr[] = +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789"; return 0; // Set break point at this line. } >From c3a9cc915377ecb49ce4c3102e1c008bb9ee2fda Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 12 Jan 2024 12:56:35 + Subject: [PATCH 2/2] fixup! formatting --- .../TestDataFormatterAdv.py | 10 .../data-formatter-advanced/main.cpp | 24 +-- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index fb22256e6fa1a8..c275904eaf2014 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -296,21 +296,21 @@ def cleanup(): ) self.runCmd("settings set target.max-string-summary-length 5") -some_string = self.frame().FindVariable('some_string') +some_string = self.frame().FindVariable("some_string") some_string_summary = some_string.GetSummary() self.assertEqual(some_string_summary, '"01234"...') -some_carr = self.frame().FindVariable('some_carr') +some_carr = self.frame().FindVariable("some_carr") some_carr_summary = some_carr.GetSummary() self.assertEqual(some_carr_summary, '"01234"...') # FIXME: c-strings should honor the target.max-string-summary-length # setting. Currently a C-string will be truncated at 64 (an internal # implementation detail) instead of the value specified in the setting. -some_cstring = self.frame().FindVariable('some_cstring') +some_cstring = self.frame().FindVariable("some_cs
[Lldb-commits] [lldb] [lldb] Adjust DynamicLoaderDarwin::GetThreadLocalData to support changes to TLS on macOS (PR #77854)
@@ -1048,70 +1048,107 @@ DynamicLoaderDarwin::GetThreadLocalData(const lldb::ModuleSP module_sp, std::lock_guard guard(m_mutex); - const uint32_t addr_size = m_process->GetAddressByteSize(); + lldb_private::Address tls_addr; + if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) +return LLDB_INVALID_ADDRESS; + + Target &target = m_process->GetTarget(); uint8_t buf[sizeof(lldb::addr_t) * 3]; + const uint32_t addr_size = m_process->GetAddressByteSize(); + const size_t tls_data_size = addr_size * 3; + Status error; + const size_t bytes_read = target.ReadMemory( + tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true); + if (bytes_read != tls_data_size || error.Fail()) +return LLDB_INVALID_ADDRESS; - lldb_private::Address tls_addr; - if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) { -Status error; -const size_t tsl_data_size = addr_size * 3; -Target &target = m_process->GetTarget(); -if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) == -tsl_data_size) { - const ByteOrder byte_order = m_process->GetByteOrder(); - DataExtractor data(buf, sizeof(buf), byte_order, addr_size); - lldb::offset_t offset = addr_size; // Skip the first pointer - const lldb::addr_t pthread_key = data.GetAddress(&offset); - const lldb::addr_t tls_offset = data.GetAddress(&offset); - if (pthread_key != 0) { -// First check to see if we have already figured out the location of -// TLS data for the pthread_key on a specific thread yet. If we have we -// can re-use it since its location will not change unless the process -// execs. -const tid_t tid = thread_sp->GetID(); -auto tid_pos = m_tid_to_tls_map.find(tid); -if (tid_pos != m_tid_to_tls_map.end()) { - auto tls_pos = tid_pos->second.find(pthread_key); - if (tls_pos != tid_pos->second.end()) { -return tls_pos->second + tls_offset; - } + DataExtractor data(buf, sizeof(buf), m_process->GetByteOrder(), addr_size); + lldb::offset_t offset = 0; + const lldb::addr_t thunk_addr = data.GetAddress(&offset); + const lldb::addr_t key = data.GetAddress(&offset); + const lldb::addr_t tls_offset = data.GetAddress(&offset); + + TypeSystemClangSP scratch_ts_sp = + ScratchTypeSystemClang::GetForTarget(target); + if (!scratch_ts_sp) +return LLVM_INVALID_ADDRESS; + CompilerType clang_void_ptr_type = + scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType(); + EvaluateExpressionOptions options; + DiagnosticManager execution_errors; + ExecutionContext exe_ctx(thread_sp); + + // On modern apple platforms, there is a small data structure that looks + // approximately like this: + // struct TLS_Thunk { + // void *(*get_addr)(struct TLS_Thunk *); + // size_t key; + // size_t offset; + // } felipepiovezan wrote: Do you think this comment would be more appropriate a few lines above? It seems like we are trying to find these fields around line 1067 https://github.com/llvm/llvm-project/pull/77854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [libc] [clang] [clang-tools-extra] [libunwind] [llvm] [libcxx] [lldb] [lld] [libcxxabi] [flang] [Sema] Use lexical DC for friend functions when getting constraint instanti
https://github.com/antangelo closed https://github.com/llvm/llvm-project/pull/77552 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
https://github.com/paolosevMSFT edited https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
https://github.com/paolosevMSFT updated https://github.com/llvm/llvm-project/pull/76683 >From 739b26b03fd3661d1c22b975e241cbbe60ca6531 Mon Sep 17 00:00:00 2001 From: Paolo Severini Date: Mon, 1 Jan 2024 06:55:40 -0800 Subject: [PATCH 1/4] [lldb] Implement WebAssembly debugging Add support for source-level debugging of WebAssembly code. --- lldb/include/lldb/Target/Process.h| 40 +++ lldb/include/lldb/Target/UnwindWasm.h | 47 +++ lldb/source/Core/Value.cpp| 2 +- lldb/source/Expression/DWARFExpression.cpp| 42 +++ .../source/Interpreter/CommandInterpreter.cpp | 18 ++ lldb/source/Plugins/Process/CMakeLists.txt| 1 + .../Process/gdb-remote/ProcessGDBRemote.cpp | 7 +- .../Process/gdb-remote/ProcessGDBRemote.h | 2 + .../Plugins/Process/wasm/CMakeLists.txt | 15 + .../Plugins/Process/wasm/ProcessWasm.cpp | 296 ++ .../source/Plugins/Process/wasm/ProcessWasm.h | 135 .../Plugins/Process/wasm/ThreadWasm.cpp | 57 lldb/source/Plugins/Process/wasm/ThreadWasm.h | 47 +++ .../Plugins/Process/wasm/UnwindWasm.cpp | 79 + lldb/source/Plugins/Process/wasm/UnwindWasm.h | 58 .../Process/wasm/wasmRegisterContext.cpp | 103 ++ .../Process/wasm/wasmRegisterContext.h| 70 + lldb/source/Target/Platform.cpp | 8 + 18 files changed, 1025 insertions(+), 2 deletions(-) create mode 100644 lldb/include/lldb/Target/UnwindWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/CMakeLists.txt create mode 100644 lldb/source/Plugins/Process/wasm/ProcessWasm.cpp create mode 100644 lldb/source/Plugins/Process/wasm/ProcessWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/ThreadWasm.cpp create mode 100644 lldb/source/Plugins/Process/wasm/ThreadWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/UnwindWasm.cpp create mode 100644 lldb/source/Plugins/Process/wasm/UnwindWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp create mode 100644 lldb/source/Plugins/Process/wasm/wasmRegisterContext.h diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 24c599e044c78f..587ae085b479b7 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1548,6 +1548,46 @@ class Process : public std::enable_shared_from_this, virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error); + /// Read of memory from a process. + /// + /// This function will read memory from the current process's address space + /// and remove any traps that may have been inserted into the memory. + /// + /// This overloads accepts an ExecutionContext as additional argument. By + /// default, it calls the previous overload without the ExecutionContext + /// argument, but it can be overridden by Process subclasses. + /// + /// \param[in] vm_addr + /// A virtual load address that indicates where to start reading + /// memory from. + /// + /// \param[out] buf + /// A byte buffer that is at least \a size bytes long that + /// will receive the memory bytes. + /// + /// \param[in] size + /// The number of bytes to read. + /// + /// \param[in] exe_ctx + ///The current execution context, if available. + /// + /// \param[out] error + /// An error that indicates the success or failure of this + /// operation. If error indicates success (error.Success()), + /// then the value returned can be trusted, otherwise zero + /// will be returned. + /// + /// \return + /// The number of bytes that were actually read into \a buf. If + /// the returned number is greater than zero, yet less than \a + /// size, then this function will get called again with \a + /// vm_addr, \a buf, and \a size updated appropriately. Zero is + /// returned in the case of an error. + virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, +ExecutionContext *exe_ctx, Status &error) { +return ReadMemory(vm_addr, buf, size, error); + } + /// Read of memory from a process. /// /// This function has the same semantics of ReadMemory except that it diff --git a/lldb/include/lldb/Target/UnwindWasm.h b/lldb/include/lldb/Target/UnwindWasm.h new file mode 100644 index 00..3880f1dd62edf2 --- /dev/null +++ b/lldb/include/lldb/Target/UnwindWasm.h @@ -0,0 +1,47 @@ +//===-- UnwindWasm.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_TARGET_UNWINDWASM_H +#define LLDB_TARGET_UNWINDWASM_H + +#includ
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
https://github.com/paolosevMSFT edited https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
https://github.com/paolosevMSFT ready_for_review https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Paolo Severini (paolosevMSFT) Changes Add support for source-level debugging of WebAssembly code that runs in a WebAssembly engine. The idea is to use the GDB-remote protocol to connect to a Wasm engine that implements a GDB-remote stub that offers the ability to access the engine runtime internal state. This protocol is already supported by the "**[WebAssembly Micro Runtime](https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/source_debugging.md)**" and the WAMR team greatly contributed to this work. A WebAssembly debugging session can be started using the new command: `wasm [:] ` The implementation is almost completely contained in Plugin classes and the only Wasm-specific changes to Core classes is in `class DWARFExpression` that handles a new Wasm-specific DWARF opcode (`DW_OP_WASM_location`) added to the DWARF standard. --- Patch is 40.00 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/76683.diff 17 Files Affected: - (modified) lldb/include/lldb/Target/Process.h (+40) - (modified) lldb/source/Core/Value.cpp (+1-1) - (modified) lldb/source/Expression/DWARFExpression.cpp (+42) - (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+18) - (modified) lldb/source/Plugins/Process/CMakeLists.txt (+1) - (modified) lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp (+1-2) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+6-1) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (+2) - (added) lldb/source/Plugins/Process/wasm/CMakeLists.txt (+15) - (added) lldb/source/Plugins/Process/wasm/ProcessWasm.cpp (+295) - (added) lldb/source/Plugins/Process/wasm/ProcessWasm.h (+135) - (added) lldb/source/Plugins/Process/wasm/ThreadWasm.cpp (+57) - (added) lldb/source/Plugins/Process/wasm/ThreadWasm.h (+47) - (added) lldb/source/Plugins/Process/wasm/UnwindWasm.cpp (+79) - (added) lldb/source/Plugins/Process/wasm/UnwindWasm.h (+58) - (added) lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp (+108) - (added) lldb/source/Plugins/Process/wasm/wasmRegisterContext.h (+75) ``diff diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 24c599e044c78f..587ae085b479b7 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1548,6 +1548,46 @@ class Process : public std::enable_shared_from_this, virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error); + /// Read of memory from a process. + /// + /// This function will read memory from the current process's address space + /// and remove any traps that may have been inserted into the memory. + /// + /// This overloads accepts an ExecutionContext as additional argument. By + /// default, it calls the previous overload without the ExecutionContext + /// argument, but it can be overridden by Process subclasses. + /// + /// \param[in] vm_addr + /// A virtual load address that indicates where to start reading + /// memory from. + /// + /// \param[out] buf + /// A byte buffer that is at least \a size bytes long that + /// will receive the memory bytes. + /// + /// \param[in] size + /// The number of bytes to read. + /// + /// \param[in] exe_ctx + ///The current execution context, if available. + /// + /// \param[out] error + /// An error that indicates the success or failure of this + /// operation. If error indicates success (error.Success()), + /// then the value returned can be trusted, otherwise zero + /// will be returned. + /// + /// \return + /// The number of bytes that were actually read into \a buf. If + /// the returned number is greater than zero, yet less than \a + /// size, then this function will get called again with \a + /// vm_addr, \a buf, and \a size updated appropriately. Zero is + /// returned in the case of an error. + virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, +ExecutionContext *exe_ctx, Status &error) { +return ReadMemory(vm_addr, buf, size, error); + } + /// Read of memory from a process. /// /// This function has the same semantics of ReadMemory except that it diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp index 995cc934c82044..47a5fdee773886 100644 --- a/lldb/source/Core/Value.cpp +++ b/lldb/source/Core/Value.cpp @@ -552,7 +552,7 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, if (process) { const size_t bytes_read = - process->ReadMemory(address, dst, byte_size, error); + process->ReadMemory(address, dst, byte_size, exe_ctx, error); if (bytes_read != byte_size) error.SetErrorStringWithF
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -2595,6 +2606,37 @@ bool DWARFExpression::Evaluate( break; } +case DW_OP_WASM_location: { + uint8_t wasm_op = opcodes.GetU8(&offset); + uint32_t index; + + /* LLDB doesn't have an address space to represents WebAssembly Locals, + * GLobals and operand stacks. JDevlieghere wrote: `s/GLobals/globals/` https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
https://github.com/JDevlieghere commented: Thanks for picking this up again. I was going to ask about testing and I see that Adrian asked a similar question on Phabricator in the original review. My recommendation would be to use `GdbRemoteTestCaseBase` style tests for this, as they'll run on all the existing bots. If you want to integration test the stub this is actually going to talk to it would be great to have that running in CI too, but that's not a requirement to get this merged. The support for `DW_OP_WASM_location` seems like it can be hoisted out in a separate patch with its own dedicated test. https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -0,0 +1,295 @@ +// This file comes from https://reviews.llvm.org/D78978. +// Author: [@paolosev](https://reviews.llvm.org/p/paolosev/). + +//===-- ProcessWasm.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "ProcessWasm.h" +#include "ThreadWasm.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Utility/DataBufferHeap.h" + +#include "lldb/Target/UnixSignals.h" +#include "llvm/ADT/ArrayRef.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_gdb_remote; +using namespace lldb_private::wasm; + +LLDB_PLUGIN_DEFINE(ProcessWasm) + +// ProcessGDBRemote constructor +ProcessWasm::ProcessWasm(lldb::TargetSP target_sp, ListenerSP listener_sp) +: ProcessGDBRemote(target_sp, listener_sp) { + /* always use linux signals for wasm process */ + m_unix_signals_sp = UnixSignals::Create(ArchSpec{"wasm32-unknown-unknown-wasm"}); +} + +void ProcessWasm::Initialize() { + static llvm::once_flag g_once_flag; + + llvm::call_once(g_once_flag, []() { +PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), CreateInstance, + DebuggerInitialize); + }); +} + +void ProcessWasm::DebuggerInitialize(Debugger &debugger) { + ProcessGDBRemote::DebuggerInitialize(debugger); +} + +// PluginInterface JDevlieghere wrote: These comments are pretty useless so while we haven't gone an removed them everywhere, we try not to introduce new instances of them. https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -2595,6 +2606,37 @@ bool DWARFExpression::Evaluate( break; } +case DW_OP_WASM_location: { + uint8_t wasm_op = opcodes.GetU8(&offset); + uint32_t index; + + /* LLDB doesn't have an address space to represents WebAssembly Locals, JDevlieghere wrote: `s/Locals/locals/` https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -0,0 +1,295 @@ +// This file comes from https://reviews.llvm.org/D78978. +// Author: [@paolosev](https://reviews.llvm.org/p/paolosev/). + +//===-- ProcessWasm.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "ProcessWasm.h" +#include "ThreadWasm.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Utility/DataBufferHeap.h" + +#include "lldb/Target/UnixSignals.h" +#include "llvm/ADT/ArrayRef.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_gdb_remote; +using namespace lldb_private::wasm; + +LLDB_PLUGIN_DEFINE(ProcessWasm) + +// ProcessGDBRemote constructor +ProcessWasm::ProcessWasm(lldb::TargetSP target_sp, ListenerSP listener_sp) +: ProcessGDBRemote(target_sp, listener_sp) { + /* always use linux signals for wasm process */ + m_unix_signals_sp = UnixSignals::Create(ArchSpec{"wasm32-unknown-unknown-wasm"}); +} + +void ProcessWasm::Initialize() { + static llvm::once_flag g_once_flag; + + llvm::call_once(g_once_flag, []() { +PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), CreateInstance, + DebuggerInitialize); + }); +} + +void ProcessWasm::DebuggerInitialize(Debugger &debugger) { + ProcessGDBRemote::DebuggerInitialize(debugger); +} + +// PluginInterface +llvm::StringRef ProcessWasm::GetPluginName() { return GetPluginNameStatic(); } + +ConstString ProcessWasm::GetPluginNameStatic() { + static ConstString g_name("wasm"); + return g_name; +} + +const char *ProcessWasm::GetPluginDescriptionStatic() { + return "GDB Remote protocol based WebAssembly debugging plug-in."; +} + +void ProcessWasm::Terminate() { + PluginManager::UnregisterPlugin(ProcessWasm::CreateInstance); +} + +lldb::ProcessSP ProcessWasm::CreateInstance(lldb::TargetSP target_sp, +ListenerSP listener_sp, +const FileSpec *crash_file_path, +bool can_connect) { + lldb::ProcessSP process_sp; + if (crash_file_path == nullptr) +process_sp = std::make_shared(target_sp, listener_sp); + return process_sp; +} + +bool ProcessWasm::CanDebug(lldb::TargetSP target_sp, +bool plugin_specified_by_name) { JDevlieghere wrote: Please run `clang-format` on the changes in this PR. https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -0,0 +1,295 @@ +// This file comes from https://reviews.llvm.org/D78978. +// Author: [@paolosev](https://reviews.llvm.org/p/paolosev/). + +//===-- ProcessWasm.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "ProcessWasm.h" +#include "ThreadWasm.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Utility/DataBufferHeap.h" + +#include "lldb/Target/UnixSignals.h" +#include "llvm/ADT/ArrayRef.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_gdb_remote; +using namespace lldb_private::wasm; + +LLDB_PLUGIN_DEFINE(ProcessWasm) + +// ProcessGDBRemote constructor +ProcessWasm::ProcessWasm(lldb::TargetSP target_sp, ListenerSP listener_sp) +: ProcessGDBRemote(target_sp, listener_sp) { + /* always use linux signals for wasm process */ + m_unix_signals_sp = UnixSignals::Create(ArchSpec{"wasm32-unknown-unknown-wasm"}); +} + +void ProcessWasm::Initialize() { + static llvm::once_flag g_once_flag; + + llvm::call_once(g_once_flag, []() { +PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), CreateInstance, + DebuggerInitialize); + }); +} + +void ProcessWasm::DebuggerInitialize(Debugger &debugger) { + ProcessGDBRemote::DebuggerInitialize(debugger); +} + +// PluginInterface +llvm::StringRef ProcessWasm::GetPluginName() { return GetPluginNameStatic(); } + +ConstString ProcessWasm::GetPluginNameStatic() { + static ConstString g_name("wasm"); + return g_name; +} + +const char *ProcessWasm::GetPluginDescriptionStatic() { + return "GDB Remote protocol based WebAssembly debugging plug-in."; +} + +void ProcessWasm::Terminate() { + PluginManager::UnregisterPlugin(ProcessWasm::CreateInstance); +} + +lldb::ProcessSP ProcessWasm::CreateInstance(lldb::TargetSP target_sp, +ListenerSP listener_sp, +const FileSpec *crash_file_path, +bool can_connect) { + lldb::ProcessSP process_sp; + if (crash_file_path == nullptr) +process_sp = std::make_shared(target_sp, listener_sp); + return process_sp; +} + +bool ProcessWasm::CanDebug(lldb::TargetSP target_sp, +bool plugin_specified_by_name) { + if (plugin_specified_by_name) +return true; + + Module *exe_module = target_sp->GetExecutableModulePointer(); + if (exe_module) { +ObjectFile *exe_objfile = exe_module->GetObjectFile(); +return exe_objfile->GetArchitecture().GetMachine() == llvm::Triple::wasm32; + } + // However, if there is no wasm module, we return false, otherwise, + // we might use ProcessWasm to attach gdb remote. + return false; +} + +std::shared_ptr ProcessWasm::CreateThread(lldb::tid_t tid) { + return std::make_shared(*this, tid); +} + +size_t ProcessWasm::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, + Status &error) { + wasm_addr_t wasm_addr(vm_addr); + + switch (wasm_addr.GetType()) { + case WasmAddressType::Memory: +return ProcessGDBRemote::ReadMemory(vm_addr, buf, size, error); + case WasmAddressType::Object: +// TODO ? +return ProcessGDBRemote::ReadMemory(vm_addr, buf, size, error); + case WasmAddressType::Invalid: + default: +error.SetErrorStringWithFormat( +"Wasm read failed for invalid address 0x%" PRIx64, vm_addr); +return 0; + } +} + +size_t ProcessWasm::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, + ExecutionContext *exe_ctx, Status &error) { + wasm_addr_t wasm_addr(vm_addr); + + switch (wasm_addr.GetType()) { + case WasmAddressType::Memory: { +// If we don't have a valid module_id, this is actually a read from the +// Wasm memory space. We can calculate the module_id from the execution +// context. +if (wasm_addr.module_id == 0 && exe_ctx != nullptr) { + StackFrame *frame = exe_ctx->GetFramePtr(); + assert(frame->CalculateTarget()->GetArchitecture().GetMachine() == + llvm::Triple::wasm32); + wasm_addr.module_id = wasm_addr_t(frame->GetStackID().GetPC()).module_id; + wasm_addr.type = WasmAddressType::Memory; +} +if (WasmReadMemory(wasm_addr.module_id, wasm_addr.offset, buf, size)) + return size; +error.SetErrorStringWithFormat("Wasm memory read failed for 0x%" PRIx64, + vm_addr); +return 0; + } + case WasmAddressType::Object: +// TODO ? +return ProcessGDBRemote::ReadMemory(vm_addr, buf, size, error); + case WasmAddressType::
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -0,0 +1,135 @@ +// This file comes from https://reviews.llvm.org/D78978. +// Author: [@paolosev](https://reviews.llvm.org/p/paolosev/). + +//===-- ProcessWasm.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_SOURCE_PLUGINS_PROCESS_WASM_PROCESSWASM_H +#define LLDB_SOURCE_PLUGINS_PROCESS_WASM_PROCESSWASM_H + +#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" +#include "lldb/Target/RegisterContext.h" + +namespace lldb_private { +namespace wasm { + +// Each WebAssembly module has separated address spaces for Code and Memory. +// A WebAssembly module also has a Data section which, when the module is +// loaded, gets mapped into a region in the module Memory. +// For the purpose of debugging, we can represent all these separated 32-bit +// address spaces with a single virtual 64-bit address space. +// +// Struct wasm_addr_t provides this encoding using bitfields +// +enum WasmAddressType { + Memory = 0x00, + Object = 0x01, + Invalid = 0x03 +}; +struct wasm_addr_t { + uint64_t offset : 32; + uint64_t module_id : 30; + uint64_t type : 2; + + wasm_addr_t(lldb::addr_t addr) + : type(addr >> 62), module_id((addr & 0x00ff) >> 32), +offset(addr & 0x) {} + + wasm_addr_t(WasmAddressType type_, uint32_t module_id_, uint32_t offset_) + : type(type_), module_id(module_id_), offset(offset_) {} + + WasmAddressType GetType() { return static_cast(type); } + operator lldb::addr_t() { return *(uint64_t *)this; } +}; + +/// ProcessWasm provides the access to the Wasm program state +/// retrieved from the Wasm engine. JDevlieghere wrote: spurious space https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -0,0 +1,135 @@ +// This file comes from https://reviews.llvm.org/D78978. +// Author: [@paolosev](https://reviews.llvm.org/p/paolosev/). + +//===-- ProcessWasm.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_SOURCE_PLUGINS_PROCESS_WASM_PROCESSWASM_H +#define LLDB_SOURCE_PLUGINS_PROCESS_WASM_PROCESSWASM_H + +#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" +#include "lldb/Target/RegisterContext.h" + +namespace lldb_private { +namespace wasm { + +// Each WebAssembly module has separated address spaces for Code and Memory. +// A WebAssembly module also has a Data section which, when the module is +// loaded, gets mapped into a region in the module Memory. +// For the purpose of debugging, we can represent all these separated 32-bit +// address spaces with a single virtual 64-bit address space. +// +// Struct wasm_addr_t provides this encoding using bitfields +// JDevlieghere wrote: These should be Doxygen style comments (`///`). https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -0,0 +1,295 @@ +// This file comes from https://reviews.llvm.org/D78978. +// Author: [@paolosev](https://reviews.llvm.org/p/paolosev/). + JDevlieghere wrote: Remove this here and everywhere else. https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -0,0 +1,295 @@ +// This file comes from https://reviews.llvm.org/D78978. +// Author: [@paolosev](https://reviews.llvm.org/p/paolosev/). + +//===-- ProcessWasm.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "ProcessWasm.h" +#include "ThreadWasm.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Utility/DataBufferHeap.h" + +#include "lldb/Target/UnixSignals.h" +#include "llvm/ADT/ArrayRef.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_gdb_remote; +using namespace lldb_private::wasm; + +LLDB_PLUGIN_DEFINE(ProcessWasm) + +// ProcessGDBRemote constructor +ProcessWasm::ProcessWasm(lldb::TargetSP target_sp, ListenerSP listener_sp) +: ProcessGDBRemote(target_sp, listener_sp) { + /* always use linux signals for wasm process */ + m_unix_signals_sp = UnixSignals::Create(ArchSpec{"wasm32-unknown-unknown-wasm"}); +} + +void ProcessWasm::Initialize() { + static llvm::once_flag g_once_flag; + + llvm::call_once(g_once_flag, []() { +PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), CreateInstance, + DebuggerInitialize); + }); +} + +void ProcessWasm::DebuggerInitialize(Debugger &debugger) { + ProcessGDBRemote::DebuggerInitialize(debugger); +} + +// PluginInterface +llvm::StringRef ProcessWasm::GetPluginName() { return GetPluginNameStatic(); } + +ConstString ProcessWasm::GetPluginNameStatic() { + static ConstString g_name("wasm"); + return g_name; +} + +const char *ProcessWasm::GetPluginDescriptionStatic() { + return "GDB Remote protocol based WebAssembly debugging plug-in."; +} + +void ProcessWasm::Terminate() { + PluginManager::UnregisterPlugin(ProcessWasm::CreateInstance); +} + +lldb::ProcessSP ProcessWasm::CreateInstance(lldb::TargetSP target_sp, +ListenerSP listener_sp, +const FileSpec *crash_file_path, +bool can_connect) { + lldb::ProcessSP process_sp; + if (crash_file_path == nullptr) +process_sp = std::make_shared(target_sp, listener_sp); + return process_sp; +} + +bool ProcessWasm::CanDebug(lldb::TargetSP target_sp, +bool plugin_specified_by_name) { + if (plugin_specified_by_name) +return true; + + Module *exe_module = target_sp->GetExecutableModulePointer(); + if (exe_module) { +ObjectFile *exe_objfile = exe_module->GetObjectFile(); +return exe_objfile->GetArchitecture().GetMachine() == llvm::Triple::wasm32; + } + // However, if there is no wasm module, we return false, otherwise, + // we might use ProcessWasm to attach gdb remote. + return false; +} + +std::shared_ptr ProcessWasm::CreateThread(lldb::tid_t tid) { + return std::make_shared(*this, tid); +} + +size_t ProcessWasm::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, + Status &error) { + wasm_addr_t wasm_addr(vm_addr); + + switch (wasm_addr.GetType()) { + case WasmAddressType::Memory: +return ProcessGDBRemote::ReadMemory(vm_addr, buf, size, error); + case WasmAddressType::Object: +// TODO ? JDevlieghere wrote: ? :-) https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -0,0 +1,15 @@ +# This file comes from https://reviews.llvm.org/D78978. +# Author: [@paolosev](https://reviews.llvm.org/p/paolosev/). + JDevlieghere wrote: Remove this https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #76683)
@@ -0,0 +1,295 @@ +// This file comes from https://reviews.llvm.org/D78978. +// Author: [@paolosev](https://reviews.llvm.org/p/paolosev/). + +//===-- ProcessWasm.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "ProcessWasm.h" +#include "ThreadWasm.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Utility/DataBufferHeap.h" + +#include "lldb/Target/UnixSignals.h" +#include "llvm/ADT/ArrayRef.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_gdb_remote; +using namespace lldb_private::wasm; + +LLDB_PLUGIN_DEFINE(ProcessWasm) + +// ProcessGDBRemote constructor +ProcessWasm::ProcessWasm(lldb::TargetSP target_sp, ListenerSP listener_sp) +: ProcessGDBRemote(target_sp, listener_sp) { + /* always use linux signals for wasm process */ + m_unix_signals_sp = UnixSignals::Create(ArchSpec{"wasm32-unknown-unknown-wasm"}); +} + +void ProcessWasm::Initialize() { + static llvm::once_flag g_once_flag; + + llvm::call_once(g_once_flag, []() { +PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), CreateInstance, + DebuggerInitialize); + }); +} + +void ProcessWasm::DebuggerInitialize(Debugger &debugger) { + ProcessGDBRemote::DebuggerInitialize(debugger); +} + +// PluginInterface +llvm::StringRef ProcessWasm::GetPluginName() { return GetPluginNameStatic(); } + +ConstString ProcessWasm::GetPluginNameStatic() { + static ConstString g_name("wasm"); + return g_name; +} JDevlieghere wrote: `GetPluginNameStatic` should return a `llvm::StringRef`. Same for `GetPluginDescriptionStatic` below. https://github.com/llvm/llvm-project/pull/76683 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ValueObject][NFC] Remove unused parameter to ReadPointedString (PR #77919)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/77919 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 844a8dc - [lldb][ValueObject][NFC] Remove unused parameter to ReadPointedString (#77919)
Author: Michael Buch Date: 2024-01-12T16:11:59Z New Revision: 844a8dcaafb3efcac936e0d89df857f818e5a209 URL: https://github.com/llvm/llvm-project/commit/844a8dcaafb3efcac936e0d89df857f818e5a209 DIFF: https://github.com/llvm/llvm-project/commit/844a8dcaafb3efcac936e0d89df857f818e5a209.diff LOG: [lldb][ValueObject][NFC] Remove unused parameter to ReadPointedString (#77919) All its usages were removed in `2206b48d6ddabad61979fa69ba09e6b6fb19b0b2`. Added: Modified: lldb/include/lldb/Core/ValueObject.h lldb/source/Core/ValueObject.cpp Removed: diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 3f8005ba696ce8..dec1c7b237ac27 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -670,8 +670,7 @@ class ValueObject { std::pair ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, -uint32_t max_length = 0, bool honor_array = true, -lldb::Format item_format = lldb::eFormatCharArray); +uint32_t max_length = 0, bool honor_array = true); virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0, uint32_t item_count = 1); diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index b2a6d9412ab40b..a5d155d3c6675f 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -814,7 +814,7 @@ static bool CopyStringDataToBufferSP(const StreamString &source, std::pair ValueObject::ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, uint32_t max_length, - bool honor_array, Format item_format) { + bool honor_array) { bool was_capped = false; StreamString s; ExecutionContext exe_ctx(GetExecutionContextRef()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ValueObject][NFC] Remove unused parameter to ReadPointedString (PR #77919)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/77919 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFCI] Remove CommandReturnObject from BreakpointIDList (PR #77858)
https://github.com/JDevlieghere approved this pull request. This improves layering so LGTM! https://github.com/llvm/llvm-project/pull/77858 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFCI] Remove CommandReturnObject from BreakpointIDList (PR #77858)
https://github.com/felipepiovezan approved this pull request. LGTM! Should we `#include llvm/Support/Error.h"` in the BreakpointIDList header? https://github.com/llvm/llvm-project/pull/77858 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adjust DynamicLoaderDarwin::GetThreadLocalData to support changes to TLS on macOS (PR #77854)
@@ -1048,70 +1048,107 @@ DynamicLoaderDarwin::GetThreadLocalData(const lldb::ModuleSP module_sp, std::lock_guard guard(m_mutex); - const uint32_t addr_size = m_process->GetAddressByteSize(); + lldb_private::Address tls_addr; + if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) +return LLDB_INVALID_ADDRESS; + + Target &target = m_process->GetTarget(); uint8_t buf[sizeof(lldb::addr_t) * 3]; + const uint32_t addr_size = m_process->GetAddressByteSize(); + const size_t tls_data_size = addr_size * 3; + Status error; + const size_t bytes_read = target.ReadMemory( + tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true); + if (bytes_read != tls_data_size || error.Fail()) +return LLDB_INVALID_ADDRESS; - lldb_private::Address tls_addr; - if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) { -Status error; -const size_t tsl_data_size = addr_size * 3; -Target &target = m_process->GetTarget(); -if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) == -tsl_data_size) { - const ByteOrder byte_order = m_process->GetByteOrder(); - DataExtractor data(buf, sizeof(buf), byte_order, addr_size); - lldb::offset_t offset = addr_size; // Skip the first pointer - const lldb::addr_t pthread_key = data.GetAddress(&offset); - const lldb::addr_t tls_offset = data.GetAddress(&offset); - if (pthread_key != 0) { -// First check to see if we have already figured out the location of -// TLS data for the pthread_key on a specific thread yet. If we have we -// can re-use it since its location will not change unless the process -// execs. -const tid_t tid = thread_sp->GetID(); -auto tid_pos = m_tid_to_tls_map.find(tid); -if (tid_pos != m_tid_to_tls_map.end()) { - auto tls_pos = tid_pos->second.find(pthread_key); - if (tls_pos != tid_pos->second.end()) { -return tls_pos->second + tls_offset; - } + DataExtractor data(buf, sizeof(buf), m_process->GetByteOrder(), addr_size); + lldb::offset_t offset = 0; + const lldb::addr_t thunk_addr = data.GetAddress(&offset); + const lldb::addr_t key = data.GetAddress(&offset); + const lldb::addr_t tls_offset = data.GetAddress(&offset); + + TypeSystemClangSP scratch_ts_sp = + ScratchTypeSystemClang::GetForTarget(target); + if (!scratch_ts_sp) +return LLVM_INVALID_ADDRESS; + CompilerType clang_void_ptr_type = + scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType(); + EvaluateExpressionOptions options; + DiagnosticManager execution_errors; + ExecutionContext exe_ctx(thread_sp); + + // On modern apple platforms, there is a small data structure that looks + // approximately like this: + // struct TLS_Thunk { + // void *(*get_addr)(struct TLS_Thunk *); + // size_t key; + // size_t offset; + // } JDevlieghere wrote: +1 as this is also shared between the "old" and "new" implementation. https://github.com/llvm/llvm-project/pull/77854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adjust DynamicLoaderDarwin::GetThreadLocalData to support changes to TLS on macOS (PR #77854)
https://github.com/JDevlieghere commented: Currently this is a little hard to read given a bunch of shared setup followed by two possible ways to read the TLS data. If those implementations don't require too many inputs, it might be worth splitting this out into two helper functions to make this easier to follow and extend in the future. https://github.com/llvm/llvm-project/pull/77854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [llvm] [compiler-rt] [lld] [libcxx] [clang] [mlir] [lldb] [clang-tools-extra] [DWARFLinker][NFC] Decrease DWARFLinker dependence on DwarfStreamer. (PR #77932)
https://github.com/avl-llvm updated https://github.com/llvm/llvm-project/pull/77932 >From 30a603f6d37afecdb2cb150bd98acd27c8d8baf5 Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Fri, 12 Jan 2024 13:07:33 +0300 Subject: [PATCH] [DWARFLinker][NFC] Decrease DWARFLinker dependence on DwarfStreamer. This patch is extracted from #74725. The DwarfStreamer interface looks overcomplicated and has unnecessary dependencies: 1. it contains emitSwiftAST, emitSwiftReflectionSection methods which are not used by DWARFLinker. 2. its interface uses DWARFLinker classes(CompileUnit) which makes it dependend on DWARFLinker. 3. it has "AsmPrinter &getAsmPrinter()" method which provides very low level interface. This patch avoids creation of DwarfStreamer by DWARFLinker and simplifies interface: 1. dwarf_linker::classic. Now client of DWARFLinker creates DwarfStreamer and pass it to the DWARFLinker through DwarfEmitter interface. It simplifies dependence. Later it would be good to remove class DwarfStreamer from dwarf_linker::classic completely. 2. dwarf_linker::parallel. Now client of DWARFLinker sets handler of output debug sections to the DWARFLinker. It simplifies dependence to following small interface: using SectionHandlerTy = std::function Section)>; virtual void setOutputDWARFHandler(const Triple &TargetTriple, SectionHandlerTy SectionHandler) = 0; --- .../llvm/DWARFLinker/Classic/DWARFLinker.h| 24 +--- .../llvm/DWARFLinker/Classic/DWARFStreamer.h | 18 ++- .../llvm/DWARFLinker/DWARFLinkerBase.h| 47 +++ .../llvm/DWARFLinker/Parallel/DWARFLinker.h | 57 llvm/lib/DWARFLinker/CMakeLists.txt | 1 + llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 33 ++--- .../lib/DWARFLinker/Classic/DWARFStreamer.cpp | 92 ++--- llvm/lib/DWARFLinker/DWARFLinkerBase.cpp | 64 + .../DWARFLinker/Parallel/DWARFEmitterImpl.cpp | 66 -- .../DWARFLinker/Parallel/DWARFEmitterImpl.h | 23 +--- .../Parallel/DWARFLinkerCompileUnit.cpp | 14 +- .../Parallel/DWARFLinkerCompileUnit.h | 7 +- .../Parallel/DWARFLinkerGlobalData.h | 29 +++- .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 92 + .../DWARFLinker/Parallel/DWARFLinkerImpl.h| 23 ++-- .../Parallel/DWARFLinkerTypeUnit.cpp | 12 +- .../Parallel/DWARFLinkerTypeUnit.h| 2 +- .../DWARFLinker/Parallel/OutputSections.cpp | 53 .../lib/DWARFLinker/Parallel/OutputSections.h | 124 ++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp | 36 +++-- llvm/tools/dsymutil/DwarfLinkerForBinary.h| 4 +- llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp | 25 +++- 22 files changed, 421 insertions(+), 425 deletions(-) create mode 100644 llvm/lib/DWARFLinker/DWARFLinkerBase.cpp diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h index d3aaa3baadc47d..bacf07beed95eb 100644 --- a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h +++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h @@ -59,7 +59,8 @@ class DwarfEmitter { virtual ~DwarfEmitter() = default; /// Emit section named SecName with data SecData. - virtual void emitSectionContents(StringRef SecData, StringRef SecName) = 0; + virtual void emitSectionContents(StringRef SecData, + DebugSectionKind SecKind) = 0; /// Emit the abbreviation table \p Abbrevs to the .debug_abbrev section. virtual void @@ -205,17 +206,6 @@ class DwarfEmitter { /// Dump the file to the disk. virtual void finish() = 0; - - /// Emit the swift_ast section stored in \p Buffer. - virtual void emitSwiftAST(StringRef Buffer) = 0; - - /// Emit the swift reflection section stored in \p Buffer. - virtual void emitSwiftReflectionSection( - llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind, - StringRef Buffer, uint32_t Alignment, uint32_t Size) = 0; - - /// Returns underlying AsmPrinter. - virtual AsmPrinter &getAsmPrinter() const = 0; }; class DwarfStreamer; @@ -249,10 +239,10 @@ class DWARFLinker : public DWARFLinkerBase { StringsTranslator); } - Error createEmitter(const Triple &TheTriple, OutputFileType FileType, - raw_pwrite_stream &OutFile); - - DwarfEmitter *getEmitter(); + /// Set output DWARF emitter. + void setOutputDWARFEmitter(DwarfEmitter *Emitter) { +TheDwarfEmitter = Emitter; + } /// Add object file to be linked. Pre-load compile unit die. Call /// \p OnCUDieLoaded for each compile unit die. If specified \p File @@ -779,7 +769,7 @@ class DWARFLinker : public DWARFLinkerBase { BumpPtrAllocator DIEAlloc; /// @} - std::unique_ptr TheDwarfEmitter; + DwarfEmitter *TheDwarfEmitter = nullptr; std::vector ObjectContexts; /// The CIEs that have been emitted in t
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
https://github.com/paolosevMSFT created https://github.com/llvm/llvm-project/pull/77949 Add support for source-level debugging of WebAssembly code that runs in a WebAssembly engine. The idea is to use the GDB-remote protocol to connect to a Wasm engine that implements a GDB-remote stub that offers the ability to access the engine runtime internal state. This protocol is already supported by the [**WebAssembly Micro Runtime**](https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/source_debugging.md) and the WAMR team greatly contributed to this work. A WebAssembly debugging session can be started using the new command: `wasm [:]` The implementation is almost completely contained in Plugin classes and the only Wasm-specific changes to Core classes is in `class DWARFExpression` that handles a new Wasm-specific DWARF opcode (`DW_OP_WASM_location`) added to the DWARF standard. >From 30d932bb0988e1c78c3e023be2270259df5e6664 Mon Sep 17 00:00:00 2001 From: Paolo Severini Date: Fri, 12 Jan 2024 09:10:59 -0800 Subject: [PATCH] Add support for source-level debugging of WebAssembly code --- lldb/include/lldb/Target/Process.h| 40 +++ lldb/source/Core/Value.cpp| 2 +- lldb/source/Expression/DWARFExpression.cpp| 41 +++ .../source/Interpreter/CommandInterpreter.cpp | 18 ++ lldb/source/Plugins/Process/CMakeLists.txt| 1 + .../Process/gdb-remote/ProcessGDBRemote.cpp | 7 +- .../Process/gdb-remote/ProcessGDBRemote.h | 2 + .../Plugins/Process/wasm/CMakeLists.txt | 12 + .../Plugins/Process/wasm/ProcessWasm.cpp | 291 ++ .../source/Plugins/Process/wasm/ProcessWasm.h | 129 .../Plugins/Process/wasm/ThreadWasm.cpp | 55 lldb/source/Plugins/Process/wasm/ThreadWasm.h | 44 +++ .../Plugins/Process/wasm/UnwindWasm.cpp | 76 + lldb/source/Plugins/Process/wasm/UnwindWasm.h | 55 .../Process/wasm/wasmRegisterContext.cpp | 108 +++ .../Process/wasm/wasmRegisterContext.h| 75 + 16 files changed, 954 insertions(+), 2 deletions(-) create mode 100644 lldb/source/Plugins/Process/wasm/CMakeLists.txt create mode 100644 lldb/source/Plugins/Process/wasm/ProcessWasm.cpp create mode 100644 lldb/source/Plugins/Process/wasm/ProcessWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/ThreadWasm.cpp create mode 100644 lldb/source/Plugins/Process/wasm/ThreadWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/UnwindWasm.cpp create mode 100644 lldb/source/Plugins/Process/wasm/UnwindWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp create mode 100644 lldb/source/Plugins/Process/wasm/wasmRegisterContext.h diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 24c599e044c78f..587ae085b479b7 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1548,6 +1548,46 @@ class Process : public std::enable_shared_from_this, virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error); + /// Read of memory from a process. + /// + /// This function will read memory from the current process's address space + /// and remove any traps that may have been inserted into the memory. + /// + /// This overloads accepts an ExecutionContext as additional argument. By + /// default, it calls the previous overload without the ExecutionContext + /// argument, but it can be overridden by Process subclasses. + /// + /// \param[in] vm_addr + /// A virtual load address that indicates where to start reading + /// memory from. + /// + /// \param[out] buf + /// A byte buffer that is at least \a size bytes long that + /// will receive the memory bytes. + /// + /// \param[in] size + /// The number of bytes to read. + /// + /// \param[in] exe_ctx + ///The current execution context, if available. + /// + /// \param[out] error + /// An error that indicates the success or failure of this + /// operation. If error indicates success (error.Success()), + /// then the value returned can be trusted, otherwise zero + /// will be returned. + /// + /// \return + /// The number of bytes that were actually read into \a buf. If + /// the returned number is greater than zero, yet less than \a + /// size, then this function will get called again with \a + /// vm_addr, \a buf, and \a size updated appropriately. Zero is + /// returned in the case of an error. + virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, +ExecutionContext *exe_ctx, Status &error) { +return ReadMemory(vm_addr, buf, size, error); + } + /// Read of memory from a process. /// /// This function has the same semantics of ReadMemory except that it diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp i
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Paolo Severini (paolosevMSFT) Changes Add support for source-level debugging of WebAssembly code that runs in a WebAssembly engine. The idea is to use the GDB-remote protocol to connect to a Wasm engine that implements a GDB-remote stub that offers the ability to access the engine runtime internal state. This protocol is already supported by the [**WebAssembly Micro Runtime**](https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/source_debugging.md) and the WAMR team greatly contributed to this work. A WebAssembly debugging session can be started using the new command: `wasm [:] ` The implementation is almost completely contained in Plugin classes and the only Wasm-specific changes to Core classes is in `class DWARFExpression` that handles a new Wasm-specific DWARF opcode (`DW_OP_WASM_location`) added to the DWARF standard. --- Patch is 38.42 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/77949.diff 16 Files Affected: - (modified) lldb/include/lldb/Target/Process.h (+40) - (modified) lldb/source/Core/Value.cpp (+1-1) - (modified) lldb/source/Expression/DWARFExpression.cpp (+41) - (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+18) - (modified) lldb/source/Plugins/Process/CMakeLists.txt (+1) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+6-1) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (+2) - (added) lldb/source/Plugins/Process/wasm/CMakeLists.txt (+12) - (added) lldb/source/Plugins/Process/wasm/ProcessWasm.cpp (+291) - (added) lldb/source/Plugins/Process/wasm/ProcessWasm.h (+129) - (added) lldb/source/Plugins/Process/wasm/ThreadWasm.cpp (+55) - (added) lldb/source/Plugins/Process/wasm/ThreadWasm.h (+44) - (added) lldb/source/Plugins/Process/wasm/UnwindWasm.cpp (+76) - (added) lldb/source/Plugins/Process/wasm/UnwindWasm.h (+55) - (added) lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp (+108) - (added) lldb/source/Plugins/Process/wasm/wasmRegisterContext.h (+75) ``diff diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 24c599e044c78f..587ae085b479b7 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1548,6 +1548,46 @@ class Process : public std::enable_shared_from_this, virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error); + /// Read of memory from a process. + /// + /// This function will read memory from the current process's address space + /// and remove any traps that may have been inserted into the memory. + /// + /// This overloads accepts an ExecutionContext as additional argument. By + /// default, it calls the previous overload without the ExecutionContext + /// argument, but it can be overridden by Process subclasses. + /// + /// \param[in] vm_addr + /// A virtual load address that indicates where to start reading + /// memory from. + /// + /// \param[out] buf + /// A byte buffer that is at least \a size bytes long that + /// will receive the memory bytes. + /// + /// \param[in] size + /// The number of bytes to read. + /// + /// \param[in] exe_ctx + ///The current execution context, if available. + /// + /// \param[out] error + /// An error that indicates the success or failure of this + /// operation. If error indicates success (error.Success()), + /// then the value returned can be trusted, otherwise zero + /// will be returned. + /// + /// \return + /// The number of bytes that were actually read into \a buf. If + /// the returned number is greater than zero, yet less than \a + /// size, then this function will get called again with \a + /// vm_addr, \a buf, and \a size updated appropriately. Zero is + /// returned in the case of an error. + virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, +ExecutionContext *exe_ctx, Status &error) { +return ReadMemory(vm_addr, buf, size, error); + } + /// Read of memory from a process. /// /// This function has the same semantics of ReadMemory except that it diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp index 995cc934c82044..47a5fdee773886 100644 --- a/lldb/source/Core/Value.cpp +++ b/lldb/source/Core/Value.cpp @@ -552,7 +552,7 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, if (process) { const size_t bytes_read = - process->ReadMemory(address, dst, byte_size, error); + process->ReadMemory(address, dst, byte_size, exe_ctx, error); if (bytes_read != byte_size) error.SetErrorStringWithFormat( "read memory from 0x%" PRIx64 " failed (%u of %u bytes read)", diff
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
paolosevMSFT wrote: @JDevlieghere I created a new PR and closed [https://github.com/llvm/llvm-project/pull/76683](https://github.com/llvm/llvm-project/pull/76683) because I made a mess with a git rebase, and since the other PR had just started I thought it made sense to start anew. I apologize for the confusion. Here I have already addressed most of your comments from 76683. What is left to do is to add tests with `GdbRemoteTestCaseBase` as you suggested. I've kept the support for `DW_OP_WASM_location` in this PR to have it fully working, but I'll be happy to hoist it out in a separate patch with its own dedicated test, if so you prefer. @xujuntwt95329, from WebAssembly Micro Runtime, has hugely contributed to this work, but I cannot add his name to the reviewers or assignees. https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][libc++] Adds missing C++20 calendar data formatters. (PR #77954)
https://github.com/mordante created https://github.com/llvm/llvm-project/pull/77954 This is a followup of #76983 and adds the libc++ data formatters for - weekday, - weekday_indexed, - weekday_last, - month_weekday, - month_weekday_last, - year_month, - year_month_day_last - year_month_weekday, and - year_month_weekday_last. >From 65b4143db4d7074d7b8604420591856a2fcfc0ee Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Fri, 12 Jan 2024 18:54:14 +0100 Subject: [PATCH] [lldb][libc++] Adds missing C++20 calendar data formatters. This is a followup of #76983 and adds the data formatters for - weekday, - weekday_indexed, - weekday_last, - month_weekday, - month_weekday_last, - year_month, - year_month_day_last - year_month_weekday, and - year_month_weekday_last. --- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 57 .../Plugins/Language/CPlusPlus/LibCxx.cpp | 21 + .../Plugins/Language/CPlusPlus/LibCxx.h | 4 + .../chrono/TestDataFormatterLibcxxChrono.py | 93 +++ .../data-formatter-stl/libcxx/chrono/main.cpp | 56 +++ 5 files changed, 231 insertions(+) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index c6937ebca319fa..7131ccb9d05eca 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1039,6 +1039,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | eTypeOptionHideValue, "day=${var.__d_%u}"))); + AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxChronoMonthSummaryProvider, "libc++ std::chrono::month summary provider", @@ -1050,6 +1051,23 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { TypeSummaryImplSP(new StringSummaryFormat( eTypeOptionHideChildren | eTypeOptionHideValue, "year=${var.__y_}"))); + AddCXXSummary(cpp_category_sp, +lldb_private::formatters::LibcxxChronoWeekdaySummaryProvider, +"libc++ std::chrono::weekday summary provider", +"^std::__[[:alnum:]]+::chrono::weekday$", +eTypeOptionHideChildren | eTypeOptionHideValue, true); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::weekday_indexed$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat( + eTypeOptionHideChildren | eTypeOptionHideValue, + "${var.__wd_} index=${var.__idx_%u}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::weekday_last$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__wd_} index=last"))); cpp_category_sp->AddTypeSummary( "^std::__[[:alnum:]]+::chrono::month_day$", eFormatterMatchRegex, TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | @@ -1060,12 +1078,51 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__m_} day=last"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::month_weekday$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__m_} ${var.__wdi_}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::month_weekday_last$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__m_} ${var.__wdl_}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::year_month$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__y_} ${var.__m_}"))); + AddCXXSummary( cpp_category_sp, lldb_private::formatters::LibcxxChronoYearMonthDaySummaryProvider, "libc++ std::chrono::year_month_day summary provider", "^std::__[[:alnum:]]+::chrono::year_month_day$", eTypeOptionHideChildren | eTypeOptionHideValue, true); + + cpp_category_sp->AddTypeSummary( +
[Lldb-commits] [lldb] [lldb][libc++] Adds missing C++20 calendar data formatters. (PR #77954)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Mark de Wever (mordante) Changes This is a followup of #76983 and adds the libc++ data formatters for - weekday, - weekday_indexed, - weekday_last, - month_weekday, - month_weekday_last, - year_month, - year_month_day_last - year_month_weekday, and - year_month_weekday_last. --- Full diff: https://github.com/llvm/llvm-project/pull/77954.diff 5 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (+57) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (+21) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.h (+4) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py (+93) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp (+56) ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index c6937ebca319fa..7131ccb9d05eca 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1039,6 +1039,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | eTypeOptionHideValue, "day=${var.__d_%u}"))); + AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxChronoMonthSummaryProvider, "libc++ std::chrono::month summary provider", @@ -1050,6 +1051,23 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { TypeSummaryImplSP(new StringSummaryFormat( eTypeOptionHideChildren | eTypeOptionHideValue, "year=${var.__y_}"))); + AddCXXSummary(cpp_category_sp, +lldb_private::formatters::LibcxxChronoWeekdaySummaryProvider, +"libc++ std::chrono::weekday summary provider", +"^std::__[[:alnum:]]+::chrono::weekday$", +eTypeOptionHideChildren | eTypeOptionHideValue, true); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::weekday_indexed$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat( + eTypeOptionHideChildren | eTypeOptionHideValue, + "${var.__wd_} index=${var.__idx_%u}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::weekday_last$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__wd_} index=last"))); cpp_category_sp->AddTypeSummary( "^std::__[[:alnum:]]+::chrono::month_day$", eFormatterMatchRegex, TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | @@ -1060,12 +1078,51 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__m_} day=last"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::month_weekday$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__m_} ${var.__wdi_}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::month_weekday_last$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__m_} ${var.__wdl_}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::year_month$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__y_} ${var.__m_}"))); + AddCXXSummary( cpp_category_sp, lldb_private::formatters::LibcxxChronoYearMonthDaySummaryProvider, "libc++ std::chrono::year_month_day summary provider", "^std::__[[:alnum:]]+::chrono::year_month_day$", eTypeOptionHideChildren | eTypeOptionHideValue, true); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::year_month_day_last$", + eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionH
[Lldb-commits] [llvm] [clang-tools-extra] [libclc] [libc] [lld] [lldb] [clang] [libcxx] [libcxxabi] [flang] [libunwind] [compiler-rt] [builtins] Generate __multc3 for z/OS (PR #77554)
@@ -374,10 +376,10 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { #endif } -#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE) +#elif defined(QUAD_PRECISION) arichardson wrote: Looks like this was actually required. Probably needs to be changed to `#elif defined(QUAD_PRECISION) && defined(CRT_HAS_F128)`. @perry-ca Could you open a new PR with this change? See https://github.com/llvm/llvm-project/issues/77898 and https://github.com/llvm/llvm-project/issues/77880 https://github.com/llvm/llvm-project/pull/77554 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [clang-tools-extra] [lldb] [libcxx] [clang] [flang] [mlir] [X86] Add "Ws" constraint and "p" modifier for symbolic address/label reference (PR #77886)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/77886 >From f5a33f9e6893250e3584a77630b771ee76693c20 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 11 Jan 2024 23:42:38 -0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- clang/lib/Basic/Targets/X86.cpp | 11 ++ .../test/CodeGen/X86/inline-asm-constraints.c | 8 + clang/test/Sema/inline-asm-validate-x86.c | 4 +++ llvm/docs/LangRef.rst | 2 ++ llvm/lib/Target/X86/X86AsmPrinter.cpp | 8 + llvm/lib/Target/X86/X86ISelLowering.cpp | 20 --- .../X86/inline-asm-Ws-constraint-error.ll | 9 + .../CodeGen/X86/inline-asm-Ws-constraint.ll | 34 +++ 8 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 llvm/test/CodeGen/X86/inline-asm-Ws-constraint-error.ll create mode 100644 llvm/test/CodeGen/X86/inline-asm-Ws-constraint.ll diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 64e281b888a95f..a68b662d9401aa 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -1418,6 +1418,14 @@ bool X86TargetInfo::validateAsmConstraint( case 'O': Info.setRequiresImmediate(0, 127); return true; + case 'W': +switch (*++Name) { +default: + return false; +case 's': + Info.setAllowsRegister(); + return true; +} // Register constraints. case 'Y': // 'Y' is the first character for several 2-character constraints. // Shift the pointer to the second character of the constraint. @@ -1715,6 +1723,9 @@ std::string X86TargetInfo::convertConstraint(const char *&Constraint) const { return std::string("{st}"); case 'u':// second from top of floating point stack. return std::string("{st(1)}"); // second from top of floating point stack. + case 'W': +assert(Constraint[1] == 's'); +return '^' + std::string(Constraint++, 2); case 'Y': switch (Constraint[1]) { default: diff --git a/clang/test/CodeGen/X86/inline-asm-constraints.c b/clang/test/CodeGen/X86/inline-asm-constraints.c index b75a84d7a7bcbf..bfcbbca7c4f6bf 100644 --- a/clang/test/CodeGen/X86/inline-asm-constraints.c +++ b/clang/test/CodeGen/X86/inline-asm-constraints.c @@ -53,3 +53,11 @@ __m512 testZMM0(void) { #endif return zmm0; } + +extern int var; + +// CHECK-LABEL: test_Ws( +// CHECK: call void asm sideeffect "// ${0:p} ${1:p}", "^Ws,^Ws,~{dirflag},~{fpsr},~{flags}"(ptr @var, ptr @test_Ws) +void test_Ws(void) { + asm("// %p0 %p1" :: "Ws"(&var), "Ws"(test_Ws)); +} diff --git a/clang/test/Sema/inline-asm-validate-x86.c b/clang/test/Sema/inline-asm-validate-x86.c index 87b60a0955301a..032d76477c4ae6 100644 --- a/clang/test/Sema/inline-asm-validate-x86.c +++ b/clang/test/Sema/inline-asm-validate-x86.c @@ -130,3 +130,7 @@ void pr40890(void) { __asm__ __volatile__("\n#define BEEF abcd%0\n" : : "n"((int*)0xdeadbeef)); #endif } + +void test_W() { + asm("" : : "Wd"(test_W)); // expected-error{{invalid input constraint 'Wd' in asm}} +} diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index d881deb30049a2..076029976ffc5d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -5336,6 +5336,7 @@ X86: operand in a SSE register. If AVX is also enabled, can also be a 256-bit vector operand in an AVX register. If AVX-512 is also enabled, can also be a 512-bit vector operand in an AVX512 register. Otherwise, an error. +- ``Ws``: A symbolic reference or label reference. - ``x``: The same as ``v``, except that when AVX-512 is enabled, the ``x`` code only allocates into the first 16 AVX-512 registers, while the ``v`` code allocates into any of the 32 AVX-512 registers. @@ -5518,6 +5519,7 @@ X86: the operand. (The behavior for relocatable symbol expressions is a target-specific behavior for this typically target-independent modifier) - ``H``: Print a memory reference with additional offset +8. +- ``p``: Print a raw symbol name (without syntax-specific prefixes). - ``P``: Print a memory reference used as the argument of a call instruction or used with explicit base reg and index reg as its offset. So it can not use additional regs to present the memory reference. (E.g. omit ``(rip)``, even diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp index 15cfd247f125ca..9f0fd4d0938e97 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -774,6 +774,14 @@ bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, PrintOperand(MI, OpNo, O); return false; +case 'p': { + const MachineOperand &MO = MI->getOperand(OpNo); + if (MO.getType() != MachineOperand:
[Lldb-commits] [llvm] [clang-tools-extra] [lldb] [libcxx] [clang] [flang] [mlir] [X86] Add "Ws" constraint and "p" modifier for symbolic address/label reference (PR #77886)
@@ -0,0 +1,34 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=i686 < %s | FileCheck %s +; RUN: llc -mtriple=x86_64 < %s | FileCheck %s + +@var = external dso_local global i32, align 4 + +define dso_local void @test() { +; CHECK-LABEL: test: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT:#APP +; CHECK-NEXT:# var test +; CHECK-NEXT:#NO_APP +; CHECK-NEXT:ret{{[l|q]}} +entry: + call void asm sideeffect "// ${0:p} ${1:p}", "^Ws,^Ws,~{dirflag},~{fpsr},~{flags}"(ptr @var, ptr @test) + ret void +} + +define dso_local void @test_label() { +; CHECK-LABEL: test_label: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: .Ltmp0: # Block address taken +; CHECK-NEXT: # %bb.1: # %label +; CHECK-NEXT:#APP +; CHECK-NEXT:# .Ltmp0 +; CHECK-NEXT:#NO_APP +; CHECK-NEXT:ret{{[l|q]}} +entry: + br label %label + +label: + tail call void asm sideeffect "// ${0:p}", "Ws,~{dirflag},~{fpsr},~{flags}"(ptr blockaddress(@test_label, %label)) MaskRay wrote: Thanks for spotting this. Fixed. I think constraint validation is primarily performed in Clang Sema and it's easy to crash LLVM with invalid LLVM IR. In this case Ws+0:p happens to work as well. https://github.com/llvm/llvm-project/pull/77886 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [clang-tools-extra] [lldb] [libcxx] [clang] [flang] [mlir] [X86] Add "Ws" constraint and "p" modifier for symbolic address/label reference (PR #77886)
@@ -56966,6 +56965,17 @@ void X86TargetLowering::LowerAsmOperandForConstraint(SDValue Op, } return; } + case 'W': { +assert(Constraint[1] == 's'); +if (const auto *GA = dyn_cast(Op)) { + Ops.push_back(DAG.getTargetGlobalAddress(GA->getGlobal(), SDLoc(Op), + GA->getValueType(0))); +} else if (const auto *BA = dyn_cast(Op)) { + Ops.push_back(DAG.getTargetBlockAddress(BA->getBlockAddress(), + BA->getValueType(0))); +} MaskRay wrote: Removed https://github.com/llvm/llvm-project/pull/77886 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] [clang-tools-extra] [llvm] [lldb][test] Add tests for target.max-string-summary-length setting (PR #77920)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/77920 >From 4de3716b55a22dc8b7dda621889089f390026739 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 12 Jan 2024 12:34:16 + Subject: [PATCH 1/2] [lldb][test] Add tests for target.max-string-summary-length setting --- .../TestDataFormatterAdv.py | 17 + .../data-formatter-advanced/main.cpp| 14 ++ 2 files changed, 31 insertions(+) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index e7c517a90134f3..fb22256e6fa1a8 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -295,6 +295,23 @@ def cleanup(): substrs=["e_2", "n_2", "r_2", "i_2", "k_2", "o_2"], ) +self.runCmd("settings set target.max-string-summary-length 5") +some_string = self.frame().FindVariable('some_string') +some_string_summary = some_string.GetSummary() +self.assertEqual(some_string_summary, '"01234"...') + +some_carr = self.frame().FindVariable('some_carr') +some_carr_summary = some_carr.GetSummary() +self.assertEqual(some_carr_summary, '"01234"...') + +# FIXME: c-strings should honor the target.max-string-summary-length +# setting. Currently a C-string will be truncated at 64 (an internal +# implementation detail) instead of the value specified in the setting. +some_cstring = self.frame().FindVariable('some_cstring') +some_cstring_summary = some_cstring.GetSummary() +self.assertEqual(len(some_cstring_summary), 66) # 64 + 2 (for quotation marks) +self.assertFalse(some_cstring_summary.endswith('...')) + # override the cap self.expect( "frame variable a_long_guy --show-all-children", diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp index e7a52fe73bd4c5..c78f381b8ebe9f 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include struct i_am_cool { @@ -164,6 +165,19 @@ int main (int argc, const char * argv[]) Simple a_simple_object(3,0.14,'E'); VeryLong a_long_guy; + +std::string some_string = +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789"; +char const* some_cstring = some_string.c_str(); + +char const some_carr[] = +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789" +"012345678901234567890123456789"; return 0; // Set break point at this line. } >From c3a9cc915377ecb49ce4c3102e1c008bb9ee2fda Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 12 Jan 2024 12:56:35 + Subject: [PATCH 2/2] fixup! formatting --- .../TestDataFormatterAdv.py | 10 .../data-formatter-advanced/main.cpp | 24 +-- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index fb22256e6fa1a8..c275904eaf2014 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -296,21 +296,21 @@ def cleanup(): ) self.runCmd("settings set target.max-string-summary-length 5") -some_string = self.frame().FindVariable('some_string') +some_string = self.frame().FindVariable("some_string") some_string_summary = some_string.GetSummary() self.assertEqual(some_string_summary, '"01234"...') -some_carr = self.frame().FindVariable('some_carr') +some_carr = self.frame().FindVariable("some_carr") some_carr_summary = some_carr.GetSummary() self.assertEqual(some_carr_summary, '"01234"...') # FIXME: c-strings should honor the target.max-string-summary-length # setting. Currently a C-string will be truncated at 64 (an internal # implementation detail) instead of the value specified in the setting. -some_cstring = self.frame().FindVariable('some_cstring') +some_cstring = self.frame().FindVariable("some_cs
[Lldb-commits] [lldb] [lldb][NFCI] Remove CommandReturnObject from BreakpointIDList (PR #77858)
bulbazord wrote: > LGTM! > > Should we `#include llvm/Support/Error.h"` in the BreakpointIDList header? Ah, I didn't add it but it builds so it's probably getting it transitively. I'll add it for future-proofing. https://github.com/llvm/llvm-project/pull/77858 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adjust DynamicLoaderDarwin::GetThreadLocalData to support changes to TLS on macOS (PR #77854)
bulbazord wrote: > Currently this is a little hard to read given a bunch of shared setup > followed by two possible ways to read the TLS data. If those implementations > don't require too many inputs, it might be worth splitting this out into two > helper functions to make this easier to follow and extend in the future. I can do that. Since this change is quite large as-is, perhaps I should break this up into smaller changes and submit them separately? https://github.com/llvm/llvm-project/pull/77854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support dSYMs as modules (PR #77966)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/77966 Generally, separate debug info files are not object files. The exception are dSYMs which are Mach-O and often contain enough information to be used as a module. This patch allows users to add dSYM symbol files as target modules to support use cases where the executable isn't available. This scenario is common when doing core file debugging and Jason has a follow up patch that allows core file debugging without just the dSYM. rdar://117773589 >From be861d00ab6027e52bce61576eda18c9a05bd1dd Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 11 Jan 2024 09:19:31 -0800 Subject: [PATCH 1/2] [lldb] Move CanBeTarget logic into the ObjectFile plugin (NFC) --- lldb/include/lldb/Symbol/ObjectFile.h | 4 lldb/source/Symbol/ObjectFile.cpp | 33 +++ lldb/source/Target/Target.cpp | 33 +++ 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index 6348d8103f85de..fb946ee71873de 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -698,6 +698,10 @@ class ObjectFile : public std::enable_shared_from_this, /// file to be complete. virtual bool CanTrustAddressRanges() { return false; } + /// Can this object file serve as a valid target module. If a Status is passed + /// and the answer is no, it will be populated with the reason. + virtual bool CanBeTarget(Status *status = nullptr); + static lldb::SymbolType GetSymbolTypeFromName( llvm::StringRef name, lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined); diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index d890ad92e83122..06457be6b606d6 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -764,6 +764,39 @@ uint32_t ObjectFile::GetCacheHash() { return *m_cache_hash; } +bool ObjectFile::CanBeTarget(Status *status) { + switch (GetType()) { + case ObjectFile::eTypeCoreFile: /// A core file that has a checkpoint of + /// a program's execution state + case ObjectFile::eTypeExecutable:/// A normal executable + case ObjectFile::eTypeDynamicLinker: /// The platform's dynamic linker + /// executable + case ObjectFile::eTypeObjectFile:/// An intermediate object file + case ObjectFile::eTypeSharedLibrary: /// A shared library that can be + /// used during execution +return true; + case ObjectFile::eTypeDebugInfo: /// An object file that contains only + /// debug information +if (status) + status->SetErrorString("debug info files aren't valid target " + "modules, please specify an executable"); +return false; + case ObjectFile::eTypeStubLibrary: /// A library that can be linked + /// against but not used for + /// execution +if (status) + status->SetErrorString("stub libraries aren't valid target " + "modules, please specify an executable"); +return false; + default: +if (status) + status->SetErrorString( + "unsupported file type, please specify an executable"); +return false; + } + llvm_unreachable("Fully covered switch above!"); +} + namespace llvm { namespace json { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 302c2bad7021b9..e5e8658163fdba 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -2254,37 +2254,10 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify, // there wasn't an equivalent module in the list already, and if there was, // let's remove it. if (module_sp) { - ObjectFile *objfile = module_sp->GetObjectFile(); - if (objfile) { -switch (objfile->GetType()) { -case ObjectFile::eTypeCoreFile: /// A core file that has a checkpoint of -/// a program's execution state -case ObjectFile::eTypeExecutable:/// A normal executable -case ObjectFile::eTypeDynamicLinker: /// The platform's dynamic linker - /// executable -case ObjectFile::eTypeObjectFile:/// An intermediate object file -case ObjectFile::eTypeSharedLibrary: /// A shared library that can be - /// used during execution - break; -case ObjectFile::eTypeDebugInfo: /// An object file that contains only - /// debug information - if (error_ptr) -error_ptr->SetErrorString("debug inf
[Lldb-commits] [lldb] [lldb] Support dSYMs as modules (PR #77966)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes Generally, separate debug info files are not object files. The exception are dSYMs which are Mach-O and often contain enough information to be used as a module. This patch allows users to add dSYM symbol files as target modules to support use cases where the executable isn't available. This scenario is common when doing core file debugging and Jason has a follow up patch that allows core file debugging without just the dSYM. rdar://117773589 --- Full diff: https://github.com/llvm/llvm-project/pull/77966.diff 8 Files Affected: - (modified) lldb/include/lldb/Symbol/ObjectFile.h (+4) - (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+6) - (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (+2) - (modified) lldb/source/Symbol/ObjectFile.cpp (+33) - (modified) lldb/source/Target/Target.cpp (+3-30) - (added) lldb/test/API/macosx/dsym-module/Makefile (+3) - (added) lldb/test/API/macosx/dsym-module/TestTargetModuleAddDsym.py (+23) - (added) lldb/test/API/macosx/dsym-module/main.c (+5) ``diff diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index 6348d8103f85de..fb946ee71873de 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -698,6 +698,10 @@ class ObjectFile : public std::enable_shared_from_this, /// file to be complete. virtual bool CanTrustAddressRanges() { return false; } + /// Can this object file serve as a valid target module. If a Status is passed + /// and the answer is no, it will be populated with the reason. + virtual bool CanBeTarget(Status *status = nullptr); + static lldb::SymbolType GetSymbolTypeFromName( llvm::StringRef name, lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined); diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index d7a2846200fcaf..d623476c4c7243 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -6128,6 +6128,12 @@ Section *ObjectFileMachO::GetMachHeaderSection() { return nullptr; } +bool ObjectFileMachO::CanBeTarget(Status *status ) { + if (m_header.filetype == MH_DSYM) +return true; + return ObjectFile::CanBeTarget(status); +} + bool ObjectFileMachO::SectionIsLoadable(const Section *section) { if (!section) return false; diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h index 0a47f3a7dd1861..7a2cda2b83ec21 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h @@ -160,6 +160,8 @@ class ObjectFileMachO : public lldb_private::ObjectFile { lldb_private::Section *GetMachHeaderSection(); + virtual bool CanBeTarget(lldb_private::Status *status = nullptr) override; + // PluginInterface protocol llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index d890ad92e83122..06457be6b606d6 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -764,6 +764,39 @@ uint32_t ObjectFile::GetCacheHash() { return *m_cache_hash; } +bool ObjectFile::CanBeTarget(Status *status) { + switch (GetType()) { + case ObjectFile::eTypeCoreFile: /// A core file that has a checkpoint of + /// a program's execution state + case ObjectFile::eTypeExecutable:/// A normal executable + case ObjectFile::eTypeDynamicLinker: /// The platform's dynamic linker + /// executable + case ObjectFile::eTypeObjectFile:/// An intermediate object file + case ObjectFile::eTypeSharedLibrary: /// A shared library that can be + /// used during execution +return true; + case ObjectFile::eTypeDebugInfo: /// An object file that contains only + /// debug information +if (status) + status->SetErrorString("debug info files aren't valid target " + "modules, please specify an executable"); +return false; + case ObjectFile::eTypeStubLibrary: /// A library that can be linked + /// against but not used for + /// execution +if (status) + status->SetErrorString("stub libraries aren't valid target " + "modules, please specify an executable"); +return false; + default: +if (status) + status->SetErrorString( + "unsupported file type, please specify an executable"); +return false; + } + llvm_unreachable("Fully covered swit
[Lldb-commits] [lldb] [lldb][NFCI] Remove CommandReturnObject from BreakpointIDList (PR #77858)
https://github.com/bulbazord updated https://github.com/llvm/llvm-project/pull/77858 >From d138a85dbddf5373e0a60d8467768c186e343f1b Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Thu, 11 Jan 2024 16:51:03 -0800 Subject: [PATCH 1/2] [lldb][NFCI] Remove CommandReturnObject from BreakpointIDList BreakpointIDList does not need to know about CommandReturnObject. BreakpointIDList::FindAndReplaceIDRanges is the last place that uses it in BreakpointIDList. Instead of passing in a CommandReturnObject, it now returns an llvm::Error. The callsite uses the Error to populate the CommandReturnObject as needed. --- .../lldb/Breakpoint/BreakpointIDList.h| 10 ++-- lldb/source/Breakpoint/BreakpointIDList.cpp | 57 +-- .../Commands/CommandObjectBreakpoint.cpp | 54 +- 3 files changed, 59 insertions(+), 62 deletions(-) diff --git a/lldb/include/lldb/Breakpoint/BreakpointIDList.h b/lldb/include/lldb/Breakpoint/BreakpointIDList.h index 6910024695d898..6416b2b04148a9 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointIDList.h +++ b/lldb/include/lldb/Breakpoint/BreakpointIDList.h @@ -54,12 +54,10 @@ class BreakpointIDList { static std::pair SplitIDRangeExpression(llvm::StringRef in_string); - static void FindAndReplaceIDRanges(Args &old_args, Target *target, - bool allow_locations, - BreakpointName::Permissions - ::PermissionKinds purpose, - CommandReturnObject &result, - Args &new_args); + static llvm::Error + FindAndReplaceIDRanges(Args &old_args, Target *target, bool allow_locations, + BreakpointName::Permissions ::PermissionKinds purpose, + Args &new_args); private: BreakpointIDArray m_breakpoint_ids; diff --git a/lldb/source/Breakpoint/BreakpointIDList.cpp b/lldb/source/Breakpoint/BreakpointIDList.cpp index 05c461827cadd8..51185c30dabad8 100644 --- a/lldb/source/Breakpoint/BreakpointIDList.cpp +++ b/lldb/source/Breakpoint/BreakpointIDList.cpp @@ -11,9 +11,9 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" -#include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; @@ -93,12 +93,9 @@ bool BreakpointIDList::FindBreakpointID(const char *bp_id_str, // NEW_ARGS should be a copy of OLD_ARGS, with and ID range specifiers replaced // by the members of the range. -void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, - bool allow_locations, - BreakpointName::Permissions - ::PermissionKinds purpose, - CommandReturnObject &result, - Args &new_args) { +llvm::Error BreakpointIDList::FindAndReplaceIDRanges( +Args &old_args, Target *target, bool allow_locations, +BreakpointName::Permissions ::PermissionKinds purpose, Args &new_args) { llvm::StringRef range_from; llvm::StringRef range_to; llvm::StringRef current_arg; @@ -109,11 +106,11 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, current_arg = old_args[i].ref(); if (!allow_locations && current_arg.contains('.')) { - result.AppendErrorWithFormat( + new_args.Clear(); + return llvm::createStringError( + llvm::inconvertibleErrorCode(), "Breakpoint locations not allowed, saw location: %s.", current_arg.str().c_str()); - new_args.Clear(); - return; } Status error; @@ -125,8 +122,8 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, } else if (BreakpointID::StringIsBreakpointName(current_arg, error)) { if (!error.Success()) { new_args.Clear(); -result.AppendError(error.AsCString()); -return; +return llvm::createStringError(llvm::inconvertibleErrorCode(), + error.AsCString()); } else names_found.insert(std::string(current_arg)); } else if ((i + 2 < old_args.size()) && @@ -152,9 +149,10 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, breakpoint_sp = target->GetBreakpointByID(bp_id->GetBreakpointID()); if (!breakpoint_sp) { new_args.Clear(); -result.AppendErrorWithFormat("'%d' is not a valid breakpoint ID.\n", - bp_id->GetBreakpointID()); -return; +return llvm::createStringError( +llvm::inconvertibleErrorCode(), +
[Lldb-commits] [lldb] [lldb] Support dSYMs as modules (PR #77966)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r dd5ce4572fb90323799f1bdf585c01d08613e277...aa8cda04994699b23df3b5dd149d9204272aa74b lldb/test/API/macosx/dsym-module/TestTargetModuleAddDsym.py `` View the diff from darker here. ``diff --- TestTargetModuleAddDsym.py 2024-01-12 19:17:51.00 + +++ TestTargetModuleAddDsym.py 2024-01-12 19:22:06.356738 + @@ -3,21 +3,19 @@ from lldbsuite.test.lldbtest import * @skipUnlessDarwin class TargetModuleAddDsymTest(TestBase): - @no_debug_info_test def test_target_module_add(self): """Test that you can add a dSYM as a module.""" self.build(debug_info="dsym") exe_path = self.getBuildArtifact("a.out") dsym_path = exe_path + ".dSYM" -sym_path = os.path.join(dsym_path, 'Contents','Resources','DWARF','a.out') +sym_path = os.path.join(dsym_path, "Contents", "Resources", "DWARF", "a.out") exe = self.getBuildArtifact("a.out") self.dbg.CreateTarget(exe) self.runCmd("target module add %s" % sym_path) self.expect("image list", substrs=[sym_path]) - `` https://github.com/llvm/llvm-project/pull/77966 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support dSYMs as modules (PR #77966)
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 dd5ce4572fb90323799f1bdf585c01d08613e277 aa8cda04994699b23df3b5dd149d9204272aa74b -- lldb/test/API/macosx/dsym-module/main.c lldb/include/lldb/Symbol/ObjectFile.h lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h lldb/source/Symbol/ObjectFile.cpp lldb/source/Target/Target.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index d623476c4c..b5ecc68239 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -6128,7 +6128,7 @@ Section *ObjectFileMachO::GetMachHeaderSection() { return nullptr; } -bool ObjectFileMachO::CanBeTarget(Status *status ) { +bool ObjectFileMachO::CanBeTarget(Status *status) { if (m_header.filetype == MH_DSYM) return true; return ObjectFile::CanBeTarget(status); diff --git a/lldb/test/API/macosx/dsym-module/main.c b/lldb/test/API/macosx/dsym-module/main.c index b5c9a5152d..9cbfa1591e 100644 --- a/lldb/test/API/macosx/dsym-module/main.c +++ b/lldb/test/API/macosx/dsym-module/main.c @@ -1,5 +1,3 @@ #include -int main(int argc, char const *argv[]) { - return argc + 1; -} +int main(int argc, char const *argv[]) { return argc + 1; } `` https://github.com/llvm/llvm-project/pull/77966 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support dSYMs as modules (PR #77966)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/77966 >From ca65108fe01931482110bf6dabef1550fd6a307e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 11 Jan 2024 09:19:31 -0800 Subject: [PATCH 1/2] [lldb] Move CanBeTarget logic into the ObjectFile plugin (NFC) --- lldb/include/lldb/Symbol/ObjectFile.h | 4 lldb/source/Symbol/ObjectFile.cpp | 33 +++ lldb/source/Target/Target.cpp | 33 +++ 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index 6348d8103f85de..31dc43f469587f 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -698,6 +698,10 @@ class ObjectFile : public std::enable_shared_from_this, /// file to be complete. virtual bool CanTrustAddressRanges() { return false; } + /// Can this object file serve as a valid target module. If a Status is passed + /// and the answer is no, it will be populated with the reason. + virtual bool CanBeTargetModule(Status *status = nullptr); + static lldb::SymbolType GetSymbolTypeFromName( llvm::StringRef name, lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined); diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index d890ad92e83122..cc63c05a4c5ec8 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -764,6 +764,39 @@ uint32_t ObjectFile::GetCacheHash() { return *m_cache_hash; } +bool ObjectFile::CanBeTargetModule(Status *status) { + switch (GetType()) { + case ObjectFile::eTypeCoreFile: /// A core file that has a checkpoint of + /// a program's execution state + case ObjectFile::eTypeExecutable:/// A normal executable + case ObjectFile::eTypeDynamicLinker: /// The platform's dynamic linker + /// executable + case ObjectFile::eTypeObjectFile:/// An intermediate object file + case ObjectFile::eTypeSharedLibrary: /// A shared library that can be + /// used during execution +return true; + case ObjectFile::eTypeDebugInfo: /// An object file that contains only + /// debug information +if (status) + status->SetErrorString("debug info files aren't valid target " + "modules, please specify an executable"); +return false; + case ObjectFile::eTypeStubLibrary: /// A library that can be linked + /// against but not used for + /// execution +if (status) + status->SetErrorString("stub libraries aren't valid target " + "modules, please specify an executable"); +return false; + default: +if (status) + status->SetErrorString( + "unsupported file type, please specify an executable"); +return false; + } + llvm_unreachable("Fully covered switch above!"); +} + namespace llvm { namespace json { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 302c2bad7021b9..d0975d6c378c50 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -2254,37 +2254,10 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify, // there wasn't an equivalent module in the list already, and if there was, // let's remove it. if (module_sp) { - ObjectFile *objfile = module_sp->GetObjectFile(); - if (objfile) { -switch (objfile->GetType()) { -case ObjectFile::eTypeCoreFile: /// A core file that has a checkpoint of -/// a program's execution state -case ObjectFile::eTypeExecutable:/// A normal executable -case ObjectFile::eTypeDynamicLinker: /// The platform's dynamic linker - /// executable -case ObjectFile::eTypeObjectFile:/// An intermediate object file -case ObjectFile::eTypeSharedLibrary: /// A shared library that can be - /// used during execution - break; -case ObjectFile::eTypeDebugInfo: /// An object file that contains only - /// debug information - if (error_ptr) -error_ptr->SetErrorString("debug info files aren't valid target " - "modules, please specify an executable"); - return ModuleSP(); -case ObjectFile::eTypeStubLibrary: /// A library that can be linked - /// against but not used for - /// execution - if (error_ptr) -error_ptr->SetErrorString("stub libraries aren't
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
JDevlieghere wrote: > @JDevlieghere I created a new PR and closed #76683 because I made a mess with > a git rebase, and since the other PR had just started I thought it made sense > to start anew. I apologize for the confusion. Here I have already addressed > most of your comments from 76683. No worries, thanks for the quick turnaround! > What is left to do is to add tests with `GdbRemoteTestCaseBase` as you > suggested. 👍 > I've kept the support for `DW_OP_WASM_location` in this PR to have it fully > working, but I'll be happy to hoist it out in a separate patch with its own > dedicated test, if so you prefer. I'd vote to break it out, it can stand on its own and needs a test anyway. As an added benefit that probably means it gets merged sooner than this larger patch. > @xujuntwt95329, from WebAssembly Micro Runtime, has hugely contributed to > this work, but I cannot add his name to the reviewers or assignees. Yeah, I believe you must be a member of the project to be listed there. @xujuntwt95329 if reply or interact with the thread they should become a subscriber and get notifications. Maybe they already do given the mention. Regardless, thank you for your contribution! https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
paolosevMSFT wrote: @JDevlieghere Thank you! I will remove the code that handles DW_OP_WASM_location as you suggest. For what concerns testing, I took a very quick look at `GdbRemoteTestCaseBase` and if I am not wrong, it works by spawning an inferior processor attaching to an inferior process to debug. But it relies on the fact that it can use lldb-server, which implements the server-side of the gdb-remote protocol. But here we need to attach to a Wasm engine, and obviously, we cannot implement a Wasm engine as part of the LLDB test code. Maybe we should implement a process that mocks the gdb-stub logic for a Wasm engine? Is there anything we could reuse in the LLDB test framework? https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
JDevlieghere wrote: > @JDevlieghere Thank you! > > I will remove the code that handles DW_OP_WASM_location as you suggest. Given we don't have a good solution for stacked commits, you don't necessarily need to remove it here, and rebase it once the other PR has been merged. > For what concerns testing, I took a very quick look at > `GdbRemoteTestCaseBase` and if I am not wrong, it works by spawning an > inferior processor attaching to an inferior process to debug. But it relies > on the fact that it can use lldb-server, which implements the server-side of > the gdb-remote protocol. But here we need to attach to a Wasm engine, and > obviously, we cannot implement a Wasm engine as part of the LLDB test code. > Maybe we should implement a process that mocks the gdb-stub logic for a Wasm > engine? Is there anything we could reuse in the LLDB test framework? You're right that there are tests that work like that and indeed, that wouldn't work for this. If you look for tests that use the `GdbRemoteTestCaseBase` you can basically spoof the other end of the GDB remote connection. You can have it respond to packets the way your real GDB stub would. You can make it as advanced or simple as you want. There's a bunch of examples in `test/API/functionalities/gdb_remote_client`. What I would do is debug a simple program using the real GDB stub and look at the gdb packet log in lldb to give you an idea what the server responds. Then I would try to mimic the debug session in the tests and implement responses from the mock server. You want to keep things as small as possible so you don't want to avoid just copy/pasting full responses (they likely wouldn't work anyway) but the real packets can serve as inspiration. https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [libcxx] [compiler-rt] [llvm] [libc] [lldb] [lld] [clang-tools-extra] [clang] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)
https://github.com/rampitec updated https://github.com/llvm/llvm-project/pull/74537 >From 7e382620cdc5999c645ed0746f242595f0294c58 Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Mon, 4 Dec 2023 16:11:53 -0800 Subject: [PATCH 01/10] [AMDGPU] Use alias info to relax waitcounts for LDS DMA LDA DMA loads increase VMCNT and a load from the LDS stored must wait on this counter to only read memory after it is written. Wait count insertion pass does not track memory dependencies, it tracks register dependencies. To model the LDS dependency a psuedo register is used in the scoreboard, acting like if LDS DMA writes it and LDS load reads it. This patch adds 8 more pseudo registers to use for independent LDS locations if we can prove they are disjoint using alias analysis. Fixes: SWDEV-433427 --- llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 16 +- llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp | 73 +- llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | 4 +- llvm/lib/Target/AMDGPU/SIInstrInfo.h| 8 + llvm/lib/Target/AMDGPU/lds-dma-waits.ll | 154 llvm/test/CodeGen/AMDGPU/llc-pipeline.ll| 2 + 6 files changed, 241 insertions(+), 16 deletions(-) create mode 100644 llvm/lib/Target/AMDGPU/lds-dma-waits.ll diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index a7f4d63229b7ef..2e079404b087fa 100644 --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -1128,11 +1128,10 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info, MachineMemOperand::MOStore | MachineMemOperand::MODereferenceable; - // XXX - Should this be volatile without known ordering? - Info.flags |= MachineMemOperand::MOVolatile; - switch (IntrID) { default: +// XXX - Should this be volatile without known ordering? +Info.flags |= MachineMemOperand::MOVolatile; break; case Intrinsic::amdgcn_raw_buffer_load_lds: case Intrinsic::amdgcn_raw_ptr_buffer_load_lds: @@ -1140,6 +1139,7 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info, case Intrinsic::amdgcn_struct_ptr_buffer_load_lds: { unsigned Width = cast(CI.getArgOperand(2))->getZExtValue(); Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8); +Info.ptrVal = CI.getArgOperand(1); return true; } } @@ -1268,8 +1268,8 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info, Info.opc = ISD::INTRINSIC_VOID; unsigned Width = cast(CI.getArgOperand(2))->getZExtValue(); Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8); -Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore | - MachineMemOperand::MOVolatile; +Info.ptrVal = CI.getArgOperand(1); +Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore; return true; } case Intrinsic::amdgcn_ds_bvh_stack_rtn: { @@ -9084,7 +9084,9 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op, MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo(); MachinePointerInfo StorePtrI = LoadPtrI; -StorePtrI.V = nullptr; +LoadPtrI.V = UndefValue::get( +PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS)); +LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS; StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS; auto F = LoadMMO->getFlags() & @@ -9162,6 +9164,8 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op, MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo(); LoadPtrI.Offset = Op->getConstantOperandVal(5); MachinePointerInfo StorePtrI = LoadPtrI; +LoadPtrI.V = UndefValue::get( +PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS)); LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS; StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS; auto F = LoadMMO->getFlags() & diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp index ede4841b8a5fd7..50ad22130e939e 100644 --- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp +++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp @@ -31,6 +31,7 @@ #include "llvm/ADT/MapVector.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/Sequence.h" +#include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/MachinePostDominators.h" #include "llvm/InitializePasses.h" @@ -121,8 +122,13 @@ enum RegisterMapping { SQ_MAX_PGM_VGPRS = 512, // Maximum programmable VGPRs across all targets. AGPR_OFFSET = 256, // Maximum programmable ArchVGPRs across all targets. SQ_MAX_PGM_SGPRS = 256, // Maximum programmable SGPRs across all targets. - NUM_EXTRA_VGPRS = 1,// A reserved slot for DS. - EXTRA_VGPR_LDS = 0, // An artificial register to track LDS writes. + NUM_EXTRA_VGPRS = 9,// Reserved slots
[Lldb-commits] [flang] [libcxx] [compiler-rt] [llvm] [libc] [lldb] [lld] [clang-tools-extra] [clang] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)
@@ -130,6 +130,8 @@ ; GCN-O0-NEXT:MachineDominator Tree Construction ; GCN-O0-NEXT:Machine Natural Loop Construction ; GCN-O0-NEXT:MachinePostDominator Tree Construction +; GCN-O0-NEXT:Basic Alias Analysis (stateless AA impl) +; GCN-O0-NEXT:Function Alias Analysis Results rampitec wrote: If I just skip getAnalysis call it does not help since analysis is requested in the getAnalysisUsage. If I do not request it it is not available at any optlevel. This is the benefit of the alternative https://github.com/llvm/llvm-project/pull/75974, it does not request the full analysis. https://github.com/llvm/llvm-project/pull/74537 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adjust DynamicLoaderDarwin::GetThreadLocalData to support changes to TLS on macOS (PR #77854)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/77854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [libcxx] [compiler-rt] [llvm] [libc] [lldb] [lld] [clang-tools-extra] [clang] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)
@@ -1183,9 +1228,21 @@ bool SIInsertWaitcnts::generateWaitcntInstBefore(MachineInstr &MI, // No need to wait before load from VMEM to LDS. if (TII->mayWriteLDSThroughDMA(MI)) continue; -unsigned RegNo = SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS; + // VM_CNT is only relevant to vgpr or LDS. -ScoreBrackets.determineWait(VM_CNT, RegNo, Wait); +unsigned RegNo = SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS; +bool FoundAliasingStore = false; +if (Ptr && Memop->getAAInfo() && Memop->getAAInfo().Scope) { rampitec wrote: I have reserved just 8 pseudo registers to track it. I do not want to fill it with unrelated stuff. I know that the only way AA will be able to handle this very specific situation is if there is scope info, otherwise there is no reason to waste a slot and compile time. If I do not enter this 'if' the pass will just do conservatively correct thing and wait for this memory regardless of aliasing or lack of it. https://github.com/llvm/llvm-project/pull/74537 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [flang] [libc] [lldb] [compiler-rt] [lld] [llvm] [libcxx] [clang] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)
@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII, setRegScore(RegNo, T, CurrScore); } } -if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) { - setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore); +if (Inst.mayStore() && +(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) { + // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS + // written can be accessed. A load from LDS to VMEM does not need a wait. + unsigned Slot = 0; + for (const auto *MemOp : Inst.memoperands()) { +if (!MemOp->isStore() || +MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS) + continue; +// Comparing just AA info does not guarantee memoperands are equal rampitec wrote: Right, there is no PSV. I have mentioned PSV because you have earlier suggested to use it. For the real IR value: it is not helpful to compare it. The IR value is a GEP, and this GEP is always different. I.e. these values never compare equal. The rest of the IR is already gone and unavailable for the analysis. Even if it would be available this GEP will address kernel module LDS variable, a single huge LDS array, and will be useless again. In this case it will tell you any LDS operation aliases any other. Now during the module LDS lowering I am creating alias scope info specifically to disambiguate aliasing after the pass has squashed all LDS variables. https://github.com/llvm/llvm-project/pull/74537 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adjust DynamicLoaderDarwin::GetThreadLocalData to support changes to TLS on macOS (PR #77854)
clayborg wrote: It will be nice to not have the TLS test failing on macOS anymore! https://github.com/llvm/llvm-project/pull/77854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/77026 >From 52d6dc8f26477b8fba839194ac1485274312a865 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Thu, 4 Jan 2024 15:42:35 -0800 Subject: [PATCH] [lldb-dap] Updating VariableDescription to use GetDescription() for hover and repl DAP evaluate requests. When generating a `display_value` for a variable the current approach calls `SBValue::GetValue()` and `SBValue::GetSummary()` to generate a `display_value` for the `SBValue`. However, there are cases where both of these return an empty string and the fallback is to print a pointer and type name instead (e.g. "FooBarType @ 0x00321"). For swift types, lldb includes a langauge runtime plugin that can generate a user description of the object but this is only used with `SBValue::GetDescription()`. For example: ``` $ lldb swift-binary ... stop at breakpoint ... lldb> script >>> event = lldb.frame.GetValueForVariablePath("event") >>> print("Value", event.GetValue()) Value None >>> print("Summary", event.GetSummary()) Summary None >>> print("Description", event) Description (main.Event) event = (name = "Greetings", time = 2024-01-04 23:38:06 UTC) ``` With this change we now call SBValue::GetDescription() which will internally include a summary (if configured) or call into a language runtime to return a formatted description of the value. --- .../lldb-dap/evaluate/TestDAP_evaluate.py | 61 +-- .../lldb-dap/variables/TestDAP_variables.py | 149 +- .../API/tools/lldb-dap/variables/main.cpp | 2 +- lldb/tools/lldb-dap/JSONUtils.cpp | 49 -- lldb/tools/lldb-dap/JSONUtils.h | 3 + lldb/tools/lldb-dap/lldb-dap.cpp | 2 +- 6 files changed, 200 insertions(+), 66 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index de9d2c93a1109d..7651a67b643094 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -2,6 +2,7 @@ Test lldb-dap completions request """ +import re import lldbdap_testcase import dap_server @@ -10,7 +11,7 @@ from lldbsuite.test.lldbtest import * -class TestDAP_variables(lldbdap_testcase.DAPTestCaseBase): +class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase): def assertEvaluate(self, expression, regex): self.assertRegexpMatches( self.dap_server.request_evaluate(expression, context=self.context)["body"][ @@ -25,6 +26,9 @@ def assertEvaluateFailure(self, expression): self.dap_server.request_evaluate(expression, context=self.context)["body"], ) +def isResultExpandedDescription(self): +return self.context == "repl" or self.context == "hover" + def isExpressionParsedExpected(self): return self.context != "hover" @@ -59,16 +63,30 @@ def run_test_evaluate_expressions( self.assertEvaluate("var2", "21") self.assertEvaluate("static_int", "42") self.assertEvaluate("non_static_int", "43") -self.assertEvaluate( -"struct1", "{foo:15}" if enableAutoVariableSummaries else "my_struct @ 0x" -) -self.assertEvaluate( -"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else "0x.*" -) -self.assertEvaluate("struct3", "0x.*0") self.assertEvaluate("struct1.foo", "15") self.assertEvaluate("struct2->foo", "16") +if self.isResultExpandedDescription(): +self.assertEvaluate( +"struct1", +r"\(my_struct\) (struct1|\$\d+) = \(foo = 15\)", +) +self.assertEvaluate("struct2", r"\(my_struct \*\) (struct2|\$\d+) = 0x.*") +self.assertEvaluate( +"struct3", r"\(my_struct \*\) (struct3|\$\d+) = nullptr" +) +else: +self.assertEvaluate( +"struct1", +re.escape("{foo:15}") +if enableAutoVariableSummaries +else "my_struct @ 0x", +) +self.assertEvaluate( +"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else "0x.*" +) +self.assertEvaluate("struct3", "0x.*0") + self.assertEvaluateFailure("var") # local variable of a_function self.assertEvaluateFailure("my_struct") # type name self.assertEvaluateFailure("int") # type name @@ -95,9 +113,18 @@ def run_test_evaluate_expressions( self.assertEvaluate( "non_static_int", "10" ) # different variable with the same name -self.assertEvaluate( -"struct1", "{foo:15}" if enableAutoVariableSummaries else "my_struct @ 0x" -) +if self.isResultExpandedDescription(): +self.assertEvaluate( +"struct1", +r"\(my_st
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/77026 >From 56d1520f2ce7eb9a9f0c5b5c199deefab15dadfa Mon Sep 17 00:00:00 2001 From: John Harrison Date: Thu, 4 Jan 2024 15:42:35 -0800 Subject: [PATCH] [lldb-dap] Updating VariableDescription to use GetDescription() for hover and repl DAP evaluate requests. When generating a `display_value` for a variable the current approach calls `SBValue::GetValue()` and `SBValue::GetSummary()` to generate a `display_value` for the `SBValue`. However, there are cases where both of these return an empty string and the fallback is to print a pointer and type name instead (e.g. "FooBarType @ 0x00321"). For swift types, lldb includes a langauge runtime plugin that can generate a user description of the object but this is only used with `SBValue::GetDescription()`. For example: ``` $ lldb swift-binary ... stop at breakpoint ... lldb> script >>> event = lldb.frame.GetValueForVariablePath("event") >>> print("Value", event.GetValue()) Value None >>> print("Summary", event.GetSummary()) Summary None >>> print("Description", event) Description (main.Event) event = (name = "Greetings", time = 2024-01-04 23:38:06 UTC) ``` With this change we now call SBValue::GetDescription() which will internally include a summary (if configured) or call into a language runtime to return a formatted description of the value. --- .../lldb-dap/evaluate/TestDAP_evaluate.py | 61 +-- .../lldb-dap/variables/TestDAP_variables.py | 149 +- .../API/tools/lldb-dap/variables/main.cpp | 2 +- lldb/tools/lldb-dap/JSONUtils.cpp | 51 -- lldb/tools/lldb-dap/JSONUtils.h | 3 + lldb/tools/lldb-dap/lldb-dap.cpp | 2 +- 6 files changed, 202 insertions(+), 66 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index de9d2c93a1109d..7651a67b643094 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -2,6 +2,7 @@ Test lldb-dap completions request """ +import re import lldbdap_testcase import dap_server @@ -10,7 +11,7 @@ from lldbsuite.test.lldbtest import * -class TestDAP_variables(lldbdap_testcase.DAPTestCaseBase): +class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase): def assertEvaluate(self, expression, regex): self.assertRegexpMatches( self.dap_server.request_evaluate(expression, context=self.context)["body"][ @@ -25,6 +26,9 @@ def assertEvaluateFailure(self, expression): self.dap_server.request_evaluate(expression, context=self.context)["body"], ) +def isResultExpandedDescription(self): +return self.context == "repl" or self.context == "hover" + def isExpressionParsedExpected(self): return self.context != "hover" @@ -59,16 +63,30 @@ def run_test_evaluate_expressions( self.assertEvaluate("var2", "21") self.assertEvaluate("static_int", "42") self.assertEvaluate("non_static_int", "43") -self.assertEvaluate( -"struct1", "{foo:15}" if enableAutoVariableSummaries else "my_struct @ 0x" -) -self.assertEvaluate( -"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else "0x.*" -) -self.assertEvaluate("struct3", "0x.*0") self.assertEvaluate("struct1.foo", "15") self.assertEvaluate("struct2->foo", "16") +if self.isResultExpandedDescription(): +self.assertEvaluate( +"struct1", +r"\(my_struct\) (struct1|\$\d+) = \(foo = 15\)", +) +self.assertEvaluate("struct2", r"\(my_struct \*\) (struct2|\$\d+) = 0x.*") +self.assertEvaluate( +"struct3", r"\(my_struct \*\) (struct3|\$\d+) = nullptr" +) +else: +self.assertEvaluate( +"struct1", +re.escape("{foo:15}") +if enableAutoVariableSummaries +else "my_struct @ 0x", +) +self.assertEvaluate( +"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else "0x.*" +) +self.assertEvaluate("struct3", "0x.*0") + self.assertEvaluateFailure("var") # local variable of a_function self.assertEvaluateFailure("my_struct") # type name self.assertEvaluateFailure("int") # type name @@ -95,9 +113,18 @@ def run_test_evaluate_expressions( self.assertEvaluate( "non_static_int", "10" ) # different variable with the same name -self.assertEvaluate( -"struct1", "{foo:15}" if enableAutoVariableSummaries else "my_struct @ 0x" -) +if self.isResultExpandedDescription(): +self.assertEvaluate( +"struct1", +r"\(my_st
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
@@ -173,21 +173,21 @@ TryCreateAutoSummaryForContainer(lldb::SBValue &v) { lldb::SBValue child = v.GetChildAtIndex(i); if (llvm::StringRef name = child.GetName(); !name.empty()) { - llvm::StringRef value; + llvm::StringRef desc; if (llvm::StringRef summary = child.GetSummary(); !summary.empty()) -value = summary; +desc = summary; + else if (llvm::StringRef value = child.GetValue(); !value.empty()) +desc = value; else -value = child.GetValue(); - - if (!value.empty()) { -// If the child is an indexed entry, we don't show its index to save -// characters. -if (name.starts_with("[")) - os << separator << value; -else - os << separator << name << ":" << value; -separator = ", "; - } +desc = "{...}"; // Fallback for nested types. ashgti wrote: Updated this to use the `{...}` for nested types. https://github.com/llvm/llvm-project/pull/77026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
@@ -405,6 +405,9 @@ struct VariableDescription { /// Create a JSON object that represents these extensions to the DAP variable /// response. llvm::json::Object GetVariableExtensionsJSON(); + + /// Returns a description of the value appropraite for the specified context. ashgti wrote: Done. https://github.com/llvm/llvm-project/pull/77026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
@@ -1210,15 +1210,16 @@ bool SBValue::GetDescription(SBStream &description) { ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); - if (value_sp) { -DumpValueObjectOptions options; -options.SetUseDynamicType(m_opaque_sp->GetUseDynamic()); -options.SetUseSyntheticValue(m_opaque_sp->GetUseSynthetic()); -value_sp->Dump(strm, options); - } else { + if (!value_sp) { strm.PutCString("No value"); ashgti wrote: I reverted this change and instead just check `IsValid()` before we call into `GetDescription()`. https://github.com/llvm/llvm-project/pull/77026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support dSYMs as modules (PR #77966)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/77966 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support dSYMs as modules (PR #77966)
https://github.com/clayborg commented: If a module is debug info only, like a dSYM file, and then you try to `target module add` it to a target, it would be nice to add it as the symbol file for an already existing module. The test below, I wouldn't want a target with two things representing a.out, which is what is happening. This can cause lookups to return less valuable results because we will always match `a.out` first, which has no debug info. Would it be better to be modify "target symbols add" to allow it to add the symbol file as a module if it returns `true` from a call to "ObjectFile::CanBeTargetModule(...)" but only if there are no matching modules to add the symbol file to? https://github.com/llvm/llvm-project/pull/77966 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support dSYMs as modules (PR #77966)
@@ -0,0 +1,21 @@ +import os +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * + + +@skipUnlessDarwin +class TargetModuleAddDsymTest(TestBase): +@no_debug_info_test +def test_target_module_add(self): +"""Test that you can add a dSYM as a module.""" +self.build(debug_info="dsym") + +exe_path = self.getBuildArtifact("a.out") +dsym_path = exe_path + ".dSYM" +sym_path = os.path.join(dsym_path, "Contents", "Resources", "DWARF", "a.out") + +exe = self.getBuildArtifact("a.out") +self.dbg.CreateTarget(exe) clayborg wrote: This creates a target with `a.out`, then adds another module which represents the exact same with from withing `a.out.dSYM`. If you build a target like this, and then load the sections in both, then lookups will always find the `a.out` first when resolving addresses. https://github.com/llvm/llvm-project/pull/77966 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support dSYMs as modules (PR #77966)
@@ -0,0 +1,21 @@ +import os +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * + + +@skipUnlessDarwin +class TargetModuleAddDsymTest(TestBase): +@no_debug_info_test +def test_target_module_add(self): +"""Test that you can add a dSYM as a module.""" +self.build(debug_info="dsym") + +exe_path = self.getBuildArtifact("a.out") +dsym_path = exe_path + ".dSYM" +sym_path = os.path.join(dsym_path, "Contents", "Resources", "DWARF", "a.out") + +exe = self.getBuildArtifact("a.out") +self.dbg.CreateTarget(exe) JDevlieghere wrote: Yes, the test isn't meant to be particularly useful, it's mostly here to prove that the functionality works. https://github.com/llvm/llvm-project/pull/77966 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support dSYMs as modules (PR #77966)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/77966 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxxabi] [clang-tools-extra] [flang] [lldb] [libcxx] [clang] [libclc] [libunwind] [libc] [llvm] [compiler-rt] [lld] [builtins] Generate __multc3 for z/OS (PR #77554)
@@ -374,10 +376,10 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { #endif } -#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE) +#elif defined(QUAD_PRECISION) perry-ca wrote: I've put up #77981 for review. https://github.com/llvm/llvm-project/pull/77554 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
https://github.com/clayborg approved this pull request. https://github.com/llvm/llvm-project/pull/77026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [flang] [openmp] [libcxx] [clang] [libc] [llvm] [mlir] [BOLT] Embed cold mapping info into function entry in BAT (PR #76903)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/76903 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [flang] [openmp] [libcxx] [clang] [libc] [llvm] [mlir] [BOLT] Embed cold mapping info into function entry in BAT (PR #76903)
https://github.com/aaupov closed https://github.com/llvm/llvm-project/pull/76903 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Progress] Separate title and details (PR #77547)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/77547 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Progress] Separate title and details (PR #77547)
@@ -35,25 +42,28 @@ Progress::~Progress() { ReportProgress(); } -void Progress::Increment(uint64_t amount, std::string update) { +void Progress::Increment(uint64_t amount, + std::optional updated_detail) { if (amount > 0) { std::lock_guard guard(m_mutex); +if (updated_detail) + m_details = std::move(updated_detail.value()); // Watch out for unsigned overflow and make sure we don't increment too // much and exceed m_total. -if (amount > (m_total - m_completed)) +if (m_total && (amount > (m_total - m_completed))) m_completed = m_total; else m_completed += amount; -ReportProgress(update); +ReportProgress(); } } -void Progress::ReportProgress(std::string update) { +void Progress::ReportProgress() { if (!m_complete) { // Make sure we only send one notification that indicates the progress is -// complete. +// complete, and only modify m_complete is m_total isn't null. clayborg wrote: Is the comment out of date? revert comment? https://github.com/llvm/llvm-project/pull/77547 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Progress] Separate title and details (PR #77547)
https://github.com/clayborg approved this pull request. Thanks for the changes. On comment might be able to be reverted, but this looks good. https://github.com/llvm/llvm-project/pull/77547 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e27561f - [lldb] Move MD5 Checksum from FileSpec to SupportFile
Author: Jonas Devlieghere Date: 2024-01-12T13:08:24-08:00 New Revision: e27561fc7de0231f2efdb750f2092c3ac807c1a3 URL: https://github.com/llvm/llvm-project/commit/e27561fc7de0231f2efdb750f2092c3ac807c1a3 DIFF: https://github.com/llvm/llvm-project/commit/e27561fc7de0231f2efdb750f2092c3ac807c1a3.diff LOG: [lldb] Move MD5 Checksum from FileSpec to SupportFile When I added the MD5 checksum I was on the fence between storing it in FileSpec or creating a new SupportFile abstraction. The latter was deemed overkill for just the MD5 hashes, but support for inline sources in the DWARF 5 line table tipped the scales. This patch moves the MD5 checksum into the new SupportFile class. Added: Modified: lldb/include/lldb/Utility/FileSpec.h lldb/include/lldb/Utility/FileSpecList.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Utility/FileSpec.cpp lldb/unittests/Utility/FileSpecTest.cpp Removed: diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h index e4276e8398b464..2e867b2b40b94f 100644 --- a/lldb/include/lldb/Utility/FileSpec.h +++ b/lldb/include/lldb/Utility/FileSpec.h @@ -13,7 +13,6 @@ #include #include -#include "lldb/Utility/Checksum.h" #include "lldb/Utility/ConstString.h" #include "llvm/ADT/StringRef.h" @@ -72,12 +71,8 @@ class FileSpec { /// \param[in] style /// The style of the path /// - /// \param[in] checksum - /// The MD5 checksum of the path. - /// /// \see FileSpec::SetFile (const char *path) - explicit FileSpec(llvm::StringRef path, Style style = Style::native, -const Checksum &checksum = {}); + explicit FileSpec(llvm::StringRef path, Style style = Style::native); explicit FileSpec(llvm::StringRef path, const llvm::Triple &triple); @@ -367,11 +362,7 @@ class FileSpec { /// /// \param[in] style /// The style for the given path. - /// - /// \param[in] checksum - /// The checksum for the given path. - void SetFile(llvm::StringRef path, Style style, - const Checksum &checksum = {}); + void SetFile(llvm::StringRef path, Style style); /// Change the file specified with a new path. /// @@ -414,19 +405,13 @@ class FileSpec { /// The lifetime of the StringRefs is tied to the lifetime of the FileSpec. std::vector GetComponents() const; - /// Return the checksum for this FileSpec or all zeros if there is none. - const Checksum &GetChecksum() const { return m_checksum; }; - protected: // Convenience method for setting the file without changing the style. void SetFile(llvm::StringRef path); /// Called anytime m_directory or m_filename is changed to clear any cached /// state in this object. - void PathWasModified() { -m_checksum = Checksum(); -m_absolute = Absolute::Calculate; - } + void PathWasModified() { m_absolute = Absolute::Calculate; } enum class Absolute : uint8_t { Calculate, @@ -440,9 +425,6 @@ class FileSpec { /// The unique'd filename path. ConstString m_filename; - /// The optional MD5 checksum of the file. - Checksum m_checksum; - /// Cache whether this path is absolute. mutable Absolute m_absolute = Absolute::Calculate; diff --git a/lldb/include/lldb/Utility/FileSpecList.h b/lldb/include/lldb/Utility/FileSpecList.h index 8cccb19417..c1107ad1135dd2 100644 --- a/lldb/include/lldb/Utility/FileSpecList.h +++ b/lldb/include/lldb/Utility/FileSpecList.h @@ -9,6 +9,7 @@ #ifndef LLDB_CORE_FILESPECLIST_H #define LLDB_CORE_FILESPECLIST_H +#include "lldb/Utility/Checksum.h" #include "lldb/Utility/FileSpec.h" #include @@ -24,17 +25,22 @@ class Stream; class SupportFile { protected: FileSpec m_file_spec; + Checksum m_checksum; public: - SupportFile(const FileSpec &spec) : m_file_spec(spec) {} + SupportFile(const FileSpec &spec) : m_file_spec(spec), m_checksum() {} + SupportFile(const FileSpec &spec, const Checksum &checksum) + : m_file_spec(spec), m_checksum(checksum) {} SupportFile(const SupportFile &other) = delete; SupportFile(SupportFile &&other) = default; virtual ~SupportFile() = default; bool operator==(const SupportFile &other) { -return m_file_spec == other.m_file_spec; +return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum; } /// Return the file name only. Useful for resolving breakpoints by file name. const FileSpec &GetSpecOnly() const { return m_file_spec; }; + /// Return the checksum or all zeros if there is none. + const Checksum &GetChecksum() const { return m_checksum; }; /// Materialize the file to disk and return the path to that temporary file. virtual const FileSpec &Materialize() { return m_file_spec; } }; @@ -90,7 +96,7 @@ class SupportFileList { template void EmplaceBack(Args &&...args) { m_files.push_back( -std::make_unique(FileSpec(
[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)
https://github.com/bulbazord created https://github.com/llvm/llvm-project/pull/77988 I decided to resubmit #77854 but broken up into multiple commits for better reviewability. I recommend reviewing each commit individually, the overall change is quite large. rdar://120676969 >From cf2597f907fd2566e202d763a91834515d9c8ae4 Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Fri, 12 Jan 2024 13:03:27 -0800 Subject: [PATCH 1/3] [lldb][NFCI] Re-organize DynamicLoaderDarwin::GetThreadLocalData This is a small re-organization of GetThreadLocalData. This makes it easier for me to add support for a newer way of getting thread local data on apple platforms. --- .../MacOSX-DYLD/DynamicLoaderDarwin.cpp | 120 +- 1 file changed, 59 insertions(+), 61 deletions(-) diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index 1e3e2e5641ad83..2deb7663b42e02 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -1048,70 +1048,68 @@ DynamicLoaderDarwin::GetThreadLocalData(const lldb::ModuleSP module_sp, std::lock_guard guard(m_mutex); + lldb_private::Address tls_addr; + if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) +return LLDB_INVALID_ADDRESS; + const uint32_t addr_size = m_process->GetAddressByteSize(); uint8_t buf[sizeof(lldb::addr_t) * 3]; + Status error; + const size_t tls_data_size = addr_size * 3; + Target &target = m_process->GetTarget(); + const size_t bytes_read = target.ReadMemory( + tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true); + if (bytes_read != tls_data_size || error.Fail()) +return LLDB_INVALID_ADDRESS; - lldb_private::Address tls_addr; - if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) { -Status error; -const size_t tsl_data_size = addr_size * 3; -Target &target = m_process->GetTarget(); -if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) == -tsl_data_size) { - const ByteOrder byte_order = m_process->GetByteOrder(); - DataExtractor data(buf, sizeof(buf), byte_order, addr_size); - lldb::offset_t offset = addr_size; // Skip the first pointer - const lldb::addr_t pthread_key = data.GetAddress(&offset); - const lldb::addr_t tls_offset = data.GetAddress(&offset); - if (pthread_key != 0) { -// First check to see if we have already figured out the location of -// TLS data for the pthread_key on a specific thread yet. If we have we -// can re-use it since its location will not change unless the process -// execs. -const tid_t tid = thread_sp->GetID(); -auto tid_pos = m_tid_to_tls_map.find(tid); -if (tid_pos != m_tid_to_tls_map.end()) { - auto tls_pos = tid_pos->second.find(pthread_key); - if (tls_pos != tid_pos->second.end()) { -return tls_pos->second + tls_offset; - } -} -StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0); -if (frame_sp) { - TypeSystemClangSP scratch_ts_sp = - ScratchTypeSystemClang::GetForTarget(target); - - if (!scratch_ts_sp) -return LLDB_INVALID_ADDRESS; - - CompilerType clang_void_ptr_type = - scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType(); - Address pthread_getspecific_addr = GetPthreadSetSpecificAddress(); - if (pthread_getspecific_addr.IsValid()) { -EvaluateExpressionOptions options; - -lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction( -*thread_sp, pthread_getspecific_addr, clang_void_ptr_type, -llvm::ArrayRef(pthread_key), options)); - -DiagnosticManager execution_errors; -ExecutionContext exe_ctx(thread_sp); -lldb::ExpressionResults results = m_process->RunThreadPlan( -exe_ctx, thread_plan_sp, options, execution_errors); - -if (results == lldb::eExpressionCompleted) { - lldb::ValueObjectSP result_valobj_sp = - thread_plan_sp->GetReturnValueObject(); - if (result_valobj_sp) { -const lldb::addr_t pthread_key_data = -result_valobj_sp->GetValueAsUnsigned(0); -if (pthread_key_data) { - m_tid_to_tls_map[tid].insert( - std::make_pair(pthread_key, pthread_key_data)); - return pthread_key_data + tls_offset; -} - } -} + DataExtractor data(buf, sizeof(buf), m_process->GetByteOrder(), addr_size); + lldb::offset_t offset = addr_size; // Skip the first pointer + const lldb::addr_t pthread_key = data.GetAddress(&offset); + const lldb::addr_t tls_offset = data.GetAddress(&of
[Lldb-commits] [lldb] [lldb] Adjust DynamicLoaderDarwin::GetThreadLocalData to support changes to TLS on macOS (PR #77854)
https://github.com/bulbazord closed https://github.com/llvm/llvm-project/pull/77854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adjust DynamicLoaderDarwin::GetThreadLocalData to support changes to TLS on macOS (PR #77854)
bulbazord wrote: I broke up this PR into multiple commits and resubmitted at https://github.com/llvm/llvm-project/pull/77988. Please take a look! https://github.com/llvm/llvm-project/pull/77854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Alex Langford (bulbazord) Changes I decided to resubmit #77854 but broken up into multiple commits for better reviewability. I recommend reviewing each commit individually, the overall change is quite large. rdar://120676969 --- Full diff: https://github.com/llvm/llvm-project/pull/77988.diff 1 Files Affected: - (modified) lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+92-63) ``diff diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index 1e3e2e5641ad83..3bfa3778ad8f9c 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -1048,74 +1048,103 @@ DynamicLoaderDarwin::GetThreadLocalData(const lldb::ModuleSP module_sp, std::lock_guard guard(m_mutex); + lldb_private::Address tls_addr; + if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) +return LLDB_INVALID_ADDRESS; + + Target &target = m_process->GetTarget(); + TypeSystemClangSP scratch_ts_sp = + ScratchTypeSystemClang::GetForTarget(target); + if (!scratch_ts_sp) +return LLDB_INVALID_ADDRESS; + + CompilerType clang_void_ptr_type = + scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType(); + + auto evaluate_tls_address = [this, &thread_sp, &clang_void_ptr_type]( + Address func_ptr, + llvm::ArrayRef args) -> lldb::addr_t { +EvaluateExpressionOptions options; + +lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction( +*thread_sp, func_ptr, clang_void_ptr_type, args, options)); + +DiagnosticManager execution_errors; +ExecutionContext exe_ctx(thread_sp); +lldb::ExpressionResults results = m_process->RunThreadPlan( +exe_ctx, thread_plan_sp, options, execution_errors); + +if (results == lldb::eExpressionCompleted) { + if (lldb::ValueObjectSP result_valobj_sp = + thread_plan_sp->GetReturnValueObject()) { +return result_valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); + } +} +return LLDB_INVALID_ADDRESS; + }; + + // On modern apple platforms, there is a small data structure that looks + // approximately like this: + // struct TLS_Thunk { + // void *(*get_addr)(struct TLS_Thunk *); + // size_t key; + // size_t offset; + // } + // + // The strategy is to take get_addr, call it with the address of the + // containing TLS_Thunk structure, and add the offset to the resulting + // pointer to get the data block. + // + // On older apple platforms, the key is treated as a pthread_key_t and passed + // to pthread_getspecific. The pointer returned from that call is added to + // offset to get the relevant data block. + const uint32_t addr_size = m_process->GetAddressByteSize(); uint8_t buf[sizeof(lldb::addr_t) * 3]; + Status error; + const size_t tls_data_size = addr_size * 3; + const size_t bytes_read = target.ReadMemory( + tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true); + if (bytes_read != tls_data_size || error.Fail()) +return LLDB_INVALID_ADDRESS; - lldb_private::Address tls_addr; - if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) { -Status error; -const size_t tsl_data_size = addr_size * 3; -Target &target = m_process->GetTarget(); -if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) == -tsl_data_size) { - const ByteOrder byte_order = m_process->GetByteOrder(); - DataExtractor data(buf, sizeof(buf), byte_order, addr_size); - lldb::offset_t offset = addr_size; // Skip the first pointer - const lldb::addr_t pthread_key = data.GetAddress(&offset); - const lldb::addr_t tls_offset = data.GetAddress(&offset); - if (pthread_key != 0) { -// First check to see if we have already figured out the location of -// TLS data for the pthread_key on a specific thread yet. If we have we -// can re-use it since its location will not change unless the process -// execs. -const tid_t tid = thread_sp->GetID(); -auto tid_pos = m_tid_to_tls_map.find(tid); -if (tid_pos != m_tid_to_tls_map.end()) { - auto tls_pos = tid_pos->second.find(pthread_key); - if (tls_pos != tid_pos->second.end()) { -return tls_pos->second + tls_offset; - } -} -StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0); -if (frame_sp) { - TypeSystemClangSP scratch_ts_sp = - ScratchTypeSystemClang::GetForTarget(target); - - if (!scratch_ts_sp) -return LLDB_INVALID_ADDRESS; - - CompilerType clang_void_ptr_type = - scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType(); - Address pthrea
[Lldb-commits] [lldb] c8ef88c - [lldb][NFCI] Remove CommandReturnObject from BreakpointIDList (#77858)
Author: Alex Langford Date: 2024-01-12T13:52:59-08:00 New Revision: c8ef88c446a3ff773c5be2fbf3df84b8b40c0c41 URL: https://github.com/llvm/llvm-project/commit/c8ef88c446a3ff773c5be2fbf3df84b8b40c0c41 DIFF: https://github.com/llvm/llvm-project/commit/c8ef88c446a3ff773c5be2fbf3df84b8b40c0c41.diff LOG: [lldb][NFCI] Remove CommandReturnObject from BreakpointIDList (#77858) BreakpointIDList does not need to know about CommandReturnObject. BreakpointIDList::FindAndReplaceIDRanges is the last place that uses it in BreakpointIDList. Instead of passing in a CommandReturnObject, it now returns an llvm::Error. The callsite uses the Error to populate the CommandReturnObject as needed. Added: Modified: lldb/include/lldb/Breakpoint/BreakpointIDList.h lldb/source/Breakpoint/BreakpointIDList.cpp lldb/source/Commands/CommandObjectBreakpoint.cpp Removed: diff --git a/lldb/include/lldb/Breakpoint/BreakpointIDList.h b/lldb/include/lldb/Breakpoint/BreakpointIDList.h index 6910024695d898..3cda1860dc1672 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointIDList.h +++ b/lldb/include/lldb/Breakpoint/BreakpointIDList.h @@ -12,12 +12,13 @@ #include #include - -#include "lldb/lldb-enumerations.h" #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointName.h" +#include "lldb/lldb-enumerations.h" #include "lldb/lldb-private.h" +#include "llvm/Support/Error.h" + namespace lldb_private { // class BreakpointIDList @@ -54,12 +55,10 @@ class BreakpointIDList { static std::pair SplitIDRangeExpression(llvm::StringRef in_string); - static void FindAndReplaceIDRanges(Args &old_args, Target *target, - bool allow_locations, - BreakpointName::Permissions - ::PermissionKinds purpose, - CommandReturnObject &result, - Args &new_args); + static llvm::Error + FindAndReplaceIDRanges(Args &old_args, Target *target, bool allow_locations, + BreakpointName::Permissions ::PermissionKinds purpose, + Args &new_args); private: BreakpointIDArray m_breakpoint_ids; diff --git a/lldb/source/Breakpoint/BreakpointIDList.cpp b/lldb/source/Breakpoint/BreakpointIDList.cpp index 05c461827cadd8..51185c30dabad8 100644 --- a/lldb/source/Breakpoint/BreakpointIDList.cpp +++ b/lldb/source/Breakpoint/BreakpointIDList.cpp @@ -11,9 +11,9 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" -#include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; @@ -93,12 +93,9 @@ bool BreakpointIDList::FindBreakpointID(const char *bp_id_str, // NEW_ARGS should be a copy of OLD_ARGS, with and ID range specifiers replaced // by the members of the range. -void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, - bool allow_locations, - BreakpointName::Permissions - ::PermissionKinds purpose, - CommandReturnObject &result, - Args &new_args) { +llvm::Error BreakpointIDList::FindAndReplaceIDRanges( +Args &old_args, Target *target, bool allow_locations, +BreakpointName::Permissions ::PermissionKinds purpose, Args &new_args) { llvm::StringRef range_from; llvm::StringRef range_to; llvm::StringRef current_arg; @@ -109,11 +106,11 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, current_arg = old_args[i].ref(); if (!allow_locations && current_arg.contains('.')) { - result.AppendErrorWithFormat( + new_args.Clear(); + return llvm::createStringError( + llvm::inconvertibleErrorCode(), "Breakpoint locations not allowed, saw location: %s.", current_arg.str().c_str()); - new_args.Clear(); - return; } Status error; @@ -125,8 +122,8 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, } else if (BreakpointID::StringIsBreakpointName(current_arg, error)) { if (!error.Success()) { new_args.Clear(); -result.AppendError(error.AsCString()); -return; +return llvm::createStringError(llvm::inconvertibleErrorCode(), + error.AsCString()); } else names_found.insert(std::string(current_arg)); } else if ((i + 2 < old_args.size()) && @@ -152,9 +149,10 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *t
[Lldb-commits] [lldb] [lldb][NFCI] Remove CommandReturnObject from BreakpointIDList (PR #77858)
https://github.com/bulbazord closed https://github.com/llvm/llvm-project/pull/77858 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
@@ -0,0 +1,291 @@ +//===-- ProcessWasm.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "ProcessWasm.h" +#include "ThreadWasm.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Utility/DataBufferHeap.h" + +#include "lldb/Target/UnixSignals.h" +#include "llvm/ADT/ArrayRef.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_gdb_remote; +using namespace lldb_private::wasm; + +LLDB_PLUGIN_DEFINE(ProcessWasm) + +// ProcessGDBRemote constructor +ProcessWasm::ProcessWasm(lldb::TargetSP target_sp, ListenerSP listener_sp) +: ProcessGDBRemote(target_sp, listener_sp) { + /* always use linux signals for wasm process */ + m_unix_signals_sp = + UnixSignals::Create(ArchSpec{"wasm32-unknown-unknown-wasm"}); bulbazord wrote: The comment and the creation of the signals object don't match up to me. How does `wasm32-unknown-unknown-wasm` yield Linux signals? https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 40a361a - [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (#77026)
Author: John Harrison Date: 2024-01-12T17:12:30-05:00 New Revision: 40a361acf5ce255054c5b2e5f67a24325bfe0398 URL: https://github.com/llvm/llvm-project/commit/40a361acf5ce255054c5b2e5f67a24325bfe0398 DIFF: https://github.com/llvm/llvm-project/commit/40a361acf5ce255054c5b2e5f67a24325bfe0398.diff LOG: [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (#77026) When generating a `display_value` for a variable the current approach calls `SBValue::GetValue()` and `SBValue::GetSummary()` to generate a `display_value` for the `SBValue`. However, there are cases where both of these return an empty string and the fallback is to print a pointer and type name instead (e.g. `FooBarType @ 0x00321`). For swift types, lldb includes a langauge runtime plugin that can generate a description of the object but this is only used with `SBValue::GetDescription()`. For example: ``` $ lldb swift-binary ... stop at breakpoint ... lldb> script >>> event = lldb.frame.GetValueForVariablePath("event") >>> print("Value", event.GetValue()) Value None >>> print("Summary", event.GetSummary()) Summary None >>> print("Description", event) # __str__ calls SBValue::GetDescription() Description (main.Event) event = (name = "Greetings", time = 2024-01-04 23:38:06 UTC) ``` With this change, if GetValue and GetSummary return empty then we try `SBValue::GetDescription()` as a fallback before using the previous logic of printing ` @ `. Added: Modified: lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py lldb/test/API/tools/lldb-dap/variables/main.cpp lldb/tools/lldb-dap/JSONUtils.cpp lldb/tools/lldb-dap/JSONUtils.h lldb/tools/lldb-dap/lldb-dap.cpp Removed: diff --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index de9d2c93a1109d..7651a67b643094 100644 --- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -2,6 +2,7 @@ Test lldb-dap completions request """ +import re import lldbdap_testcase import dap_server @@ -10,7 +11,7 @@ from lldbsuite.test.lldbtest import * -class TestDAP_variables(lldbdap_testcase.DAPTestCaseBase): +class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase): def assertEvaluate(self, expression, regex): self.assertRegexpMatches( self.dap_server.request_evaluate(expression, context=self.context)["body"][ @@ -25,6 +26,9 @@ def assertEvaluateFailure(self, expression): self.dap_server.request_evaluate(expression, context=self.context)["body"], ) +def isResultExpandedDescription(self): +return self.context == "repl" or self.context == "hover" + def isExpressionParsedExpected(self): return self.context != "hover" @@ -59,16 +63,30 @@ def run_test_evaluate_expressions( self.assertEvaluate("var2", "21") self.assertEvaluate("static_int", "42") self.assertEvaluate("non_static_int", "43") -self.assertEvaluate( -"struct1", "{foo:15}" if enableAutoVariableSummaries else "my_struct @ 0x" -) -self.assertEvaluate( -"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else "0x.*" -) -self.assertEvaluate("struct3", "0x.*0") self.assertEvaluate("struct1.foo", "15") self.assertEvaluate("struct2->foo", "16") +if self.isResultExpandedDescription(): +self.assertEvaluate( +"struct1", +r"\(my_struct\) (struct1|\$\d+) = \(foo = 15\)", +) +self.assertEvaluate("struct2", r"\(my_struct \*\) (struct2|\$\d+) = 0x.*") +self.assertEvaluate( +"struct3", r"\(my_struct \*\) (struct3|\$\d+) = nullptr" +) +else: +self.assertEvaluate( +"struct1", +re.escape("{foo:15}") +if enableAutoVariableSummaries +else "my_struct @ 0x", +) +self.assertEvaluate( +"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else "0x.*" +) +self.assertEvaluate("struct3", "0x.*0") + self.assertEvaluateFailure("var") # local variable of a_function self.assertEvaluateFailure("my_struct") # type name self.assertEvaluateFailure("int") # type name @@ -95,9 +113,18 @@ def run_test_evaluate_expressions( self.assertEvaluate( "non_static_int", "10" ) # diff erent variable with the same name -self.assertEvaluate( -"struct1", "{foo:15}" if enableAutoVariableSummaries else "my_struct @ 0x" -) +if self.isResultExpandedDescription(): +self.assertE
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
https://github.com/DavidGoldman closed https://github.com/llvm/llvm-project/pull/77026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [llvm] [clang-tools-extra] [lldb] [lldb][test] Add tests for target.max-string-summary-length setting (PR #77920)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/77920 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f4461cf - [lldb][test] Add tests for target.max-string-summary-length setting (#77920)
Author: Michael Buch Date: 2024-01-12T22:26:31Z New Revision: f4461cf4f30417be118487142bca6635e07ed1e6 URL: https://github.com/llvm/llvm-project/commit/f4461cf4f30417be118487142bca6635e07ed1e6 DIFF: https://github.com/llvm/llvm-project/commit/f4461cf4f30417be118487142bca6635e07ed1e6.diff LOG: [lldb][test] Add tests for target.max-string-summary-length setting (#77920) This adds API tests for the `target.max-string-summary-length`, which was recently fixed in https://github.com/llvm/llvm-project/pull/72233 Added: Modified: lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp Removed: diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index e7c517a90134f3..c275904eaf2014 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -295,6 +295,23 @@ def cleanup(): substrs=["e_2", "n_2", "r_2", "i_2", "k_2", "o_2"], ) +self.runCmd("settings set target.max-string-summary-length 5") +some_string = self.frame().FindVariable("some_string") +some_string_summary = some_string.GetSummary() +self.assertEqual(some_string_summary, '"01234"...') + +some_carr = self.frame().FindVariable("some_carr") +some_carr_summary = some_carr.GetSummary() +self.assertEqual(some_carr_summary, '"01234"...') + +# FIXME: c-strings should honor the target.max-string-summary-length +# setting. Currently a C-string will be truncated at 64 (an internal +# implementation detail) instead of the value specified in the setting. +some_cstring = self.frame().FindVariable("some_cstring") +some_cstring_summary = some_cstring.GetSummary() +self.assertEqual(len(some_cstring_summary), 66) # 64 + 2 (for quotation marks) +self.assertFalse(some_cstring_summary.endswith("...")) + # override the cap self.expect( "frame variable a_long_guy --show-all-children", diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp index e7a52fe73bd4c5..9d12ca30f984c1 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp @@ -1,6 +1,7 @@ +#include #include #include -#include +#include struct i_am_cool { @@ -164,6 +165,17 @@ int main (int argc, const char * argv[]) Simple a_simple_object(3,0.14,'E'); VeryLong a_long_guy; - + +std::string some_string = "012345678901234567890123456789" + "012345678901234567890123456789" + "012345678901234567890123456789" + "012345678901234567890123456789"; +char const *some_cstring = some_string.c_str(); + +char const some_carr[] = "012345678901234567890123456789" + "012345678901234567890123456789" + "012345678901234567890123456789" + "012345678901234567890123456789"; + return 0; // Set break point at this line. } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [llvm] [clang-tools-extra] [lldb] [lldb][test] Add tests for target.max-string-summary-length setting (PR #77920)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/77920 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Store SupportFile in LineEntry (NFC) (PR #77999)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/77999 This is a series of 4 NFC commit to store `SupportFile`s rather than `FileSpec`s in `LineEntry`. This is work towards having the `SourceManager`operate on `SupportFile`s so that it can (1) validate the Checksum and (2) materialize the content of inline source information. I highly recommend looking at the individual commits rather than the unified diff. >From 2966f226fb052a4265abef4fa132cdc102cb1f8e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 12 Jan 2024 15:04:35 -0800 Subject: [PATCH 1/4] [lldb] Hoist SupportFile out of FileSpecList (NFC) This hoists SupportFile out of FileSpecList. SupportFileList is still implemented there as it's very similar to FileSpecList. --- lldb/include/lldb/Utility/FileSpecList.h | 29 + lldb/include/lldb/Utility/SupportFile.h | 52 2 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 lldb/include/lldb/Utility/SupportFile.h diff --git a/lldb/include/lldb/Utility/FileSpecList.h b/lldb/include/lldb/Utility/FileSpecList.h index c1107ad1135dd2..6ddb9d1aa646a2 100644 --- a/lldb/include/lldb/Utility/FileSpecList.h +++ b/lldb/include/lldb/Utility/FileSpecList.h @@ -9,8 +9,8 @@ #ifndef LLDB_CORE_FILESPECLIST_H #define LLDB_CORE_FILESPECLIST_H -#include "lldb/Utility/Checksum.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/SupportFile.h" #include #include @@ -18,33 +18,6 @@ namespace lldb_private { class Stream; -/// Wraps either a FileSpec that represents a local file or a source -/// file whose contents is known (for example because it can be -/// reconstructed from debug info), but that hasn't been written to a -/// file yet. -class SupportFile { -protected: - FileSpec m_file_spec; - Checksum m_checksum; - -public: - SupportFile(const FileSpec &spec) : m_file_spec(spec), m_checksum() {} - SupportFile(const FileSpec &spec, const Checksum &checksum) - : m_file_spec(spec), m_checksum(checksum) {} - SupportFile(const SupportFile &other) = delete; - SupportFile(SupportFile &&other) = default; - virtual ~SupportFile() = default; - bool operator==(const SupportFile &other) { -return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum; - } - /// Return the file name only. Useful for resolving breakpoints by file name. - const FileSpec &GetSpecOnly() const { return m_file_spec; }; - /// Return the checksum or all zeros if there is none. - const Checksum &GetChecksum() const { return m_checksum; }; - /// Materialize the file to disk and return the path to that temporary file. - virtual const FileSpec &Materialize() { return m_file_spec; } -}; - /// A list of support files for a CompileUnit. class SupportFileList { public: diff --git a/lldb/include/lldb/Utility/SupportFile.h b/lldb/include/lldb/Utility/SupportFile.h new file mode 100644 index 00..5156b3e72b32d4 --- /dev/null +++ b/lldb/include/lldb/Utility/SupportFile.h @@ -0,0 +1,52 @@ +//===-- SupportFile.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_UTILITY_SUPPORTFILE_H +#define LLDB_UTILITY_SUPPORTFILE_H + +#include "lldb/Utility/Checksum.h" +#include "lldb/Utility/FileSpec.h" + +namespace lldb_private { + +/// Wraps either a FileSpec that represents a local file or a source +/// file whose contents is known (for example because it can be +/// reconstructed from debug info), but that hasn't been written to a +/// file yet. This also stores an optional checksum of the on-disk content. +class SupportFile { +public: + SupportFile(const FileSpec &spec) : m_file_spec(spec), m_checksum() {} + SupportFile(const FileSpec &spec, const Checksum &checksum) + : m_file_spec(spec), m_checksum(checksum) {} + + SupportFile(const SupportFile &other) = delete; + SupportFile(SupportFile &&other) = default; + + virtual ~SupportFile() = default; + + bool operator==(const SupportFile &other) { +return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum; + } + + /// Return the file name only. Useful for resolving breakpoints by file name. + const FileSpec &GetSpecOnly() const { return m_file_spec; }; + + /// Return the checksum or all zeros if there is none. + const Checksum &GetChecksum() const { return m_checksum; }; + + /// Materialize the file to disk and return the path to that temporary file. + virtual const FileSpec &Materialize() { return m_file_spec; } + +protected: + FileSpec m_file_spec; + Checksum m_checksum; +}; + +} // namespace lldb_private + +#endif // LLDB_UTILITY_SUPPORTFILE_H >From cdaf541b7bb5550d8260ea2a45f8e046bd99d5e7 Mon Sep