Skip to content

DLPX-95232 Merge conflict with upstream drgn - #75

Merged
mmaybee merged 354 commits into
developfrom
dlpx/pr/mmaybee/ea2b8bac-b860-436f-a705-4f194be02b33
Aug 27, 2025
Merged

mmaybee merged 354 commits into
developfrom
dlpx/pr/mmaybee/ea2b8bac-b860-436f-a705-4f194be02b33

Conversation

@mmaybee

@mmaybee mmaybee commented Aug 27, 2025

Copy link
Copy Markdown

Problem

There is a small confict with the auto-merge with the upstream drgn repo.
The file .pre-commit-config.yaml has been deleted by us, but was modified
upstream.

Solution

Delete file from incomming merge.

Testing Done

https://selfservice-jenkins.eng-tools-prd.aws.delphixcloud.com/job/appliance-build-orchestrator-pre-push/12033

osandov and others added 30 commits March 25, 2025 08:14
Signed-off-by: Omar Sandoval <osandov@osandov.com>
…ols-by

It'd be useful to be able to control debug info finders in addition to
options. Rather than adding yet another set of command-line options,
co-opt --try-symbols-by and --no-symbols-by.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Drgn has a set of globals provided in interactive mode, but they can be
useful to other modes (e.g. for executing statements directly). They may
also be useful to client code. Make this a separate, public helper. It
does make the globals_func argument to run_interactive() a bit much, but
that's ok.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
The Python interpreter has "-c" which allows directly running code
provided as a command line argument. This is useful for quick tests,
without needing to write a script and execute it, and without needing to
run the interactive interpreter. It can also be used in scripts or
one-liners.

Unfortunately, "-c" is already used in the drgn CLI. However, this
functionality would be quite useful. Let's add it to the CLI using the
option "-e", which is short for "execute" or "exec", the underlying
Python function.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Prior to Python 3.10, the object returned by @staticmethod apparently
cannot be called unless bound to the class instance. So the new changes
in the fixed commit cause the CLI to fail on Python < 3.10.

We can resolve this in a variety of ways, but the one which doesn't
result in any static checker warnings is the simplest: just move this
function out to a module-level function. There are no users in
sub-classes which need to be converted.

Fixes: 4a6a9f3 ("cli: allow enabling/disabling debug info finders with --{try,no}-symbols-by")

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Do this for consistency with the other modes.

Fixes: 150ee76 ("cli: add -e option to exec() code directly")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
With -e, args.script doesn't necessarily mean that we're running a
script. That's a bug waiting to happen, so rename it and add a local
variable for whether we're running a script.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Redirecting drgn's stdin (e.g., to a pipe or a file) is really broken:
with the enhanced REPL, it fails with "termios.error: (25,
'Inappropriate ioctl for device')" and "AttributeError: 'UnixConsole'
object has no attribute '_UnixConsole__buffer'". With the basic REPL, it
prints ps1/ps2 prompts and expects extra newlines to terminate indented
blocks.

The standard Python REPL handles this by checking if stdin is a
terminal. Unfortunately, code.interact()/_pyrepl don't do this, so let's
do the check and exec manually.

Reported-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Reported-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Also cover script mode and piping in a script and check that we set
__name__, __file__, sys.path, sys.argv, prog, and the default program
appropriately.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This is a shortcut for `for _ in prog.loaded_modules: pass` or
`list(prog.loaded_modules())`, which is used in several test cases and
is occasionally useful elsewhere.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Include the kernel version and silence the loaded module iterator
warning.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
…_debug_info()

We don't need iterator_tried_missing since we can just check num_missing
(renamed from num_warnings).

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Instead of manually bolding the warning, always bold critical messages
and log as critical or warning depending on whether we're missing the
main debug info.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
…all_function() docstring

