Commit Graph

63 Commits

Author SHA1 Message Date
Omar Sandoval
5dd03eead9 Build manylinux2014 wheels instead of manylinux2010
manylinux2010 has been EOL since August 2022; see pypa/manylinux#1281.
In particular, the manylinux2010 image wasn't updated with Python 3.11.
Update scripts/build_dist.sh to use manylinux2014 and drop some CentOS 6
workarounds from scripts/build_manylinux_in_docker.sh.

If someone really wants manylinux2010, we can probably build both, but
none of the popular packages I checked (NumPy, SciPy, cryptography,
charset-normalizer) do this.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-01-05 20:10:36 -08:00
Omar Sandoval
69d3ce5ced Update libkdumpfile in manylinux wheels to 0.5.0
And make sure that it's built with zstd support.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-01-05 20:08:55 -08:00
Omar Sandoval
134393f5f0 Update elfutils in manylinux wheels to 0.188
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-01-05 19:44:24 -08:00
Omar Sandoval
4031093848 Add some missing copyright/license notices
I wanted to make REUSE pass, but I'm not sure what to do about trivial
files. REUSE suggests using CC0, but Fedora no longer allows CC0. I'll
punt that until later. For now, let's add notices to some code files.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-11-01 17:14:02 -07:00
Omar Sandoval
87b7292aa5 Relicense drgn from GPLv3+ to LGPLv2.1+
drgn is currently licensed as GPLv3+. Part of the long term vision for
drgn is that other projects can use it as a library providing
programmatic interfaces for debugger functionality. A more permissive
license is better suited to this goal. We decided on LGPLv2.1+ as a good
balance between software freedom and permissiveness.

