diff options
author | Johnny Chen <johnny.chen@apple.com> | 2011-08-05 21:35:43 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2011-08-05 21:35:43 +0000 |
commit | cbf1737ea18e60cf20ef7688e17bc4ec4abbe1f6 (patch) | |
tree | 007e9d62c947b105701f99dfe10eb3f9b1441185 /lldb/scripts/Python/interface | |
parent | c320c85261b6787007dc3e3ed521b3e0b26e7070 (diff) | |
download | bcm5719-llvm-cbf1737ea18e60cf20ef7688e17bc4ec4abbe1f6.tar.gz bcm5719-llvm-cbf1737ea18e60cf20ef7688e17bc4ec4abbe1f6.zip |
Add SBType.GetBasicType() to the test scenario.
Add docstring for SBType, too.
llvm-svn: 136983
Diffstat (limited to 'lldb/scripts/Python/interface')
-rw-r--r-- | lldb/scripts/Python/interface/SBType.i | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/lldb/scripts/Python/interface/SBType.i b/lldb/scripts/Python/interface/SBType.i index 1936c04039f..48f20f1f2d6 100644 --- a/lldb/scripts/Python/interface/SBType.i +++ b/lldb/scripts/Python/interface/SBType.i @@ -9,6 +9,79 @@ namespace lldb { +%feature("docstring", +"Represents a data type in lldb. The FindFirstType() method of SBTarget/SBModule +returns a SBType. + +SBType supports the eq/ne operator. For example, + +main.cpp: + +class Task { +public: + int id; + Task *next; + Task(int i, Task *n): + id(i), + next(n) + {} +}; + +int main (int argc, char const *argv[]) +{ + Task *task_head = new Task(-1, NULL); + Task *task1 = new Task(1, NULL); + Task *task2 = new Task(2, NULL); + Task *task3 = new Task(3, NULL); // Orphaned. + Task *task4 = new Task(4, NULL); + Task *task5 = new Task(5, NULL); + + task_head->next = task1; + task1->next = task2; + task2->next = task4; + task4->next = task5; + + int total = 0; + Task *t = task_head; + while (t != NULL) { + if (t->id >= 0) + ++total; + t = t->next; + } + printf('We have a total number of %d tasks\n', total); + + // This corresponds to an empty task list. + Task *empty_task_head = new Task(-1, NULL); + + return 0; // Break at this line +} + +find_type.py: + + # Get the type 'Task'. + task_type = target.FindFirstType('Task') + self.assertTrue(task_type) + + # Get the variable 'task_head'. + frame0.FindVariable('task_head') + task_head_type = task_head.GetType() + self.assertTrue(task_head_type.IsPointerType()) + + # task_head_type is 'Task *'. + task_pointer_type = task_type.GetPointerType() + self.assertTrue(task_head_type == task_pointer_type) + + # Get the child mmember 'id' from 'task_head'. + id = task_head.GetChildMemberWithName('id') + id_type = id.GetType() + + # SBType.GetBasicType() takes an enum 'BasicType' (lldb-enumerations.h). + int_type = id_type.GetBasicType(lldb.eBasicTypeInt) + # id_type and int_type should be the same type! + self.assertTrue(id_type == int_type) + +... +") SBType; class SBType { public: |