Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
f29e1de
crash.types.task: improve task flag handling
jeffmahoney Apr 29, 2019
86422cb
crash.commands.ps: add support for TASK_IDLE
jeffmahoney Apr 29, 2019
68f6630
crash.commands.help: sort commands in help output
jeffmahoney Sep 19, 2018
4fb4c3a
crash.util: add struct_has_member
jeffmahoney Apr 29, 2019
7fe8aa7
crash.types.task: handle anonymous sub-structure in mm_struct
jeffmahoney Apr 29, 2019
b8de0ab
crash.util: add uuid decoding
jeffmahoney May 1, 2019
e75bc23
crash.util: add decode_flags helper
jeffmahoney Apr 26, 2019
81cb971
crash.types.{,k}list: use the type from the symbol when available
jeffmahoney Sep 19, 2018
736fdf7
crash.types.list: add list_empty
jeffmahoney Apr 26, 2019
df92870
crash.types.list: fix cycle tests
jeffmahoney Apr 22, 2019
87aec81
tests: clear file during test teardown
jeffmahoney Apr 22, 2019
ff7ef81
crash.kernel: convert setup to use DelayedSymvals
jeffmahoney Apr 22, 2019
a132e76
crash.arch: add baseline ppc64 support
jeffmahoney Apr 22, 2019
bbe3d6f
crash.types.bitmap: add find first/last/next helpers
jeffmahoney Apr 22, 2019
527e044
crash: use new gdb.Target to create standalone target
jeffmahoney Apr 22, 2019
afdd5b2
crash.types.module: create module for modules
jeffmahoney May 7, 2019
96be843
kdump.target: don't specify offset for .data..percpu
jeffmahoney May 1, 2019
fa71477
crash.types.percpu: handle missing pcpu_nr_slots
jeffmahoney May 6, 2019
c6ec4bc
crash.types.percpu: get_percpu_var, raise exception with passed val
jeffmahoney May 1, 2019
7502b34
crash.types.cpu: fix online cpu mask and add possible cpu mask
jeffmahoney May 7, 2019
36a58b8
crash.types.percpu: better percpu handling
jeffmahoney Apr 22, 2019
118bbfe
crash.types.percpu: separate the all-cpus and single-cpu cases
jeffmahoney May 21, 2019
7b38ed4
crash.types.percpu: add percpu_counter_sum
jeffmahoney Apr 30, 2019
a515eef
crash: auto-select crashing task and print backtrace on startup
jeffmahoney Apr 22, 2019
f6feb54
crash.sh: use $TMPDIR for gdbinit in --gdb mode
jeffmahoney May 1, 2019
fe1c40e
crash.kernel: use new KernelError exception to report errors during s…
jeffmahoney May 1, 2019
18707a4
crash.kernel: add debug option to load_modules
jeffmahoney May 1, 2019
823e505
crash.kernel: use objfile.has_symbols() to detect debuginfo
jeffmahoney May 1, 2019
58b7c35
crash.util: promote to be its own sub-package
jeffmahoney May 3, 2019
4175429
crash: add static percpu regions for modules
jeffmahoney May 1, 2019
40352e2
crash.kernel: handle failure to add module symbols
jeffmahoney May 1, 2019
9a86bc6
crash.kernel: improve and document debuginfo and module loading
jeffmahoney May 1, 2019
95b3d0d
crash.kernel: check module version on load
jeffmahoney Apr 26, 2019
917c3a9
crash.commands.task: allow 'task' command with no argument to show cu…
jeffmahoney May 2, 2019
a18e2b7
crash.infra.callbacks: explicitly connect to callbacks
jeffmahoney May 17, 2019
e0fa23e
crash.infra.lookup: move type name resolution into TypeCallback
jeffmahoney May 3, 2019
5dee123
crash.util.symbols: introduce simplified delayed lookups
jeffmahoney May 3, 2019
cc56e25
crash.subsystem.filesystem: add super_flags
jeffmahoney Apr 26, 2019
5f69e54
crash.subsystem.filesystem: add for_each_super_block, get_super_block
jeffmahoney Sep 18, 2018
7d72016
crash.subsystem.filesystem.mount: use type from symbol when available
jeffmahoney Sep 19, 2018
b4facc0
crash.subsystem.filesystem.mount: use crash.util.decode_flags
jeffmahoney May 4, 2019
b2817c9
crash.subsystem.filesystem: include sector number when describing dio…
jeffmahoney May 1, 2019
b7085be
crash.subsystem.{filesystem,storage}: refactor bio decoders
jeffmahoney May 3, 2019
c27620b
crash.types.vmstat: remove dead code
jeffmahoney May 6, 2019
fcb22c4
crash: remove CrashBaseClass
jeffmahoney May 3, 2019
30dd42b
crash.util: add more documentation
jeffmahoney May 20, 2019
65a7e06
crash: factor out task iteration
jeffmahoney May 7, 2019
abfd2dc
crash.commands: handle DelayedAttributeError gracefully
jeffmahoney May 8, 2019
62bb502
crash.commands.dmesg: handling dictionary string encoding better
jeffmahoney May 8, 2019
e7ff8dd
crash.types.slab: improve address printing
jeffmahoney May 9, 2019
6da88b1
crash.commands.kmem: use exceptions to exit command with error
jeffmahoney May 9, 2019
29ea504
crash.commands.kmem: fix argument parsing
jeffmahoney May 9, 2019
f2142e5
crash.commands.kmem: clean up some trivial things
jeffmahoney May 9, 2019
08749dd
crash.commands.ps: uncomment -G mode
jeffmahoney May 10, 2019
004ad94
crash: add kernel testing against vmcores
jeffmahoney May 7, 2019
cfac8fb
crash.types.classdev: update classdev iteration to use device_private
jeffmahoney May 7, 2019
39131e1
crash.subsystem.filesystems: add is_fstype_super and is_fstype_inode
jeffmahoney May 9, 2019
bfd2628
crash.subsystem.filesystem: document gdb.NotAvailableError
jeffmahoney May 15, 2019
c5691bf
crash.subsytem.filesystem.mount: add API documentation
jeffmahoney May 9, 2019
4e60c1c
crash.subsystem.filesystem.btrfs: add helpers for super, inode, and u…
jeffmahoney Apr 29, 2019
7e077de
crash.commands.btrfs: add basic btrfs command
jeffmahoney Sep 18, 2018
575d1ef
crash.subsystem.filesystem.xfs: Add basic XFS infra
jeffmahoney Sep 18, 2018
1522012
crash.commands.xfs: add basic xfs command
jeffmahoney Sep 18, 2018
5483d9f
crash.subsystem.storage.blocksq: add per-queue requests_in_flight call
jeffmahoney Apr 22, 2019
538acd1
crash.commands.lsmod: add basic lsmod command
jeffmahoney May 1, 2019
e7789d4
crash.types.task: get_stack_pointer should take thread_struct
jeffmahoney May 15, 2019
1d22d73
crash.types.task: add accessor-helpers
jeffmahoney May 15, 2019
af12734
crash.commands.ps: factor out formatting
jeffmahoney May 15, 2019
550c337
crash.cache.syscache: update config parsing
jeffmahoney May 9, 2019
d04844b
tests: silence as much noise as possible
jeffmahoney May 17, 2019
cb870bb
crash.util: fix get_typed_pointer semantics
jeffmahoney May 20, 2019
0f70ab1
crash.types.task: add documentation and static typing hints
jeffmahoney May 20, 2019
d6bc98b
crash: more documentation and typing
jeffmahoney May 21, 2019
2834470
WIP: Add initial support for "live" debugging
May 9, 2019
14529d1
WIP: Add new "kcore" target using "drgn" backend
sdimitro May 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions 19 INTERNALS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# GDB

