Now we'll always get the same compiler that was used for the actual
kernel build. Also split this into its own runnable module, vmtest.kmod,
for testing and custom scripting.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
In order to hopefully not have jobs time out, split it into jobs by
architecture and flavor, but limit the parallelism to leave room for
actual test runs. Some of the very old kernel versions don't work on the
other architectures, but we can look into that later.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Old kernel versions (and new kernel versions built with old binutils)
need this for ppc64 module builds.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Before Linux kernel commit 05f6bbf2d714 ("kbuild: remove ld-version
macro") (in v5.12), ppc64 module builds require it.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
I don't know yet whether this is safe to upstream, but for now it should
be good enough for testing.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
This was patched in recent stable and longterm branches, but we need it
for older branches. We need a few different backports of it.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Move vmlinux to the module build directory and copy in resolve_btfids.
This is mainly to silence the annoying warning:
Skipping BTF generation for /home/osandov/repos/drgn/build/vmtest/x86_64/tmpge3udm_a/drgn_test.ko due to unavailability of vmlinux
But it might also be useful for testing in the future.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Add the per-architecture QEMU options to the Architecture class and
allow specifying an architecture in -k.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
This will automatically download and use a standard cross compiler
instead of requiring the user to do so.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
It defaults to the host architecture (if available). x86_64 is currently
the only option. CROSS_COMPILE must be set in the environment manually.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
To prepare for building architectures other than x86-64, add a
description of architectures, and split the architecture-specific kernel
options into it. For now, we still hard-code x86-64 everywhere.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Move the definitions of the section names to a Python script,
gen_elf_sections.py, and use that to generate the enum definitions and a
lookup function. This is preparation for checking for section names with
the .dwo suffix in the future.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
The helper function returns a tuple with load
averaged over last 1, 5 and 15 minutes.
Signed-off-by: Martin Liska <mliska@suse.cz>
Co-authored-by: Omar Sandoval <osandov@osandov.com>
The test case checks `drgn_test_slob` from the test kmod.
Fixes: 975255f209 ("tests: handle cases without slab support in print_annotated_stack() test")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
First, call user-provided callbacks before changing any global state.
Second, only write the history file if we make it to code.interact().
Signed-off-by: Omar Sandoval <osandov@osandov.com>
It's quite useful to run drgn's interactive REPL from a user-provided
script. One reason is saving the drgn core dump and debuginfo setup into
a script to more easily start analysis. Another might be to replace
drgn's debuginfo loading scheme with one customized to a different
environment. Or, a script might want to handle errors by allowing an
interactive user to examine the program themselves.
To serve all of these cases and more, separate out the logic of running
the drgn REPL from the internal logic relating to argument parsing,
choosing the correct target, and loading debuginfo. While this may seem
like a simple case of code.interact, there are several important
internal features drgn provides in its CLI: a custom displayhook, a
custom readline completer, a history file, and of course the logic to
import and include the proper drgn APIs and helpers for a core dump.
This means creating a run_interactive() function and moving the cli
module out of the drgn.internal package.
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
For the sock_cgroup_ptr() test case in #255, we need
CONFIG_SOCK_CGROUP_DATA to be selected. Since Linux 4.10, we get that
from CONFIG_CGROUP_BPF, but before that, we need either
CONFIG_CGROUP_NET_CLASSID or CONFIG_CGROUP_NET_PRIO. The former appears
to be slightly smaller than the latter, so let's enable that one.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Currently on Ubuntu 22.04 LTS, pre-commit hook installation is broken
for isort, with an error that can be seen at [1]. The solution is to
update isort to 5.12.0.
[1]: https://github.com/PyCQA/isort/issues/2077
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Since Linux kernel commit cae3873c5b3a ("net: inet: Retire port only
listening_hash") (in v5.19), listening_hash is removed and we need
to iterate lhash2 table.
The script reports now:
LISTEN [::]:22 [::]:0 /system.slice/sshd.service
LISTEN 0.0.0.0:22 0.0.0.0:0 /system.slice/sshd.service
LISTEN [::1]:631 [::]:0 /system.slice/cups.service
LISTEN 127.0.0.1:25 0.0.0.0:0 /system.slice/postfix.service
LISTEN [::1]:25 [::]:0 /system.slice/postfix.service
LISTEN 127.0.0.1:631 0.0.0.0:0 /system.slice/cups.service
ESTABLISHED 192.168.122.99:22 192.168.122.1:45906 /system.slice/sshd.service
ESTABLISHED 192.168.122.99:22 192.168.122.1:48066 /system.slice/sshd.service
ESTABLISHED 192.168.122.99:22 192.168.122.1:41128 /system.slice/sshd.service
Signed-off-by: Martin Liska <mliska@suse.cz>
Since Linux kernel commit 8520e224f547 ("bpf, cgroups: Fix
cgroup v2 fallback on v1/v2 mixed mode") (in v5.15), the sock_cgroup_data
contains directly cgroup member (of struct cgroup * type).
Signed-off-by: Martin Liska <mliska@suse.cz>
New output:
PID PPID CPU ST COMM
1 0 4 S systemd
2 0 13 S [kthreadd]
3 2 0 I [rcu_gp]
4 2 0 I [rcu_par_gp]
5 2 0 I [slub_flushwq]
6 2 0 I [netns]
8 2 0 I [kworker/0:0H]
10 2 0 I [mm_percpu_wq]
11 2 0 I [rcu_tasks_kthre]
...
Signed-off-by: Martin Liska <mliska@suse.cz>
Co-authored-by: Omar Sandoval <osandov@osandov.com>
Linux commit 1ad53d9fa3f6 ("slub: improve bit diffusion for freelist ptr
obfuscation"), adds a swab() into the freelist_ptr() calculation.
Unfortunately we can't detect this except by trial and error. The commit
was added in 5.7 and has been included in stable backports, which means
that pre-5.7 kernels which haven't recently been updated may still have
this behavior. Add in logic to do the trial and error in order to
support this oddity.
Reported-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>