[PATCH 0/6] utilities: kernelscan - tool to scan for klog messages
Colin King
colin.king at canonical.com
Fri Nov 2 16:58:31 UTC 2012
From: Colin Ian King <colin.king at canonical.com>
As discussed at the Ubuntu Developer Summit this week we decided it would
be useful to be able to find if there are any new kernel log messages that
are ACPI or BIOS related that need to be added to the klog.json file.
To address this, I've written a very crude but simple kernel source parser
that will look for printk KERN_ERR and dev_err calls and will then check to
see if these match any of the strings or regular expressions in the klog.json
file.
This tool comes in two parts, a C parser and a wrapper script. The C parser
takes input from stdin and emits the results to stdout. The C parser has
two modes, the first is a simple CPP mode (used with the -E flag) and then
a C parser mode (used with the -P) flag. Typically one drives the tool as
follows:
cat kernelsource.c | ./kernelscan -E | gcc -E - | ./kernelscan -P
The resulting output is something like the following:
OK : printk(KERN_ERR "ACPI: Invalid _BCL data\n")
OK : printk(KERN_ERR "ACPI: Invalid _DDC data\n")
ADD: printk(KERN_ERR "can't allocate memory\n")
ADD: printk(KERN_ERR "ACPI: Invalid data\n")
ADD: printk(KERN_ERR "ACPI: Create sysfs link\n")
ADD: printk(KERN_ERR "ACPI: Create sysfs link\n")
ADD: printk(KERN_ERR "ACPI: Error installing notify handler\n")
OK : printk(KERN_ERR "ACPI: Invalid _DOD data in element %d\n", i)
OK : printk(KERN_ERR "ACPI: Failed to switch the brightness\n")
The lines prefixed with OK mean that the message is already in the
klog.json file. Lines prefixed with ADD: need to be added to the klog.json
file.
The tool handles literal string pasting, so lines that span multiple lines
or are constructed from macros get expaneded and pasted to make a coherent
message. It is not a full C parser, but it understands enough tokens to
seem to work for what we need.
Finally, this patch set includes a wrapper bash script to allow us to
easily drive this tool. Compile the kernelscan tool and then run from
the utiltities directory using:
./kernelscan.sh path-to-kernel-sources
e.g.
./kernelscan.sh /home/king/repos/linux
Currentl this bash script just parsers the ACPI driver but I hope
to expand this over time.
Colin Ian King (6):
utilities: kernelscan: Tool to scan kernel for error messages
utilities: kernelscan: tidy up the formatting of output messages.
utilities: kernelscan.sh: scan various directories for kernel error
messages
utlities: kernelscan: make some regex optimisations
utilities: kernelscan: fix comment that explains how to use this tool
utilities: kernelscan.sh - add execute flag to script
Makefile.am | 2 +-
configure.ac | 1 +
src/utilities/Makefile.am | 6 +
src/utilities/kernelscan.c | 985 +++++++++++++++++++++++++++++++++++++++++++
src/utilities/kernelscan.sh | 57 +++
5 files changed, 1050 insertions(+), 1 deletion(-)
create mode 100644 src/utilities/Makefile.am
create mode 100644 src/utilities/kernelscan.c
create mode 100755 src/utilities/kernelscan.sh
--
1.7.10.4
More information about the fwts-devel
mailing list