## Python contexts within GDB

Each time gdb enters the Python interpreter it establishes a context.
Part of the context includes what architecture gdb believes it is
debugging ('gdbarch') and that is passed into the context. If anything
changes the gdbarch in that Python context, it won't be visible to any
subsequent Python code until a new session is established.

When gdb starts up on x86_64, it uses a gdbarch of i386 -- with 32-bit words
and pointers. Only when we load an executable or target does it switch
to i386:x86_64.

The effect of this is that any code that relys on type information *must*
be executed in a separate context from the one that loaded the executable
and/or taret. Otherwise, any built-in types that are pointers or `long`
based will use the 32-bit sizes.
61 changes: 61 additions & 0 deletions 61 TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Testing

## Summary

There are unit tests in the tests/ dir that are standalone and useful for
testing basic functionality.

There are unit tests in the kernel-tests dir that require configuration,
kernel images, debuginfo, and vmcores to use.

## Configuration

The configuration for each kernel/vmcore to be tested goes in a .ini file
with the following format. All fields except kernel and vmcore are
optional, and defaults will be used. A kernel missing debuginfo cannot
be used for testing. Missing modules will mean module-specific tests
will be skipped.

```[test]
kernel=/path/to/kernel
vmcore=/path/to/vmcore
vmlinux_debuginfo=/path/to/vmlinux-debuginfo
modules=/path/to/modules
module_debuginfo_path=/path/to/module/debuginfo
root=/root/for/tree/searches```

The optional fields match those defined in crash.kernel.CrashKernel.

Example 1:
```[test]
kernel=/var/crash/2019-04-23-11:35/vmlinux-4.12.14-150.14-default.gz
vmcore=/var/crash/2019-04-23-11:35/vmcore```

In this example, the kernel and debuginfo packages are installed in the
default locations and will be searched automatically.

Example 2:
```[test]
kernel=/var/crash/2019-04-23-11:35/vmlinux-4.12.14-150.14-default.gz
vmcore=/var/crash/2019-04-23-11:35/vmcore
root=/var/cache/crash-setup/leap15/4.12.14-150.14-default
```

In this example, the kernel and debuginfo packages are installed under
/var/cache/crash-setup/leap15/4.12.14-150.14-default and so we only
specify a root directory.

## Running

The script `test-all.sh` when run with no options will execute only
the standalone tests. The script takes a list of the .ini files
described above and will execute the kernel tests against those
configurations immediately after the standalone tests.

Example:
```sh test-all.sh kernel-test-configs/4.12.14-150.14-default.ini kernel-test-configs/5.1.0-rc7-vanilla.ini```
or
```sh test-all.sh kernel-test-configs/*.ini```

Each configuration will execute independently from one another.

54 changes: 54 additions & 0 deletions 54 crash-kcore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

if [[ "$EUID" -ne "0" ]]; then
echo "ERROR: Must be run as root." >&2
exit 1
fi

for gdb in crash-python-gdb gdb; do
if $gdb -v >/dev/null 2>/dev/null; then
GDB=$gdb
break
fi
done

if [[ -z "$GDB" ]]; then
echo "ERROR: gdb is not available." >&2
exit 1
fi

GDBINIT=$(mktemp)
trap "rm '$GDBINIT'" EXIT

VMLINUX="/usr/lib/debug/boot/vmlinux-$(uname -r)"

DIR="$(dirname $0)"
if [[ -e "$DIR/setup.py" ]]; then
pushd $DIR >/dev/null
rm -rf build/lib/crash
python3 setup.py build >/dev/null
echo "python sys.path.insert(0, '$DIR/build/lib')" >>"$GDBINIT"
popd >/dev/null
fi

cat <<EOF >>"$GDBINIT"
set python print-stack full
set height 0
set print pretty on

python
from kcore.target import Target
target = Target("$VMLINUX", debug=False)
end

target drgn /proc/kcore

python
import crash.session
x = crash.session.Session(None, None, None)
target.unregister()
del target
end
EOF

$GDB -nh -q -x "$GDBINIT"
156 changes: 129 additions & 27 deletions 156 crash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,98 @@

usage() {
cat <<END >&2
usage: $(basename $0) [-d|--search-dir <debuginfo/module dir>] <vmlinux> <vmcore>
usage: $(basename $0) [options] <vmlinux> <vmcore>

Debugging options:
--gdb Run the embedded gdb underneath a separate gdb instance.
This is useful for debugging issues in gdb that are seen
while running crash-python.
--valgrind Run the embedded gdb underneath valgrind.
This is useful for debugging memory leaks in gdb patches.
--nofiles Start up without loading any object files.
This is useful for testing delayed lookup error handling.
Options:
-r <dir> | --root <dir>
Use the specified directory as the root for all file searches. When
using properly configured .build-id symbolic links, this is the
best method to use as the debuginfo will be loaded automatically via
gdb without searching for filenames.

-m <dir> | --modules <dir>
Use the specified directory to search for modules

-d <dir> | --modules-debuginfo <dir>
Use the specified directory to search for module debuginfo

-D <dir> | --vmlinux-debuginfo <dir>
Use the specified directory to search for vmlinux debuginfo

-b <dir> | --build-dir <dir>
Use the specified directory as the root for all file searches. This
directory should be the root of a built kernel source tree. This is
shorthand for "-r <dir> -m . -d . -D ." and will override preceding
options.

Debugging options:
--debug
Enable noisy output for debugging the debugger
-v | --verbose
Enable verbose output for debugging the debugger
--gdb
Run the embedded gdb underneath a separate gdb instance. This is useful
for debugging issues in gdb that are seen while running crash-python.
--valgrind
Run the embedded gdb underneath valgrind. This is useful
for debugging memory leaks in gdb patches.
END
exit 1
}

TEMP=$(getopt -o 'd:h' --long 'search-dir:,gdb,valgrind,nofiles,help' -n "$(basename $0)" -- "$@")
TEMP=$(getopt -o 'vr:d:m:D:b:h' --long 'verbose,root:,modules-debuginfo:,modules:,vmlinux-debuginfo:,build-dir:,debug,gdb,valgrind,help' -n "$(basename $0)" -- "$@")

