[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)

2024-07-15 Thread Pavel Labath via lldb-commits

https://github.com/labath closed 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)

2024-07-08 Thread Pavel Labath via lldb-commits

https://github.com/labath approved this pull request.


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)

2024-07-03 Thread via lldb-commits

https://github.com/jimingham approved this pull request.

LGTM

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)

2024-07-03 Thread Vincent Belliard via lldb-commits

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(
+

[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)

2024-07-03 Thread Vincent Belliard via lldb-commits

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(
+

[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)

2024-07-03 Thread Vincent Belliard via lldb-commits

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(
+

[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)

2024-07-03 Thread via lldb-commits

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 5da7179cb3ff80203f58ddea71562816b2ae4ff6 
bcfebfbcbc4196daa9ab03874a58b53d44afeb3c -- lldb/include/lldb/API/SBValue.h 
lldb/source/API/SBValue.cpp lldb/test/API/python_api/formatters/main.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/API/python_api/formatters/main.cpp 
b/lldb/test/API/python_api/formatters/main.cpp
index f731fd2c7b..50c29657a0 100644
--- a/lldb/test/API/python_api/formatters/main.cpp
+++ b/lldb/test/API/python_api/formatters/main.cpp
@@ -52,7 +52,7 @@ int main(int argc, char const *argv[]) {
 
CCC ccc = {111, 222, 333};
 
-int bar_int = 20;
+int bar_int = 20;
 
 Empty1 e1;
 Empty2 e2;

``




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)

2024-07-03 Thread Vincent Belliard via lldb-commits

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)

2024-07-03 Thread Vincent Belliard via lldb-commits

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(
+

[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)

2024-07-03 Thread Vincent Belliard via lldb-commits

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(
+

[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)

2024-06-27 Thread Pavel Labath via lldb-commits

labath wrote:

> 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?

Sounds like a good idea to me.


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)

2024-06-26 Thread via lldb-commits

jimingham 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.  
Getting the NonSynthetic Value 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, and return an empty SBValue if it is not?

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)

2024-06-21 Thread Vincent Belliard via lldb-commits

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(
+

[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)

2024-06-21 Thread Pavel Labath via lldb-commits


@@ -155,6 +155,18 @@ def cleanup():
 ],
 )

labath wrote:

You have two categories, but they both have a summary provider for the same 
type (`CCC`). (Enabling one category does not automatically disable the other 
ones.) Right now, lldb seems to pick the one you want, but I don't think we 
promise that anywhere (in fact, I wouldn't be surprised if this comes down to 
some (nondeterministic) ordering in some hash container). By disabling the 
first category, we make sure that lldb always pick the one we want (in case, 
e.g., the container ordering changes). Alternatively, you could just attach the 
summary provider to a different type (CCC2?)

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)

2024-06-21 Thread Vincent Belliard via lldb-commits


@@ -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)

2024-06-21 Thread Pavel Labath via lldb-commits

https://github.com/labath approved this pull request.

Thanks.

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)

2024-06-21 Thread Pavel Labath via lldb-commits


@@ -155,6 +155,18 @@ def cleanup():
 ],
 )

labath wrote:

```suggestion
)
self.dbg.GetCategory("CCCSynth").SetEnabled(False)
```

I'm not sure how lldb chooses the summary providers in case of conflicts, but 
since that's not what we're testing here, we might as well remove the ambiguity.

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)

2024-06-21 Thread Pavel Labath via lldb-commits

https://github.com/labath edited 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)

2024-06-20 Thread Vincent Belliard via lldb-commits

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(
+

[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)

2024-06-20 Thread via lldb-commits

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 
d8091522664248a4ba73d8d1e7fa6ac57bfcf67c...e0ed752849486f67d9fddbef3767a1756afd1ab2
 lldb/test/API/python_api/formatters/TestFormattersSBAPI.py 
lldb/test/API/python_api/formatters/synth.py
``





View the diff from darker here.


``diff
--- synth.py2024-06-21 00:23:31.00 +
+++ synth.py2024-06-21 00:26:49.436805 +
@@ -37,11 +37,13 @@
 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"))
+return "CCC object with leading synthetic value " + str(
+sbvalue.GetChildMemberWithName("a")
+)
 
 
 class CCCSynthProvider(object):
 def __init__(self, sbvalue, internal_dict):
 self._sbvalue = sbvalue

``




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)

2024-06-20 Thread Vincent Belliard via lldb-commits

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(
+

[Lldb-commits] [lldb] [API] add GetSyntheticValue (PR #95959)

2024-06-20 Thread Vincent Belliard via lldb-commits

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)

2024-06-19 Thread Pavel Labath via lldb-commits

labath wrote:

We should also add a test case for the new API. You can just take an existing 
test case with some synthetic values (e.g. `TestFormattersSBAPI.py`), add some 
Get(Non)SyntheticValue calls, and make sure they do what they should.

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)

2024-06-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vincent Belliard (v-bulle)


Changes

Adds GetSyntheticValue to the API on top of GetNonSyntheticValue.

---
Full diff: https://github.com/llvm/llvm-project/pull/95959.diff


2 Files Affected:

- (modified) lldb/include/lldb/API/SBValue.h (+2) 
- (modified) lldb/source/API/SBValue.cpp (+12) 


``diff
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);
 

``




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)

2024-06-18 Thread Vincent Belliard via lldb-commits

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