Commit | Line | Data |
---|---|---|
9143c6d5 | 1 | #!/bin/bash |
b7cdc182 | 2 | # SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
61baff6e | 3 | # SPDX-FileCopyrightText: 2020 EfficiOS Inc. |
9143c6d5 MJ |
4 | |
5 | set -eu | |
6 | ||
7 | outfile="${1:-}" | |
8 | ||
b03cf820 | 9 | if [ "$outfile" = "" ]; then |
9143c6d5 MJ |
10 | echo "Specify an output file as first argument, it will be overwritten." |
11 | exit 1 | |
12 | fi | |
13 | ||
9143c6d5 MJ |
14 | # Generate a random string to use as an identifier |
15 | ident=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 8 | head -n1) | |
16 | ||
b03cf820 MJ |
17 | cd ../.. || exit 1 |
18 | make syscalls_extractor | |
19 | ||
20 | sudo insmod ./src/lttng-wrapper.ko | |
21 | sudo insmod ./src/lttng-syscalls-extractor.ko ident="$ident" || true | |
22 | sudo rmmod lttng-wrapper | |
23 | ||
24 | cd - || exit 1 | |
9143c6d5 MJ |
25 | |
26 | sudo dmesg | sed -n -e 's/\(\[.*\] \)\?'"$ident"'//p' > "$outfile" | |
27 | ||
28 | # Make sure we have both the start and end markers | |
29 | if grep -q -- '---START---' "$outfile"; then | |
30 | sed -i '/^---START---/d' "$outfile" | |
31 | else | |
32 | echo "Error: Start marker missing from dmesg output, your kernel log buffer is probably too small, set CONFIG_LOG_BUF_SHIFT to a bigger value." | |
33 | exit 1 | |
34 | fi | |
35 | ||
36 | if grep -q -- '---END---' "$outfile"; then | |
37 | sed -i '/^---END---/d' "$outfile" | |
38 | else | |
39 | echo "Error: End marker missing from dmesg output, something went wrong." | |
40 | exit 1 | |
41 | fi |