Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch 'master' into '6.0/stage' #8

Merged
merged 87 commits into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
739fe56
vmtest: move to top-level directory
osandov Mar 28, 2020
dda5980
vmtest/manage: move kernel config to separate file
osandov Mar 28, 2020
32deb22
vmtest/manage: remove relocations from vmlinux
osandov Mar 28, 2020
0548926
vmtest/manage: add type annotations
osandov Mar 30, 2020
b369ca0
Split some utility functions out of setup.py
osandov Mar 30, 2020
f73f4f4
vmtest/manage: use util.nproc() instead of multiprocessing.cpu_count()
osandov Mar 30, 2020
435a344
vmtest/manage: chmod -x
osandov Mar 30, 2020
c55d199
vmtest/manage: always get dropbox token for --build-kernel-org
osandov Mar 30, 2020
2a31b05
vmtest/manage: don't open-code dict.fromkeys()
osandov Mar 30, 2020
9d4b214
vmtest/manage: handle API errors in get_available_kernel_releases()
osandov Mar 31, 2020
6d8d415
vmtest: add -vmtestN localversion
osandov Mar 30, 2020
7c7286e
util: add version comparison implementation
osandov Mar 30, 2020
dabfe19
Rewrite virtual machine testing setup
osandov Mar 31, 2020
6c28b37
disable drgn testing when constructing debian package
sdimitro Apr 3, 2020
d53ffe5
Merge pull request #6 from sdimitro/disable_testing
sdimitro Apr 3, 2020
bd902f2
libdrgn: return unknown language from drgn_language_from_die()
osandov Mar 13, 2020
fa61977
libdrgn: fix default language detection
osandov Mar 13, 2020
d8fadf1
libdrgn: Add cpp language and tests
jgkamat Mar 3, 2020
63613d4
Add missing files to MANIFEST.in
osandov Apr 3, 2020
2addae5
Update README to note that C++ support is in progress
osandov Apr 3, 2020
5ac71b4
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Apr 4, 2020
512acbc
Rebase elfutils to pick up PN_XNUM fix
osandov Apr 6, 2020
98f8275
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Apr 7, 2020
bf05d9b
libdrgn: allow to build without openmp
jeffmahoney Apr 8, 2020
7b818f3
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Apr 9, 2020
cf8d969
Run black on some stray changes
osandov Apr 10, 2020
3adc8f2
vmtest: use -cpu host instead of kvm64
osandov Apr 9, 2020
1dbc718
helpers: add pgtable_l5_enabled()
osandov Apr 9, 2020
5ac95e4
libdrgn: fix _page_offset() helper and move to object finder
osandov Apr 9, 2020
7a9fad0
libdrgn: move _vmemmap() to object finder
osandov Apr 9, 2020
35bb024
tests: add mm helper tests
osandov Apr 10, 2020
b62c002
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Apr 11, 2020
ecef9d7
libdrgn: get rid of arrays embedded in drgn_type
jgkamat Mar 24, 2020
a3248b5
libdrgn: fix use after free when formatting compound types
osandov Apr 13, 2020
1376674
setup.py: log test returncode from VM
osandov Apr 14, 2020
75c3692
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Apr 14, 2020
9bb2cce
Enable DWARF indexing to work with partial units
jeffmahoney Apr 10, 2020
ca1153a
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Apr 15, 2020
e035632
vmtest: use BusyBox shell script as init
osandov Apr 17, 2020
3b0988b
docs: mention tools directory
osandov Apr 17, 2020
2668f55
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Apr 18, 2020
7613dfb
helpers: fix enum_type_to_class() return type annotation
osandov Apr 18, 2020
12a23a6
Add stubs for internal helpers
osandov Apr 18, 2020
7b08f76
Fix mypy errors
osandov Apr 19, 2020
da0c637
Fix Object.__getattribute__() return type annotation
osandov Apr 20, 2020
ea3cdb4
libdrgn/python: optimize Object.__getattribute__()
osandov Apr 20, 2020
24fb95b
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Apr 21, 2020
a070f1c
drgndoc: visit submodules in deterministic order
osandov Apr 21, 2020
55135d5
Remove stray type comments
osandov Apr 21, 2020
ea8cded
Fix Program.pointer_type() type annotation
osandov Apr 21, 2020
61a7a0c
Fix Object.__getitem__() idx type annotation
osandov Apr 21, 2020
1af5723
drgn 0.0.4
osandov Apr 21, 2020
23a2916
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Apr 22, 2020
0d64d66
Add examples and tools to source distribution
osandov Apr 27, 2020
36d350b
Add scripts/cscope.sh
osandov Apr 28, 2020
02743b2
drgndoc: don't add :rtype: if function doesn't have docstring
osandov Apr 26, 2020
b1315fc
libdrgn: add drgn_program_bswap()
osandov Apr 26, 2020
10e5877
Add Program.read_{u8,u16,u32,u64,word}()
osandov Apr 27, 2020
8df1fee
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Apr 28, 2020
510b6ef
libdrgn: read vmcoreinfo physical address as uint64_t
osandov May 4, 2020
f8c3351
libdrgn: handle kernel core dumps with all zero p_paddr
osandov May 4, 2020
5505628
libdrgn: get rid of struct drgn_program.num_file_segments
osandov May 4, 2020
23574e5
libdrgn: add /proc/kcore physical segments on old kernels
osandov May 4, 2020
1844ceb
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
May 5, 2020
596df1a
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
May 6, 2020
d759c7e
libdrgn: get rid of OFF_MAX
osandov May 7, 2020
0a10006
libdrgn: improve and rename DRGN_UNREACHABLE()
osandov May 7, 2020
a95e42e
libdrgn/python: use vector for Program_load_debug_info()
osandov May 7, 2020
f49d68d
libdrgn: split generic utility functions out of internal.h
osandov May 7, 2020
340e00d
libdrgn: improve and document bit operations
osandov May 8, 2020
3d59e04
libdrgn: don't open-code fls()
osandov May 8, 2020
8f81ea2
libdrgn: don't use unaligned loads to parse DWARF
osandov May 8, 2020
63299e0
libdrgn: actually use uint64_t for two's complement unary ops
osandov May 8, 2020
d0a1718
libdrgn: implement virtual address translation/page table walking
osandov May 6, 2020
8a27683
helpers: add access_process_vm() and access_remote_vm()
osandov May 6, 2020
4b82d1e
helpers: add cmdline() and environ()
osandov May 6, 2020
e697be7
libdrgn: use swapper_pg_dir in vmcoreinfo for fallback PAGE_OFFSET
osandov May 1, 2020
2d1481f
libdrgn: add page table walker kernel memory reader
osandov May 6, 2020
62ddc96
setup.py: add 5.7 to vmtest kernels
osandov May 9, 2020
5ed0631
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
May 9, 2020
bf54510
libdrgn: build in silent mode by default
osandov May 10, 2020
e39448d
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
May 12, 2020
175f83f
Update elfutils with noreturn unwinding fix
osandov May 13, 2020
c339113
libdrgn: adjust program counter when looking up frame symbol
osandov May 14, 2020
8097403
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
May 14, 2020
adbc347
Sync "6.0/stage" with "master" via GitHub Actions
sdimitro May 15, 2020
987c85a
Merge pull request #7 from sdimitro/automate_backports_r
sdimitro May 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/sync-with-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
push:
branches:
- master
schedule:
- cron: '0 0 * * *'