if [ $? -ne 0 ]; then
echo "Terminating." >&2
exit 1
usage
fi

eval set -- "$TEMP"
unset TEMP

VERBOSE=False
DEBUG=False

while true; do
case "$1" in
'-d'|'--search-dir')
SEARCHDIRS="$SEARCHDIRS $2"
'-r'|'--root')
SEARCH_DIRS="$SEARCH_DIRS $2"
shift 2
continue
;;
'-m'|'--modules')
MODULES="$MODULES $2"
shift 2
continue
;;
'-d'|'--modules-debuginfo')
MODULES_DEBUGINFO="$MODULES_DEBUGINFO $2"
shift 2
continue
;;
'-D'|'--vmlinux-debuginfo')
VMLINUX_DEBUGINFO="$VMLINUX_DEBUGINFO $2"
shift 2
continue
;;
'-b'|'--build-dir')
SEARCH_DIRS="$2"
VMLINUX_DEBUGINFO="."
MODULES="."
MODULES_DEBUGINFO="."
shift 2
continue
;;
'-v'|'--verbose')
VERBOSE="True"
shift
continue
;;
'--debug')
DEBUG="True"
shift
continue
;;

'--gdb')
DEBUGMODE=gdb
shift
Expand All @@ -45,11 +105,6 @@ while true; do
shift
continue
;;
'--nofiles')
NOFILES=yes
shift
continue
;;
'-h'|'--help')
usage ;;
'--')
Expand All @@ -63,7 +118,7 @@ while true; do
esac
done

if [ "$#" -ne 2 -a -z "$NOFILES" ]; then
if [ "$#" -ne 2 ]; then
usage
fi

Expand Down Expand Up @@ -111,26 +166,70 @@ else
fi

VMCORE=$2
for path in $SEARCH_DIRS; do
if test -n "$DFD"; then
DFD="$DFD:$path"
else
DFD="$path"
fi
done
cat << EOF >> $GDBINIT
set debug-file-directory $DFD:/usr/lib/debug
set build-id-verbose 0
set python print-stack full
set prompt py-crash>
set height 0
set print pretty on

file "$KERNEL"

python
from kdump.target import Target
target = Target(debug=False)
end

target kdumpfile $VMCORE

python
import sys
import traceback
try:
import crash.session
from crash.kernel import CrashKernel
except RuntimeError as e:
print("crash-python: {}, exiting".format(str(e)), file=sys.stderr)
traceback.print_exc()
sys.exit(1)
path = "$SEARCHDIRS".split(' ')

roots = None
module_path = None
module_debuginfo_path = None
vmlinux_debuginfo = None
verbose=$VERBOSE
debug=$DEBUG

s = "$SEARCH_DIRS"
if len(s) > 0:
roots = s.split(" ")

s = "$VMLINUX_DEBUGINFO"
if len(s) > 0:
vmlinux_debuginfo = s.split(" ")

s = "$MODULES"
if len(s) > 0:
module_path = s.split(" ")

s = "$MODULES_DEBUGINFO"
if len(s) > 0:
module_debuginfo_path = s.split(" ")

try:
x = crash.session.Session("$KERNEL", "$VMCORE", "$ZKERNEL", path)
print("The 'pyhelp' command will list the command extensions.")
kernel = CrashKernel(roots, vmlinux_debuginfo, module_path,
module_debuginfo_path, verbose, debug)

x = crash.session.Session(kernel, verbose=verbose, debug=debug)
print("The 'pyhelp' command will list the command extensions.")
except gdb.error as e:
print("crash-python: {}, exiting".format(str(e)), file=sys.stderr)
traceback.print_exc()
Expand All @@ -140,16 +239,19 @@ except RuntimeError as e:
file=sys.stderr)
traceback.print_exc()
sys.exit(1)

target.unregister()
del target
EOF

# This is how we debug gdb problems when running crash
if [ "$DEBUGMODE" = "gdb" ]; then
RUN="run -nh -q -x $GDBINIT"
RUN="run -nx -q -x $GDBINIT"

echo $RUN > /tmp/gdbinit
gdb $GDB -nh -q -x /tmp/gdbinit
echo $RUN > $TMPDIR/gdbinit-debug
gdb $GDB -nx -q -x $TMPDIR/gdbinit-debug
elif [ "$DEBUGMODE" = "valgrind" ]; then
valgrind --keep-stacktraces=alloc-and-free $GDB -nh -q -x $GDBINIT
else
$GDB -nh -q -x $GDBINIT
$GDB -nx -q -x $GDBINIT
fi
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.