Commit Graph

1588 Commits

Author SHA1 Message Date
Omar Sandoval
dd08658a6e libdrgn: don't cache ORC sections in struct drgn_elf_file
.orc_unwind_ip and .orc_unwind are only referenced while initially
parsing ORC data and then never touched again, so it's wasteful to cache
them in struct drgn_elf_file. Look them up if and when we parse the ORC
data instead.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-22 15:27:39 -07:00
Omar Sandoval
0bb503c6a0 libdrgn: orc_info: check ORC section alignment instead of copying
In practice, the .orc_unwind and .orc_unwind_ip sections will always be
suitably aligned. Check it, then assume the alignment later.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-22 15:27:39 -07:00
Omar Sandoval
8526b86644 libdrgn: linux_kernel: get slightly smaller code for kernel_module_iterator_next()
By using the same temporary objects in the Linux 6.4 branch as the
pre-6.4 branch, we get slightly better code generation.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-22 15:27:39 -07:00
Omar Sandoval
104a14781d tests: test compressed debug sections
Test both .zdebug_* sections and SHF_COMPRESSED .debug_* sections.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-20 13:45:04 -07:00
Omar Sandoval
2ee625fc74 libdrgn: handle DWARF sections exactly* like libdw
We only support .debug_* sections, but libdw also supports .zdebug_*,
.debug_*.dwo, and .gnu.debuglto_.debug_*. Mimic how libdw chooses debug
sections, with one exception: .debug_cu_index and .debug_tu_index (used
for DWP, which we don't support yet but will) should be considered DWO
sections (this needs to be fixed in libdw, too).

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-20 13:45:04 -07:00
Omar Sandoval
9ad47a97eb contrib: add script to dump platform drivers
For a discussion on the linux-debuggers mailing list:
https://lore.kernel.org/linux-debuggers/87v8fiw0fm.fsf@oracle.com/T/#t

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-20 11:11:23 -07:00
Stephen Brennan
e9141fa396 ci: reduce usage and add Python 3.12 beta
With 3.12 beta, there are 7 Python versions to test, which is making the
test matrix too large. To reduce the amount of CI test runs that occur,
by default we will only run 2: the oldest and newest released Python
versions. To further reduce the CI test runs, we will eliminate CI runs
when a branch is pushed (only main will be tested).

The "ci" action becomes a reusable workflow, which gets called by other
possible workflows:

1. pull_request.yml: On pull request, only the 2 default Python versions
   are tested.  The "test-all-python-versions" label can be applied to
   pull requests to override this.
2. push.yml: On push to main, all Python versions are tested.
3. vmtest-build.yml: After the vmtest kernels are built
4. On manual request: the user has the option to specify

Signed-off-by: Stephen Brennan <stephen@brennan.io>
2023-06-15 17:31:57 -07:00
Omar Sandoval
cff9b6185c libdrgn: fix typo in ORC unwinder handling of ORC_REG_SP_INDIRECT
ORC_REG_SP_INDIRECT is supposed to be an indirect access via rsp, but we
have a typo and are using rbp instead. This is a partial fix for #304.

Fixes: 630d39e345 ("libdrgn: add ORC unwinder")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-15 13:03:10 -07:00
Omar Sandoval
95c7d9ab63 tests: add better test for kernel Program.crashed_thread()
Instead of simply checking whether the thread ID is non-zero, write a
specific task name to /proc/self/comm before crashing and check that.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-15 09:57:18 -07:00
Omar Sandoval
e2e2ebc317 libdrgn: fix Linux kernel crashed_thread() on non-x86 architectures
We currently use crashing_cpu to determine the thread that caused a
kernel crash. However, crashing_cpu is x86-specific (it is defined in
arch/x86/kernel/reboot.c). Since Linux 4.5, the generic panic code
defines a very similar variable, panic_cpu. Use that instead so that we
support all architectures, but fall back to crashing_cpu to support
older kernels on x86 (even though we don't claim to support 4.4
anymore).

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-15 07:56:19 -07:00
Johannes Thumshirn
e4b7749463 contrib: add btrfs block group dumper
Add a script to dump all btrfs block groups and decode relevant members to
contrib.

Example output for a given filesystem:
BG at 536870912
        flags: BTRFS_BLOCK_GROUP_DATA (0x1)
        length: 134217728
        used: 0
        pinned: 0
        reserved: 0
        runtime_flags: BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE|BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE (0x120)
        zone_unsuable: 0

BG at 671088640
        flags: BTRFS_BLOCK_GROUP_SYSTEM|BTRFS_BLOCK_GROUP_DUP (0x22)
        length: 134217728
        used: 16384
        pinned: 0
        reserved: 0
        runtime_flags: BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE|BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE (0x120)
        zone_unsuable: 16384

BG at 805306368
        flags: BTRFS_BLOCK_GROUP_METADATA|BTRFS_BLOCK_GROUP_DUP (0x24)
        length: 134217728
        used: 131072
        pinned: 0
        reserved: 0
        runtime_flags: BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE|BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE (0x120)
        zone_unsuable: 147456

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
2023-06-14 16:36:13 -07:00
Boris Burkov
c0694d6ce2 Add btrfs helpers to contrib
btrfs_tree.py is a pile of helpers Omar gave me once that I have
cherished ever since. It mostly deals with walking and parsing btrees.

btrfs_tree_mod_log.py is a script I wrote to do a tree mod log search
and rewind while debugging a btrfs issue.

Signed-off-by: Boris Burkov <boris@bur.io>
2023-06-09 09:38:26 -07:00
Omar Sandoval
772492838f drgn.helpers.linux.mm: add arbitrary address translation helpers
follow_{page,pfn,phys}() translate the virtual address by walking the
page table for a given mm_struct (built on top of the existing page
table iterator interface). vmalloc_to_page() and vmalloc_to_pfn() are
special cases for vmalloc addresses.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-02 23:40:38 -07:00
Omar Sandoval
573bfad9fb vmtest.kbuild: make BTF patches also fix kernel modules
Applying the 5.10-stable patches fixing BTF with older pahole to
5.11-5.13 missed updating the pahole flags for kernel modules (because
kernel modules didn't have BTF in 5.10). Regenerate the patches for 5.11
ourselves.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-01 23:47:15 -07:00
Omar Sandoval
de1251a72a vmtest.kbuild: add patch to fix --Werror=use-after-free build failures
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-01 23:47:08 -07:00
Omar Sandoval
5c92485950 setup.py: add 6.3 to vmtest kernels
Commit bf9159cff367 ("drgn.helpers.linux.mm: fix compound_{order,nr} for
Linux 6.3+") is the only change necessary for Linux v6.3.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-01 14:50:25 -07:00
Omar Sandoval
2d2a69a322 drgn.helpers.linux.mm: fix compound_{order,nr} for Linux 6.3+
Linux 6.3 removed struct page::compound_order. Instead, we need to use
struct folio::_folio_order. Update compound_order() and redefine
compound_nr() in terms of compound_order() so we only need to handle the
divergence in one place.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-01 14:50:25 -07:00
Omar Sandoval
da7a11f83e drgn.helpers.linux.block: update for_each_{disk,partition} for Linux 6.4
Linux kernel commits 884f8ce42cce ("driver core: class: implement
class_get/put without the private pointer.") and 2df418cf4b72 ("driver
core: class: remove subsystem private pointer from struct class") (in
v6.4) changed the way to go from struct class to struct subsys_private.
_for_each_block_device(), used by for_each_disk() and
for_each_partition(), needs struct subsys_private. The "new" way also
works on old kernels, so add _class_to_subsys() mirroring
class_to_subsys() in Linux 6.4 and make _for_each_block_device() use it.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-06-01 14:50:25 -07:00
Stephen Brennan
ce8b2938e6 libdrgn: linux_kernel: Fix compiler warning
With GCC 13.1.1 and the recommended build
setup (CONFIGURE_FLAGS="--enable-compiler-warnings=error"), I get the
following failure:

In function 'linux_kernel_get_vmemmap',
    inlined from 'linux_kernel_object_find' at ../../libdrgn/linux_kernel_object_find.inc.strswitch:34:12:
../../libdrgn/linux_kernel.c:370:23: error: 'address' may be used uninitialized [-Werror=maybe-uninitialized]
  370 |                 err = drgn_object_set_unsigned(&prog->vmemmap, qualified_type,
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  371 |                                                address, 0);
      |                                                ~~~~~~~~~~~
../../libdrgn/linux_kernel.c: In function 'linux_kernel_object_find':
../../libdrgn/linux_kernel.c:361:26: note: 'address' was declared here
  361 |                 uint64_t address;
      |                          ^~~~~~~
cc1: all warnings being treated as errors

While linux_kernel_get_vmemmap_address should always update address in a
non-error case, the compiler seems to disagree. It's easy enough to shut
up the compiler by initializing address to 0. What's more, if there is
an actual issue where the linux_kernel_get_vmemmap_address does NOT
update the address variable, a 0 value will be easier to debug than
garbage from an uninitialized variable.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
2023-06-01 14:49:34 -07:00
Stephen Brennan
49d6bfdb24 Fix test failure on Python 3.12 (fixes #298)
Running tests on Python 3.12, we get:

test_int (tests.test_language_c.TestLiteral.test_int) ... python3.12: /usr/include/python3.12/object.h:215: Py_SIZE: Assertion `ob->ob_type != &PyLong_Type' failed.
Aborted (core dumped)

We're relying on an implementation detail to check whether the object is
negative. Instead, catch an overflow error, negate and try again.
Genuine overflows will still overflow on the second time, but negative
numbers will succeed.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
2023-06-01 14:23:51 -07:00
Ido Schimmel
3f3a957562 libdrgn: linux_kernel: Fix module detection on kernel v6.4
Kernel commit ac3b43283923 ("module: replace module_layout with
module_memory") in v6.4 changed the layout of `struct module`, resulting
in the following drgn error [1].

Fix this by first trying to determine the base address and size of each
kernel module via the `struct module_memory mem[MOD_TEXT]` member,
before falling back to previous methods that work on older kernels.

Tested on v6.4-rc2 and v6.3 which does not include the above mentioned
commit.

Note that kernel commit b4aff7513df3 ("scripts/gdb: use mem instead of
core_layout to get the module address") performs a similar fix in Python
GDB scripts.

Closes #296.

[1]
```
# drgn
drgn 0.0.22 (using Python 3.11.3, elfutils 0.189, with libkdumpfile)
For help, type help(drgn).
>>> import drgn
>>> from drgn import NULL, Object, cast, container_of, execscript, offsetof, reinterpret, sizeof
>>> from drgn.helpers.common import *
>>> from drgn.helpers.linux import *
warning: could not get debugging information for:
kernel modules (could not find loaded kernel modules: 'struct module' has no member 'core_size')
```

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2023-05-28 22:08:18 -07:00
Omar Sandoval
fc3ea4184a libdrgn: use new include-what-you-use exported declarations and fix warnings
include-what-you-use/include-what-you-use#1164 fixed
include-what-you-use/include-what-you-use#971 so that we can export
forward declarations instead of hacking around it. I can't reproduce the
issue with BINARY_OP_SIGNED_2C anymore either, so we can remove that
hack, too. Also fix any other warnings.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-05-24 00:25:25 -07:00
Omar Sandoval
067c139355 vmtest.kmod: document that -k may be given multiple times
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-03-27 13:18:44 -07:00
Sven Schnelle
73e451d588 tests: enable MM tests on s390x
s390x now has full mm support, so enable the tests for it.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
2023-03-22 15:24:11 -07:00
Sven Schnelle
3483a69a56 libdrgn: add s390x pagetable walk support
Add support for walking s390x page tables. This supports
up to 5 level page table walking and huge/large pages. In order
to figure out the level of paging used, we read the first entry
of the pgd, which is always mapped for lowcore access and use the
level bits of the next page table. This is because drgn passes mm::pgd
as pgtable argument to the walker function which doesn't contain the
ASCE bits.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
2023-03-22 15:24:11 -07:00
Martin Liska
1133b2fd31 Fix output for of lsmod.py
Unify it with what lsmod(8) does.

Signed-off-by: Martin Liska <mliska@suse.cz>
2023-02-27 14:22:14 -08:00
Martin Liska
983ec87a77 contrib: add vmmap.py script
Mimics `cat /proc/$pid/maps` and the script output is:

Start        End          Flgs   Offset Dev   Inode            File path
55dee5284000-55dee53f3000 r-xp 00000000 fd:02 10515            /usr/lib/systemd/systemd
55dee53f3000-55dee5441000 r--p 0016f000 fd:02 10515            /usr/lib/systemd/systemd
55dee5441000-55dee5442000 rw-p 001bd000 fd:02 10515            /usr/lib/systemd/systemd
55dee5f4c000-55dee615d000 rw-p 00000000 00:00 0
7f5fc801c000-7f5fc8024000 r-xp 00000000 fd:02 1181379          /usr/lib64/libffi.so.7.1.0
7f5fc8024000-7f5fc8224000 ---p 00008000 fd:02 1181379          /usr/lib64/libffi.so.7.1.0
7f5fc8224000-7f5fc8225000 r--p 00008000 fd:02 1181379          /usr/lib64/libffi.so.7.1.0
...

Signed-off-by: Martin Liska <mliska@suse.cz>
Co-authored-by: Omar Sandoval <osandov@osandov.com>
2023-02-25 02:08:46 -08:00
Martin Liska
35f9de75b3 contrib: add memory statistics to ps.py
New output of the command is:

PID     PPID    CPU  ST    VMS     RSS  MEM%  COMM
1       0       0    S   10.4M    6.5M   0.4 init
2       0       0    S       0       0   0.0 [kthreadd]
...
263     1       4    S    2.4G  163.5M   9.5 python3
264     1       5    S    2.4G  163.5M   9.5 python3
265     1       6    S    2.4G  163.5M   9.5 python3
266     1       10   S    2.4G  163.5M   9.5 python3
267     1       12   S    2.4G  163.5M   9.5 python3
268     1       13   S    2.4G  163.5M   9.5 python3
269     1       14   S    2.4G  163.5M   9.5 python3
270     1       15   S    2.4G  163.5M   9.5 python3
271     1       16   S    2.4G  163.5M   9.5 python3
...

Supports also older kernel releases like 4.4.

Signed-off-by: Martin Liska <mliska@suse.cz>
2023-02-25 02:07:57 -08:00
Martin Liska
e6228245a0 Fix TCP listing contrib script
Since Linux kernel commit 8dbd76e79a16 ("tcp/dccp: fix possible race
__inet_lookup_established()") (in v5.5), it's actually hlist_nulls_head
what is used for items of inet_hashinfo::listening_hash. This commit was
also backported to stable kernels, so with the change it works for all
releases starting with v4.9. The version 4.4 is not supported right now
(nulls head list is probably not known at the time).

Fixes: #268

Signed-off-by: Martin Liska <mliska@suse.cz>
2023-02-24 13:15:00 -08:00
Martin Liska
adc8c430bb add kernel_sys.py to contrib
This script mimics crash>sys and provides the following output:

CPUS             16
DATE             Fri Jan 27 20:26:24 2023
UPTIME           1 day, 7:29:37
LOAD AVERAGE     0.00, 0.00, 0.00
TASKS            317
NODENAME         tw
RELEASE          6.1.7-1-default
VERSION          #1 SMP PREEMPT_DYNAMIC Wed Jan 18 11:12:34 UTC 2023 (872045c)
MACHINE          x86_64
MEMORY           12.67 GiB

Signed-off-by: Martin Liska <mliska@suse.cz>
2023-02-24 12:22:00 -08:00
Omar Sandoval
0d03be7d62 libdrgn: silence -Wmaybe-uninitialized false positive
This false positive appears to only trigger on 32-bit. I reproduced it
with GCC 10 and 12.

Fixes #242.

Reported-by: Timothée Cocault <timothee.cocault@gmail.com>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-24 01:04:15 -08:00
Omar Sandoval
030fb78eaf vmtest.config: enable LPAE for Arm alternative flavor
LPAE uses a different page table format and enables 2GB huge pages, so
it'll be interesting to test.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 18:03:02 -08:00
Omar Sandoval
0b7238baa3 vmtest.config: fix CONFIG_KEXEC_FILE for s390x
On s390x, CONFIG_KEXEC_FILE depends on CONFIG_CRYPTO_SHA256_S390.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 17:44:05 -08:00
Omar Sandoval
cc77c444ba vmtest.config: enable rtc-cmos driver in x86-64 Kconfig
We go through the trouble of enabling a real-time clock driver for other
architectures, so do the same on x86-64.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 17:19:23 -08:00
Omar Sandoval
ee20b2d759 vmtest.config: enable hugetlbfs in kconfig
This will be used to test huge page address translation.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 17:09:40 -08:00
Omar Sandoval
07b9ee5f36 vmtest.kbuild: generate package in final directory
vmtest.kbuild -b $build_dir -p $package_dir --package-format directory
fails when attempting to rename the temporary package directory if
$build_dir and $package_dir are on different filesystems or Btrfs
subvolumes. Put the temporary package directory in $package_dir so that
the rename can succeed.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 11:16:46 -08:00
Omar Sandoval
ff89a6d267 drgn.helpers.linux.slab: fix check for directly mapped address
High memory is not directly mapped, so _find_containing_slab() needs to
check against max_low_pfn, not max_pfn.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-23 01:37:29 -08:00
Omar Sandoval
3a4480289c tests: remove @skip_unless_have_full_mm_support from page <-> pfn <-> phys helper tests
The phys <-> pfn helpers only need PAGE_SHIFT, which is always
available, the page <-> pfn helpers only need vmemmap or mem_map, which
is independent of virtual address translation, and the page <-> phys
helpers are built on top of those.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-22 16:12:33 -08:00
Omar Sandoval
7cf3d7ddf9 drgn.helpers.linux.mm: handle CONFIG_FLATMEM
AArch64, ppc64, s390x, and x86-64 all default to
CONFIG_SPARSEMEM_VMEMMAP, which allows us to translate between struct
page * and PFN with trivial array operations on vmemmap. Arm and i386,
however, use CONFIG_FLATMEM, which has a different array, mem_map, that
we can use similarly. Update the helpers that use vmemmap to use a new
wrapper that gets the proper array.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-22 16:06:21 -08:00
Omar Sandoval
101639caaf tests: don't compare values of reference objects in assertIdentical()
The value can change between two reads. This caused test failures in the
previous commit 18a8f69ad8 ("libdrgn: linux_kernel: add object finder
for jiffies"). The important thing is that the addresses are the same.

Fixes: 75c3679147 ("Rewrite drgn core in C")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-22 13:33:47 -08:00
Omar Sandoval
18a8f69ad8 libdrgn: linux_kernel: add object finder for jiffies
We have a lot of examples that use jiffies, but they stopped working
long ago on x86-64 (since Linux kernel commit d8ad6d39c35d ("x86_64: Fix
jiffies ODR violation") (in v5.8 and backported to stable releases)) and
never worked on other architectures. This is because jiffies is defined
in the Linux kernel's linker script. #277 proposed updating the examples
to use jiffies_64, but I would guess that most kernel developers are
familiar with jiffies and many have never seen jiffies_64. jiffies is
also a nicer name to type in live demos. Let's add a case to the Linux
kernel object finder to get the jiffies variable.

Reported-by: Martin Liska <mliska@suse.cz>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-22 11:15:37 -08:00
Omar Sandoval
69f5352cb6 tests: replace mmap with test kernel module for test_read_physical()
tests.linux_kernel.helpers.test_mm.TestMm.test_read_physical() fails on
Arm when the user page is mapped from high memory. Replace it with a
test case that uses the test physical address from the test kernel
module and asserts the expected PRNG data. (We will probably run into
more tests that fail with high memory once #244 is merged.)

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-22 10:07:55 -08:00
Omar Sandoval
dc38822e6c tests: use PRNG to generate data for tests
This replaces the multiples of a prime sequence used for the per-CPU
helper tests with a slightly more self-documenting PRNG interface in
both the test kernel module and Python test scaffolding. It will be used
more in upcoming tests.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-22 02:10:03 -08:00
Omar Sandoval
38b090ea9d setup.py: handle git not being installed
My previous change to call git unconditionally caused Packit failures,
presumably because git isn't installed for the build:

Traceback (most recent call last):
  File "/builddir/build/BUILD/drgn-0.0.22+71.g2f97cc0/setup.py", line 411, in <module>
    version=get_version(),
            ^^^^^^^^^^^^^
  File "/builddir/build/BUILD/drgn-0.0.22+71.g2f97cc0/setup.py", line 343, in get_version
    subprocess.call(
  File "/usr/lib64/python3.11/subprocess.py", line 389, in call
    with Popen(*popenargs, **kwargs) as p:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib64/python3.11/subprocess.py", line 1901, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'git'

We shouldn't bother calling git if .git doesn't exist.

Fixes: 2e9e66cedc ("setup.py: use stricter check for git repository")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-21 18:12:54 -08:00
Omar Sandoval
2f97cc0f5f libdrgn: platform: expand on page table iterator documentation
There are a lot of details about how the page table iterator functions
should be used/implemented that commit 174b797ae3 ("libdrgn: platform:
add documentation (especially for drgn_architecture_info)") didn't
cover. Add an example and expand/clarify the documentation for the
callbacks.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-21 17:42:22 -08:00
Jay Kamat
08cb38cc2f Expand DW_AT_upper_bound quirk on zero size arrays
GCC appears to use data8 at -1 when reporting zero length arrays when
comping c++ code, this patch adds support and a test for that behavior.

dwarf_info.c: Remove check for sdata on quirk for array length == 0

Signed-off-by: Jay Kamat <jaygkamat@gmail.com>
2023-02-21 16:44:20 -08:00
Omar Sandoval
58664bedfb tests: allow test_identify_unrecognized() to pass on s390x
When testing #245, I encountered this error:

======================================================================
ERROR: test_identify_unrecognized (tests.linux_kernel.helpers.test_common.TestIdentifyAddress)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/host/home/osandov/repos/drgn/tests/linux_kernel/helpers/test_common.py", line 57, in test_identify_unrecognized
    self.assertIsNone(identify_address(self.prog, start_addr - 1))
  File "/host/home/osandov/repos/drgn/drgn/helpers/common/memory.py", line 99, in identify_address
    symbol = prog.symbol(addr)
OverflowError: can't convert negative int to unsigned

This is because the lowest kernel address in s390x is 0, so we're
passing -1 to identify_address(). Work around that in the test.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-21 14:44:53 -08:00
Omar Sandoval
5276af94fd contrib: add kcore_list.py
I used this to look at RAM regions on different architectures.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-21 14:26:54 -08:00
Omar Sandoval
2e9e66cedc setup.py: use stricter check for git repository
To test builds on other architectures, I'm setting up a Debian chroot
with debootstrap and then building with something like:

  mount --bind . "$chroot/mnt"
  chroot "$chroot" sh -c 'cd /mnt && python3 setup.py build_ext -i'

However, if I do this from a Git worktree, this fails with an error from
the git call to determine the local version:

  fatal: not a git repository: /home/osandov/repos/drgn/.git/worktrees/drgn2

Instead of only checking whether .git exists, use `git --git-dir=.git
rev-parse` to verify that .git is valid. (This will of course rely on
drgn/internal/version.py already having been generated.)

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-02-21 12:07:37 -08:00
Martin Liska
7e7fdf6978 tests: limit SMP count to 8 at maximum
Sometimes one can see an OOM with a higher number of SMP count
while still having 2G of memory.

Signed-off-by: Martin Liska <mliska@suse.cz>
2023-02-20 01:30:52 -08:00