Debian Codegraph @

util/dtrace.sh

raw
1 #!/bin/sh
2
3 # Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4 #
5 # SPDX-License-Identifier: MPL-2.0
6 #
7 # This Source Code Form is subject to the terms of the Mozilla Public
8 # License, v. 2.0. If a copy of the MPL was not distributed with this
9 # file, you can obtain one at https://mozilla.org/MPL/2.0/.
10 #
11 # See the COPYRIGHT file distributed with this work for additional
12 # information regarding copyright ownership.
13
14 USAGE="# Usage: ${0} [-h | -G] -s File.d [-o <File>]"
15
16 mode=
17 while getopts hGs:o: opt; do
18 case "${opt}" in
19 h) mode=header ;;
20 s) input=$OPTARG ;;
21 o) output=$OPTARG ;;
22 G) mode=object ;;
23 \?)
24 echo $USAGE
25 exit 1
26 ;;
27 esac
28 done
29 shift $((OPTIND - 1))
30
31 if test -z "${mode}" || test -z "${input}"; then
32 echo $USAGE
33 exit 1
34 fi
35
36 case "${mode}" in
37 header)
38 if test -z "${output}"; then
39 output="$(basename "${input}" .d).h"
40 fi
41 PROVIDER=$(cat "${input}" | sed -ne 's/^provider \(.*\) {/\1/p' | tr "a-z" "A-Z")
42 sed -ne 's/.*probe \(.*\)(.*);/\1/p' "${input}" | tr "a-z" "A-Z" | while read PROBE; do
43 echo "#define ${PROVIDER}_${PROBE}_ENABLED() 0"
44 echo "#define ${PROVIDER}_${PROBE}(...)"
45 done >"${output}"
46 ;;
47 object)
48 if test -z "${output}"; then
49 output="$(basename "${input}" .d).o"
50 fi
51 echo "extern int empty;" | gcc -xc -c - -fPIC -DPIC -o "${output}"
52 ;;
53 esac