[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/95959 >From 27a00b54bc991dfb4747e0d37b15878beebaabba Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 12 Jun 2024 14:23:15 -0700 Subject: [PATCH 1/4] [API] add GetSyntheticValue --- lldb/include/lldb/API/SBValue.h | 2 ++ lldb/source/API/SBValue.cpp | 12 2 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 65920c76df7a8..bec816fb45184 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -89,6 +89,8 @@ class LLDB_API SBValue { lldb::SBValue GetNonSyntheticValue(); + lldb::SBValue GetSyntheticValue(); + lldb::DynamicValueType GetPreferDynamicValue(); void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 9d7efba024d11..6b77c0e95cedd 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -761,6 +761,18 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { return value_sb; } +lldb::SBValue SBValue::GetSyntheticValue() { + LLDB_INSTRUMENT_VA(this); + + SBValue value_sb; + if (IsValid()) { +ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), + m_opaque_sp->GetUseDynamic(), true)); +value_sb.SetSP(proxy_sp); + } + return value_sb; +} + lldb::DynamicValueType SBValue::GetPreferDynamicValue() { LLDB_INSTRUMENT_VA(this); >From e0ed752849486f67d9fddbef3767a1756afd1ab2 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 20 Jun 2024 17:04:15 -0700 Subject: [PATCH 2/4] add test --- .../formatters/TestFormattersSBAPI.py | 12 lldb/test/API/python_api/formatters/synth.py | 28 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py index 7e802f92da352..460afbc1202cf 100644 --- a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py +++ b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py @@ -155,6 +155,18 @@ def cleanup(): ], ) +self.dbg.GetCategory("CCCSynth2").SetEnabled(True) +self.expect( +"frame variable ccc", +matching=True, +substrs=[ +"CCC object with leading synthetic value (int) b = 222", +"a = 111", +"b = 222", +"c = 333", +], +) + foo_var = ( self.dbg.GetSelectedTarget() .GetProcess() diff --git a/lldb/test/API/python_api/formatters/synth.py b/lldb/test/API/python_api/formatters/synth.py index 474c18bc62ebd..2b8f7c86ac6f1 100644 --- a/lldb/test/API/python_api/formatters/synth.py +++ b/lldb/test/API/python_api/formatters/synth.py @@ -29,11 +29,19 @@ def ccc_summary(sbvalue, internal_dict): # This tests that the SBValue.GetNonSyntheticValue() actually returns a # non-synthetic value. If it does not, then sbvalue.GetChildMemberWithName("a") # in the following statement will call the 'get_child_index' method of the -# synthetic child provider CCCSynthProvider below (which raises an -# exception). +# synthetic child provider CCCSynthProvider below (which return the "b" field"). return "CCC object with leading value " + str(sbvalue.GetChildMemberWithName("a")) +def ccc_synthetic(sbvalue, internal_dict): +sbvalue = sbvalue.GetSyntheticValue() +# This tests that the SBValue.GetNonSyntheticValue() actually returns a +# synthetic value. If it does, then sbvalue.GetChildMemberWithName("a") +# in the following statement will call the 'get_child_index' method of the +# synthetic child provider CCCSynthProvider below (which return the "b" field"). +return "CCC object with leading synthetic value " + str(sbvalue.GetChildMemberWithName("a")) + + class CCCSynthProvider(object): def __init__(self, sbvalue, internal_dict): self._sbvalue = sbvalue @@ -42,6 +50,9 @@ def num_children(self): return 3 def get_child_index(self, name): +if name == "a": +# Return b for test. +return 1 raise RuntimeError("I don't want to be called!") def get_child_at_index(self, index): @@ -119,3 +130,16 @@ def __lldb_init_module(debugger, dict): "synth.empty2_summary", lldb.eTypeOptionHideEmptyAggregates ), ) +cat2 = debugger.CreateCategory("CCCSynth2") +cat2.AddTypeSynthetic( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSynthetic.CreateWithClassName( +"synth.CCCSynthProvider", lldb.eTypeOptionCascade +), +) +cat2.AddTypeSummary( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSummary.CreateWithFunctionName( +"synth.ccc_synthetic"
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/95959 >From 27a00b54bc991dfb4747e0d37b15878beebaabba Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 12 Jun 2024 14:23:15 -0700 Subject: [PATCH 01/10] [API] add GetSyntheticValue --- lldb/include/lldb/API/SBValue.h | 2 ++ lldb/source/API/SBValue.cpp | 12 2 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 65920c76df7a8..bec816fb45184 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -89,6 +89,8 @@ class LLDB_API SBValue { lldb::SBValue GetNonSyntheticValue(); + lldb::SBValue GetSyntheticValue(); + lldb::DynamicValueType GetPreferDynamicValue(); void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 9d7efba024d11..6b77c0e95cedd 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -761,6 +761,18 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { return value_sb; } +lldb::SBValue SBValue::GetSyntheticValue() { + LLDB_INSTRUMENT_VA(this); + + SBValue value_sb; + if (IsValid()) { +ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), + m_opaque_sp->GetUseDynamic(), true)); +value_sb.SetSP(proxy_sp); + } + return value_sb; +} + lldb::DynamicValueType SBValue::GetPreferDynamicValue() { LLDB_INSTRUMENT_VA(this); >From e0ed752849486f67d9fddbef3767a1756afd1ab2 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 20 Jun 2024 17:04:15 -0700 Subject: [PATCH 02/10] add test --- .../formatters/TestFormattersSBAPI.py | 12 lldb/test/API/python_api/formatters/synth.py | 28 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py index 7e802f92da352..460afbc1202cf 100644 --- a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py +++ b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py @@ -155,6 +155,18 @@ def cleanup(): ], ) +self.dbg.GetCategory("CCCSynth2").SetEnabled(True) +self.expect( +"frame variable ccc", +matching=True, +substrs=[ +"CCC object with leading synthetic value (int) b = 222", +"a = 111", +"b = 222", +"c = 333", +], +) + foo_var = ( self.dbg.GetSelectedTarget() .GetProcess() diff --git a/lldb/test/API/python_api/formatters/synth.py b/lldb/test/API/python_api/formatters/synth.py index 474c18bc62ebd..2b8f7c86ac6f1 100644 --- a/lldb/test/API/python_api/formatters/synth.py +++ b/lldb/test/API/python_api/formatters/synth.py @@ -29,11 +29,19 @@ def ccc_summary(sbvalue, internal_dict): # This tests that the SBValue.GetNonSyntheticValue() actually returns a # non-synthetic value. If it does not, then sbvalue.GetChildMemberWithName("a") # in the following statement will call the 'get_child_index' method of the -# synthetic child provider CCCSynthProvider below (which raises an -# exception). +# synthetic child provider CCCSynthProvider below (which return the "b" field"). return "CCC object with leading value " + str(sbvalue.GetChildMemberWithName("a")) +def ccc_synthetic(sbvalue, internal_dict): +sbvalue = sbvalue.GetSyntheticValue() +# This tests that the SBValue.GetNonSyntheticValue() actually returns a +# synthetic value. If it does, then sbvalue.GetChildMemberWithName("a") +# in the following statement will call the 'get_child_index' method of the +# synthetic child provider CCCSynthProvider below (which return the "b" field"). +return "CCC object with leading synthetic value " + str(sbvalue.GetChildMemberWithName("a")) + + class CCCSynthProvider(object): def __init__(self, sbvalue, internal_dict): self._sbvalue = sbvalue @@ -42,6 +50,9 @@ def num_children(self): return 3 def get_child_index(self, name): +if name == "a": +# Return b for test. +return 1 raise RuntimeError("I don't want to be called!") def get_child_at_index(self, index): @@ -119,3 +130,16 @@ def __lldb_init_module(debugger, dict): "synth.empty2_summary", lldb.eTypeOptionHideEmptyAggregates ), ) +cat2 = debugger.CreateCategory("CCCSynth2") +cat2.AddTypeSynthetic( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSynthetic.CreateWithClassName( +"synth.CCCSynthProvider", lldb.eTypeOptionCascade +), +) +cat2.AddTypeSummary( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSummary.CreateWithFunctionName( +"synth.ccc_synthe
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
v-bulle wrote: > The one thing about this that strikes me as odd is that if you have an > SBValue that doesn't have a Synthetic Value, this will return the > non-synthetic value. The GetNonSyntheticValue didn't have this problem > because there's always a non-synthetic value, so provided the SBValue was > valid you could always hand that out. > > Would it make more sense to make the ValueImpl that's going to represent the > synthetic value then check whether that really is synthetic, and return an > empty SBValue if it is not? done https://github.com/llvm/llvm-project/pull/95959 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/95959 >From 27a00b54bc991dfb4747e0d37b15878beebaabba Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 12 Jun 2024 14:23:15 -0700 Subject: [PATCH 01/11] [API] add GetSyntheticValue --- lldb/include/lldb/API/SBValue.h | 2 ++ lldb/source/API/SBValue.cpp | 12 2 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 65920c76df7a8..bec816fb45184 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -89,6 +89,8 @@ class LLDB_API SBValue { lldb::SBValue GetNonSyntheticValue(); + lldb::SBValue GetSyntheticValue(); + lldb::DynamicValueType GetPreferDynamicValue(); void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 9d7efba024d11..6b77c0e95cedd 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -761,6 +761,18 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { return value_sb; } +lldb::SBValue SBValue::GetSyntheticValue() { + LLDB_INSTRUMENT_VA(this); + + SBValue value_sb; + if (IsValid()) { +ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), + m_opaque_sp->GetUseDynamic(), true)); +value_sb.SetSP(proxy_sp); + } + return value_sb; +} + lldb::DynamicValueType SBValue::GetPreferDynamicValue() { LLDB_INSTRUMENT_VA(this); >From e0ed752849486f67d9fddbef3767a1756afd1ab2 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 20 Jun 2024 17:04:15 -0700 Subject: [PATCH 02/11] add test --- .../formatters/TestFormattersSBAPI.py | 12 lldb/test/API/python_api/formatters/synth.py | 28 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py index 7e802f92da352..460afbc1202cf 100644 --- a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py +++ b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py @@ -155,6 +155,18 @@ def cleanup(): ], ) +self.dbg.GetCategory("CCCSynth2").SetEnabled(True) +self.expect( +"frame variable ccc", +matching=True, +substrs=[ +"CCC object with leading synthetic value (int) b = 222", +"a = 111", +"b = 222", +"c = 333", +], +) + foo_var = ( self.dbg.GetSelectedTarget() .GetProcess() diff --git a/lldb/test/API/python_api/formatters/synth.py b/lldb/test/API/python_api/formatters/synth.py index 474c18bc62ebd..2b8f7c86ac6f1 100644 --- a/lldb/test/API/python_api/formatters/synth.py +++ b/lldb/test/API/python_api/formatters/synth.py @@ -29,11 +29,19 @@ def ccc_summary(sbvalue, internal_dict): # This tests that the SBValue.GetNonSyntheticValue() actually returns a # non-synthetic value. If it does not, then sbvalue.GetChildMemberWithName("a") # in the following statement will call the 'get_child_index' method of the -# synthetic child provider CCCSynthProvider below (which raises an -# exception). +# synthetic child provider CCCSynthProvider below (which return the "b" field"). return "CCC object with leading value " + str(sbvalue.GetChildMemberWithName("a")) +def ccc_synthetic(sbvalue, internal_dict): +sbvalue = sbvalue.GetSyntheticValue() +# This tests that the SBValue.GetNonSyntheticValue() actually returns a +# synthetic value. If it does, then sbvalue.GetChildMemberWithName("a") +# in the following statement will call the 'get_child_index' method of the +# synthetic child provider CCCSynthProvider below (which return the "b" field"). +return "CCC object with leading synthetic value " + str(sbvalue.GetChildMemberWithName("a")) + + class CCCSynthProvider(object): def __init__(self, sbvalue, internal_dict): self._sbvalue = sbvalue @@ -42,6 +50,9 @@ def num_children(self): return 3 def get_child_index(self, name): +if name == "a": +# Return b for test. +return 1 raise RuntimeError("I don't want to be called!") def get_child_at_index(self, index): @@ -119,3 +130,16 @@ def __lldb_init_module(debugger, dict): "synth.empty2_summary", lldb.eTypeOptionHideEmptyAggregates ), ) +cat2 = debugger.CreateCategory("CCCSynth2") +cat2.AddTypeSynthetic( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSynthetic.CreateWithClassName( +"synth.CCCSynthProvider", lldb.eTypeOptionCascade +), +) +cat2.AddTypeSummary( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSummary.CreateWithFunctionName( +"synth.ccc_synthe
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/95959 >From 27a00b54bc991dfb4747e0d37b15878beebaabba Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 12 Jun 2024 14:23:15 -0700 Subject: [PATCH 01/12] [API] add GetSyntheticValue --- lldb/include/lldb/API/SBValue.h | 2 ++ lldb/source/API/SBValue.cpp | 12 2 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 65920c76df7a8d..bec816fb451844 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -89,6 +89,8 @@ class LLDB_API SBValue { lldb::SBValue GetNonSyntheticValue(); + lldb::SBValue GetSyntheticValue(); + lldb::DynamicValueType GetPreferDynamicValue(); void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 9d7efba024d115..6b77c0e95cedd6 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -761,6 +761,18 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { return value_sb; } +lldb::SBValue SBValue::GetSyntheticValue() { + LLDB_INSTRUMENT_VA(this); + + SBValue value_sb; + if (IsValid()) { +ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), + m_opaque_sp->GetUseDynamic(), true)); +value_sb.SetSP(proxy_sp); + } + return value_sb; +} + lldb::DynamicValueType SBValue::GetPreferDynamicValue() { LLDB_INSTRUMENT_VA(this); >From e0ed752849486f67d9fddbef3767a1756afd1ab2 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 20 Jun 2024 17:04:15 -0700 Subject: [PATCH 02/12] add test --- .../formatters/TestFormattersSBAPI.py | 12 lldb/test/API/python_api/formatters/synth.py | 28 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py index 7e802f92da352a..460afbc1202cfd 100644 --- a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py +++ b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py @@ -155,6 +155,18 @@ def cleanup(): ], ) +self.dbg.GetCategory("CCCSynth2").SetEnabled(True) +self.expect( +"frame variable ccc", +matching=True, +substrs=[ +"CCC object with leading synthetic value (int) b = 222", +"a = 111", +"b = 222", +"c = 333", +], +) + foo_var = ( self.dbg.GetSelectedTarget() .GetProcess() diff --git a/lldb/test/API/python_api/formatters/synth.py b/lldb/test/API/python_api/formatters/synth.py index 474c18bc62ebd9..2b8f7c86ac6f12 100644 --- a/lldb/test/API/python_api/formatters/synth.py +++ b/lldb/test/API/python_api/formatters/synth.py @@ -29,11 +29,19 @@ def ccc_summary(sbvalue, internal_dict): # This tests that the SBValue.GetNonSyntheticValue() actually returns a # non-synthetic value. If it does not, then sbvalue.GetChildMemberWithName("a") # in the following statement will call the 'get_child_index' method of the -# synthetic child provider CCCSynthProvider below (which raises an -# exception). +# synthetic child provider CCCSynthProvider below (which return the "b" field"). return "CCC object with leading value " + str(sbvalue.GetChildMemberWithName("a")) +def ccc_synthetic(sbvalue, internal_dict): +sbvalue = sbvalue.GetSyntheticValue() +# This tests that the SBValue.GetNonSyntheticValue() actually returns a +# synthetic value. If it does, then sbvalue.GetChildMemberWithName("a") +# in the following statement will call the 'get_child_index' method of the +# synthetic child provider CCCSynthProvider below (which return the "b" field"). +return "CCC object with leading synthetic value " + str(sbvalue.GetChildMemberWithName("a")) + + class CCCSynthProvider(object): def __init__(self, sbvalue, internal_dict): self._sbvalue = sbvalue @@ -42,6 +50,9 @@ def num_children(self): return 3 def get_child_index(self, name): +if name == "a": +# Return b for test. +return 1 raise RuntimeError("I don't want to be called!") def get_child_at_index(self, index): @@ -119,3 +130,16 @@ def __lldb_init_module(debugger, dict): "synth.empty2_summary", lldb.eTypeOptionHideEmptyAggregates ), ) +cat2 = debugger.CreateCategory("CCCSynth2") +cat2.AddTypeSynthetic( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSynthetic.CreateWithClassName( +"synth.CCCSynthProvider", lldb.eTypeOptionCascade +), +) +cat2.AddTypeSummary( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSummary.CreateWithFunctionName( +"synth.cc
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/95959 >From 27a00b54bc991dfb4747e0d37b15878beebaabba Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 12 Jun 2024 14:23:15 -0700 Subject: [PATCH 01/14] [API] add GetSyntheticValue --- lldb/include/lldb/API/SBValue.h | 2 ++ lldb/source/API/SBValue.cpp | 12 2 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 65920c76df7a8..bec816fb45184 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -89,6 +89,8 @@ class LLDB_API SBValue { lldb::SBValue GetNonSyntheticValue(); + lldb::SBValue GetSyntheticValue(); + lldb::DynamicValueType GetPreferDynamicValue(); void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 9d7efba024d11..6b77c0e95cedd 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -761,6 +761,18 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { return value_sb; } +lldb::SBValue SBValue::GetSyntheticValue() { + LLDB_INSTRUMENT_VA(this); + + SBValue value_sb; + if (IsValid()) { +ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), + m_opaque_sp->GetUseDynamic(), true)); +value_sb.SetSP(proxy_sp); + } + return value_sb; +} + lldb::DynamicValueType SBValue::GetPreferDynamicValue() { LLDB_INSTRUMENT_VA(this); >From e0ed752849486f67d9fddbef3767a1756afd1ab2 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 20 Jun 2024 17:04:15 -0700 Subject: [PATCH 02/14] add test --- .../formatters/TestFormattersSBAPI.py | 12 lldb/test/API/python_api/formatters/synth.py | 28 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py index 7e802f92da352..460afbc1202cf 100644 --- a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py +++ b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py @@ -155,6 +155,18 @@ def cleanup(): ], ) +self.dbg.GetCategory("CCCSynth2").SetEnabled(True) +self.expect( +"frame variable ccc", +matching=True, +substrs=[ +"CCC object with leading synthetic value (int) b = 222", +"a = 111", +"b = 222", +"c = 333", +], +) + foo_var = ( self.dbg.GetSelectedTarget() .GetProcess() diff --git a/lldb/test/API/python_api/formatters/synth.py b/lldb/test/API/python_api/formatters/synth.py index 474c18bc62ebd..2b8f7c86ac6f1 100644 --- a/lldb/test/API/python_api/formatters/synth.py +++ b/lldb/test/API/python_api/formatters/synth.py @@ -29,11 +29,19 @@ def ccc_summary(sbvalue, internal_dict): # This tests that the SBValue.GetNonSyntheticValue() actually returns a # non-synthetic value. If it does not, then sbvalue.GetChildMemberWithName("a") # in the following statement will call the 'get_child_index' method of the -# synthetic child provider CCCSynthProvider below (which raises an -# exception). +# synthetic child provider CCCSynthProvider below (which return the "b" field"). return "CCC object with leading value " + str(sbvalue.GetChildMemberWithName("a")) +def ccc_synthetic(sbvalue, internal_dict): +sbvalue = sbvalue.GetSyntheticValue() +# This tests that the SBValue.GetNonSyntheticValue() actually returns a +# synthetic value. If it does, then sbvalue.GetChildMemberWithName("a") +# in the following statement will call the 'get_child_index' method of the +# synthetic child provider CCCSynthProvider below (which return the "b" field"). +return "CCC object with leading synthetic value " + str(sbvalue.GetChildMemberWithName("a")) + + class CCCSynthProvider(object): def __init__(self, sbvalue, internal_dict): self._sbvalue = sbvalue @@ -42,6 +50,9 @@ def num_children(self): return 3 def get_child_index(self, name): +if name == "a": +# Return b for test. +return 1 raise RuntimeError("I don't want to be called!") def get_child_at_index(self, index): @@ -119,3 +130,16 @@ def __lldb_init_module(debugger, dict): "synth.empty2_summary", lldb.eTypeOptionHideEmptyAggregates ), ) +cat2 = debugger.CreateCategory("CCCSynth2") +cat2.AddTypeSynthetic( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSynthetic.CreateWithClassName( +"synth.CCCSynthProvider", lldb.eTypeOptionCascade +), +) +cat2.AddTypeSummary( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSummary.CreateWithFunctionName( +"synth.ccc_synthe
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
https://github.com/v-bulle created https://github.com/llvm/llvm-project/pull/95959 Adds GetSyntheticValue to the API on top of GetNonSyntheticValue. >From 27a00b54bc991dfb4747e0d37b15878beebaabba Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 12 Jun 2024 14:23:15 -0700 Subject: [PATCH] [API] add GetSyntheticValue --- lldb/include/lldb/API/SBValue.h | 2 ++ lldb/source/API/SBValue.cpp | 12 2 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 65920c76df7a8..bec816fb45184 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -89,6 +89,8 @@ class LLDB_API SBValue { lldb::SBValue GetNonSyntheticValue(); + lldb::SBValue GetSyntheticValue(); + lldb::DynamicValueType GetPreferDynamicValue(); void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 9d7efba024d11..6b77c0e95cedd 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -761,6 +761,18 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { return value_sb; } +lldb::SBValue SBValue::GetSyntheticValue() { + LLDB_INSTRUMENT_VA(this); + + SBValue value_sb; + if (IsValid()) { +ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), + m_opaque_sp->GetUseDynamic(), true)); +value_sb.SetSP(proxy_sp); + } + return value_sb; +} + lldb::DynamicValueType SBValue::GetPreferDynamicValue() { LLDB_INSTRUMENT_VA(this); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/95959 >From 27a00b54bc991dfb4747e0d37b15878beebaabba Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 12 Jun 2024 14:23:15 -0700 Subject: [PATCH] [API] add GetSyntheticValue --- lldb/include/lldb/API/SBValue.h | 2 ++ lldb/source/API/SBValue.cpp | 12 2 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 65920c76df7a8..bec816fb45184 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -89,6 +89,8 @@ class LLDB_API SBValue { lldb::SBValue GetNonSyntheticValue(); + lldb::SBValue GetSyntheticValue(); + lldb::DynamicValueType GetPreferDynamicValue(); void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 9d7efba024d11..6b77c0e95cedd 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -761,6 +761,18 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { return value_sb; } +lldb::SBValue SBValue::GetSyntheticValue() { + LLDB_INSTRUMENT_VA(this); + + SBValue value_sb; + if (IsValid()) { +ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), + m_opaque_sp->GetUseDynamic(), true)); +value_sb.SetSP(proxy_sp); + } + return value_sb; +} + lldb::DynamicValueType SBValue::GetPreferDynamicValue() { LLDB_INSTRUMENT_VA(this); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/95959 >From 27a00b54bc991dfb4747e0d37b15878beebaabba Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 12 Jun 2024 14:23:15 -0700 Subject: [PATCH 1/2] [API] add GetSyntheticValue --- lldb/include/lldb/API/SBValue.h | 2 ++ lldb/source/API/SBValue.cpp | 12 2 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 65920c76df7a8..bec816fb45184 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -89,6 +89,8 @@ class LLDB_API SBValue { lldb::SBValue GetNonSyntheticValue(); + lldb::SBValue GetSyntheticValue(); + lldb::DynamicValueType GetPreferDynamicValue(); void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 9d7efba024d11..6b77c0e95cedd 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -761,6 +761,18 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { return value_sb; } +lldb::SBValue SBValue::GetSyntheticValue() { + LLDB_INSTRUMENT_VA(this); + + SBValue value_sb; + if (IsValid()) { +ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), + m_opaque_sp->GetUseDynamic(), true)); +value_sb.SetSP(proxy_sp); + } + return value_sb; +} + lldb::DynamicValueType SBValue::GetPreferDynamicValue() { LLDB_INSTRUMENT_VA(this); >From e0ed752849486f67d9fddbef3767a1756afd1ab2 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 20 Jun 2024 17:04:15 -0700 Subject: [PATCH 2/2] add test --- .../formatters/TestFormattersSBAPI.py | 12 lldb/test/API/python_api/formatters/synth.py | 28 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py index 7e802f92da352..460afbc1202cf 100644 --- a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py +++ b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py @@ -155,6 +155,18 @@ def cleanup(): ], ) +self.dbg.GetCategory("CCCSynth2").SetEnabled(True) +self.expect( +"frame variable ccc", +matching=True, +substrs=[ +"CCC object with leading synthetic value (int) b = 222", +"a = 111", +"b = 222", +"c = 333", +], +) + foo_var = ( self.dbg.GetSelectedTarget() .GetProcess() diff --git a/lldb/test/API/python_api/formatters/synth.py b/lldb/test/API/python_api/formatters/synth.py index 474c18bc62ebd..2b8f7c86ac6f1 100644 --- a/lldb/test/API/python_api/formatters/synth.py +++ b/lldb/test/API/python_api/formatters/synth.py @@ -29,11 +29,19 @@ def ccc_summary(sbvalue, internal_dict): # This tests that the SBValue.GetNonSyntheticValue() actually returns a # non-synthetic value. If it does not, then sbvalue.GetChildMemberWithName("a") # in the following statement will call the 'get_child_index' method of the -# synthetic child provider CCCSynthProvider below (which raises an -# exception). +# synthetic child provider CCCSynthProvider below (which return the "b" field"). return "CCC object with leading value " + str(sbvalue.GetChildMemberWithName("a")) +def ccc_synthetic(sbvalue, internal_dict): +sbvalue = sbvalue.GetSyntheticValue() +# This tests that the SBValue.GetNonSyntheticValue() actually returns a +# synthetic value. If it does, then sbvalue.GetChildMemberWithName("a") +# in the following statement will call the 'get_child_index' method of the +# synthetic child provider CCCSynthProvider below (which return the "b" field"). +return "CCC object with leading synthetic value " + str(sbvalue.GetChildMemberWithName("a")) + + class CCCSynthProvider(object): def __init__(self, sbvalue, internal_dict): self._sbvalue = sbvalue @@ -42,6 +50,9 @@ def num_children(self): return 3 def get_child_index(self, name): +if name == "a": +# Return b for test. +return 1 raise RuntimeError("I don't want to be called!") def get_child_at_index(self, index): @@ -119,3 +130,16 @@ def __lldb_init_module(debugger, dict): "synth.empty2_summary", lldb.eTypeOptionHideEmptyAggregates ), ) +cat2 = debugger.CreateCategory("CCCSynth2") +cat2.AddTypeSynthetic( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSynthetic.CreateWithClassName( +"synth.CCCSynthProvider", lldb.eTypeOptionCascade +), +) +cat2.AddTypeSummary( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSummary.CreateWithFunctionName( +"synth.ccc_synthetic"
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/95959 >From 27a00b54bc991dfb4747e0d37b15878beebaabba Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 12 Jun 2024 14:23:15 -0700 Subject: [PATCH 1/3] [API] add GetSyntheticValue --- lldb/include/lldb/API/SBValue.h | 2 ++ lldb/source/API/SBValue.cpp | 12 2 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 65920c76df7a8..bec816fb45184 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -89,6 +89,8 @@ class LLDB_API SBValue { lldb::SBValue GetNonSyntheticValue(); + lldb::SBValue GetSyntheticValue(); + lldb::DynamicValueType GetPreferDynamicValue(); void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 9d7efba024d11..6b77c0e95cedd 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -761,6 +761,18 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { return value_sb; } +lldb::SBValue SBValue::GetSyntheticValue() { + LLDB_INSTRUMENT_VA(this); + + SBValue value_sb; + if (IsValid()) { +ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), + m_opaque_sp->GetUseDynamic(), true)); +value_sb.SetSP(proxy_sp); + } + return value_sb; +} + lldb::DynamicValueType SBValue::GetPreferDynamicValue() { LLDB_INSTRUMENT_VA(this); >From e0ed752849486f67d9fddbef3767a1756afd1ab2 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 20 Jun 2024 17:04:15 -0700 Subject: [PATCH 2/3] add test --- .../formatters/TestFormattersSBAPI.py | 12 lldb/test/API/python_api/formatters/synth.py | 28 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py index 7e802f92da352..460afbc1202cf 100644 --- a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py +++ b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py @@ -155,6 +155,18 @@ def cleanup(): ], ) +self.dbg.GetCategory("CCCSynth2").SetEnabled(True) +self.expect( +"frame variable ccc", +matching=True, +substrs=[ +"CCC object with leading synthetic value (int) b = 222", +"a = 111", +"b = 222", +"c = 333", +], +) + foo_var = ( self.dbg.GetSelectedTarget() .GetProcess() diff --git a/lldb/test/API/python_api/formatters/synth.py b/lldb/test/API/python_api/formatters/synth.py index 474c18bc62ebd..2b8f7c86ac6f1 100644 --- a/lldb/test/API/python_api/formatters/synth.py +++ b/lldb/test/API/python_api/formatters/synth.py @@ -29,11 +29,19 @@ def ccc_summary(sbvalue, internal_dict): # This tests that the SBValue.GetNonSyntheticValue() actually returns a # non-synthetic value. If it does not, then sbvalue.GetChildMemberWithName("a") # in the following statement will call the 'get_child_index' method of the -# synthetic child provider CCCSynthProvider below (which raises an -# exception). +# synthetic child provider CCCSynthProvider below (which return the "b" field"). return "CCC object with leading value " + str(sbvalue.GetChildMemberWithName("a")) +def ccc_synthetic(sbvalue, internal_dict): +sbvalue = sbvalue.GetSyntheticValue() +# This tests that the SBValue.GetNonSyntheticValue() actually returns a +# synthetic value. If it does, then sbvalue.GetChildMemberWithName("a") +# in the following statement will call the 'get_child_index' method of the +# synthetic child provider CCCSynthProvider below (which return the "b" field"). +return "CCC object with leading synthetic value " + str(sbvalue.GetChildMemberWithName("a")) + + class CCCSynthProvider(object): def __init__(self, sbvalue, internal_dict): self._sbvalue = sbvalue @@ -42,6 +50,9 @@ def num_children(self): return 3 def get_child_index(self, name): +if name == "a": +# Return b for test. +return 1 raise RuntimeError("I don't want to be called!") def get_child_at_index(self, index): @@ -119,3 +130,16 @@ def __lldb_init_module(debugger, dict): "synth.empty2_summary", lldb.eTypeOptionHideEmptyAggregates ), ) +cat2 = debugger.CreateCategory("CCCSynth2") +cat2.AddTypeSynthetic( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSynthetic.CreateWithClassName( +"synth.CCCSynthProvider", lldb.eTypeOptionCascade +), +) +cat2.AddTypeSummary( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSummary.CreateWithFunctionName( +"synth.ccc_synthetic"
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
@@ -155,6 +155,18 @@ def cleanup(): ], ) v-bulle wrote: I don't think we can have a conflict. In this test we have several categories which are enabled one after the other. I just add a new one (with a new name CCCSynth2). https://github.com/llvm/llvm-project/pull/95959 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/95959 >From 27a00b54bc991dfb4747e0d37b15878beebaabba Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 12 Jun 2024 14:23:15 -0700 Subject: [PATCH 1/4] [API] add GetSyntheticValue --- lldb/include/lldb/API/SBValue.h | 2 ++ lldb/source/API/SBValue.cpp | 12 2 files changed, 14 insertions(+) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 65920c76df7a8..bec816fb45184 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -89,6 +89,8 @@ class LLDB_API SBValue { lldb::SBValue GetNonSyntheticValue(); + lldb::SBValue GetSyntheticValue(); + lldb::DynamicValueType GetPreferDynamicValue(); void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 9d7efba024d11..6b77c0e95cedd 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -761,6 +761,18 @@ lldb::SBValue SBValue::GetNonSyntheticValue() { return value_sb; } +lldb::SBValue SBValue::GetSyntheticValue() { + LLDB_INSTRUMENT_VA(this); + + SBValue value_sb; + if (IsValid()) { +ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), + m_opaque_sp->GetUseDynamic(), true)); +value_sb.SetSP(proxy_sp); + } + return value_sb; +} + lldb::DynamicValueType SBValue::GetPreferDynamicValue() { LLDB_INSTRUMENT_VA(this); >From e0ed752849486f67d9fddbef3767a1756afd1ab2 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 20 Jun 2024 17:04:15 -0700 Subject: [PATCH 2/4] add test --- .../formatters/TestFormattersSBAPI.py | 12 lldb/test/API/python_api/formatters/synth.py | 28 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py index 7e802f92da352..460afbc1202cf 100644 --- a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py +++ b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py @@ -155,6 +155,18 @@ def cleanup(): ], ) +self.dbg.GetCategory("CCCSynth2").SetEnabled(True) +self.expect( +"frame variable ccc", +matching=True, +substrs=[ +"CCC object with leading synthetic value (int) b = 222", +"a = 111", +"b = 222", +"c = 333", +], +) + foo_var = ( self.dbg.GetSelectedTarget() .GetProcess() diff --git a/lldb/test/API/python_api/formatters/synth.py b/lldb/test/API/python_api/formatters/synth.py index 474c18bc62ebd..2b8f7c86ac6f1 100644 --- a/lldb/test/API/python_api/formatters/synth.py +++ b/lldb/test/API/python_api/formatters/synth.py @@ -29,11 +29,19 @@ def ccc_summary(sbvalue, internal_dict): # This tests that the SBValue.GetNonSyntheticValue() actually returns a # non-synthetic value. If it does not, then sbvalue.GetChildMemberWithName("a") # in the following statement will call the 'get_child_index' method of the -# synthetic child provider CCCSynthProvider below (which raises an -# exception). +# synthetic child provider CCCSynthProvider below (which return the "b" field"). return "CCC object with leading value " + str(sbvalue.GetChildMemberWithName("a")) +def ccc_synthetic(sbvalue, internal_dict): +sbvalue = sbvalue.GetSyntheticValue() +# This tests that the SBValue.GetNonSyntheticValue() actually returns a +# synthetic value. If it does, then sbvalue.GetChildMemberWithName("a") +# in the following statement will call the 'get_child_index' method of the +# synthetic child provider CCCSynthProvider below (which return the "b" field"). +return "CCC object with leading synthetic value " + str(sbvalue.GetChildMemberWithName("a")) + + class CCCSynthProvider(object): def __init__(self, sbvalue, internal_dict): self._sbvalue = sbvalue @@ -42,6 +50,9 @@ def num_children(self): return 3 def get_child_index(self, name): +if name == "a": +# Return b for test. +return 1 raise RuntimeError("I don't want to be called!") def get_child_at_index(self, index): @@ -119,3 +130,16 @@ def __lldb_init_module(debugger, dict): "synth.empty2_summary", lldb.eTypeOptionHideEmptyAggregates ), ) +cat2 = debugger.CreateCategory("CCCSynth2") +cat2.AddTypeSynthetic( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSynthetic.CreateWithClassName( +"synth.CCCSynthProvider", lldb.eTypeOptionCascade +), +) +cat2.AddTypeSummary( +lldb.SBTypeNameSpecifier("CCC"), +lldb.SBTypeSummary.CreateWithFunctionName( +"synth.ccc_synthetic"
[Lldb-commits] [lldb] [lldb] fix dead lock in TypeCategoryMap.cpp (PR #87540)
https://github.com/v-bulle edited https://github.com/llvm/llvm-project/pull/87540 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] fix dead lock in TypeCategoryMap.cpp (PR #87540)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/87540 >From 5234f6873d894dd80b2c1fef40fd18e4b722a2c9 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 3 Apr 2024 11:31:06 -0700 Subject: [PATCH 1/2] [lldb] fix dead lock in TypeCategoryMap.cpp FormatManager::GetCategoryForLanguage and FormatManager::GetCategory(can_create = true) can be called concurently and they both take the TypeCategory::m_map_mutex and the FormatManager::m_language_categories_mutex but in reverse order. Without the patch, we can have a dead lock. --- .../source/DataFormatters/TypeCategoryMap.cpp | 28 +++ 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp index fd76bab95826af..0d1f55fff473d1 100644 --- a/lldb/source/DataFormatters/TypeCategoryMap.cpp +++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp @@ -25,19 +25,23 @@ TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst) } void TypeCategoryMap::Add(KeyType name, const TypeCategoryImplSP &entry) { - std::lock_guard guard(m_map_mutex); - m_map[name] = entry; + { +std::lock_guard guard(m_map_mutex); +m_map[name] = entry; + } if (listener) listener->Changed(); } bool TypeCategoryMap::Delete(KeyType name) { - std::lock_guard guard(m_map_mutex); - MapIterator iter = m_map.find(name); - if (iter == m_map.end()) -return false; - m_map.erase(name); - Disable(name); + { +std::lock_guard guard(m_map_mutex); +MapIterator iter = m_map.find(name); +if (iter == m_map.end()) + return false; +m_map.erase(name); +Disable(name); + } if (listener) listener->Changed(); return true; @@ -123,9 +127,11 @@ void TypeCategoryMap::DisableAllCategories() { } void TypeCategoryMap::Clear() { - std::lock_guard guard(m_map_mutex); - m_map.clear(); - m_active_categories.clear(); + { +std::lock_guard guard(m_map_mutex); +m_map.clear(); +m_active_categories.clear(); + } if (listener) listener->Changed(); } >From 7305de06ab0425631fdf554cd1ad0498ac9fc7ed Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 4 Apr 2024 15:20:59 -0700 Subject: [PATCH 2/2] Adds comments --- lldb/source/DataFormatters/TypeCategoryMap.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp index 0d1f55fff473d1..ecbdcde98d07d3 100644 --- a/lldb/source/DataFormatters/TypeCategoryMap.cpp +++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp @@ -29,6 +29,7 @@ void TypeCategoryMap::Add(KeyType name, const TypeCategoryImplSP &entry) { std::lock_guard guard(m_map_mutex); m_map[name] = entry; } + // The lock is now released for the eventual call to Changed. if (listener) listener->Changed(); } @@ -42,6 +43,7 @@ bool TypeCategoryMap::Delete(KeyType name) { m_map.erase(name); Disable(name); } + // The lock is now released for the eventual call to Changed. if (listener) listener->Changed(); return true; @@ -132,6 +134,7 @@ void TypeCategoryMap::Clear() { m_map.clear(); m_active_categories.clear(); } + // The lock is now released for the eventual call to Changed. if (listener) listener->Changed(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] fix dead lock in TypeCategoryMap.cpp (PR #87540)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/87540 >From 5234f6873d894dd80b2c1fef40fd18e4b722a2c9 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Wed, 3 Apr 2024 11:31:06 -0700 Subject: [PATCH 1/3] [lldb] fix dead lock in TypeCategoryMap.cpp FormatManager::GetCategoryForLanguage and FormatManager::GetCategory(can_create = true) can be called concurently and they both take the TypeCategory::m_map_mutex and the FormatManager::m_language_categories_mutex but in reverse order. Without the patch, we can have a dead lock. --- .../source/DataFormatters/TypeCategoryMap.cpp | 28 +++ 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp index fd76bab95826af..0d1f55fff473d1 100644 --- a/lldb/source/DataFormatters/TypeCategoryMap.cpp +++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp @@ -25,19 +25,23 @@ TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst) } void TypeCategoryMap::Add(KeyType name, const TypeCategoryImplSP &entry) { - std::lock_guard guard(m_map_mutex); - m_map[name] = entry; + { +std::lock_guard guard(m_map_mutex); +m_map[name] = entry; + } if (listener) listener->Changed(); } bool TypeCategoryMap::Delete(KeyType name) { - std::lock_guard guard(m_map_mutex); - MapIterator iter = m_map.find(name); - if (iter == m_map.end()) -return false; - m_map.erase(name); - Disable(name); + { +std::lock_guard guard(m_map_mutex); +MapIterator iter = m_map.find(name); +if (iter == m_map.end()) + return false; +m_map.erase(name); +Disable(name); + } if (listener) listener->Changed(); return true; @@ -123,9 +127,11 @@ void TypeCategoryMap::DisableAllCategories() { } void TypeCategoryMap::Clear() { - std::lock_guard guard(m_map_mutex); - m_map.clear(); - m_active_categories.clear(); + { +std::lock_guard guard(m_map_mutex); +m_map.clear(); +m_active_categories.clear(); + } if (listener) listener->Changed(); } >From 7305de06ab0425631fdf554cd1ad0498ac9fc7ed Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 4 Apr 2024 15:20:59 -0700 Subject: [PATCH 2/3] Adds comments --- lldb/source/DataFormatters/TypeCategoryMap.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp index 0d1f55fff473d1..ecbdcde98d07d3 100644 --- a/lldb/source/DataFormatters/TypeCategoryMap.cpp +++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp @@ -29,6 +29,7 @@ void TypeCategoryMap::Add(KeyType name, const TypeCategoryImplSP &entry) { std::lock_guard guard(m_map_mutex); m_map[name] = entry; } + // The lock is now released for the eventual call to Changed. if (listener) listener->Changed(); } @@ -42,6 +43,7 @@ bool TypeCategoryMap::Delete(KeyType name) { m_map.erase(name); Disable(name); } + // The lock is now released for the eventual call to Changed. if (listener) listener->Changed(); return true; @@ -132,6 +134,7 @@ void TypeCategoryMap::Clear() { m_map.clear(); m_active_categories.clear(); } + // The lock is now released for the eventual call to Changed. if (listener) listener->Changed(); } >From bb51c8944ccecac2af5d9527a61718e1d1e85d4b Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Tue, 9 Apr 2024 08:33:36 -0700 Subject: [PATCH 3/3] Modify comment --- lldb/source/DataFormatters/TypeCategoryMap.cpp | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp index ecbdcde98d07d3..ce2cf369b5be53 100644 --- a/lldb/source/DataFormatters/TypeCategoryMap.cpp +++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp @@ -29,7 +29,10 @@ void TypeCategoryMap::Add(KeyType name, const TypeCategoryImplSP &entry) { std::lock_guard guard(m_map_mutex); m_map[name] = entry; } - // The lock is now released for the eventual call to Changed. + // Release the mutex to avoid a potential deadlock between + // TypeCategoryMap::m_map_mutex and + // FormatManager::m_language_categories_mutex which can be acquired in + // reverse order when calling FormatManager::Changed. if (listener) listener->Changed(); } @@ -43,7 +46,10 @@ bool TypeCategoryMap::Delete(KeyType name) { m_map.erase(name); Disable(name); } - // The lock is now released for the eventual call to Changed. + // Release the mutex to avoid a potential deadlock between + // TypeCategoryMap::m_map_mutex and + // FormatManager::m_language_categories_mutex which can be acquired in + // reverse order when calling FormatManager::Changed. if (listener) listener->Changed(); return true; @@ -134,7 +140,10 @@ void TypeCategoryMap::Clear() { m_map.clear(); m_active_categories
[Lldb-commits] [lldb] [lldb] fix dead lock in TypeCategoryMap.cpp (PR #87540)
@@ -25,19 +25,25 @@ TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst) } void TypeCategoryMap::Add(KeyType name, const TypeCategoryImplSP &entry) { - std::lock_guard guard(m_map_mutex); - m_map[name] = entry; + { +std::lock_guard guard(m_map_mutex); +m_map[name] = entry; + } + // The lock is now released for the eventual call to Changed. v-bulle wrote: done https://github.com/llvm/llvm-project/pull/87540 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] fix step in AArch64 trampoline (PR #90783)
https://github.com/v-bulle created https://github.com/llvm/llvm-project/pull/90783 Detects AArch64 trampolines in order to be able to step in a function through a trampoline on AArch64. >From 12464941c1b11ffad0ff2566642df3d30976a3f9 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 18 Apr 2024 10:39:59 -0700 Subject: [PATCH] [lldb] fix step in AArch64 trampoline --- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 26 --- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 19 +- .../StepIn/Inputs/aarch64_thunk.cc| 15 +++ .../StepIn/step_through-aarch64-thunk.test| 17 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc create mode 100644 lldb/test/Shell/ExecControl/StepIn/step_through-aarch64-thunk.test diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 9fa245fc41d40c..232030268e42c8 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -506,9 +506,29 @@ DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread, Target &target = thread.GetProcess()->GetTarget(); const ModuleList &images = target.GetImages(); - images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols); - if (!target_symbols.GetSize()) -return thread_plan_sp; + llvm::StringRef target_name = sym_name.GetStringRef(); + // On AArch64, the trampoline name has a prefix (__AArch64ADRPThunk_ or + // __AArch64AbsLongThunk_) added to the function name. If we detect a + // trampoline with the prefix, we need to remove the prefix to find the + // function symbol. + if (target_name.consume_front("__AArch64ADRPThunk_")) { +// An empty target name can happen when for trampolines generated for +// section-referencing relocations. +if (!target_name.empty()) { + images.FindSymbolsWithNameAndType(ConstString(target_name), +eSymbolTypeCode, target_symbols); +} + } else if (target_name.consume_front("__AArch64AbsLongThunk_")) { +// An empty target name can happen when for trampolines generated for +// section-referencing relocations. +if (!target_name.empty()) { + images.FindSymbolsWithNameAndType(ConstString(target_name), +eSymbolTypeCode, target_symbols); +} + } else { +images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, + target_symbols); + } typedef std::vector AddressVector; AddressVector addrs; diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 16f6d2e884b577..1646ee9aa34a61 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2356,13 +2356,30 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, bool symbol_size_valid = symbol.st_size != 0 || symbol.getType() != STT_FUNC; +bool is_trampoline = false; +if (arch.IsValid() && (arch.GetMachine() == llvm::Triple::aarch64)) { + // On AArch64, trampolines are registered as code. + // If we detect a trampoline (which starts with __AArch64ADRPThunk_ or + // __AArch64AbsLongThunk_) we register the symbol as a trampoline. This + // way we will be able to detect the trampoline when we step in a function + // and step through the trampoline. + if (symbol_type == eSymbolTypeCode) { +llvm::StringRef trampoline_name = mangled.GetName().GetStringRef(); +if (trampoline_name.starts_with("__AArch64ADRPThunk_") || +trampoline_name.starts_with("__AArch64AbsLongThunk_")) { + symbol_type = eSymbolTypeTrampoline; + is_trampoline = true; +} + } +} + Symbol dc_symbol( i + start_id, // ID is the original symbol table index. mangled, symbol_type,// Type of this symbol is_global, // Is this globally visible? false, // Is this symbol debug info? -false, // Is this symbol a trampoline? +is_trampoline, // Is this symbol a trampoline? false, // Is this symbol artificial? AddressRange(symbol_section_sp, // Section in which this symbol is // defined or null. diff --git a/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc b/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc new file mode 100644 index 00..02f3bef32a59a3 --- /dev/null +++ b/lldb/test/Shell/ExecCont
[Lldb-commits] [lldb] [lldb] fix step in AArch64 trampoline (PR #90783)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/90783 >From 12464941c1b11ffad0ff2566642df3d30976a3f9 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 18 Apr 2024 10:39:59 -0700 Subject: [PATCH 1/2] [lldb] fix step in AArch64 trampoline --- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 26 --- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 19 +- .../StepIn/Inputs/aarch64_thunk.cc| 15 +++ .../StepIn/step_through-aarch64-thunk.test| 17 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc create mode 100644 lldb/test/Shell/ExecControl/StepIn/step_through-aarch64-thunk.test diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 9fa245fc41d40c..232030268e42c8 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -506,9 +506,29 @@ DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread, Target &target = thread.GetProcess()->GetTarget(); const ModuleList &images = target.GetImages(); - images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols); - if (!target_symbols.GetSize()) -return thread_plan_sp; + llvm::StringRef target_name = sym_name.GetStringRef(); + // On AArch64, the trampoline name has a prefix (__AArch64ADRPThunk_ or + // __AArch64AbsLongThunk_) added to the function name. If we detect a + // trampoline with the prefix, we need to remove the prefix to find the + // function symbol. + if (target_name.consume_front("__AArch64ADRPThunk_")) { +// An empty target name can happen when for trampolines generated for +// section-referencing relocations. +if (!target_name.empty()) { + images.FindSymbolsWithNameAndType(ConstString(target_name), +eSymbolTypeCode, target_symbols); +} + } else if (target_name.consume_front("__AArch64AbsLongThunk_")) { +// An empty target name can happen when for trampolines generated for +// section-referencing relocations. +if (!target_name.empty()) { + images.FindSymbolsWithNameAndType(ConstString(target_name), +eSymbolTypeCode, target_symbols); +} + } else { +images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, + target_symbols); + } typedef std::vector AddressVector; AddressVector addrs; diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 16f6d2e884b577..1646ee9aa34a61 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2356,13 +2356,30 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, bool symbol_size_valid = symbol.st_size != 0 || symbol.getType() != STT_FUNC; +bool is_trampoline = false; +if (arch.IsValid() && (arch.GetMachine() == llvm::Triple::aarch64)) { + // On AArch64, trampolines are registered as code. + // If we detect a trampoline (which starts with __AArch64ADRPThunk_ or + // __AArch64AbsLongThunk_) we register the symbol as a trampoline. This + // way we will be able to detect the trampoline when we step in a function + // and step through the trampoline. + if (symbol_type == eSymbolTypeCode) { +llvm::StringRef trampoline_name = mangled.GetName().GetStringRef(); +if (trampoline_name.starts_with("__AArch64ADRPThunk_") || +trampoline_name.starts_with("__AArch64AbsLongThunk_")) { + symbol_type = eSymbolTypeTrampoline; + is_trampoline = true; +} + } +} + Symbol dc_symbol( i + start_id, // ID is the original symbol table index. mangled, symbol_type,// Type of this symbol is_global, // Is this globally visible? false, // Is this symbol debug info? -false, // Is this symbol a trampoline? +is_trampoline, // Is this symbol a trampoline? false, // Is this symbol artificial? AddressRange(symbol_section_sp, // Section in which this symbol is // defined or null. diff --git a/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc b/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc new file mode 100644 index 00..02f3bef32a59a3 --- /dev/null +++ b/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc @@ -0,0 +1,15 @@ +extern "C" int __attribute__((naked)) __AArch64A
[Lldb-commits] [lldb] [lldb] fix step in AArch64 trampoline (PR #90783)
https://github.com/v-bulle updated https://github.com/llvm/llvm-project/pull/90783 >From 12464941c1b11ffad0ff2566642df3d30976a3f9 Mon Sep 17 00:00:00 2001 From: Vincent Belliard Date: Thu, 18 Apr 2024 10:39:59 -0700 Subject: [PATCH 1/3] [lldb] fix step in AArch64 trampoline --- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 26 --- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 19 +- .../StepIn/Inputs/aarch64_thunk.cc| 15 +++ .../StepIn/step_through-aarch64-thunk.test| 17 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc create mode 100644 lldb/test/Shell/ExecControl/StepIn/step_through-aarch64-thunk.test diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 9fa245fc41d40c..232030268e42c8 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -506,9 +506,29 @@ DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread, Target &target = thread.GetProcess()->GetTarget(); const ModuleList &images = target.GetImages(); - images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols); - if (!target_symbols.GetSize()) -return thread_plan_sp; + llvm::StringRef target_name = sym_name.GetStringRef(); + // On AArch64, the trampoline name has a prefix (__AArch64ADRPThunk_ or + // __AArch64AbsLongThunk_) added to the function name. If we detect a + // trampoline with the prefix, we need to remove the prefix to find the + // function symbol. + if (target_name.consume_front("__AArch64ADRPThunk_")) { +// An empty target name can happen when for trampolines generated for +// section-referencing relocations. +if (!target_name.empty()) { + images.FindSymbolsWithNameAndType(ConstString(target_name), +eSymbolTypeCode, target_symbols); +} + } else if (target_name.consume_front("__AArch64AbsLongThunk_")) { +// An empty target name can happen when for trampolines generated for +// section-referencing relocations. +if (!target_name.empty()) { + images.FindSymbolsWithNameAndType(ConstString(target_name), +eSymbolTypeCode, target_symbols); +} + } else { +images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, + target_symbols); + } typedef std::vector AddressVector; AddressVector addrs; diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 16f6d2e884b577..1646ee9aa34a61 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2356,13 +2356,30 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, bool symbol_size_valid = symbol.st_size != 0 || symbol.getType() != STT_FUNC; +bool is_trampoline = false; +if (arch.IsValid() && (arch.GetMachine() == llvm::Triple::aarch64)) { + // On AArch64, trampolines are registered as code. + // If we detect a trampoline (which starts with __AArch64ADRPThunk_ or + // __AArch64AbsLongThunk_) we register the symbol as a trampoline. This + // way we will be able to detect the trampoline when we step in a function + // and step through the trampoline. + if (symbol_type == eSymbolTypeCode) { +llvm::StringRef trampoline_name = mangled.GetName().GetStringRef(); +if (trampoline_name.starts_with("__AArch64ADRPThunk_") || +trampoline_name.starts_with("__AArch64AbsLongThunk_")) { + symbol_type = eSymbolTypeTrampoline; + is_trampoline = true; +} + } +} + Symbol dc_symbol( i + start_id, // ID is the original symbol table index. mangled, symbol_type,// Type of this symbol is_global, // Is this globally visible? false, // Is this symbol debug info? -false, // Is this symbol a trampoline? +is_trampoline, // Is this symbol a trampoline? false, // Is this symbol artificial? AddressRange(symbol_section_sp, // Section in which this symbol is // defined or null. diff --git a/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc b/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc new file mode 100644 index 00..02f3bef32a59a3 --- /dev/null +++ b/lldb/test/Shell/ExecControl/StepIn/Inputs/aarch64_thunk.cc @@ -0,0 +1,15 @@ +extern "C" int __attribute__((naked)) __AArch64A
[Lldb-commits] [lldb] [lldb] fix step in AArch64 trampoline (PR #90783)
@@ -506,9 +506,29 @@ DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread, Target &target = thread.GetProcess()->GetTarget(); const ModuleList &images = target.GetImages(); - images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols); - if (!target_symbols.GetSize()) -return thread_plan_sp; + llvm::StringRef target_name = sym_name.GetStringRef(); + // On AArch64, the trampoline name has a prefix (__AArch64ADRPThunk_ or + // __AArch64AbsLongThunk_) added to the function name. If we detect a + // trampoline with the prefix, we need to remove the prefix to find the + // function symbol. + if (target_name.consume_front("__AArch64ADRPThunk_")) { v-bulle wrote: done https://github.com/llvm/llvm-project/pull/90783 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits