Commit a97f6c4
committed
Associate types with program
I originally envisioned types as dumb descriptors. This mostly works for
C because in C, types are fairly simple. However, even then the
drgn_program_member_info() API is awkward. You should be able to look up
a member directly from a type, but we need the program for caching
purposes. This has also held me back from adding offsetof() or
has_member() APIs.
Things get even messier with C++. C++ template parameters can be objects
(e.g., template <int N>). Such parameters would best be represented by a
drgn object, which we need a drgn program for. Static members are a
similar case.
So, let's reimagine types as being owned by a program. This has a few
parts:
1. In libdrgn, simple types are now created by factory functions,
drgn_foo_type_create().
2. To handle their variable length fields, compound types, enum types,
and function types are constructed with a "builder" API.
3. Simple types are deduplicated.
4. The Python type factory functions are replaced by methods of the
Program class.
5. While we're changing the API, the parameters to pointer_type() and
array_type() are reordered to be more logical (and to allow
pointer_type() to take a default size of None for the program's
default pointer size).
6. Likewise, the type factory methods take qualifiers as a keyword
argument only.
A big part of this change is updating the tests and splitting up large
test cases into smaller ones in a few places.
Signed-off-by: Omar Sandoval <[email protected]>1 parent c31208f commit a97f6c4
File tree
26 files changed
+6535
-4814
lines changed- docs
- drgn
- helpers/linux
- libdrgn
- python
- tests
26 files changed
+6535
-4814
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
77 | 75 | | |
78 | | - | |
79 | | - | |
80 | 76 | | |
81 | | - | |
82 | 77 | | |
83 | | - | |
84 | | - | |
85 | 78 | | |
86 | | - | |
87 | | - | |
88 | 79 | | |
89 | 80 | | |
90 | 81 | | |
91 | 82 | | |
92 | 83 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | 84 | | |
98 | 85 | | |
99 | 86 | | |
| |||
122 | 109 | | |
123 | 110 | | |
124 | 111 | | |
125 | | - | |
126 | | - | |
127 | 112 | | |
128 | | - | |
129 | | - | |
130 | 113 | | |
131 | | - | |
132 | 114 | | |
133 | 115 | | |
134 | | - | |
135 | | - | |
136 | 116 | | |
137 | | - | |
138 | | - | |
139 | 117 | | |
140 | 118 | | |
141 | 119 | | |
142 | 120 | | |
143 | 121 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | 122 | | |
149 | 123 | | |
150 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| 428 | + | |
428 | 429 | | |
429 | 430 | | |
430 | 431 | | |
| |||
493 | 494 | | |
494 | 495 | | |
495 | 496 | | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
496 | 503 | | |
497 | 504 | | |
498 | 505 | | |
| |||
0 commit comments