[Lldb-commits] [PATCH] Make SBValue::GetNonSyntheticValue return really that.
Siva Chandra
sivachandra at google.com
Mon Jun 22 12:50:47 PDT 2015
The following is a small repro case I am using.
C++ source (class.cc):
1 class CCC
2 {
3 public:
4 int a, b, c;
5 };
6
7 int
8 main ()
9 {
10 CCC obj = { 111, 222, 333 };
11 return 0;
12 }
Python (ccc.py):
1 import lldb
2
3 def ccc_summary(sbvalue, internal_dict):
4 sbvalue = sbvalue.GetNonSyntheticValue()
5 return ("%s, %s, %s" %
6 (str(sbvalue.GetChildMemberWithName("a")),
7 str(sbvalue.GetChildMemberWithName("b")),
8 str(sbvalue.GetChildMemberWithName("c"))))
9
10
11 class CCCSynthProvider(object):
12 def __init__(self, sbvalue, internal_dict):
13 self._sbvalue = sbvalue
14
15 def num_children(self):
16 return 3
17
18 def get_child_index(self, name):
19 raise RuntimeError("I don't want to be called!")
20
21 def get_child_at_index(self, index):
22 if index == 0:
23 return self._sbvalue.GetChildMemberWithName("a")
24 if index == 1:
25 return self._sbvalue.GetChildMemberWithName("b")
26 if index == 2:
27 return self._sbvalue.GetChildMemberWithName("c")
28
29
30 cat = lldb.debugger.CreateCategory("my_cat")
31 cat.AddTypeSynthetic(
32 lldb.SBTypeNameSpecifier("CCC"),
33 lldb.SBTypeSynthetic.CreateWithClassName("ccc.CCCSynthProvider",
34 lldb.eTypeOptionCascade))
35 cat.AddTypeSummary(
36 lldb.SBTypeNameSpecifier("CCC"),
37 lldb.SBTypeSummary.CreateWithFunctionName("ccc.ccc_summary",
38 lldb.eTypeOptionCascade))
39 cat.SetEnabled(True)
Without the proposed change, this is what happens:
(lldb) script import ccc
(lldb) b class.cc :11
Breakpoint 1: where = a.out`main + 25 at class.cc:11, address = 0x0000000000400506
(lldb) r
Process 31046 launched: '/usr/local/google/home/sivachandra/LAB/lldb_scripting/a.out' (x86_64)
Process 31046 stopped
* thread #1: tid = 31046, 0x0000000000400506 a.out`main + 25 at class.cc:11, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000400506 a.out`main + 25 at class.cc:11
8 main ()
9 {
10 CCC obj = { 111, 222, 333 };
-> 11 return 0;
12 }
(lldb) p obj
Traceback (most recent call last):
File "./ccc.py", line 19, in get_child_index
raise RuntimeError("I don't want to be called!")
RuntimeError: I don't want to be called!
Traceback (most recent call last):
File "./ccc.py", line 19, in get_child_index
raise RuntimeError("I don't want to be called!")
RuntimeError: I don't want to be called!
Traceback (most recent call last):
File "./ccc.py", line 19, in get_child_index
raise RuntimeError("I don't want to be called!")
RuntimeError: I don't want to be called!
Traceback (most recent call last):
File "./ccc.py", line 19, in get_child_index
raise RuntimeError("I don't want to be called!")
RuntimeError: I don't want to be called!
Traceback (most recent call last):
File "./ccc.py", line 19, in get_child_index
raise RuntimeError("I don't want to be called!")
RuntimeError: I don't want to be called!
Traceback (most recent call last):
File "./ccc.py", line 19, in get_child_index
raise RuntimeError("I don't want to be called!")
RuntimeError: I don't want to be called!
(CCC) $0 = No value, No value, No value {
a = 111
b = 222
c = 333
}
After the proposed change:
(lldb) script import ccc
(lldb) b class.cc :11
Breakpoint 1: where = a.out`main + 25 at class.cc:11, address = 0x0000000000400506
(lldb) r
Process 31412 launched: '/usr/local/google/home/sivachandra/LAB/lldb_scripting/a.out' (x86_64)
Process 31412 stopped
* thread #1: tid = 31412, 0x0000000000400506 a.out`main + 25 at class.cc:11, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000400506 a.out`main + 25 at class.cc:11
8 main ()
9 {
10 CCC obj = { 111, 222, 333 };
-> 11 return 0;
12 }
(lldb) p obj
(CCC) $0 = (int) a = 111, (int) b = 222, (int) c = 333 {
a = 111
b = 222
c = 333
}
http://reviews.llvm.org/D10581
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the lldb-commits
mailing list