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
Omar Sandoval
26f26f0e91
dwarfindex: parallelize relocations
...
The tricky part here is that we don't have a single flat array of
relocations, so we have to map a single iterator variable to iterate
over files and sections.
2018-04-02 23:37:35 -07:00
Omar Sandoval
96c35e0f68
dwarfindex: use OpenMP to parallelize CU indexing
...
A couple of tricky things to handle:
- The DIE hash needs to be thread-safe. This implements a lock-free
algorithm.
- We need to make sure exceptions are only raised with the GIL held.
This adds some hacky macro magic to avoid adding a bunch of
easy-to-forget boilerplate everywhere.
- We need to make sure the main thread reraises any exceptions thrown by
the worker threads.
2018-04-02 00:33:23 -07:00
Omar Sandoval
fdd9604db5
dwarfindex: use global CU array instead of per-file
...
This will make it easier to parallelize indexing CUs.
2018-04-01 13:33:51 -07:00
Omar Sandoval
90fbec02fc
dwarfindex: delete unused read_sleb128() and read_strlen()
2018-03-31 15:58:26 -07:00
Omar Sandoval
1ea45146be
dwarfindex: split up strp command based on is_64_bit
2018-03-31 15:47:11 -07:00
Omar Sandoval
f8a0e8ced3
dwarfindex: store abbreviation tag and children in same byte
2018-03-31 15:37:44 -07:00
Omar Sandoval
2c5c8c005a
dwarfindex: parse abbreviation table separately from compilation unit
...
We don't need the abbreviation table until we are actually indexing the
CU, and we don't need it afterwards, so parse it in index_cu() and free
it before returning.
2018-03-31 15:29:30 -07:00
Omar Sandoval
a1026d2a1f
dwarfindex: make index_die() iterative instead of recursive
...
This avoids the function call overhead.
2018-03-30 00:27:38 -07:00
Omar Sandoval
500917469d
dwarfindex: convert abbreviation table to commands
...
We don't need the actual abbreviation table; we just need to know how
much to skip and where the attributes we care about are.
2018-03-27 22:08:19 -07:00
Omar Sandoval
7599691dd1
dwarfindex: don't check that strp is null-terminated
...
If we make sure .debug_str is null-terminated, we just need to make sure
strp is not out of bounds.
2018-03-27 21:38:58 -07:00
Omar Sandoval
b45e930336
dwarf: rewrite drgn.dwarf in pure Python
...
Now that DwarfIndex is in C, the rest can be simpler Python rather than
Cython.
2018-03-26 01:51:20 -07:00
Omar Sandoval
a4dc1fb75f
dwarf: get rid of DWARF cdef enums
...
Just use the the Python enum classes since the performance critical path
is in C now.
2018-03-25 14:39:37 -07:00
Omar Sandoval
142e2ae45d
dwarf: rename CompilationUnitHeader to CompilationUnit
2018-03-25 14:38:23 -07:00
Omar Sandoval
acbf14d10c
dwarf: rewrite DwarfIndex in pure C
...
Most of drgn.dwarf is not performance-sensitive, and the part that is
(DwarfIndex) can use some extra tuning which is easier to do in C rather
than Cython.
2018-03-25 02:10:15 -07:00
Omar Sandoval
9a689c6e71
readwrite: pass char * and size instead of Py_buffer
...
Also remove the unused arange and line number program parsing rather
than refactoring it.
2018-03-15 00:49:12 -07:00
Omar Sandoval
b7b8661408
elf: microoptimize apply_relocations()
...
We can do 1/3 of the bounds checks if we loop over relocation structures
rather than reading individual fields. This makes reading sections with
relocations about 10% faster.
2018-03-13 20:26:48 -07:00
Omar Sandoval
e63128502b
elf: don't do unnecessary copy of section before applying relocations
...
This makes reading sections with relocations about 4% faster.
2018-03-13 19:36:28 -07:00
Omar Sandoval
7ebda948c6
dwarf: fix undefined signed integer overflow in LEB128
...
And add back the old lldwarf LEB128 tests.
2018-03-13 01:38:52 -07:00
Omar Sandoval
0ecef8d655
Move CLIs out of drgn module
2018-03-13 00:45:22 -07:00
Omar Sandoval
c81b7729c3
Compile Cython with language level 3
2018-03-13 00:20:24 -07:00
Omar Sandoval
97d578aa61
cli: introduce debugging REPL
...
Move the existing CLI to a separate drgntool CLI and make the drgn CLI
the main debugger tool.
2018-03-12 21:10:34 -07:00
Omar Sandoval
dad1c62fc9
dwarf: microoptimize DwarfIndex
...
A handful of optimizations that make indexing many CUs about 3% faster.
2018-03-11 01:47:13 -08:00
Omar Sandoval
de6c7ee2c6
elf: don't construct a python object for & 0xffffffff
...
I'm not sure why Cython was treating the integer literal as a Python
object, but this fixes it and saves about 75% of time running
relocations.
2018-03-11 00:06:05 -08:00
Omar Sandoval
c6c0494e5b
readwrite: return int instead of object
...
This shaves off about 8% of time in parsing relocations and DWARF since
we don't have to refcount None.
2018-03-10 12:40:15 -08:00
Omar Sandoval
a7309d2a15
elf: support debug sections with relocations
2018-03-09 17:41:54 -08:00
Omar Sandoval
238ce0f3dc
elf: handle compressed sections
2018-03-08 23:43:03 -08:00
Omar Sandoval
dac4f9156a
elf: clean up ElfFile API
...
Use functions instead of properties to make it clear that they're not
free, and make it possible to construct a DwarfFile directly from an
ElfFile.
2018-03-08 23:31:02 -08:00
Omar Sandoval
2efa9343fb
dwarf: add Die.size()
...
Instead of having to do die.find_constant(DW_AT.byte_size).
2018-03-08 21:30:05 -08:00
Omar Sandoval
35e6750f5a
dwarf: read() instead of using mmap()
...
This removes the need to clean anything up, avoids the issue of the file
changing from under us after we've indexed it, and simplifies offset
handling in a few places.
2018-03-08 21:10:32 -08:00
Omar Sandoval
792a2d22af
coredump: support reading strings
2018-03-07 21:30:26 -08:00
Omar Sandoval
aa4d5852b3
type: fix handling of arrays with zero-length elements
...
Encountered in s_writers_key in struct file_system_type.
2018-03-07 21:20:38 -08:00
Omar Sandoval
c625845a62
coredump: add containerof() to CoredumpObject
2018-03-07 21:07:19 -08:00
Omar Sandoval
16b3e672e1
coredump: use Type.format() for CoredumpObject.__str__()
2018-03-07 02:07:11 -08:00
Omar Sandoval
7d21255007
type: add format() to type classes
...
For formatting read values nicely in C syntax.
2018-03-07 02:04:09 -08:00
Omar Sandoval
4f7e35181e
coredump: add support for casting types
2018-03-07 00:31:14 -08:00
Omar Sandoval
adeeca927b
type: add TypeFactory.from_type_name()
2018-03-07 00:31:00 -08:00
Omar Sandoval
5eac4fe225
coredump: support array and pointer indexing
2018-03-06 01:44:21 -08:00
Omar Sandoval
f71d2a8fd9
type: add read() to type classes
...
For reading a value out of memory.
2018-03-06 01:22:14 -08:00
Omar Sandoval
84e0910342
type: remove all DWARF-specific code from type classes
2018-03-06 00:42:03 -08:00
Omar Sandoval
1717c060cd
type: further improve type handling
...
Make specific type classes which are separate from the type name
classes.
2018-03-03 02:14:09 -08:00