wake_up_process() is one of the best use cases for call_function(), so
use it as the first example.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
My debuginfod optimizations for the Linux kernel haven't been deployed
anywhere other than Fedora's debuginfod servers. On other servers, it's
better to not even try since downloads will take forever. Do a sketchy
check to determine whether the kernel is from Fedora and disable the
debuginfod finder if not. It can still be reenabled manually with
--try-symbols-by debuginfod or by a plugin.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
pyroute 0.9.1 dropped support for Python < 3.9. On Python 3.6 and 3.7,
it fails with an ImportError from typing that the try/except in
tests/linux_kernel/helpers/test_tc.py catches by accident, but on 3.8 it
fails with a TypeError: 'type' object is not subscriptable. Fix it by
installing an older version of pyroute2 on those Python versions.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
An object can be absent for multiple reasons: e.g., the object is a
placeholder, it was optimized out, or its value is represented using a
DWARF opcode we don't support. We print all of these as "<absent>",
which is technically correct but criminally vague.

Add an absence reason to struct drgn_object/drgn.Object. For now, this
only has one possible value, "OTHER", but it will be made more specific
in follow-up commits.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
The most common ways users will run into absent objects are optimized
out local variables and inlined functions. Add an absence reason for
this and use it for DWARF, then use it to display such objects with more
familiar terminology ("<optimized out>").

We might want to distinguish between truly optimized out values and
unsaved registers, but we can improve that later.

See osandov#488.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Rather than failing hard on an unknown DWARF expression opcode, log a
warning and return an absent object with a NOT_IMPLEMENTED absence
reason. Since DW_OP_(GNU_)entry_value is somewhat common and we already
know about it, we still classify it as OPTIMIZED_OUT rather than
NOT_IMPLEMENTED.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Famous last words: "it hasn't changed since v2.6.38, so let's hardcode
it for now." Linux 6.15 changed the value of DCACHE_MOUNTED, which broke
path_lookup(). I sent a patch converting the DCACHE_* flags to an enum
[1], but we need to unbreak 6.15 (with a version check, unfortunately)
until that lands.

[1]: https://lore.kernel.org/linux-fsdevel/177665a082f048cf536b9cd6af467b3be6b6e6ed.1744141838.git.osandov@fb.com/T/#u

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Linux 6.15 renamed kernfs_node::parent to __parent, which broke a couple
of kernfs helpers. Add a kernfs_parent() helper that handles the change
and use it in the existing helpers.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
We already have this internally, so let's make it public.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This one needed updates to the kernfs helpers and path_lookup().

Signed-off-by: Omar Sandoval <osandov@osandov.com>
I'm experimenting with kprobes-based breakpoint support via kmodify (not
coming soon but eventually). Enable CONFIG_KPROBES so I can test it.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
I think I only used drgn_module_find_or_create() instead of
drgn_module_find_or_create_relocatable() because at some point earlier
in development, the latter didn't have new_ret. Change it so we can make
drgn_module_find_or_create() static.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This is more type safe and more consistent with the Python API.
(drgn_module_find() still exists as a static function in debug_info.c.)

Signed-off-by: Omar Sandoval <osandov@osandov.com>
osandov and others added 20 commits August 13, 2025 23:21
argparse apparently interprets % in the help string as %-style
formatting. We don't want that, but we also don't want to escape it in
the string literal and make drgndoc deal with unescaping it, so escape
it in the framework right before we pass it to argparse.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
The nastiest part of this one is handling the ambiguities between
expressions, command line flags, pipelines, and redirections. Other than
that, the expression syntax that crash supports is very limited, so it's
fairly simple.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
…lpers

The crash tree command visits red-black tree entries in pre-order by
default. Add helpers to do this, which are straightforward variants of
the existing in-order helpers.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This way we can make kind default to "*", which will be more convenient
for most of the existing callers and the upcoming list and tree
commands.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
There are a few functions in drgn.commands._builtin.crash.structunion
that will also be needed for the list and tree commands. Move them to
drgn.commands.crash. For now, they're considered private, but they could
be made public if we needed.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This one has nice correspondence to existing drgn helpers, although the
various offset options are a bit of a pain to generate drgn code for.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This should only be logged if we don't find a uprobe consumer, but we're
always logging it because we never mark that we found a consumer.

