This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 82a4b2186363dc773317b0af0487dc2411c5fc34 Author: wangmingrong1 <wangmingro...@xiaomi.com> AuthorDate: Mon Mar 31 15:57:39 2025 +0800 gcov: Output mode judgment is implemented in the kernel layer Signed-off-by: wangmingrong1 <wangmingro...@xiaomi.com> --- libs/libbuiltin/libgcc/gcov.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libs/libbuiltin/libgcc/gcov.c b/libs/libbuiltin/libgcc/gcov.c index 6d6680382c..5039fdde6f 100644 --- a/libs/libbuiltin/libgcc/gcov.c +++ b/libs/libbuiltin/libgcc/gcov.c @@ -430,7 +430,6 @@ void __gcov_init(FAR struct gcov_info *info) tm_info); setenv("GCOV_PREFIX_STRIP", CONFIG_COVERAGE_DEFAULT_PREFIX_STRIP, 1); - setenv("GCOV_DUMP_ONEFILE", "1", 1); setenv("GCOV_PREFIX", path, 1); #ifdef CONFIG_COVERAGE_GCOV_DUMP_REBOOT @@ -473,8 +472,8 @@ pid_t __gcov_fork(void) void __gcov_dump(void) { int ret = -1; - bool onefile; FAR char *prefix; + struct stat state; struct dump_args args = { 0 @@ -493,8 +492,8 @@ void __gcov_dump(void) return; } - onefile = strcmp(getenv("GCOV_DUMP_ONEFILE"), "1") == 0; - if (onefile) + if (stat(prefix, &state) || + S_ISREG(state.st_mode) || S_ISCHR(state.st_mode)) { struct lib_rawoutstream_s stream; int fd = _NX_OPEN(prefix, O_WRONLY | O_CREAT | O_TRUNC, 0666); @@ -511,7 +510,7 @@ void __gcov_dump(void) _NX_CLOSE(fd); } - else + else if(S_ISDIR(state.st_mode)) { args.mkdir = gcov_mkdir; args.strip = atoi(getenv("GCOV_PREFIX_STRIP")); @@ -521,6 +520,10 @@ void __gcov_dump(void) ret = gcov_dump_foreach(gcov_standard_dump, &args); } + else + { + ret = -ENOTDIR; + } exit: