08 Aug, 2020

4 commits

  • Add option decode_stacktrace -r to specify only release name.
    This is enough to guess standard paths to vmlinux and modules:

    $ echo -e 'schedule+0x0/0x0
    tap_open+0x0/0x0 [tap]' |
    ./scripts/decode_stacktrace.sh -r 5.4.0-37-generic
    schedule (kernel/sched/core.c:4138)
    tap_open (drivers/net/tap.c:502) tap

    Signed-off-by: Konstantin Khlebnikov
    Signed-off-by: Andrew Morton
    Cc: Sasha Levin
    Link: http://lkml.kernel.org/r/159282923334.248444.2399153100007347838.stgit@buzz
    Signed-off-by: Linus Torvalds

    Konstantin Khlebnikov
     
  • Try to find module in directory with vmlinux (for fresh build). Then try
    standard paths where debuginfo are usually placed. Pick first file which
    have elf section '.debug_line'.

    Before:

    $ echo 'tap_open+0x0/0x0 [tap]' |
    ./scripts/decode_stacktrace.sh /usr/lib/debug/boot/vmlinux-5.4.0-37-generic
    WARNING! Modules path isn't set, but is needed to parse this symbol
    tap_open+0x0/0x0 tap

    After:

    $ echo 'tap_open+0x0/0x0 [tap]' |
    ./scripts/decode_stacktrace.sh /usr/lib/debug/boot/vmlinux-5.4.0-37-generic
    tap_open (drivers/net/tap.c:502) tap

    Signed-off-by: Konstantin Khlebnikov
    Signed-off-by: Andrew Morton
    Cc: Sasha Levin
    Link: http://lkml.kernel.org/r/159282923068.248444.5461337458421616083.stgit@buzz
    Signed-off-by: Linus Torvalds

    Konstantin Khlebnikov
     
  • Guess path to kernel sources using known location of symbol "kernel_init".
    Make basepath argument optional.

    Before:

    $ echo 'vfs_open+0x0/0x0' | ./scripts/decode_stacktrace.sh vmlinux ""
    vfs_open (home/khlebnikov/src/linux/fs/open.c:912)

    After:

    $ echo 'vfs_open+0x0/0x0' | ./scripts/decode_stacktrace.sh vmlinux
    vfs_open (fs/open.c:912)

    Signed-off-by: Konstantin Khlebnikov
    Signed-off-by: Andrew Morton
    Cc: Sasha Levin
    Link: http://lkml.kernel.org/r/159282922803.248444.2379229451667913634.stgit@buzz
    Signed-off-by: Linus Torvalds

    Konstantin Khlebnikov
     
  • For now script turns missing symbols into '0' and make bogus decode. Skip
    them instead. Also simplify parsing output of 'nm'.

    Before:

    $ echo 'xxx+0x0/0x0' | ./scripts/decode_stacktrace.sh vmlinux ""
    xxx (home/khlebnikov/src/linux/./arch/x86/include/asm/processor.h:398)

    After:

    $ echo 'xxx+0x0/0x0' | ./scripts/decode_stacktrace.sh vmlinux ""
    xxx+0x0/0x0

    Signed-off-by: Konstantin Khlebnikov
    Signed-off-by: Andrew Morton
    Cc: Sasha Levin
    Link: http://lkml.kernel.org/r/159282922499.248444.4883465570858385250.stgit@buzz
    Signed-off-by: Linus Torvalds

    Konstantin Khlebnikov
     

25 Jul, 2020

1 commit

  • Currently the basepath is removed only from the beginning of the string.
    When the symbol is inlined and there's multiple line outputs of
    addr2line, only the first line would have basepath removed.

    Change to remove the basepath prefix from all lines.

    Fixes: 31013836a71e ("scripts/decode_stacktrace: match basepath using shell prefix operator, not regex")
    Co-developed-by: Shik Chen
    Signed-off-by: Pi-Hsun Shih
    Signed-off-by: Shik Chen
    Signed-off-by: Andrew Morton
    Reviewed-by: Stephen Boyd
    Cc: Sasha Levin
    Cc: Nicolas Boichat
    Cc: Jiri Slaby
    Link: http://lkml.kernel.org/r/20200720082709.252805-1-pihsun@chromium.org
    Signed-off-by: Linus Torvalds

    Pi-Hsun Shih
     

16 Jun, 2020

