C ++ debugging: ../ nptl / sysdeps / unix / sysv / linux / raise.c: no such file or directory

I use gdb to debug a C++ program. In line

 assert(prevId == GetTagIdFromState(maxState)); 
  • parameter value prevId 0 ;
  • method GetTagIdFromState(maxState) return 50 ;

when debugging, I get the following errors.

 Assertion `prevId == GetTagIdFromState(maxState)' failed. Program received signal SIGABRT, Aborted. 0x00007ffff6ecbba5 in raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. in ../nptl/sysdeps/unix/sysv/linux/raise.c 
+8
c ++ gdb
source share
3 answers

Your application works as intended. The assertion fails (because the values ​​you pass to it are not equal, the assert macro takes 0), and therefore your program terminates. This is how the work claims:

If NDEBUG is not defined, then assert checks to see if its argument (which should be of a scalar type) is compared to zero. If so, they claim that it displays project-specific diagnostic information according to the standard error output and calls to std :: abort .

my emphasis.

Check this link for confirmation for more information.

+7
source share

I just ran into this error while trying to debug a program on Raspberry Pi. The program uses GPIO so that the program runs as root. For example, I run a program that I wrote as follows:

 sudo ./foo 

I forgot this, however, when starting the debugger and tried

 gdb foo 

And I got an error that you seem to encounter:

 Program received signal SIGABRT, Aborted. 0x76cd0f70 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. 

When I ran it using sudo, it worked fine.

 sudo gdb foo 

Hope this helps someone in the same boat.

+1
source share

This should speed up the use of the assert function.

 void assert (int expression); 

Evaluate a statement If the argument expression of this macro with the functional form is compared to zero (i.e., the expression is false), the message is written to the standard error device and an interrupt is called, terminating the program.

The specificity of the displayed message depends on the particular implementation in the compiler, but it should include: an expression whose statement failed, the name of the source file and the line number in which it occurred. The usual expression format is:

Assertion failed: expression, file name, line number This macro is disabled if a macro named NDEBUG is already defined at the time you turned on assert.h. This allows the encoder to include many assert calls in the source code when debugging the program, and then disable all of them for the production version by simply including a line, for example:

 #define NDEBUG at the beginning of its code, before the inclusion of assert.h. 

Thus, this macro is designed to capture programming errors, not user errors or launches, as it usually shuts down after the program exits the debug phase. from: C ++ Ref

0
source share

All Articles