Fixes: a5da128 ("tools/fsrefs.py: check for references from uprobes")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Linux kernel commit cac5cefbade9 ("sched/smp: Make SMP unconditional")
(in v6.17) changed init_task.comm from "swapper" to "swapper/0" on !SMP
kernels. We have a couple of tests that check for the old behavior.
Replace them with different checks that work regardless of kernel.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This is our preferred format, but repr() returns a single-quoted string.
Add a hacky helper function to return a double-quoted repr when it's
preferrable and use it where appropriate.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
argparse allows specifying a different name per argument by passing a
tuple as the metavar. Handle that.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This is needed for the crash mod command.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Since we just added the helper for module-specific taints, let's add one
for the global taints.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
I wasn't planning on implementing -s or -S at first, but they're easy
enough to do with the module API.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
These are trivial.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
We need a couple of ioctls for upcoming test cases. Annoyingly, the
_IO{,R,W,WR} macros used to define ioctl numbers are
architecture-dependent. Add Python functions based on these macros,
generated from the kernel source code, along with the script used to
generate them.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Instead, require that the file already exists when mkswap() is called,
like mkswap(8), and get the file or partition size automatically. This
will simplify upcoming tests.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Upcoming tests for swap helpers need to write a partition table. We
could use an external command, but the only one provided in BusyBox is
fdisk, which is a pain to script. The format is simple enough, so add a
function to do it ourselves.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
These are needed for the crash kmem -i and swap commands.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This one wasn't super high priority, but I implemented the necessary
helpers while working on the kmem -i command, and it doesn't have any
options, so it was quick.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
@mmaybee
mmaybee force-pushed the dlpx/pr/mmaybee/ea2b8bac-b860-436f-a705-4f194be02b33 branch from c11a228 to 2a0c489 Compare August 27, 2025 15:10
@mmaybee
mmaybee requested review from prakashsurya and sebroy August 27, 2025 15:37
@mmaybee
mmaybee marked this pull request as ready for review August 27, 2025 15:38

@sebroy sebroy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing this! We could probably follow this up with a change to restore that deleted file so that it stops being a merge conflict in the future. For now, let's move forward with this to unblock us.

That said, it looks like the package doesn't build in your pre-push run: https://selfservice-jenkins.eng-tools-prd.aws.delphixcloud.com/job/linux-pkg/job/develop/job/build-package/job/drgn/job/pre-push/44/console
I'm interpreting this as perhaps this requires a new version of libkdumpfile, which is another linux-pkg package that hasn't been updated in a long time stuck behind its own merge conflict.

@sebroy

sebroy commented Aug 27, 2025

Copy link
Copy Markdown

Thank you for doing this! We could probably follow this up with a change to restore that deleted file so that it stops being a merge conflict in the future. For now, let's move forward with this to unblock us.

That said, it looks like the package doesn't build in your pre-push run: https://selfservice-jenkins.eng-tools-prd.aws.delphixcloud.com/job/linux-pkg/job/develop/job/build-package/job/drgn/job/pre-push/44/console I'm interpreting this as perhaps this requires a new version of libkdumpfile, which is another linux-pkg package that hasn't been updated in a long time stuck behind its own merge conflict.

delphix/libkdumpfile#39 is merged now, so we should be able to depend on libkdumpfile 0.5.5 now.

@mmaybee
mmaybee merged commit 6d40ce3 into develop Aug 27, 2025
4 of 10 checks passed
@mmaybee
mmaybee deleted the dlpx/pr/mmaybee/ea2b8bac-b860-436f-a705-4f194be02b33 branch August 27, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

10 participants