1 commit

  • When a user tries to parse a symbol located inside a module he must have
    modpath set. Otherwise, decode_stacktrace won't be able to parse the
    symbol correctly.

    Right now the failure is silent and easily missed by the user. What's
    worse is that by the time the user realizes what happened (or someone on
    LKML asks him to add the modpath and re-run), he might have already got
    rid of the vmlinux/modules.

    Signed-off-by: Sasha Levin
    Signed-off-by: Linus Torvalds

    Sasha Levin
     

13 Jul, 2019

3 commits

  • The manpage for modprobe mentions that dashes and underscores are
    treated interchangeably in module names. The stack trace dumps seem to
    print module names with underscores. Use bash to replace _ with the
    pattern [-_] so that file names with dashes or underscores can be found.

    For example, this line:
    [ 27.919759] hda_widget_sysfs_init+0x2b8/0x3a5 [snd_hda_core]

    should find a module named snd-hda-core.ko.

    Link: http://lkml.kernel.org/r/20190531205926.42474-1-evgreen@chromium.org
    Signed-off-by: Evan Green
    Reviewed-by: Douglas Anderson
    Acked-by: Konstantin Khlebnikov
    Cc: Stephen Rothwell
    Cc: Douglas Anderson
    Cc: Evan Green
    Cc: Nicolas Boichat
    Cc: Marc Zyngier
    Cc: Manuel Traut
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Evan Green
     
  • In Chromium OS kernel builds, we split the debug information as .ko.debug
    files, and that's what decode_stacktrace.sh needs to use.

    Relax objfile matching rule to allow any .ko* file to be matched.

    [drinkcat@chromium.org: add quotes around name pattern]
    Link: http://lkml.kernel.org/r/20190528103346.42720-1-drinkcat@chromium.org
    Link: http://lkml.kernel.org/r/20190521234148.64060-1-drinkcat@chromium.org
    Signed-off-by: Nicolas Boichat
    Cc: Marc Zyngier
    Cc: Konstantin Khlebnikov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nicolas Boichat
     
  • The basepath may contain special characters, which would confuse the regex
    matcher. ${var#prefix} does the right thing.

    Link: http://lkml.kernel.org/r/20190518055946.181563-1-drinkcat@chromium.org
    Fixes: 67a28de47faa8358 ("scripts/decode_stacktrace: only strip base path when a prefix of the path")
    Signed-off-by: Nicolas Boichat
    Reviewed-by: Stephen Boyd
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nicolas Boichat
     

14 Jun, 2019

1 commit

  • At least for ARM64 kernels compiled with the crosstoolchain from
    Debian/stretch or with the toolchain from kernel.org the line number is
    not decoded correctly by 'decode_stacktrace.sh':

    $ echo "[ 136.513051] f1+0x0/0xc [kcrash]" | \
    CROSS_COMPILE=/opt/gcc-8.1.0-nolibc/aarch64-linux/bin/aarch64-linux- \
    ./scripts/decode_stacktrace.sh /scratch/linux-arm64/vmlinux \
    /scratch/linux-arm64 \
    /nfs/debian/lib/modules/4.20.0-devel
    [ 136.513051] f1 (/linux/drivers/staging/kcrash/kcrash.c:68) kcrash

    If addr2line from the toolchain is used the decoded line number is correct:

    [ 136.513051] f1 (/linux/drivers/staging/kcrash/kcrash.c:57) kcrash

    Link: http://lkml.kernel.org/r/20190527083425.3763-1-manut@linutronix.de
    Signed-off-by: Manuel Traut
    Acked-by: Konstantin Khlebnikov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manuel Traut
     

06 Mar, 2019

1 commit


29 Dec, 2018

1 commit

  • Running something like:

    decodecode vmlinux .

    leads to interested results where not only the leading "." gets stripped
    from the displayed paths, but also anywhere in the string, displaying
    something like:

    kvm_vcpu_check_block (arch/arm64/kvm/virt/kvm/kvm_mainc:2141)

    which doesn't help further processing.

    Fix it by only stripping the base path if it is a prefix of the path.

    Link: http://lkml.kernel.org/r/20181210174659.31054-3-marc.zyngier@arm.com
    Signed-off-by: Marc Zyngier
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Marc Zyngier
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

29 Nov, 2016

1 commit

  • Kirill reported that the decode_stacktrace.sh script was broken by the
    following commit:

    bb5e5ce545f2 ("x86/dumpstack: Remove kernel text addresses from stack dump")

    Fix it by updating the per-line absolute address check to also check for
    function-based address lines like the following:

    write_sysrq_trigger+0x51/0x60

    I didn't remove the check for absolute addresses because it's still
    needed for ARM.

    Reported-by: Kirill A. Shutemov
    Tested-by: Kirill A. Shutemov
    Signed-off-by: Josh Poimboeuf
    Cc: Konstantin Khlebnikov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Sasha Levin
    Cc: Thomas Gleixner
    Fixes: bb5e5ce545f2 ("x86/dumpstack: Remove kernel text addresses from stack dump")
    Link: http://lkml.kernel.org/r/20161128230635.4n2ofgawltgexgcg@treble
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

20 May, 2016

1 commit

  • scripts/decode_stacktrace.sh presently displays module symbols as

    func+0x0ff/0x5153 [module]

    Add a third argument: the pathname of a directory where the script
    should look for the file module.ko so that the output appears as

    func (foo/bar.c:123) module

    Without the argument or if the module file isn't found the script prints
    such symbols as is without decoding.

    Signed-off-by: Konstantin Khlebnikov
    Cc: Sasha Levin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Konstantin Khlebnikov
     

05 Sep, 2015

1 commit

  • Fix the stack decoder for the ARM architecture.
    An ARM stack is designed as :

    [ 81.547704] [] (bucket_find_contain) from [] (check_sync+0x40/0x4f8)
    [ 81.559668] [] (check_sync) from [] (debug_dma_sync_sg_for_cpu+0x128/0x194)
    [ 81.571583] [] (debug_dma_sync_sg_for_cpu) from [] (__videobuf_s

    The current script doesn't expect the symbols to be bound by
    parenthesis, and triggers the following errors :

    awk: cmd. line:1: error: Unmatched ( or \(: / (check_sync$/
    [ 81.547704] (bucket_find_contain) from (check_sync+0x40/0x4f8)

    Fix it by chopping starting and ending parenthesis from the each symbol
    name.

    As a side note, this probably comes from the function
    dump_backtrace_entry(), which is implemented differently for each
    architecture. That makes a single decoding script a bit a challenge.

    Signed-off-by: Robert Jarzmik
    Cc: Sasha Levin
    Cc: Russell King
    Cc: Michal Marek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robert Jarzmik
     

11 Jun, 2014

1 commit

  • Right now when people try to report issues in the kernel they send stack
    dumps to eachother, which looks something like this:

    [ 6.906437] [] ? backtrace_test_irq_callback+0x20/0x20
    [ 6.907121] [] dump_stack+0x52/0x7f
    [ 6.907640] [] backtrace_regression_test+0x38/0x110
    [ 6.908281] [] ? proc_create_data+0xa0/0xd0
    [ 6.908870] [] ? proc_modules_init+0x22/0x22
    [ 6.909480] [] do_one_initcall+0xc2/0x1e0
    [...]

    However, most of the text you get is pure garbage.

    The only useful thing above is the function name. Due to the amount of
    different kernel code versions and various configurations being used,
    the kernel address and the offset into the function are not really
    helpful in determining where the problem actually occured.

    Too often the result of someone looking at a stack dump is asking the
    person who sent it for a translation for one or more 'addr2line'
    translations. Which slows down the entire process of debugging the
    issue (and really annoying).

    The decode_stacktrace script is an attempt to make the output more
    useful and easy to work with by translating all kernel addresses in the
    stack dump into line numbers. Which means that the stack dump would
    look like this:

    [ 635.148361] dump_stack (lib/dump_stack.c:52)
    [ 635.149127] warn_slowpath_common (kernel/panic.c:418)
    [ 635.150214] warn_slowpath_null (kernel/panic.c:453)
    [ 635.151031] _oalloc_pages_slowpath+0x6a/0x7d0
    [ 635.152171] ? zone_watermark_ok (mm/page_alloc.c:1728)
    [ 635.152988] ? get_page_from_freelist (mm/page_alloc.c:1939)
    [ 635.154766] __alloc_pages_nodemask (mm/page_alloc.c:2766)

    It's pretty obvious why this is better than the previous stack dump
    before.

    Usage is pretty simple:

    ./decode_stacktrace.sh [vmlinux] [base path]

    Where vmlinux is the vmlinux to extract line numbers from and base path
    is the path that points to the root of the build tree, for example:

    ./decode_stacktrace.sh vmlinux /home/sasha/linux/ < input.log > output.log

    The stack trace should be piped through it (I, for example, just pipe
    the output of the serial console of my KVM test box through it).

    Signed-off-by: Sasha Levin
    Signed-off-by: Linus Torvalds

    Sasha Levin