diff --git a/Documentation/applications/system/gcov/index.rst b/Documentation/applications/system/gcov/index.rst index 6d35f89097bbb..62ab2eb23b80f 100644 --- a/Documentation/applications/system/gcov/index.rst +++ b/Documentation/applications/system/gcov/index.rst @@ -86,6 +86,16 @@ Examples of applicable platforms find ./ -name "*.gcda" ``` + 5. Examples: + ``` + $ ./tools/configure.sh sim:nsh + nsh: poweroff + $ ./nuttx/tools/gcov.py -t gcov + Then open ./gcov/result/index.html with your browser + ``` + +2. Applicable to device + 2. Applicable to device Due to differences in implementation methods, the device side is divided into GCC and CLANG @@ -129,10 +139,10 @@ Examples of applicable platforms # The -t parameter specifies the gcov version, which needs to match the gcc version # sim - ./tools/gcov.sh -t gcov-13 + ./tools/gcov.py -t gcov # arm platform - ./tools/gcov.sh -t arm-none-eabi-gcov + ./tools/gcov.py -t arm-none-eabi-gcov 5. Impact and precautions ``` diff --git a/tools/gcov.py b/tools/gcov.py index 311df031f14e2..946b73d6b0618 100755 --- a/tools/gcov.py +++ b/tools/gcov.py @@ -110,19 +110,17 @@ def arg_parser(): ) parser.add_argument("-i", "--input", help="Input dump data") parser.add_argument("-t", dest="gcov_tool", help="Path to gcov tool") - parser.add_argument( - "-b", dest="base_dir", default=os.getcwd(), help="Compile base directory" - ) + parser.add_argument("-b", dest="base_dir", help="Compile base directory") parser.add_argument( "-s", dest="gcno_dir", - default=os.getcwd(), + default=".", help="Directory containing gcno files", ) parser.add_argument( "-a", dest="gcda_dir", - default=os.getcwd(), + default=".", nargs="+", help="Directory containing gcda files", ) @@ -136,8 +134,7 @@ def arg_parser(): parser.add_argument( "-o", dest="gcov_dir", - nargs="?", - default=os.getcwd(), + default="gcov", help="Directory to store gcov data and report", ) @@ -151,10 +148,7 @@ def main(): gcov_dir = os.path.abspath(args.gcov_dir) gcno_dir = os.path.abspath(args.gcno_dir) - if os.path.exists(gcov_dir): - shutil.rmtree(gcov_dir) - - os.makedirs(gcov_dir) + os.makedirs(gcov_dir, exist_ok=True) gcda_dir = [] for i in args.gcda_dir: @@ -249,11 +243,6 @@ def main(): print("Failed to generate coverage file.") sys.exit(1) - for i in gcov_data_dir: - shutil.rmtree(i) - - os.remove(coverage_file) - if __name__ == "__main__": main()