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

Including corelens & drgn versions in reports #147

Merged
merged 4 commits into from
Feb 4, 2025

Conversation

brenns10
Copy link
Member

There are two related issues fixed here:

  1. The useful messages that give the debuginfo type and the runtime are only printed in "report mode", which is when -o is used. LKCE does not use report mode, so its reports don't have that information, which is a shame. To fix this, add a "corelens" section to the stdout output whenever more than one module is run. This ensures that the common case of corelens VMCORE -M one_module doesn't get a bunch of extra output that won't be useful for most people.
  2. Some useful info was missing in this output - the drgn-tools & drgn versions. So add that in.

To make the versions even more useful, I've updated the packaging scripts so that the version string reported by corelens is (nearly) identical to the RPM version, if it was installed via the RPM. That can help differentiate between supported & unsupported installations (e.g. running from git or from source).

I'm avoiding adding options like --verbose or --quiet here because the logic is already complicated enough. I'd like to avoid custom flags to add or remove specific kinds of output. Hopefully each of the above modes is intuitive enough that people don't really need to think about it - the output just makes sense.

To test this, I've verified that the output for each of the three possible cases (described in the code) and I've also built the RPMs on OL9 and installed. Here's what it looks like for a silly (small) output on my laptop where we're running multiple modules to stdout:

$ corelens /proc/kcore -M ls / -c -M ls /home/stepbren -c
warning: Running corelens against a live system.
         Data may be inconsistent, or corelens may crash.

====== MODULE ls ======
/:
        23 positive, 339 negative dentries

====== MODULE ls ======
/home/stepbren:
        115 positive, 375 negative dentries

====== corelens ======
drgn-tools 2.0.1+1.el9, drgn 0.0.30 (using Python 3.9.21, elfutils 0.191, with libkdumpfile), with CTF
Loaded CTF debuginfo in in 0.790s
Running module ls... completed in 0.002s
Running module ls... completed in 0.005s
corelens total runtime: 0.807s

Compared to the below, when it's just one module:

$ corelens /proc/kcore -M ls / -c
warning: Running corelens against a live system.
         Data may be inconsistent, or corelens may crash.
/:
        23 positive, 339 negative dentries

The version "2.0.1" is fake (we haven't released it yet), but it illustrates the idea. The version & release are separated by the + sign due to limitations in what Python allows for version names.

Orabug: 37503503

Currently we have an ad-hoc way of writing informative messages about
the corelens debuginfo type, and the runtime of the various modules. In
preparation for upcoming improvements, refactor it so we setup a single
info_msg() function that will do the right thing in any situation.

Orabug: 37503503
Signed-off-by: Stephen Brennan <[email protected]>
The "report mode" (-o) has historically been the best way to run several
modules at the same time, e.g. with -a or by selecting several manually.
When run in report mode, corelens prints extra metadata, such as the
debuginfo type, how long it took to load the debuginfo, and then the
runtime of each corelens module. When handling corelens bugs, this can
be quite useful.

Some users may prefer to run several modules, but keep all output on
stdout. This means we end up losing the informative messages, so we'd
like to add them in, even when printing to stdout.

But another key use of case corelens is running a single module. The
informative messages break up and muddle the module output, and they
also can be quite large compared to a few lines of module output.
They're not very useful in that case either.

To navigate this, we continue extending the CLI output behavior of
corelens when running multiple modules to stdout. We already use
print_header to insert divisions between modules on stdout. Let's also
add the ability to collect the informative messages into a single block
of text, and print them at the end, with the same header we use for
modules. This is just like how we print those informative messages to a
file named "corelens" in report-mode.

Orabug: 37503503
Signed-off-by: Stephen Brennan <[email protected]>
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jan 21, 2025
In addition to knowing the runtime & debuginfo type, it's useful to know
the various versions of drgn-tools, drgn, & python. Add a "-V" option
which will print the version, and also add this information to the
corelens info messages.

Orabug: 37503503
Signed-off-by: Stephen Brennan <[email protected]>
The result should be that we get version strings like "1.1.1+1.el9".
This will provide some implicit information about what OS corelens runs
on (if different from the kernel it analyzes). It will also provide
confirmation that an RPM installation was used, rather than some source
version of drgn-tools.

Orabug: 37503503
Signed-off-by: Stephen Brennan <[email protected]>
@brenns10 brenns10 force-pushed the version_in_corelens branch from 5b25483 to c9ad447 Compare February 3, 2025 22:13
@brenns10 brenns10 requested a review from biger410 February 3, 2025 23:12
@brenns10 brenns10 merged commit 90a3e35 into oracle-samples:main Feb 4, 2025
4 checks passed
@brenns10 brenns10 deleted the version_in_corelens branch February 4, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants