Omar Sandoval
4891a6341f
typeindex: add method for getting type of literal
...
This will be used for ProgramObject operators where one operand is not a
ProgramObject.
2018-05-02 22:56:16 -07:00
Omar Sandoval
b060c9dcf7
typeindex: make sure we can find base types
...
The compiler might call a base type by any variation of its name (e.g.,
long or long int). Make sure we find it no matter what it chose.
2018-05-02 22:41:26 -07:00
Omar Sandoval
d7236962db
type: fix BoolType.__repr__()
...
It shouldn't include self.signed.
2018-05-02 01:20:30 -07:00
Omar Sandoval
389f483dbb
program: implement unary operators for ProgramObject
2018-05-01 23:52:02 -07:00
Omar Sandoval
eb32ef6756
program: pass TypeIndex to Program instead of callback
2018-05-01 23:42:25 -07:00
Omar Sandoval
e458348409
type: rename EnumType.compatible to compatible_name
...
More descriptive but not too verbose.
2018-05-01 21:07:38 -07:00
Omar Sandoval
90f6913242
program: convert value when creating rvalue
...
This is useful for a few cases:
- We should make sure that the value of an object is actually valid for
its type
- When casting, the value should be converted to the new type where
appropriate
- For the upcoming ProgramObject operators
2018-05-01 20:58:37 -07:00
Omar Sandoval
c3dbe939ad
program: fix Program.object() type annotation
...
It can also be used to create rvalues, so make the address optional.
2018-05-01 20:56:50 -07:00
Omar Sandoval
812951c340
type: add Type.convert()
...
For converting a value to a valid value of that type (i.e., casting).
2018-05-01 20:49:49 -07:00
Omar Sandoval
68462da720
typeindex: add usual arithmetic conversions
...
The rules are really subtle and not completely specified, so hopefully
this covers all of the corner cases... This will be used for
ProgramObject operators.
2018-05-01 00:17:20 -07:00
Omar Sandoval
78a745588a
type: add TypedefType.real_type()
...
Instead of open-coding it in ProgramObject.
2018-04-30 22:23:55 -07:00
Omar Sandoval
c49426359b
type: add Type.unqualified()
...
Used to get the same type with no qualifiers.
2018-04-30 22:16:44 -07:00
Omar Sandoval
26d8e0f7e9
type: add compatible integer type to EnumType
2018-04-30 19:33:40 -07:00
Omar Sandoval
22ddd198ce
type: rename BasicType to ArithmeticType
...
This is more descriptive and allows for future expansion to complex
types.
2018-04-30 19:11:52 -07:00
Omar Sandoval
da4ff78f36
type: make BoolType a subclass of IntType
...
_Bool is a standard unsigned integer type.
2018-04-30 19:05:24 -07:00
Omar Sandoval
cef86a18c0
Move from_dwarf_type{,_name}() logic to a class
2018-04-30 18:11:28 -07:00
Omar Sandoval
80d3058b17
type: canonicalize basic type names
...
Instead of using whatever the compiler emits, make sure we are
consistent with naming.
2018-04-30 00:01:18 -07:00
Omar Sandoval
e1673f9f29
typename: use a better canonical formatting for integer types
...
I.e., omit "int" for "short", "long", and "long long".
2018-04-29 23:56:31 -07:00
Omar Sandoval
8a7bf0edf7
program: implement ProgramObject.__iter__()
2018-04-28 23:18:49 -07:00
Omar Sandoval
41c74593b3
program: implement ProgramObject.__len__()
2018-04-28 23:12:53 -07:00
Omar Sandoval
322b35259b
program: better error message for ProgramObject.__getattr__() on non-struct
...
Instead of propagating the "not a struct or union" from member_(),
provide the usual attribute error message.
2018-04-28 23:03:49 -07:00
Omar Sandoval
6ca83a3775
program: implement ProgramObject.__dir__()
2018-04-28 22:54:03 -07:00
Omar Sandoval
e38ddba9c6
type: fix pretty-print of array of structs
...
We need to handle indentation like we do with nested structs.
2018-04-28 22:42:01 -07:00
Omar Sandoval
650896b619
dwarfindex: fix variable shadowing warning
2018-04-15 23:32:53 -07:00
Omar Sandoval
bb22a8e417
Add more documentation
2018-04-15 23:21:57 -07:00
Omar Sandoval
0713c57217
Add version information
2018-04-15 15:30:54 -07:00
Omar Sandoval
a4768ba2a4
License under GPL-3.0 or later
2018-04-15 15:03:33 -07:00
Omar Sandoval
1d2b90e62b
Document drgn.program and drgn.type more
2018-04-12 00:51:32 -07:00
Omar Sandoval
abc286df76
Rename Coredump{,Object} to Program{,Object}
2018-04-09 23:12:17 -07:00
Omar Sandoval
170df11650
type: cache calls to from_dwarf_type{,_name}()
...
And CompilationUnit.die(), otherwise caching from_dwarf_type() is
completely ineffective. This speeds up scripts drastically.
2018-04-09 22:52:18 -07:00
Omar Sandoval
4c9a454cd2
type{,name}: get rid of __eq__()
...
We should only have these for testing.
2018-04-09 22:49:39 -07:00
Omar Sandoval
f347a51399
type{,name}: make qualifiers a frozenset
2018-04-09 21:57:52 -07:00
Omar Sandoval
d5ba112e36
coredump: add rvalue objects
...
Sometimes it's useful to have a computed object that does not exist in
the coredump itself (e.g., when doing pointer arithmetic). Introduce the
notion of "rvalues", which have an explicit value instead of an address.
2018-04-09 21:14:23 -07:00
Omar Sandoval
366a706a96
type: replace Type.format() with Type.pretty(Type.read())
...
Most of the implementations of format() call read(). Make pretty() do
just the formatting part of format() and take the already read value.
2018-04-09 21:02:03 -07:00
Omar Sandoval
226bdd20d6
coredump: fix spelling of container_of in exceptions
2018-04-09 19:59:42 -07:00
Omar Sandoval
89f58ffd4f
coredump: don't open-code pointer value_() in __getitem__()
2018-04-09 19:39:45 -07:00
Omar Sandoval
b848134c49
Add (partial) support for function types
...
The only part not implemented is function type name parsing.
2018-04-08 23:04:08 -07:00
Omar Sandoval
d41137d6e2
type: format empty struct without newline
...
This shows up in, e.g., Linux's struct lock_class_key if compiled
without lockdep.
2018-04-07 15:36:46 -07:00
Omar Sandoval
76cba644a8
Reorganize packaging
2018-04-07 10:42:48 -07:00
Omar Sandoval
a655325b4c
coredump: add Coredump.object() instead of exposing CoredumpObject constructor
2018-04-06 22:48:18 -07:00
Omar Sandoval
422c39823f
type: allow reading incomplete array types
...
Just return a zero-length array.
2018-04-06 00:27:17 -07:00
Omar Sandoval
c6c7c080ce
type: handle typedef bitfields
2018-04-06 00:24:48 -07:00
Omar Sandoval
a63fbdb975
coredump: raise better errors from CoredumpObject.__getattr__()
2018-04-06 00:22:31 -07:00
Omar Sandoval
e6a1ece77f
type: don't eagerly repr compound types
...
Something like struct list_head will trivially get into an infinite
recursion.
2018-04-06 00:04:50 -07:00
Omar Sandoval
87d9058ba3
Add type annotations everywhere
2018-04-05 23:40:28 -07:00
Omar Sandoval
2bd81fd5fc
coredump: push ELF/DWARF-specific logic out of Coredump
...
Instead, take callbacks for looking up variables and reading memory.
While we're at it, get rid of TypeFactory and instead implement its
methods as functions taking a DwarfIndex.
2018-04-05 00:52:00 -07:00
Omar Sandoval
f4e62cfc1b
cli: include CoredumpObject in globals
...
For constructing objects from computed addresses. This is required for,
e.g., Linux kernel percpu allocations.
2018-04-05 00:25:52 -07:00
Omar Sandoval
3f6130a9b3
coredump: document Coredump and CoredumpObject
2018-04-05 00:22:56 -07:00
Omar Sandoval
65a8060a15
dwarfindex: fix heap overflow when reading abbreviation table
...
We might need to reallocate the array to make room for the null
terminator and tag/children byte.
2018-04-03 00:15:43 -07:00
Omar Sandoval
2d7a052356
dwarfindex: remove dependency on dwarf.h
2018-04-03 00:03:31 -07:00