Commit Graph

1994 Commits

Author SHA1 Message Date
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
Omar Sandoval
ec75400cc0 type: improve type handling
Add a parser for C type names and push the type logic out of the
CoredumpObject class.
2018-02-24 19:37:51 -08:00
Omar Sandoval
3c7c5f0035 dwarf: add optimized index by name 2018-02-20 21:55:59 -08:00
Omar Sandoval
c1671d6ae7 dwarf: merge dwarfdefs into drgn.dwarf 2018-02-20 20:28:38 -08:00
Omar Sandoval
c19f5d90cc dwarf: use flat array for abbreviation codes 2018-02-19 20:25:14 -08:00
Omar Sandoval
16c5cff47c Prototype of "crash" utility 2018-02-19 00:46:39 -08:00
Omar Sandoval
a04e7c7bbe cli/probe: implement struct member fetching
The parser is minimal and kinda jank, but it works. With a real parser
this could be extended to do pointer dereferencing, array subscripting,
and casting.
2017-09-05 00:27:14 -07:00
Omar Sandoval
89c2861e2b cli/probe: for filename:lineno, probe all matching addresses
Instead of just the first one. Also omit variables that cannot be
fetched instead of erroring out.
2017-09-04 23:15:17 -07:00
Omar Sandoval
0013015f2c cli/probe: better error messages 2017-09-04 22:35:59 -07:00
Omar Sandoval
c677749bcb cli/probe: implement variable fetching by name
This supports fetching both at a function and at an arbitrary
filename:lineno. It still needs better error messages and some other
extras.
2017-09-04 22:17:23 -07:00
Omar Sandoval
ccc9cbc862 dwarfdefs: add DW_ATE_* and move *_name() functions 2017-09-03 19:57:09 -07:00
Omar Sandoval
5f84ccfa1c drgn.dwarf: allow some DWARF sections to be missing
Not all files will have every DWARF section.
2017-09-03 09:23:27 -07:00
Omar Sandoval
97e604c05c Rewrite in Cython
The lldwarf/drgn.dwarf split wasn't working out too well, and moving all
of drgn.dwarf into lldwarf (by rewriting it into C) would be way too
much work. Instead, use Cython, which results in a parser which is just
as fast but with much cleaner code overall. It also turns out lldwarf
wasn't doing GC right, so the switch also fixed that.
2017-08-28 21:16:43 -07:00
Omar Sandoval
682fd172a4 cli/probe: start implementing variable fetching
Resolving parameters, variables with function scope, and global
variables should work. This is just the variable resolution, no fetching
yet, but a bunch of refactors snuck in here so committing it all now.
2017-08-27 23:56:14 -07:00
Omar Sandoval
e6a58f533a Store CU and parent in DIE
Back-references from the DIE to the CU and the parent DIE will make it
much easier to implement several features.
2017-08-27 11:35:38 -07:00
Omar Sandoval
64f66f747f lldwarf: get rid of explicit offset members
The parsing library shouldn't really care about keeping track of these.
Instead, add __dict__ and getattr()/setattr() to all of the lldwarf
objects so higher layers can store the offset if they want.

DwarfDie is special in two ways:

1. We want to store an offset for the DIE so we know where to parse
   sibling and children entries.
2. For some attributes, we need to store an offset so we know where to
   find them later.

Both of these are changed to be relative to the CU rather than the
buffer.
2017-08-27 10:53:04 -07:00
Omar Sandoval
72b9af2b82 Add address range table parsing 2017-08-25 23:24:38 -07:00
Omar Sandoval
bb5881243f Get rid of spurious commas in DW_* enums 2017-08-25 22:39:15 -07:00
Omar Sandoval
1fc2b6e89b Initial commit
I wrote all of this code a few months back and am just now getting
around to committing it. The low-level DWARF parsing library is pretty
solid, although it only implements a subset of DWARF so far. The CLI and
higher-level interface are experimental.
2017-08-24 22:46:16 -07:00