All contributors not employed by Meta were contacted via email and
consented to the license change. The only exception was the author of
commit c4fbf7e589 ("libdrgn: fix for compilation error"), who did not
respond. That commit reverted a single line of code to one originally
written by me in commit 640b1c011d ("libdrgn: embed DWARF index in
DWARF info cache").

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-11-01 17:05:16 -07:00
Omar Sandoval
d465071651 libdrgn: replace copies of elfutils headers with generated files
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-11-01 15:41:53 -07:00
Omar Sandoval
42e7d474d1 drgn.helpers.linux.mm: add compound page helpers
I had these helpers lying around from a couple of bugs related to
compound pages that I debugged.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-09-09 15:54:43 -07:00
Omar Sandoval
d14f751475 drgn.helpers.linux.mm: add simple PageFlag() getters
There are a bunch of page flag getters in the kernel like
PageUptodate(), PageLocked(), etc., that kernel developers are
accustomed to using. Most of them are simple bit tests. Let's add
helpers for all of those. These are generated from
include/linux/page-flags.h in the Linux kernel source tree as of Linux
v6.0-rc1.

More complicated getters that need to do more than a simple flag check
(e.g., PageCompound()) will need to be added manually.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-08-18 15:50:15 -07:00
Omar Sandoval
c47dd9952e Update elfutils in manylinux wheels to 0.187
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-07-25 16:52:24 -07:00
Omar Sandoval
b300021ba3 scripts/build_dists.sh: use docker run --pull always instead of docker pull
This way we only need to invoke docker (and sudo, if running with
DOCKER="sudo docker") once.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-03-03 01:23:01 -08:00
Omar Sandoval
6418ad1403 Run tests when building manylinux wheels
This will catch issues like the one fixed in commit 549cd7facc ("Add
tests/sample.core.zst to sdist").

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-03-03 01:20:03 -08:00
Omar Sandoval
24609a3a2e libdrgn: add autoconf option to enable compiler warnings
This adds an --enable-compiler-warnings flag that:

* Defines a canonical list of warnings that we enforce. For now, this is
  -Wall -Wformat-overflow=2 -Wformat-truncation=2, but we can add to it
  going forward.
* Enables warnings by default.
* Allows erroring on warnings. We recommend that developers use this and
  use it for the CI.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-03-01 15:38:05 -08:00
Kevin Svetlitski
e6306853d2 Make iwyu.py respect the CFLAGS environment variable
Previously iwyu.py overwrote the value of the `CFLAGS` environment
variable regardless of whether it was already set. This was very
frustrating when trying to set custom `CFLAGS` to be used in the
generation of compile_commands.json, so the script now only sets
`CFLAGS` if it is not already present in the environment.

Signed-off-by: Kevin Svetlitski <svetlitski@fb.com>
2022-02-25 11:33:30 -08:00
Kevin Svetlitski
9add9529eb Ensure compile_commands.json contains -Wall
This minor change is a quality of life improvement ensuring developers
receive more warnings and diagnostics in their editors.

Signed-off-by: Kevin Svetlitski <svetlitski@fb.com>
2021-12-17 12:08:22 -08:00
Omar Sandoval
ad23378977 Update elfutils and libkdumpfile in manylinux wheels
Use the latest version of elfutils (0.186) and libkdumpfile (0.4.1). We
can drop the elfutils patch since 0.186 has the fix (and we have our own
workaround), but we need a new patch to build libkdumpfile.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-12-08 15:13:09 -08:00
Omar Sandoval
2c6e36847f Remove some include-what-you-use workarounds
include-what-you-use 0.17 fixed a couple of issues we were working
around with a mapping file.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-12-06 01:51:54 -08:00
Omar Sandoval
c0d8709b45 Update copyright headers to Meta
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-11-21 15:59:44 -08:00
Omar Sandoval
07d00b7b11 tests: add tests for ELF symbols
Add some scaffolding to generate ELF files with symbol tables and use it
to test symbol lookups and Elf_Sym -> drgn.Symbol translation.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-11-19 17:04:20 -08:00
Omar Sandoval
c84d7e8c15 tests: generate ELF constants from elf.h
Generalize generate_dwarf_constants.py for ELF and replace tests/elf.py
with the generated version.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-11-19 17:02:32 -08:00
Omar Sandoval
d1745755f1 Fix some include-what-you-use warnings
Also:

* Rename struct string to struct nstring and move it to its own header.
* Fix scripts/iwyu.py, which was broken by commit 5541fad063 ("Fix
  some flake8 errors").
* Add workarounds for a few outstanding include-what-you-use issues.

There is still a false positive for
include-what-you-use/include-what-you-use#970, but hopefully that is
fixed soon.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-11-10 15:09:29 -08:00
Omar Sandoval
9c54083830 libdrgn: pp: make PP_CAT not variadic
The overloaded version is slower to compile, and we don't actually need
it. We can add a variadic version if we need to in the future. Also add
the script used to generate the macros.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-10-29 18:38:49 -07:00
Omar Sandoval
861c61eda0 Update elfutils in manylinux wheels
Use the latest version of elfutils (0.185) and apply the fix "libdwfl:
fix potential NULL pointer dereference when reading link map" since that
hasn't been released yet and is needed to avoid crashing when debugging
userspace core dumps.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-08-12 11:53:22 -07:00
Omar Sandoval
5541fad063 Fix some flake8 errors
Mainly unused imports, unused variables, unnecessary f-strings, and
regex literals missing the r prefix. I'm not adding it to the CI linter
because it's too noisy, though.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-08-11 14:52:44 -07:00
Omar Sandoval
87809f7692 libdrgn: dwarf_index: improve file path hashing for deduplication
We currently don't include the compilation directory when hashing file
names for deduplication. This can cause us to incorrectly deduplicate a
definition if, for example, two libraries have a definition with the
same name in files with the same name. Fix this by hashing the full file
path including the compilation directory.

This also requires reworking our strategy for path normalization to
better handle ".." components, since directories may end up outside of
the compilation directory. The new strategy keeps a linked list of
hashes (now FNV-1a instead of SipHash) for each parent directory. This
is actually more efficient than the previous approach, offsetting the
cost of the extra hash computations for the compilation directory. It
also correctly handles file names in the line number program header
which consist of multiple components.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-06-25 18:03:01 -07:00
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