First I apologize for my english, im french.
I have a big pb with debugging.
config: win10, cb 20.03, mingw from cb, language c++
my problem can be reduced to :
#include <cassert>
int main() {
assert(true);
assert(false);
return 0;
}
Compiled in debug mode the console does not show assert error and exits directly not stopping.
Debuggers window tells :
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.8
Child process PID: 20048
[Inferior 1 (process 20048) exited with code 03]
Debugger finished with status 0
I have tried with other debuggers (lastest mingw, tdm gcc), uninstalled/reinstalled CB, tried CB nightly build, uninstalled/removed all cb occurrences from registry and disk/reinstalled etc.
No change: the console close and asserts are not shown.
Note that previously it was same with c++ exceptions but now they are shown. juste the console does not stop too.
If someone can help...
(Edit: No answer found on the forum too)
more, checking various implementations, assert is nothing more than :
if (!value)
print(value)
abort()
here a gnu excerpt :
__BEGIN_DECLS
#ifndef __cplusplus
void abort(void) __dead2;
#endif /* !__cplusplus */
int printf(const char * __restrict, ...);
__END_DECLS
#define assert(e) \
((void) ((e) ? 0 : __assert (#e, __FILE__, __LINE__)))
#define __assert(e, file, line) \
((void)printf ("%s:%u: failed assertion `%s'\n", file, line, e), abort())
from so simple code, failed assert is always reported in debug mode and I should see it !
I didn't intend or feel rude. It's my bad and you'r right I should have clarified my experience.
1) Open codeblocks
2) Create new project
3) Paste the code from top
4) Hit compile and run
5) Console window pops up but closes immediately. I expect that it remains open...
for me step 1 to 5 work without problems, in step 5 the console stays open
step 1 to 5 is fine for me too. but step 5 my console closes.
1) Open codeblocks
2) Create new project
3) Paste code form the top
4) place a breakpoint in line 3
5) Hit debug
6) Program exits, but it should stop in line 3
Also this works for me for step 1 to 6. But on step 6 for me the debugger stops and whaits for next instruction
step 1 to 6 is fine too, the debugger stops on the BP as expected, but continuing debug the console closes.
1) Open codeblocks
2) Create new project
3) Paste code from the top
4) Hit compile and run
5) close codeblocks
6) go to the project bin folder
7) Double click my program
8) Black window pops up for a short time. But i expect to read some assert text
Again steps 1-8 work for me and step 8 should be the black window poping up but closing fast
All is fine but step 8 there is no message.
C:\Dev\cpp\test\bin\Debug>test
C:\Dev\cpp\test\bin\Debug>echo %errorlevel%
-1073741515
however it can be noted that the execution did not reach the 'return 0', as expected.
what makes me think that the problems come from CB is that they appeared right after a CB crash.
However we will never know what the problem is or its solution, I will take out the hammer and do a relatively recent restoration of my drive.
And I'll add a startup script to save the CB settings. But having reinstalled it all settings in %appdata%/codeblocks should have been reset, so pb is probably not from settings in this directory.
This sound as a side effect of the crash somewhere :(
Thank you for your help
Ok, now we know the problem and can work on a solution.
To see the output at the end of the execution of your program, codeblocks uses the "console runner". This is the black screen you see at the end of your program with the text. If the console runner is not used your program will exit without notice
step 1 to 5 is fine for me too. but step 5 my console closes.
this should not happen if you run it in codeblocks and the following option is set:
Project->Properties->Build targets->Check if Debug is selected on the left->Check the option "Pause when execution ends"
If this mark is set, and your console disappears, then there is some deeper problem.
step 1 to 6 is fine too, the debugger stops on the BP as expected, but continuing debug the console closes.
This is expected behavior. If your application is run in the debugger the "console runner" is not used and for this you will not see any output at the end of the execution
C:\Dev\cpp\test\bin\Debug>test
C:\Dev\cpp\test\bin\Debug>echo %errorlevel%
-1073741515
This is strange... Can you please post a build log:
1) Run Build->Rebuild project
2) Post the content of the Build log tab at the bottom