You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When turning on Testing and Debugging -> Enable debug features: instruction tracing and watchpoint (macro CONFIG_DEBUG ), compiling NEMU will get a format-truncation error:
开启 Testing and Debugging -> Enable debug features: instruction tracing and watchpoint (宏 CONFIG_DEBUG )之后,编译 NEMU 会出现 format-truncation 报错:
include/common.h:34:39: error: ‘%s’ directive output may be truncated writing up to 79 bytes into a region of size 58 [-Werror=format-truncation=]
Full Error logs
ln -sf resource/softfloat/repo/build/Linux-x86_64-GCC/softfloat.a resource/softfloat/build/softfloat.a
In file included from include/common.h:26,
from include/cpu/cpu.h:19,
from src/cpu/cpu-exec.c:18:
src/cpu/cpu-exec.c: In function ‘fetch_decode’:
include/common.h:34:39: error: ‘%s’ directive output may be truncated writing up to 79 bytes into a region of size 58 [-Werror=format-truncation=]
34 | #define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016lx", "0x%08x")
| ^~~~~~~~~~
include/macro.h:69:21: note: in definition of macro ‘__KEEP’
69 | #define __KEEP(...) __VA_ARGS__
| ^~~~~~~~~~~
src/cpu/cpu-exec.c:577:3: note: in expansion of macro ‘IFDEF’
577 | IFDEF(CONFIG_DEBUG,
| ^~~~~
include/macro.h:41:45: note: in expansion of macro ‘CHOOSE2nd’
41 | #define MUX_WITH_COMMA(contain_comma, a, b) CHOOSE2nd(contain_comma a, b)
| ^~~~~~~~~
include/macro.h:42:44: note: in expansion of macro ‘MUX_WITH_COMMA’
42 | #define MUX_MACRO_PROPERTY(p, macro, a, b) MUX_WITH_COMMA(concat(p, macro), a, b)
| ^~~~~~~~~~~~~~
include/macro.h:49:30: note: in expansion of macro ‘MUX_MACRO_PROPERTY’
49 | #define MUXDEF(macro, X, Y) MUX_MACRO_PROPERTY(__P_DEF_, macro, X, Y)
| ^~~~~~~~~~~~~~~~~~
include/common.h:34:18: note: in expansion of macro ‘MUXDEF’
34 | #define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016lx", "0x%08x")
| ^~~~~~
src/cpu/cpu-exec.c:578:48: note: in expansion of macro ‘FMT_WORD’
578 | snprintf(s->logbuf, sizeof(s->logbuf), FMT_WORD ": %s%*.s%s", s->pc,
| ^~~~~~~~
src/cpu/cpu-exec.c:578:62: note: format string is defined here
578 | snprintf(s->logbuf, sizeof(s->logbuf), FMT_WORD ": %s%*.s%s", s->pc,
| ^~
In file included from include/common.h:26,
from include/cpu/cpu.h:19,
from src/cpu/cpu-exec.c:18:
include/common.h:34:39: note: assuming directive output of 1 byte
34 | #define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016lx", "0x%08x")
| ^~~~~~~~~~
include/macro.h:69:21: note: in definition of macro ‘__KEEP’
69 | #define __KEEP(...) __VA_ARGS__
| ^~~~~~~~~~~
src/cpu/cpu-exec.c:577:3: note: in expansion of macro ‘IFDEF’
577 | IFDEF(CONFIG_DEBUG,
| ^~~~~
include/macro.h:41:45: note: in expansion of macro ‘CHOOSE2nd’
41 | #define MUX_WITH_COMMA(contain_comma, a, b) CHOOSE2nd(contain_comma a, b)
| ^~~~~~~~~
include/macro.h:42:44: note: in expansion of macro ‘MUX_WITH_COMMA’
42 | #define MUX_MACRO_PROPERTY(p, macro, a, b) MUX_WITH_COMMA(concat(p, macro), a, b)
| ^~~~~~~~~~~~~~
include/macro.h:49:30: note: in expansion of macro ‘MUX_MACRO_PROPERTY’
49 | #define MUXDEF(macro, X, Y) MUX_MACRO_PROPERTY(__P_DEF_, macro, X, Y)
| ^~~~~~~~~~~~~~~~~~
include/common.h:34:18: note: in expansion of macro ‘MUXDEF’
34 | #define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016lx", "0x%08x")
| ^~~~~~
src/cpu/cpu-exec.c:578:48: note: in expansion of macro ‘FMT_WORD’
578 | snprintf(s->logbuf, sizeof(s->logbuf), FMT_WORD ": %s%*.s%s", s->pc,
| ^~~~~~~~
In file included from /usr/include/stdio.h:867,
from include/debug.h:20,
from include/common.h:55,
from include/cpu/cpu.h:19,
from src/cpu/cpu-exec.c:18:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output between 23 and 2147483828 bytes into a destination of size 80
67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
I think this warning is a misreport. This debug output may be truncated in theroy, not not in practice. I think add -Wno-format-truncation to CFLAGS and CXXFLAGS in Makefile will solve this. I can't think of any unexpected results.
我认为这个警告是误报。这个调试输出理论上可能被截断,但实际并不会(实际上就算节段了也完全不影响)。在Makefile中的 CFLAGS 和 CXXFLAGS 中添加 -Wno-format-truncation 可以解决此问题。我想不出有什么出乎意料的结果。
The text was updated successfully, but these errors were encountered:
Description 描述
When turning on
Testing and Debugging
->Enable debug features: instruction tracing and watchpoint
(macroCONFIG_DEBUG
), compiling NEMU will get aformat-truncation
error:开启
Testing and Debugging
->Enable debug features: instruction tracing and watchpoint
(宏CONFIG_DEBUG
)之后,编译 NEMU 会出现format-truncation
报错:Full Error logs
Environment 环境
Possible solutions 可能的解决方案
I think this warning is a misreport. This debug output may be truncated in theroy, not not in practice. I think add
-Wno-format-truncation
toCFLAGS
andCXXFLAGS
in Makefile will solve this. I can't think of any unexpected results.我认为这个警告是误报。这个调试输出理论上可能被截断,但实际并不会(实际上就算节段了也完全不影响)。在Makefile中的
CFLAGS
和CXXFLAGS
中添加-Wno-format-truncation
可以解决此问题。我想不出有什么出乎意料的结果。The text was updated successfully, but these errors were encountered: