xref: /aosp_15_r20/external/libtraceevent/check-manpages.sh (revision 436bf2bcd5202612ffffe471bbcc1f277cc8d28e)
1#!/bin/bash
2# SPDX-License-Identifier: LGPL-2.1
3# Copyright (C) 2022, Google Inc, Steven Rostedt <[email protected]>
4#
5# This checks if any function is listed in a man page that is not listed
6# in the main man page.
7
8if [ $# -lt 1 ]; then
9	echo "usage: check-manpages man-page-path"
10	exit 1
11fi
12
13cd $1
14
15MAIN=libtraceevent
16MAIN_FILE=${MAIN}.txt
17
18PROCESSED=""
19
20# Ignore man pages that do not contain functions
21IGNORE=""
22
23for man in ${MAIN}-*.txt; do
24
25	for a in `sed -ne '/^NAME/,/^SYNOP/{/^[a-z]/{s/, *$//;s/,/\n/g;s/ //g;s/-.*$/-/;/-/{s/-//p;q};p}}' $man`; do
26		if [ "${PROCESSED/:${a} /}" != "${PROCESSED}" ]; then
27			P="${PROCESSED/:${a} */}"
28			echo "Found ${a} in ${man} and in ${P/* /}"
29		fi
30		PROCESSED="${man}:${a} ${PROCESSED}"
31		if [ "${IGNORE/$man/}" != "${IGNORE}" ]; then
32			continue
33		fi
34		if ! grep -q '\*'${a}'\*' $MAIN_FILE; then
35			if [ "$last" == "" ]; then
36				echo
37			fi
38			if [ "$last" != "$man" ]; then
39				echo "Missing functions from $MAIN_FILE that are in $man"
40				last=$man
41			fi
42			echo "   ${a}"
43		fi
44	done
45done
46
47DEPRECATED="*tep_print_field*"
48
49# Should not be used by applications, only internal use by trace-cmd
50IGNORE="*kbuffer_set_old_format* *kbuffer_raw_get* *kbuffer_ptr_delta* *kbuffer_translate_data*"
51
52HEADER=event-parse.h
53
54sed -ne 's/^[a-z].*[ \*]\([a-z_][a-z_]*\)(.*/\1/p' -e 's/^\([a-z_][a-z_]*\)(.*/\1/p' ../include/traceevent/{event-parse,trace-seq,kbuffer}.h | while read f; do
55	if ! grep -q '\*'${f}'\*' $MAIN_FILE; then
56		if [ "${DEPRECATED/\*$f\*/}" != "${DEPRECATED}" ]; then
57			continue;
58		fi
59		if [ "${IGNORE/\*$f\*/}" != "${IGNORE}" ]; then
60			continue;
61		fi
62		for head in event-parse.h trace-seq.h kbuffer.h; do
63			if grep -q $f ../include/traceevent/$head; then
64				if [ "$HEADER" != "$head" ]; then
65					last=""
66					HEADER=$head
67					break
68				fi
69			fi
70		done
71		if [ "$last" == "" ]; then
72			echo
73			echo "Missing functions from $MAIN_FILE that are in $HEADER"
74			last=$f
75		fi
76		echo "   ${f}"
77	fi
78done
79