Fix syscall generator scripts
[lttng-modules.git] / tools / syscalls / lttng-syscalls-extract.sh
CommitLineData
9143c6d5 1#!/bin/bash
b7cdc182 2# SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
9143c6d5
MJ
3
4set -eu
5
6outfile="${1:-}"
7
b03cf820 8if [ "$outfile" = "" ]; then
9143c6d5
MJ
9 echo "Specify an output file as first argument, it will be overwritten."
10 exit 1
11fi
12
9143c6d5
MJ
13# Generate a random string to use as an identifier
14ident=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 8 | head -n1)
15
b03cf820
MJ
16cd ../.. || exit 1
17make syscalls_extractor
18
19sudo insmod ./src/lttng-wrapper.ko
20sudo insmod ./src/lttng-syscalls-extractor.ko ident="$ident" || true
21sudo rmmod lttng-wrapper
22
23cd - || exit 1
9143c6d5
MJ
24
25sudo dmesg | sed -n -e 's/\(\[.*\] \)\?'"$ident"'//p' > "$outfile"
26
27# Make sure we have both the start and end markers
28if grep -q -- '---START---' "$outfile"; then
29 sed -i '/^---START---/d' "$outfile"
30else
31 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."
32 exit 1
33fi
34
35if grep -q -- '---END---' "$outfile"; then
36 sed -i '/^---END---/d' "$outfile"
37else
38 echo "Error: End marker missing from dmesg output, something went wrong."
39 exit 1
40fi
This page took 0.039845 seconds and 4 git commands to generate.