You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "SPRESENSE (via GitHub)" <gi...@apache.org> on 2023/08/28 04:14:06 UTC

[GitHub] [nuttx] SPRESENSE opened a new issue, #10416: How to print filename and line by assert

SPRESENSE opened a new issue, #10416:
URL: https://github.com/apache/nuttx/issues/10416

   `CONFIG_DEBUG_ASSERTIONS_FILENAME` must be enabled in order to print filename and line by assert function.
   And, `CONFIG_DEBUG_ASSERTIONS_FILENAME` depends on `CONFIG_DEBUG_ASSERTIONS` and `CONFIG_DEBUG`.
   So `assert()` and `ASSERT()` macro, not `DEBUGASSERT()`, cannot output the filename and line if `CONFIG_DEBUG=n`.
   
   Is this behavior as intended?
   It is strange because there is no distinction between `ASSERT()` and `DEBUGASSERT()`.
   


-- 
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: commits-unsubscribe@nuttx.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on issue #10416: How to print filename and line by assert

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on issue #10416:
URL: https://github.com/apache/nuttx/issues/10416#issuecomment-1697545692

   so you want to remove the dependence?


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] SPRESENSE commented on issue #10416: How to print filename and line by assert

Posted by "SPRESENSE (via GitHub)" <gi...@apache.org>.
SPRESENSE commented on issue #10416:
URL: https://github.com/apache/nuttx/issues/10416#issuecomment-1695910370

   Introduced by https://github.com/apache/nuttx/pull/9498


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to print filename and line by assert [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on issue #10416:
URL: https://github.com/apache/nuttx/issues/10416#issuecomment-1765982237

   You mean `CONFIG_DEBUG` is actually `CONFIG_NDEBUG=y` right? This is not introduced by my PR:
   https://github.com/apache/nuttx/blob/master/include/assert.h#L110-L114
   
   so your point is that `assert()` is a syscall, and it should be able to generate assertions normally whether config `CONFIG_NDEBUG` is enable or disabled, right?
   
   However,  I think `CONFIG_DEBUG` is a balance config, for the RTOS devices with limited resources, we can turn on this feature to remove filename/line to reduce the code size, if you want the NuttX to be in strict mode, just turn off `CONFIG_NDEBUG` is fine.
   
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to print filename and line by assert [nuttx]

Posted by "SPRESENSE (via GitHub)" <gi...@apache.org>.
SPRESENSE commented on issue #10416:
URL: https://github.com/apache/nuttx/issues/10416#issuecomment-1758684786

   I think that `assert()` should print the filename and line without `CONFIG_DEBUG`.
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] SPRESENSE commented on issue #10416: How to print filename and line by assert

Posted by "SPRESENSE (via GitHub)" <gi...@apache.org>.
SPRESENSE commented on issue #10416:
URL: https://github.com/apache/nuttx/issues/10416#issuecomment-1698415927

   We should not only remove the dependencies, but rename the configration name.
   Or, it is a good idea to create a separate `CONFIG_ASSERTIONS_FILENAME` from `CONFIG_DEBUG_ASSERTIONS_FILENAME` and apply it to `assert()`, `ASSERT()` and `PANIC()`.
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to print filename and line by assert [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 closed issue #10416: How to print filename and line by assert
URL: https://github.com/apache/nuttx/issues/10416


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to print filename and line by assert [nuttx]

Posted by "SPRESENSE (via GitHub)" <gi...@apache.org>.
SPRESENSE commented on issue #10416:
URL: https://github.com/apache/nuttx/issues/10416#issuecomment-1767541151

   @anchao
   > You mean CONFIG_DEBUG is actually CONFIG_NDEBUG=y right?
   
   No. It is not about `CONFIG_NDEBUG`.
   
   The NuttX assertion has two types, `assert()`(=`ASSERT()`) and `DEBUGASSERT()`.
   The former is used standardly by applications.
   The latter is used for special debugging purposes.
   To prevent an increase of the code size, the `DEBUGASSERT()` code can be disabled by `CONFIG_DEBUG_ASSERTIONS=n`.
   
   | Function         |CONFIG                   | CONFIG                           | Show filename/line |
   | ---              | ---                     | ---                              | ---                    |
   |assert(), ASSERT()|CONFIG_DEBUG_ASSERTIONS=n|                                  | No(*1)                 |
   |DEBUGASSERT()     |CONFIG_DEBUG_ASSERTIONS=y|CONFIG_DEBUG_ASSERTIONS_FILENAME=n| No                     |
   |DEBUGASSERT()     |CONFIG_DEBUG_ASSERTIONS=y|CONFIG_DEBUG_ASSERTIONS_FILENAME=y| Yes                    |
   
   (*1)
   When the general application uses `assert()`, the filename and line are not shown.
   Before your commit, the filename and line were shown.
   
   This comes from the following code.
   https://github.com/apache/nuttx/blob/master/include/assert.h#L45-L51
   
   For `assert()` to print the filename and line, we need to enable `CONFIG_DEBUG=y`, `CONFIG_DEBUG_ASSERTIONS=y` and `CONFIG_DEBUG_ASSERTIONS_FILENAME=y`. It causes an increase in code size since `DEBUGASSERT()` is also enabled.
   
   Essentially, since `assert()` is also used by the application, it should show the filename and line by default, as it does on other platforms.
   
   How do you think?
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to print filename and line by assert [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on issue #10416:
URL: https://github.com/apache/nuttx/issues/10416#issuecomment-1770170073

   Thanks for the clear explanation, I followed your suggestion to separate CONFIG_ASSERTIONS_FILENAME from CONFIG_DEBUG_ASSERTIONS_FILENAME, and remove the coupling between assert(3) with CONFIG_DEBUG_ASSERTIONS,
   Please review PR https://github.com/apache/nuttx/pull/10978


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to print filename and line by assert [nuttx]

Posted by "SPRESENSE (via GitHub)" <gi...@apache.org>.
SPRESENSE commented on issue #10416:
URL: https://github.com/apache/nuttx/issues/10416#issuecomment-1757166309

   @xiaoxiang781216 @anchao How about this issue?
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to print filename and line by assert [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on issue #10416:
URL: https://github.com/apache/nuttx/issues/10416#issuecomment-1757382171

   I just check the config, `CONFIG_DEBUG_ASSERTIONS_FILENAME` is default y if enable `CONFIG_DEBUG_ASSERTIONS` ,
   the assert file name could be printed if enable `CONFIG_DEBUG_ASSERTIONS` and call `assert()`, `ASSERT() `and `PANIC().`
   
   I don't quite understand what your problem is. Do you want to enable `CONFIG_DEBUG_ASSERTIONS_FILENAME` without  `CONFIG_DEBUG_ASSERTIONS`?


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org