casaroli commented on code in PR #20813: URL: https://github.com/apache/nuttx/pull/20813#discussion_r4319223588
########## tools/Config.mk: ########## @@ -70,6 +70,15 @@ MODULECC ?= $(CC) MODULELD ?= $(LD) MODULESTRIP ?= $(STRIP) +# A loadable module of a flat or protected build cannot use the coverage +# functions of the image (__gcov_init(), ...): its crt0 is built without Review Comment: Exporting the gcov functions alone is not enough: `__gcov_init()` adds the gcov_info of a module to the list of the runtime, and it stays there after the module is unloaded, so the next dump reads freed memory. With `CONFIG_COVERAGE_MINI` (libs/libbuiltin gcov.c) I will export the functions to modules and add a hook that removes (and first dumps) the gcov_info of a module when the loader unloads it. Then modules keep their coverage options. With `CONFIG_COVERAGE_TOOLCHAIN` (sim:nsh in CI) the runtime is libgcov: there is no call to remove one gcov_info, and the `__gcov_exit()` of a module dumps the data of the whole image, marks it dumped and unlinks it. A correct fix gives each module its own libgcov, as a shared library has on Linux. Which behaviour do you need there: keep building modules without coverage with libgcov, export the functions anyway (a module that is unloaded before the dump breaks the later dumps), or is your setup one where modules are never unloaded before the dump? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
