lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Tue, 28 Apr 2020 16:52:01 +0900
From:   Masahiro Yamada <masahiroy@...nel.org>
To:     xujialu <xujialu@...ux.org>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jonathan Corbet <corbet@....net>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
Subject: Re: [PATCH] scripts: gtags_files_generator.sh

On Sun, Apr 26, 2020 at 11:48 AM xujialu <xujialu@...ux.org> wrote:
>
> Add a script to generate a more precise gtags.files from *.cmd files.
>
> For navigating linux sources, it will be more efficient if gtags/cscope
> just collects source files that needed for compilation. The kernel
> makefiles already create *.cmd files that contain the files we needed,
> then just extracts files list from them and into gtags.files cause it's
> the the default name list file for gtags.


This is unneeded.

scripts/tags.sh supports COMPILED_SOURCE=1
to collect tags only from compiled sources.

Please do not reinvent the wheel
to achieve similar things.


$ time make COMPILED_SOURCE=1 gtags
  GEN     gtags

real 0m7.623s
user 0m7.459s
sys 0m1.124s


is fine for me.

If the existing code is problematic,
we need to improve it,
not add the second one.





>
> make defconfig
> make
> scripts/gtags_files_generator.sh
> gtags [-f gtags.files]
>
> Enjoy with vim+gtags. :)
>
> Here is a log for comparison with 'make gtags':
>
> $ time make ARCH=arm cscope
>   GEN     cscope
>
> real    1m20.600s
> user    1m36.004s
> sys     0m8.192s
> $ wc -l cscope.files
> 31201 cscope.files              #collected too many files we don't care
>
> $ time ./scripts/gtags_files_generator.sh
>
> Succeed, 3716 gtags.files listed!
>
> real    0m1.593s                #collected files only we care
> user    0m1.704s
> sys     0m0.256s
>                                 #collected also dts and dtsi


Why do you need to collect dts and dtsi?







> $ grep dts gtags.files
> arch/arm/boot/dts/xxxxxx-clocks.dtsi
> arch/arm/boot/dts/xxxxxx.dtsi
> arch/arm/boot/dts/xxxxxxxx.dts
> arch/arm/boot/dts/xxxxxxxx.dtsi
>
> Signed-off-by: xujialu <xujialu@...ux.org>
> ---
>  scripts/gtags_files_generator.sh | 48 ++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100755 scripts/gtags_files_generator.sh
>
> diff --git a/scripts/gtags_files_generator.sh b/scripts/gtags_files_generator.sh
> new file mode 100755
> index 000000000000..04698d9234a7
> --- /dev/null
> +++ b/scripts/gtags_files_generator.sh
> @@ -0,0 +1,48 @@
> +#!/bin/bash -e
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Author: xujialu <xujialu@...ux.org>
> +#
> +# A script for generating gtags.files after compilation.
> +#
> +# Usage:
> +#      make defconfig
> +#      make
> +#      scripts/gtags_files_generator.sh
> +#      gtags [-f gtags.files]
> +
> +
> +gtags_files_list()
> +{
> +       ls ${AUTOCONF_H} $(realpath -e --relative-to=. \
> +               $(find ${KBUILD_OUTPUT} -name "*$1.cmd" -exec \
> +               grep -Poh '(?(?=^source_.* \K).*|(?=^  \K\S).*(?= \\))' {} \+ |
> +               awk '!a[$0]++' | sed "s,^,${KBUILD_OUTPUT},") |
> +               sed -e '/\.\./d' | awk '!a[$0]++'
> +       )
> +}
> +
> +gtags_files_generator()
> +{
> +       GTAGS_FILES=$PWD/gtags.files
> +
> +       echo && [ $# = 1 ] && cd $1
> +
> +       SYSTEM_MAP=$(find -name System.map -print -quit)
> +
> +       [ -z "${SYSTEM_MAP}" ] && echo "Failed, please compile first!" && exit 1
> +
> +       KBUILD_OUTPUT=${SYSTEM_MAP%/*}/
> +       KBUILD_OUTPUT=${KBUILD_OUTPUT#*/}
> +
> +       AUTOCONF_H=${KBUILD_OUTPUT}include/generated/autoconf.h
> +
> +       grep Configuration ${AUTOCONF_H} | sed 's/ \* //'
> +       gtags_files_list > ${GTAGS_FILES}
> +
> +       echo && [ $# = 1 ] && sed -i "s|^|$1|" ${GTAGS_FILES}
> +
> +       echo "Succeed, $(wc -l ${GTAGS_FILES}) listed!"
> +}
> +
> +gtags_files_generator $1 2>/dev/null
> --
> 2.20.1
>


-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