Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp412071ybi; Thu, 13 Jun 2019 19:06:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxw6WQprlsgCJfn1sF7u2roov7YwmLrDVotIYOioEftf1nVkgwFT3uCty3qtMh40ZljmD9U X-Received: by 2002:a62:6:: with SMTP id 6mr32189996pfa.159.1560477962270; Thu, 13 Jun 2019 19:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560477962; cv=none; d=google.com; s=arc-20160816; b=XS2QxjZ+vrgen0d8HvVDFV6uSLJbMTCnU/VfZIw1mv9Pa2bJheGzzykRCHFX0zW+rt k0S/WDRzP6dSuzLvu+dJOxtl3UU8JScF28acep4axPYUdRhd4BmrpDkwMQUvnRalG67D wr6QNJx6szgIwciCLRBo8X9GFd2upIV12oNzwkwM3R0wZYRUetYV4e6G4DghboAXT5Nv Q+0ELYt73bugFRC5asRQFBNoZU3tYkoq10HLJN6C9h+NFhnWO7uVYHBQtnlrKdF9Mjm4 IHpsQtt8tjXUJTvc6i2CispmgdHHuADNVPb+J2AeA/YVIQ1ialw7WtYnLLG1g5pUNvGu xZEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4WfH3WvA3aZdEU2vnsQylDIgSyaOvEi4N8Ko1jrRcs4=; b=SobNinNAQI16Z3kcXcQx06/qnls8ELtNUVKYXkwdD2o8JlO0DdN7nc7I4eG71pLgQT RbHdeJT+m20sdiYay/0IWjerNvawnl93MSt3Ix1gEewDbQY+rzE5FIqCKb3eSkqEI3jH 8fY3R5LrY/tGKsSpOT864ciICdzx1AbBCgJEG6oJyZMFQvfAc3cqOFe+bz1dmkm2S0qG Hkmnk6t1FVdVfK8Tlnip0+8eqq1/fisqMpdqYaNa7hALgFwjFCCQp+43DKs5dtWIZI7q 23CcB7PBPLSTy6Uv1dE5kEMpgR/eMp7Gh3CVU4r8D5RcNSzKDEMUdzZ//ixHekhAPS3l SdbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PEwK1zmI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b18si1154680pgi.260.2019.06.13.19.05.46; Thu, 13 Jun 2019 19:06:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PEwK1zmI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726894AbfFNCE3 (ORCPT + 99 others); Thu, 13 Jun 2019 22:04:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52874 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbfFNCE2 (ORCPT ); Thu, 13 Jun 2019 22:04:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4WfH3WvA3aZdEU2vnsQylDIgSyaOvEi4N8Ko1jrRcs4=; b=PEwK1zmIeYoZJMuF3+kyVaK/lo 374rH5MV5bn/OgWuMlyqPttGCSu7FTc1/4emjSRrcC+9G6M+b9k8HSz+JoGa7gjLRXYK3omM/xj8+ hFX70iRlXKrk7S3G3Z0NApNxM1UoUNEjYwFCJ+fAp8CdDrfG2pokGZ/leMk+TVJWsUvQjy3LYGwqr BzA3y4AX0CS6e4ruHRDQopGGvRIbezXumDZC8nVAye9o6fd+dQW2vOKGHULTvUKSOOrXZDHHP9KPd EYiRJlepRnZ+usvKQBY1NCfSWoAHEchiBTz/6B2PPl6RpN4Vd+qG/6gifEWSboMWDu5xPs0iBtD2s icVaDPeA==; Received: from 201.86.169.251.dynamic.adsl.gvt.net.br ([201.86.169.251] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hbbZr-0000E6-Dy; Fri, 14 Jun 2019 02:04:27 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92) (envelope-from ) id 1hbbZn-0002o4-Tu; Thu, 13 Jun 2019 23:04:23 -0300 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Greg Kroah-Hartman Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, Jonathan Corbet , Mauro Carvalho Chehab Subject: [PATCH 09/14] scripts/get_abi.pl: add support for searching for ABI symbols Date: Thu, 13 Jun 2019 23:04:15 -0300 Message-Id: <8a21e26ab9d3a67433f7d5fddf227a8562e48adb.1560477540.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mauro Carvalho Chehab Change its syntax to allow switching between ReST output mode and a new search mode, with allows to seek for ABI symbols using regex. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- scripts/get_abi.pl | 112 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 103 insertions(+), 9 deletions(-) diff --git a/scripts/get_abi.pl b/scripts/get_abi.pl index d437e148b1c0..c202292af1a2 100755 --- a/scripts/get_abi.pl +++ b/scripts/get_abi.pl @@ -9,9 +9,11 @@ use Fcntl ':mode'; my $help; my $man; my $debug; +my $prefix="Documentation/ABI"; GetOptions( "debug|d+" => \$debug, + "dir=s" => \$prefix, 'help|?' => \$help, man => \$man ) or pod2usage(2); @@ -19,9 +21,12 @@ GetOptions( pod2usage(1) if $help; pod2usage(-exitstatus => 0, -verbose => 2) if $man; -pod2usage(2) if (scalar @ARGV != 1); +pod2usage(2) if (scalar @ARGV < 1 || @ARGV > 2); -my ($prefix) = @ARGV; +my ($cmd, $arg) = @ARGV; + +pod2usage(2) if ($cmd ne "search" && $cmd ne "rest"); +pod2usage(2) if ($cmd eq "search" && !$arg); require Data::Dumper if ($debug); @@ -53,6 +58,7 @@ sub parse_abi { $data{$nametag}->{what} = "File $name"; $data{$nametag}->{type} = "File"; $data{$nametag}->{file} = $name; + $data{$nametag}->{filepath} = $file; $data{$nametag}->{is_file} = 1; my $type = $file; @@ -115,6 +121,7 @@ sub parse_abi { $data{$what}->{type} = $type; $data{$what}->{file} = $name; + $data{$what}->{filepath} = $file; print STDERR "\twhat: $what\n" if ($debug > 1); } @@ -183,7 +190,9 @@ sub parse_abi { close IN; } -# Outputs the output on ReST format +# +# Outputs the book on ReST format +# sub output_rest { foreach my $what (sort keys %data) { my $type = $data{$what}->{type}; @@ -262,6 +271,45 @@ sub output_rest { } } +# +# Searches for ABI symbols +# +sub search_symbols { + foreach my $what (sort keys %data) { + next if (!($what =~ m/($arg)/)); + + my $type = $data{$what}->{type}; + next if ($type eq "File"); + + my $file = $data{$what}->{filepath}; + + my $bar = $what; + $bar =~ s/./-/g; + + print "\n$what\n$bar\n\n"; + + my $kernelversion = $data{$what}->{kernelversion}; + my $contact = $data{$what}->{contact}; + my $users = $data{$what}->{users}; + my $date = $data{$what}->{date}; + my $desc = $data{$what}->{description}; + $kernelversion =~ s/^\s+//; + $contact =~ s/^\s+//; + $users =~ s/^\s+//; + $users =~ s/\n//g; + $date =~ s/^\s+//; + $desc =~ s/^\s+//; + + printf "Kernel version:\t\t%s\n", $kernelversion if ($kernelversion); + printf "Date:\t\t\t%s\n", $date if ($date); + printf "Contact:\t\t%s\n", $contact if ($contact); + printf "Users:\t\t\t%s\n", $users if ($users); + print "Defined on file:\t$file\n\n"; + print "Description:\n\n$desc"; + } +} + + # # Parses all ABI files located at $prefix dir # @@ -270,9 +318,13 @@ find({wanted =>\&parse_abi, no_chdir => 1}, $prefix); print STDERR Data::Dumper->Dump([\%data], [qw(*data)]) if ($debug); # -# Outputs an ReST file with the ABI contents +# Handles the command # -output_rest +if ($cmd eq "rest") { + output_rest; +} else { + search_symbols; +} __END__ @@ -283,12 +335,27 @@ abi_book.pl - parse the Linux ABI files and produce a ReST book. =head1 SYNOPSIS -B [--debug] ] +B [--debug] [] + +Where can be: + +=over 8 + +B [SEARCH_REGEX] - search for [SEARCH_REGEX] inside ABI + +B - output the ABI in ReST markup language + +=back =head1 OPTIONS =over 8 +=item B<--dir> + +Changes the location of the ABI search. By default, it uses +the Documentation/ABI directory. + =item B<--debug> Put the script in verbose mode, useful for debugging. Can be called multiple @@ -306,8 +373,35 @@ Prints the manual page and exits. =head1 DESCRIPTION -Parse the Linux ABI files from ABI DIR (usually located at Documentation/ABI) -and produce a ReST book containing the Linux ABI. +Parse the Linux ABI files from ABI DIR (usually located at Documentation/ABI), +allowing to search for ABI symbols or to produce a ReST book containing +the Linux ABI documentation. + +=head1 EXAMPLES + +Search for all stable symbols with the word "usb": + +=over 8 + +$ scripts/get_abi.pl search usb --dir Documentation/ABI/stable + +=back + +Search for all symbols that match the regex expression "usb.*cap": + +=over 8 + +$ scripts/get_abi.pl search usb.*cap + +=back + +Output all obsoleted symbols in ReST format + +=over 8 + +$ scripts/get_abi.pl rest --dir Documentation/ABI/obsolete + +=back =head1 BUGS @@ -315,7 +409,7 @@ Report bugs to Mauro Carvalho Chehab =head1 COPYRIGHT -Copyright (c) 2016 by Mauro Carvalho Chehab . +Copyright (c) 2016-2017 by Mauro Carvalho Chehab . License GPLv2: GNU GPL version 2 . -- 2.21.0