jobs:
sync:
strategy:
matrix:
branch:
- 6.0/stage
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: delphix/actions/sync-with-master@master
with:
branch-to-sync: ${{ matrix.branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/.mypy_cache
/build
/coverage.info
/cscope.*
/dist
/docs/_build
/drgn.egg-info
Expand Down
192 changes: 25 additions & 167 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,169 +1,27 @@
# Generated by scripts/generate_travis_yml.py

dist: bionic

jobs:
include:
- language: python
python: 3.8
addons:
apt:
packages:
- libbz2-dev
- liblzma-dev
- zlib1g-dev
install:
script: python setup.py build -j "$(nproc)" test
- language: python
python: 3.7
addons:
apt:
packages:
- libbz2-dev
- liblzma-dev
- zlib1g-dev
install:
script: python setup.py build -j "$(nproc)" test
- language: python
python: 3.6
addons:
apt:
packages:
- libbz2-dev
- liblzma-dev
- zlib1g-dev
install:
script: python setup.py build -j "$(nproc)" test
- name: "vmtest Linux 5.6"
language: minimal
env: KERNEL=5.6
addons:
apt:
packages:
- python3
- python3-setuptools
- qemu-kvm
- rsync
- zstd
install: sudo adduser "$USER" kvm
before_script:
# The double sudo is necessary to pick up the new group membership.
- sudo -E sudo -E -u "$USER" scripts/vmtest/run.sh -k "$KERNEL"'.*' -o -d ~ ~/root.img; exitstatus=$?
# Exit status 0 is success, 1 is test failure (should fail in the script
# step), anything else is an error (should fail here).
- test $exitstatus -le 1
script: test $exitstatus -eq 0
- name: "vmtest Linux 5.5"
language: minimal
env: KERNEL=5.5
addons:
apt:
packages:
- python3
- python3-setuptools
- qemu-kvm
- rsync
- zstd
install: sudo adduser "$USER" kvm
before_script:
# The double sudo is necessary to pick up the new group membership.
- sudo -E sudo -E -u "$USER" scripts/vmtest/run.sh -k "$KERNEL"'.*' -o -d ~ ~/root.img; exitstatus=$?
# Exit status 0 is success, 1 is test failure (should fail in the script
# step), anything else is an error (should fail here).
- test $exitstatus -le 1
script: test $exitstatus -eq 0
- name: "vmtest Linux 5.4"
language: minimal
env: KERNEL=5.4
addons:
apt:
packages:
- python3
- python3-setuptools
- qemu-kvm
- rsync
- zstd
install: sudo adduser "$USER" kvm
before_script:
# The double sudo is necessary to pick up the new group membership.
- sudo -E sudo -E -u "$USER" scripts/vmtest/run.sh -k "$KERNEL"'.*' -o -d ~ ~/root.img; exitstatus=$?
# Exit status 0 is success, 1 is test failure (should fail in the script
# step), anything else is an error (should fail here).
- test $exitstatus -le 1
script: test $exitstatus -eq 0
- name: "vmtest Linux 4.19"
language: minimal
env: KERNEL=4.19
addons:
apt:
packages:
- python3
- python3-setuptools
- qemu-kvm
- rsync
- zstd
install: sudo adduser "$USER" kvm
before_script:
# The double sudo is necessary to pick up the new group membership.
- sudo -E sudo -E -u "$USER" scripts/vmtest/run.sh -k "$KERNEL"'.*' -o -d ~ ~/root.img; exitstatus=$?
# Exit status 0 is success, 1 is test failure (should fail in the script
# step), anything else is an error (should fail here).
- test $exitstatus -le 1
script: test $exitstatus -eq 0
- name: "vmtest Linux 4.14"
language: minimal
env: KERNEL=4.14
addons:
apt:
packages:
- python3
- python3-setuptools
- qemu-kvm
- rsync
- zstd
install: sudo adduser "$USER" kvm
before_script:
# The double sudo is necessary to pick up the new group membership.
- sudo -E sudo -E -u "$USER" scripts/vmtest/run.sh -k "$KERNEL"'.*' -o -d ~ ~/root.img; exitstatus=$?
# Exit status 0 is success, 1 is test failure (should fail in the script
# step), anything else is an error (should fail here).
- test $exitstatus -le 1
script: test $exitstatus -eq 0
- name: "vmtest Linux 4.9"
language: minimal
env: KERNEL=4.9
addons:
apt:
packages:
- python3
- python3-setuptools
- qemu-kvm
- rsync
- zstd
install: sudo adduser "$USER" kvm
before_script:
# The double sudo is necessary to pick up the new group membership.
- sudo -E sudo -E -u "$USER" scripts/vmtest/run.sh -k "$KERNEL"'.*' -o -d ~ ~/root.img; exitstatus=$?
# Exit status 0 is success, 1 is test failure (should fail in the script
# step), anything else is an error (should fail here).
- test $exitstatus -le 1
script: test $exitstatus -eq 0
- name: "vmtest Linux 4.4"
language: minimal
env: KERNEL=4.4
addons:
apt:
packages:
- python3
- python3-setuptools
- qemu-kvm
- rsync
- zstd
install: sudo adduser "$USER" kvm
before_script:
# The double sudo is necessary to pick up the new group membership.
- sudo -E sudo -E -u "$USER" scripts/vmtest/run.sh -k "$KERNEL"'.*' -o -d ~ ~/root.img; exitstatus=$?
# Exit status 0 is success, 1 is test failure (should fail in the script
# step), anything else is an error (should fail here).
- test $exitstatus -le 1
script: test $exitstatus -eq 0
language: python
python:
- '3.8'
- '3.7'
- '3.6'
install:
# Upstream defaults to world-read-writeable /dev/kvm. Debian/Ubuntu override
# this; see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892945. We want
# the upstream default.
- sudo echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /lib/udev/rules.d/99-fix-kvm.rules > /dev/null
- sudo udevadm control --reload-rules
# On systemd >= 238 we can use udevadm trigger -w and remove udevadm settle.
- sudo udevadm trigger /dev/kvm
- sudo udevadm settle
script: python setup.py test -K

addons:
apt:
packages:
- busybox-static
- libbz2-dev
- liblzma-dev
- qemu-kvm
- zlib1g-dev
- zstd
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
recursive-include docs *.py *.rst
recursive-include examples *.py
recursive-include tests *.py
recursive-include scripts/vmtest *.py *.rst *.sh
recursive-include tools *.py
recursive-include vmtest *.c *.py *.rst
include util.py vmtest/config
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ Although other debuggers like `GDB <https://www.gnu.org/software/gdb/>`_ have
scripting support, drgn aims to make scripting as natural as possible so that
debugging feels like coding. This makes it well-suited for introspecting the
complex, inter-connected state in large programs. It is also designed as a
library that can be used for more purpose-built tools.
library that can be used to build debugging and introspection tools; see the
official `tools <https://github.com/osandov/drgn/tree/master/tools>`_.

drgn was developed for debugging the Linux kernel (as an alternative to the
`crash <http://people.redhat.com/anderson/>`_ utility), but it can also debug
userspace programs written in C. C++ support is planned.
userspace programs written in C. C++ support is in progress.

.. end-introduction

Expand Down
57 changes: 49 additions & 8 deletions _drgn.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class Program:
...
def pointer_type(
self,
type: Type,
type: Union[str, Type],
qualifiers: Optional[Qualifiers] = None,
*,
language: Optional[Language] = None,
Expand Down Expand Up @@ -236,6 +236,30 @@ class Program:
:raises ValueError: if *size* is negative
"""
...
def read_u8(self, address: int, physical: bool = False) -> int: ...
def read_u16(self, address: int, physical: bool = False) -> int: ...
def read_u32(self, address: int, physical: bool = False) -> int: ...
def read_u64(self, address: int, physical: bool = False) -> int: ...
def read_word(self, address: int, physical: bool = False) -> int:
"""
Read an unsigned integer from the program's memory in the program's
byte order.

:meth:`read_u8()`, :meth:`read_u16()`, :meth:`read_u32()`, and
:meth:`read_u64()` read an 8-, 16-, 32-, or 64-bit unsigned integer,
respectively. :meth:`read_word()` reads a program word-sized unsigned
integer.

For signed integers, alternate byte order, or other formats, you can
use :meth:`read()` and :meth:`int.from_bytes()` or the :mod:`struct`
module.

:param address: Address of the integer.
:param physical: Whether *address* is a physical memory address; see
:meth:`read()`.
:raises FaultError: if the address is invalid; see :meth:`read()`
"""
...
def add_memory_segment(
self,
address: int,
Expand Down Expand Up @@ -665,7 +689,7 @@ class Object:
"""
Size in bits of this object if it is a bit field, ``None`` if it is not.
"""
def __getattribute__(self, name: str) -> Any:
def __getattribute__(self, name: str) -> Object:
"""
Implement ``self.name``.

Expand All @@ -679,7 +703,7 @@ class Object:
:param name: Attribute name.
"""
...
def __getitem__(self, idx: int) -> Object:
def __getitem__(self, idx: Union[int, Object]) -> Object:
"""
Implement ``self[idx]``. Get the array element at the given index.

Expand Down Expand Up @@ -961,7 +985,6 @@ def container_of(ptr: Object, type: Union[str, Type], member: str) -> Object:

:param ptr: The pointer.
:param type: The type of the containing object.
:type type: str or Type
:param member: The name of the member in ``type``.
:raises TypeError: if the object is not a pointer or the type is not a
structure, union, or class type
Expand Down Expand Up @@ -1027,13 +1050,20 @@ class StackFrame:

pc: int
"""
The return address at this stack frame, i.e., the value of the program
counter when control returns to this frame.
The program counter at this stack frame.

For the innermost frame, this is typically the instruction that was being
executed when the stack trace was captured. For function calls, this is
generally the return address, i.e., the value of the program counter when
control returns to this frame.
"""
def symbol(self) -> Symbol:
"""
Get the function symbol at this stack frame. This is equivalent to
:meth:`prog.symbol(frame.pc) <Program.symbol>`.
Get the function symbol at this stack frame.

This may differ from :meth:`prog.symbol(frame.pc) <Program.symbol>`, as
for function calls, the program counter may be adjusted to the call
instruction instead of the return address.
"""
...
def register(self, reg: Union[str, int, Register]) -> int:
Expand Down Expand Up @@ -1603,3 +1633,14 @@ class OutOfBoundsError(Exception):
"""

...

_with_libkdumpfile: bool

def _linux_helper_read_vm(prog, pgtable, address, size): ...
def _linux_helper_radix_tree_lookup(root, index): ...
def _linux_helper_idr_find(idr, id): ...
def _linux_helper_find_pid(ns, pid): ...
def _linux_helper_pid_task(pid, pid_type): ...
def _linux_helper_find_task(ns, pid): ...
def _linux_helper_task_state_to_char(task): ...
def _linux_helper_pgtable_l5_enabled(prog): ...
14 changes: 14 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,17 @@

%:
dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_test:
#
# Don't run drgn's tests during the build step; The repo comes
# with its own testing that takes place elsewhere ->
# https://travis-ci.org/github/delphix/drgn/branches
#
# Ideally it wouldn't hurt having them run here too but due to
# drgn's testing setup, we'd have to override pybuild's default
# behavior. Since drgn is not a project that is owned by us,
# disabling tests here makes even more sense as we won't have
# to adjust the setup here every time a change in the test
# framework of drgn is applied upstream.
#
2 changes: 1 addition & 1 deletion docs/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ Some of drgn's behavior can be modified through environment variables:

``DRGN_USE_LIBKDUMPFILE_FOR_ELF``
Whether drgn should use libkdumpfile for ELF vmcores (0 or 1). The default
is 1 if drgn was built with libkdumpfile support.
is 0. This functionality will be removed in the future.
3 changes: 3 additions & 0 deletions docs/exts/drgndoc/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ def _add_function_info(
node = resolved.node

if rst:
if node.docstring is None:
want_rtype = False

params_need_type = set()
params_have_type = set()
for line in lines:
Expand Down
Loading