Skip to content

Commit 482a982

Browse files
authored
Miscellaneous Test Suite And Userland Core Support Changes (#324)
Contains the following changes: 1] New Crash Dump Directory Hierarchy Instead of unarchiving one reference dump at a time and testing it it is now possible to have multiple unpacked crash dumps at the same time and run the regression tests against both. Each dump is now automatically unpacked under `test/integration/data/dumps/<name>`. It is also possible now to generate regression output for multiple dumps at the same time. 2] Better support for automatically loading userland shared libs The `-s`/`load_debug_info()` functionality would only look for `.ko` files (e.g. kernel modules) given a directory. Now it can also automatically detect debug links and shared objects. 3] Self-Descriptive Regression Output All regression output files now contain the following appendix: ``` @#$ EXIT CODE $#@ <exit code number> ``` This makes it easier for us to not have to declare in the test suite code whether a test case is negative or positive. Simplifying our test code. 4] Test Infrastructure Refactor & Userland Support The test suite infrastructure code has been refactored to handle userland core dumps together with kernel crash dumps. Unfortuantely due to a bug in drgn we can't use a ztest core dump for regressions (even though sdb/drgn can handle a userland core dump just fine in the host system). I'll come up with a smaller userland core dump soon so we can test the userland version of stacks and work on the drgn bug when my free time allows.
1 parent 01017b0 commit 482a982

File tree

467 files changed

+1305
-408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

467 files changed

+1305
-408
lines changed

.github/scripts/clear-dump.sh

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,7 @@ if [ ! -d $DATA_DIR ]; then
77
exit 1
88
fi
99

10-
echo "removing current crash dump if any ..."
11-
rm -f $DATA_DIR/dump.*
12-
13-
echo "removing any extracted vmlinux ..."
14-
rm -f $DATA_DIR/vmlinux*
15-
16-
echo "removing any extracted modules ..."
17-
rm -rf $DATA_DIR/mods
18-
rm -rf $DATA_DIR/usr
19-
20-
echo "removing any savedump scripts ..."
21-
rm -rf $DATA_DIR/run-*.sh
10+
echo "removing all crash/core dumps ..."
11+
rm -rf $DATA_DIR/dumps
2212

2313
echo "Done"

.github/scripts/download-dump-from-s3.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,33 @@ else
4141
[ $? -eq 0 ] || exit 1
4242
fi
4343

44-
if [[ $1 == *.lzma ]]; then
44+
if [[ $1 == *.tar.lzma ]]; then
4545
# Profile A
46+
dump_name=${1%.tar.lzma}
4647

4748
echo "decompressing dump ..."
4849
tar -x --lzma -f $1
4950

50-
echo "moving contents to tests/integration/data ..."
51-
mv dump-data/* $DATA_DIR
51+
echo "moving contents to tests/integration/data/dumps/${dump_name} ..."
52+
mkdir -p $DATA_DIR/dumps/${dump_name}
53+
mv dump-data/* $DATA_DIR/dumps/${dump_name}
5254
[ $? -eq 0 ] || exit 1
5355

5456
rmdir dump-data
5557
[ $? -eq 0 ] || exit 1
5658
elif [[ $1 == *.tar.gz ]]; then
5759
# Profile B
60+
dump_name=${1%.tar.gz}
5861

5962
echo "decompressing dump ..."
6063
tar xzf $1
6164

62-
decompressed_dir=${1%.tar.gz}
63-
64-
echo "moving contents to tests/integration/data ..."
65-
mv *$decompressed_dir/* $DATA_DIR
65+
echo "moving contents to tests/integration/data/dumps/${dump_name} ..."
66+
mkdir -p $DATA_DIR/dumps/${dump_name}
67+
mv *${dump_name}/* $DATA_DIR/dumps/${dump_name}
6668
[ $? -eq 0 ] || exit 1
6769

68-
rmdir *$decompressed_dir
70+
rmdir *${dump_name}
6971
[ $? -eq 0 ] || exit 1
7072
else
7173
echo "unknown dump profile"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,6 @@ tests/integration/data/mods/
114114
# zipped folders - usually crash dumps
115115
*.lzma
116116
*.tar.gz
117+
118+
# crash dump directory
119+
tests/integration/data/dumps/

README.md

Lines changed: 3 additions & 21 deletions

sdb/internal/cli.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import argparse
2222
import os
23+
import re
2324
import sys
2425

2526
from typing import List
@@ -126,7 +127,8 @@ def parse_arguments() -> argparse.Namespace:
126127
return args
127128

128129

129-
def load_debug_info(prog: drgn.Program, dpaths: List[str]) -> None:
130+
def load_debug_info(prog: drgn.Program, dpaths: List[str], quiet: bool,
131+
no_filter: bool) -> None:
130132
"""
131133
Iterates over all the paths provided (`dpaths`) and attempts
132134
to load any debug information it finds. If the path provided
@@ -140,9 +142,28 @@ def load_debug_info(prog: drgn.Program, dpaths: List[str]) -> None:
140142
kos = []
141143
for (ppath, __, files) in os.walk(path):
142144
for i in files:
143-
if i.endswith(".ko"):
145+
if i.endswith(".ko") or i.endswith(".debug") or re.match(
146+
r".+\.so(\.\d)?", i) or no_filter:
147+
# matches:
148+
# kernel modules - .ko suffix
149+
# userland debug files - .debug suffix
150+
# userland shared objects - .so suffix
144151
kos.append(os.sep.join([ppath, i]))
145-
prog.load_debug_info(kos)
152+
try:
153+
prog.load_debug_info(kos)
154+
except drgn.MissingDebugInfoError as debug_info_err:
155+
#
156+
# If we encounter such an error it means that we can't
157+
# find the debug info for one or more kernel modules.
158+
# That's fine because the user may not need those, so
159+
# print a warning and proceed.
160+
#
161+
# Again because of the aforementioned short-coming of drgn
162+
# we quiet any errors when loading the *default debug info*
163+
# if we are looking at a crash/core dump.
164+
#
165+
if not quiet:
166+
print("sdb: " + str(debug_info_err), file=sys.stderr)
146167
else:
147168
print("sdb: " + path + " is not a regular file or directory")
148169

@@ -191,7 +212,7 @@ def setup_target(args: argparse.Namespace) -> drgn.Program:
191212

192213
if args.symbol_search:
193214
try:
194-
load_debug_info(prog, args.symbol_search)
215+
load_debug_info(prog, args.symbol_search, args.quiet, False)
195216
except (
196217
drgn.MissingDebugInfoError,
197218
OSError,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
sdb: addr: symbol not found: bogus
2+
@#$ EXIT CODE $#@
3+
1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
sdb: deref: cannot dereference function pointer
2+
@#$ EXIT CODE $#@
3+
1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
(volatile unsigned long)4294968498
2+
@#$ EXIT CODE $#@
3+
0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
sdb: deref: 'volatile unsigned long' is not a valid pointer type
2+
@#$ EXIT CODE $#@
3+
1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
(avl_tree_t *)spa_namespace_avl+0x0 = 0xffffffffc07d0fe0
2+
@#$ EXIT CODE $#@
3+
0

0 commit comments

Comments
 (0)