- Update to drgn-0.0.30:

* Linux 6.13 support
  * Support for symbols without debuginfo
  * Use Python 3.13 enhanced REPL when available
  * Add a 'stat' subcommand to contrib/cgroup.py
  * Many bug fixes
- API compatibility with libkdumpfile-0.5.5:
  * libdrgn-kdump-prepare-for-incompatible-changes-in-li.patch
  * libdrgn-kdump-simplify-getting-the-PRSTATUS-attribut.patch

OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/python-drgn?expand=0&rev=23
This commit is contained in:
Petr Tesařík 2024-12-30 13:16:26 +00:00 committed by Git OBS Bridge
commit a2b38e6dfe
8 changed files with 373 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

BIN
drgn-0.0.29.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

3
drgn-0.0.30.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:828cb0a3ea424654314548d0f39765cad36c6c285ca0d9f53d0bd29f8f419a52
size 853847

View File

@ -0,0 +1,37 @@
From: Petr Tesarik <ptesarik@suse.com>
Date: Tue, 3 Dec 2024 13:54:40 +0100
Subject: libdrgn: kdump: prepare for incompatible changes in
libkdumpfile-0.5.5
Upstream: merged
Git-commit: 4e06cfdff158935eee725e726a63a5d9c9e57dab
The kdump_get_typed_attr() function prototype changed in libkdumpfile
commit e182aeaf4d72 ("Make kdump_get_typed_attr() easier to use").
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
libdrgn/kdump.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libdrgn/kdump.c b/libdrgn/kdump.c
index 0bb594d1..4e5eea92 100644
--- a/libdrgn/kdump.c
+++ b/libdrgn/kdump.c
@@ -318,9 +318,14 @@ struct drgn_error *drgn_program_cache_kdump_threads(struct drgn_program *prog)
+ 1];
snprintf(attr_name, sizeof(attr_name), FORMAT, i);
#undef FORMAT
+#if KDUMPFILE_VERSION >= KDUMPFILE_MKVER(0, 5, 5)
+ ks = kdump_get_typed_attr(prog->kdump_ctx, attr_name,
+ KDUMP_BLOB, &prstatus_attr.val);
+#else
prstatus_attr.type = KDUMP_BLOB;
ks = kdump_get_typed_attr(prog->kdump_ctx, attr_name,
&prstatus_attr);
+#endif
if (ks != KDUMP_OK) {
return drgn_error_format(DRGN_ERROR_OTHER,
"kdump_get_typed_attr(%s): %s",
--
2.47.1

View File

@ -0,0 +1,86 @@
From: Petr Tesarik <ptesarik@suse.com>
Date: Mon, 2 Dec 2024 17:38:24 +0100
Subject: libdrgn: kdump: simplify getting the PRSTATUS attributes
Upstream: merged
Git-commit: 885a3209f3603593fb89327c1072f94e5862ffbb
Since libkdumpfile commit 5b044292abe9 ("Clarify and fix attribute data
lifetime") changes the lifetime of attribute values retrieved with
kdump_attr_ref_get(), the extra reference would keep the PRSTATUS blob
around even after kdump_free().
However, the attribute hierarchy cannot change while iterating over the
PRSTATUS attributes, so it is not necessary to take an attribute reference
and we can use kdump_get_typed_attr().
The attribute blob itself should not change either, but it is a good idea
to keep its data pinned, because a raw pointer to it is stored in the
drgn_thread_set hash table. If some code tries to modify the PRSTATUS
attribute data, the attempt will fail with KDUMP_ERR_BUSY rather than leave
a dangling pointer in the hash table and possibly cause a UAF bug later.
The blob pin does not prevent freeing the blob when the blob reference
count reaches zero.
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
libdrgn/kdump.c | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/libdrgn/kdump.c b/libdrgn/kdump.c
index 09efd965..0bb594d1 100644
--- a/libdrgn/kdump.c
+++ b/libdrgn/kdump.c
@@ -299,39 +299,31 @@ struct drgn_error *drgn_program_cache_kdump_threads(struct drgn_program *prog)
}
/*
- * Note that in the following loop we never call kdump_attr_unref() on
- * prstatus_ref, nor kdump_blob_unpin() on the prstatus blob that we get
- * from libkdumpfile. Since drgn is completely read-only as a consumer
- * of that library, we "leak" both the attribute reference and blob pin
- * until kdump_free() is called which will clean up everything for us.
+ * Note that in the following loop we never call kdump_blob_unpin() on
+ * the prstatus blob that we get from libkdumpfile. Since drgn never
+ * modifies the PRSTATUS attributes (neither directly nor indirectly),
+ * we "leak" the blob pin until kdump_free() is called, which will
+ * clean up everything for us.
*/
for (i = 0; i < ncpus; i++) {
- /* Enough for the longest possible PRSTATUS attribute name. */
- kdump_attr_ref_t prstatus_ref;
kdump_attr_t prstatus_attr;
void *prstatus_data;
size_t prstatus_size;
#define FORMAT "cpu.%" PRIuFAST64 ".PRSTATUS"
+ /* Enough for the longest possible PRSTATUS attribute name. */
char attr_name[sizeof(FORMAT)
- sizeof("%" PRIuFAST64)
+ max_decimal_length(uint_fast64_t)
+ 1];
snprintf(attr_name, sizeof(attr_name), FORMAT, i);
#undef FORMAT
- ks = kdump_attr_ref(prog->kdump_ctx, attr_name, &prstatus_ref);
- if (ks != KDUMP_OK) {
- return drgn_error_format(DRGN_ERROR_OTHER,
- "kdump_attr_ref(%s): %s",
- attr_name,
- kdump_get_err(prog->kdump_ctx));
- }
-
- ks = kdump_attr_ref_get(prog->kdump_ctx, &prstatus_ref,
- &prstatus_attr);
+ prstatus_attr.type = KDUMP_BLOB;
+ ks = kdump_get_typed_attr(prog->kdump_ctx, attr_name,
+ &prstatus_attr);
if (ks != KDUMP_OK) {
return drgn_error_format(DRGN_ERROR_OTHER,
- "kdump_attr_ref_get(%s): %s",
+ "kdump_get_typed_attr(%s): %s",
attr_name,
kdump_get_err(prog->kdump_ctx));
}
--
2.47.1

135
python-drgn.changes Normal file
View File

@ -0,0 +1,135 @@
-------------------------------------------------------------------
Mon Dec 30 13:01:09 UTC 2024 - Petr Tesařík <ptesarik@suse.com>
- Update to drgn-0.0.30:
* Linux 6.13 support
* Support for symbols without debuginfo
* Use Python 3.13 enhanced REPL when available
* Add a 'stat' subcommand to contrib/cgroup.py
* Many bug fixes
- API compatibility with libkdumpfile-0.5.5:
* libdrgn-kdump-prepare-for-incompatible-changes-in-li.patch
* libdrgn-kdump-simplify-getting-the-PRSTATUS-attribut.patch
-------------------------------------------------------------------
Wed Oct 9 06:46:34 UTC 2024 - Petr Tesařík <ptesarik@suse.com>
- Update to drgn-0.0.29:
* Fix call_function(), write_memory(), and write_object() for
kernels with CONFIG_MODVERSIONS=y
- Fix a few rpmlint warnings.
-------------------------------------------------------------------
Wed Oct 9 06:24:34 UTC 2024 - Petr Tesařík <ptesarik@suse.com>
- Update to drgn-0.0.28:
* Linux 6.11 and 6.12 support
* Helpers for modifying the running kernel
* 32-bit Arm address translation
* AArch64 52-bit virtual addresses with 4k or 16k pages
-------------------------------------------------------------------
Thu Sep 26 16:45:15 UTC 2024 - Michal Koutný <mkoutny@suse.com>
- Update RPM's Source: to match tarball proper
-------------------------------------------------------------------
Tue Jul 2 03:32:44 UTC 2024 - Petr Tesařík <petr@tesarici.cz>
- Update to drgn-0.0.27:
* Linux 6.9 and 6.10 support
* New helpers for interpreting memory
* New scripts in contrib
-------------------------------------------------------------------
Tue Mar 12 18:14:42 UTC 2024 - Petr Tesařík <petr@tesarici.cz>
- Update to drgn-0.0.26:
* Linux 6.8 Support
* Python 3.13 Support
* new tool: fsrefs.py
* new Linux helpers: print_dmesg(), idr_for_each_entry(),
stack_depot_fetch(), priority-sorted lists
* support split DWARF package (.dwp) files
-------------------------------------------------------------------
Mon Dec 4 14:46:37 UTC 2023 - Michal Koutný <mkoutny@suse.com>
- Cleanup .gitignore'd files from tarball
-------------------------------------------------------------------
Sat Dec 2 16:59:32 UTC 2023 - Petr Tesařík <petr@tesarici.cz>
- Update to drgn-0.0.25:
* omitting the prog argument
* running without root privileges
* maple tree helpers
* VMA helpers
* wait queue helpers
* ppc64 radix MMU support
-------------------------------------------------------------------
Fri Sep 8 19:25:20 UTC 2023 - Petr Tesařík <petr@tesarici.cz>
- Update to drgn-0.0.24:
* Linked list length helper
* Networking helpers
* C++ lookups
* Split DWARF
* Performance improvements
-------------------------------------------------------------------
Thu Jun 29 09:48:44 UTC 2023 - Petr Tesařík <petr@tesarici.cz>
- Update to drgn-0.0.23:
* Support Linux 6.3 and 6.4
* Full s390x support
* Extend idr helpers for pre-4.11 Linux
* Support GNU-style compressed .zdebug_* sections
* New scripts in contrib
-------------------------------------------------------------------
Sat Jan 7 20:40:49 UTC 2023 - Petr Tesařík <ptesarik@suse.com>
- Update to drgn-0.0.22:
* License changed to LGPLv2.1+.
* Linux kernel support was tested up to Linux 6.2-rc2.
* Oldest kernel version officially supported is now 4.9.
* The StackFrame.locals() method was added.
* The StackFrame.sp attribute was added.
* Helpers for XArrays were added.
* The drgn.helpers.linux.slab.get_slab_aliases() helper was added.
* The drgn.helpers.linux.slab.slab_object_info() helper was added.
* The drgn.helpers.common.memory.identify_address() helper now
provide the offset from the beginning of the slab object and
whether it is allocated or free.
* The drgn.helpers.common.stack.print_annotated_stack() helper was
added.
* Support for Linux kernel modules and stack unwinding on s390x.
* Partial support for looking up types with C++ template
arguments.
* Parsing debug info for C++ template parameter packs.
-------------------------------------------------------------------
Fri Oct 14 16:11:33 UTC 2022 - Petr Tesařík <ptesarik@suse.com>
- Update to drgn-0.0.21:
* Linux kernel support up to Linux 6.0.
* Helpers for lockless linked lists in the Linux kernel.
* A helper to find the slab cache that a virtual address came.
* A drgn.helpers.common package for helpers that can be used with
any program (which may have program-specific additional
behavior).
* A helper to identify an arbitrary address (e.g., as a symbol or
slab object).
* PageFoo() helpers to check various struct page flags.
* Helpers for working with compound pages.
* A helper to get the CPU that a task last ran on.
* Automatic pretty-printing in IPython/Jupyter.
* drgn.StackTrace.prog was added as a way to get the program that a stack trace came from.
* Bug fixes, documentation, minor API changes.
-------------------------------------------------------------------
Sun Aug 14 20:51:07 UTC 2022 - Petr Tesařík <ptesarik@suse.com>
- Initial packaging for openSUSE.

85
python-drgn.spec Normal file
View File

@ -0,0 +1,85 @@
#
# spec file for package python-drgn
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define skip_python2 1
%{?!python_module:%define python_module() python3-%{**}}
Name: python-drgn
Version: 0.0.30
Release: 0
Summary: Scriptable debugger library
License: LGPL-2.1-or-later
Group: Development/Tools/Debuggers
URL: https://github.com/osandov/drgn
Source: https://github.com/osandov/drgn/archive/refs/tags/v%{version}.tar.gz#/drgn-%{version}.tar.gz
Patch1: libdrgn-kdump-simplify-getting-the-PRSTATUS-attribut.patch
Patch2: libdrgn-kdump-prepare-for-incompatible-changes-in-li.patch
BuildRequires: %{python_module devel}
BuildRequires: %{python_module setuptools}
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: check-devel
BuildRequires: fdupes
BuildRequires: libdw-devel
BuildRequires: libelf-devel
BuildRequires: libkdumpfile-devel
BuildRequires: libtool
BuildRequires: python-rpm-macros
Requires(post): update-alternatives
Requires(postun): update-alternatives
%python_subpackages
%description
drgn (pronounced “dragon”) is a debugger with an emphasis on
programmability. drgn exposes the types and variables in a program
for easy, expressive scripting in Python.
%prep
%setup -q -n drgn-%{version}
%autopatch -p1
%build
export CFLAGS="%{optflags}"
%python_build
%install
%python_install
%python_clone -a %{buildroot}%{_bindir}/drgn
%python_expand %fdupes %{buildroot}%{$python_sitearch}
%check
%python_exec setup.py test
%post
%python_install_alternative drgn
%postun
%python_uninstall_alternative drgn
%files %{python_files}
%doc README.rst
%license COPYING
%python_alternative %{_bindir}/drgn
%{python_sitearch}/drgn
%{python_sitearch}/drgn-%{version}*-info
%{python_sitearch}/_drgn*.pyi
%{python_sitearch}/_drgn*.so
%{python_sitearch}/_drgn_util
%changelog