Commit Graph

39 Commits

Author SHA1 Message Date
Omar Sandoval
dbe1d4539b scripts: only build manylinux wheels for CPython.
The manylinux image apparently added a PyPy interpreter, which drgn
doesn't support.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-06-07 01:10:59 -07:00
Omar Sandoval
6a8d335a1f Add scripts to build manylinux2010 wheels
One nice side effect of commit e0921c5bdb ("libdrgn: don't use OpenMP
tasking") is that drgn now works with older versions of libgomp that
don't implement taskloop, including version 4.4 in manylinux2010. So, we
can finally build manylinux2010 wheels. These scripts are based on
scripts from Stephen Brennan, with some cleanups and updates for changes
in drgn's build requirements.

Closes #69.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-05-07 09:50:13 -07:00
Omar Sandoval
a4b9d68a8c Use GPL-3.0-or-later license identifier instead of GPL-3.0+
Apparently the latter is deprecated and the former is preferred.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-04-03 01:10:35 -07:00
Omar Sandoval
e5bc41f16c libdrgn: add latest elf.h and dwarf.h to support elfutils 0.165
The oldest LTS version of Ubuntu, 16.04, has elfutils 0.165. This
version is missing some ELF and DWARF definitions used by drgn. Add
copies of elf.h from glibc 2.33 and dwarf.h and elfutils/known-dwarf.h
from elfutils 0.183 to get the latest definitions and drop the minimum
required version of elfutils further to 0.165.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-03-21 23:18:39 -07:00
Omar Sandoval
4c5c5f3842 Remove bundled version of elfutils
We currently bundle a version of elfutils with patches to export
additional stack tracing functionality. This has a few drawbacks:

- Most of drgn's build time is actually building elfutils.
- Distributions don't like packages that bundle verions of other
  packages.
- elfutils, and thus drgn, can't be built with clang.

Now that we've replaced the elfutils DWARF unwinder with our own, we
don't need the patches, so we can drop the bundled elfutils and fix
these issues.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-03-16 00:52:09 -07:00
Omar Sandoval
b5ed892481 Fix some include-what-you-use warnings and update for Bear 3
Bear 3 changed the CLI arguments, so update scripts/iwyu.py for it and
clean up some new warnings.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-02-26 16:05:49 -08:00
Omar Sandoval
9fda010789 Track byte order in scalar types instead of objects
Currently, reference objects and buffer value objects have a byte order.
However, this doesn't always make sense for a couple of reasons:

- Byte order is only meaningful for scalars. What does it mean for a
  struct to be big endian? A struct doesn't have a most or least
  significant byte; its scalar members do.
- The DWARF specification allows either types or variables to have a
  byte order (DW_AT_endianity). The only producer I could find that uses
  this is GCC for the scalar_storage_order type attribute, and it only
  uses it for base types, not variables. GDB only seems to use to check
  it for base types, as well.

So, remove the byte order from objects, and move it to integer, boolean,
floating-point, and pointer types. This model makes more sense, and it
means that we can get the binary representation of any object now.

The only downside is that we can no longer support a bit offset for
non-scalars, but as far as I can tell, nothing needs that.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-02-19 21:41:29 -08:00
Omar Sandoval
286c09844e Clean up #includes with include-what-you-use
I recently hit a couple of CI failures caused by relying on transitive
includes that weren't always present. include-what-you-use is a
Clang-based tool that helps with this. It's a bit finicky and noisy, so
this adds scripts/iwyu.py to make running it more convenient (but not
reliable enough to automate it in Travis).

This cleans up all reasonable include-what-you-use warnings and
reorganizes a few header files.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2020-09-23 16:29:42 -07:00
Omar Sandoval
d40526d85d scripts: add Python include header path to cscope
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2020-08-25 18:07:31 -07:00
Omar Sandoval
4e770fb18a Format imports with isort
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2020-08-20 16:55:07 -07:00
Omar Sandoval
8b264f8823 Update copyright headers to Facebook and add missing headers
drgn was originally my side project, but for awhile now it's also been
my work project. Update the copyright headers to reflect this, and add a
copyright header to various files that were missing it.
2020-05-15 15:13:02 -07:00
Omar Sandoval
36d350bf93 Add scripts/cscope.sh
For generating the cscope index from the proper files.
2020-04-27 17:07:15 -07:00
Omar Sandoval
dabfe19719 Rewrite virtual machine testing setup
The current implementation of vmtest has a few issues:

1. Building drgn for each kernel version on Travis is slow, mostly
   because they don't all run in parallel.
2. For local, incremental testing, recreating the filesystem image and
   rebuilding drgn is slow, and syncing the code to the filesystem image
   is brittle.
3. The filesystem image is the only communication channel, and reading
   the exit status from the filesystem image is awkward and fragile.
4. Creating and accessing the filesystem image requires root.

This reworks vmtest to use the build on the host via VirtFS with a
simple agent on the guest that can execute arbitrary commands and return
the exit status. This has a few more moving parts but is faster and
saner overall.
2020-04-02 17:35:24 -07:00
Omar Sandoval
739fe5686d vmtest: move to top-level directory 2020-03-27 17:13:44 -07:00
Omar Sandoval
fe42a71116 Add DW_LANG to generated dwarf.py
While we're here, make generate_dwarf_constants.py use the bundled
dwarf.h, generate code that black is happy with, and use the keyword
list from the standard library.
2020-02-26 19:55:42 -08:00
Omar Sandoval
71ce81ecbf travis.yml: add 5.6 to vmtest kernels and remove 5.3
v5.6-rc1 was released today, and 5.3 was recently EOL'd. (It might be
worthwhile to continue testing EOL kernels, but for now I don't want
Travis runs to take forever).
2020-02-10 12:43:25 -08:00
Omar Sandoval
87dd27ee12 setup.py: build in parallel by default
This is especially helpful for pip which doesn't have an easy way to
pass build parameters (and most people wouldn't bother, anyways).
2020-01-24 16:47:56 -08:00
Omar Sandoval
ce06683861 vmtest/run: always get list of source files from SOURCES.txt
The next change will make non-git builds depend on a fully-formed source
distribution. So, let's copy in everything from SOURCES.txt, which
should include the egg metadata and anything else setuptools decides is
important.
2020-01-23 10:02:29 -08:00
Omar Sandoval
660276a0b8 Format Python code with Black
I'm not a fan of 100% of the Black coding style, but I've spent too much
time manually formatting Python code, so let's just pull the trigger.
2020-01-14 11:51:58 -08:00
Omar Sandoval
d71b57e3e8 vmtest/manage: scrub compilation directory in debug info
In order to make builds slightly more reproducible (and avoid leaking
details about the build machine's directory layout), let's remap the
compilation directory in DW_AT_comp_dir to be empty.
2020-01-13 11:15:26 -08:00
Omar Sandoval
e0c6a2281d travis.yml: add 5.5 to vmtest kernels
v5.5-rc1 was released this week. Run vmtest with it.
2019-12-11 22:34:20 -08:00
Omar Sandoval
00f5d5b034 vmtest: fix README link 2019-12-04 09:57:43 -08:00
Omar Sandoval
b727e39aa2 vmtest: split files up by architecture
For now, x86_64 is the only architecture, but in the future we will want
to test on others. Let's rearrange things now while it's not too
disruptive.
2019-12-04 03:32:46 -08:00
Omar Sandoval
1721a42dcd vmtest: rename bzImage uploads to vmlinuz
Not all architectures name the bootable image bzImage, so to make
supporting other architectures easier in the future, let's use the more
generic name, vmlinuz.
2019-12-03 22:59:57 -08:00
Omar Sandoval
a3acea9027 vmtest/manage: check that commit exists before trying to build
If I forget to git fetch, manage.py tries to build releases that don't
exist, which litters the repository with incomplete build-$release
directories. Verify that the commit exists before we do anything.
2019-12-03 15:29:15 -08:00
Omar Sandoval
cbe0900ba9 vmtest/manage: handle paginated shared folder webpage
The vmtest shared folder just got large enough to be paginated, which
manage.py doesn't handle. Handle it by making the same XHR requests that
the webpage makes in a browser.
2019-12-03 15:14:14 -08:00
Omar Sandoval
5b1cdded3c vmtest: support running with local kernel build
This is useful for experimenting.
2019-11-29 13:02:22 -08:00
Omar Sandoval
e00373de3c vmtest: use rsync -c to copy vmlinux and source files
This is safer than relying on the existence/time stamps of the files in
the disk image.
2019-11-29 13:02:22 -08:00
Omar Sandoval
26b2708f5e vmtest: add long options to run.sh
Use getopt instead of getopts and add long options.
2019-11-29 13:02:22 -08:00
Omar Sandoval
1c9acb8eed Add virtual machine testing setup
Now that we have tests for kernel-specific functionality, we should run
them on various kernel versions. This adds a script for doing so using
QEMU with a pre-built root filesystem image and kernels that I'm hosting
on my Dropbox. The script can be run locally, but this also sets it up
to be run on Travis. For now, we're testing the mainline, stable, and
longterm releases from kernel.org (not including v3.16, which doesn't
even boot for me).
2019-11-22 16:54:00 -08:00
Omar Sandoval
1cedca8ff4 Import elfutils
Based on:

c950e8a9 config: Fix spec file, add manpages and new GFDL license.

With the following patches:

configure: Add --disable-programs
configure: Add --disable-shared
configure: Fix -D_FORTIFY_SOURCE=2 check when CFLAGS contains -Wno-error
libcpu: compile i386_lex.c with -Wno-implicit-fallthrough

The plan is to stop relying on the distribution's version of elfutils
and instead ship our own. This gives us freedom to assume that we're
using the latest version and even ship our own patches (starting with a
few build system improvements). More details are in
scripts/update-elfutils.sh, which was used to generate this commit.
2019-09-05 01:04:33 -07:00
Omar Sandoval
932b7857b5 libdrgn: expose primitive type concept to public interface
Previously known as c_type.
2019-05-06 14:55:34 -07:00
Omar Sandoval
75c3679147 Rewrite drgn core in C
The current mixed Python/C implementation works well, but it has a
couple of important limitations:

- It's too slow for some common use cases, like iterating over large
  data structures.
- It can't be reused in utilities written in other languages.

This replaces the internals with a new library written in C, libdrgn. It
includes Python bindings with mostly the same public interface as
before, with some important improvements:

- Types are now represented by a single Type class rather than the messy
  polymorphism in the Python implementation.
- Qualifiers are a bitmask instead of a set of strings.
- Bit fields are not considered a separate type.
- The lvalue/rvalue terminology is replaced with reference/value.
- Structure, union, and array values are better supported.
- Function objects are supported.
- Program distinguishes between lookups of variables, constants, and
  functions.

The C rewrite is about 6x as fast as the original Python when using the
Python bindings, and about 8x when using the C API directly.

Currently, the exposed API in C is fairly conservative. In the future,
the memory reader, type index, and object index APIs will probably be
exposed for more flexibility.
2019-04-02 14:12:07 -07:00
Omar Sandoval
c2d51fe295 Support userspace program core dumps
We only need to add a little bit of infrastructure to map variable
addresses for ASLR/shared libraries, which we find using the NT_FILE
note.
2018-07-09 22:34:03 -07:00
Omar Sandoval
800ee3ec36 corereader: take fd and list of segments instead of path
Now, we can get rid of the ELF parsing implementation in CoreReader.
Instead, we parse in ElfFile and pass the parsed information to
CoreReader.
2018-07-09 19:12:33 -07:00
Omar Sandoval
3ff1cc185a variableindex: distinguish vmlinux vs modules with ELF e_type
For /boot/vmlinux-$(uname -r) or if passed a vmlinux image with -e, the
basename of vmlinux is not always exactly "vmlinux". Don't rely on the
filename.
2018-07-03 00:27:56 -07:00
Omar Sandoval
263f8c2c4d dwarf: update DWARF constants
Update generate_dwarf_constants.py to parse dwarf.h, and update it with
the dwarf.h on my system.
2018-06-27 22:31:01 -07:00
Omar Sandoval
0adac0747c Bring back ElfFile
Instead of constructing DwarfFile with a dict of sections, pass in an
ElfFile.
2018-06-25 23:43:14 -07:00
Omar Sandoval
76cba644a8 Reorganize packaging 2018-04-07 10:42:48 -07:00