Code::Blocks Forums

User forums => Help => Topic started by: Rixius44 on May 16, 2020, 04:43:46 am

Title: Debugging Exit with Error Code 1
Post by: Rixius44 on May 16, 2020, 04:43:46 am
Hello everyone! New to the community, first post...

So, regarding my debugger in the most recent Code::Blocks release...

I was having trouble getting the debugger to even start. I found out about a bunch of configuration settings that needed to be changed and about how the project path couldn't have any spaces in it... Eventually I got the debugger to run and even stop at a breakpoint, but it goes through the first conditional loop and seems to mess up and stops with status 1...

Here is my code:

Code
#include <stdio.h>
/* count characters in input; 2nd version */

main()
{
    double nc;
    for (nc = 0; getchar() != EOF; ++nc)
    {
        ;
    }
    printf("%.0f\n", nc);

}

My configurations settings have -b turned on and -s turned off.
I have the Code::Blocks which includes MINGW64 installed.
My project paths do not contain any spaces, only underscores and numbers.
The code is in C...

The debugger seems to stop working when it reaches the for loop...

Here is the debug log...

Code
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW\
Adding source dir: D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW\
Adding file: D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW\bin\Debug\Chapter_1NEW.exe
Changing directory to: D:/Programming_Education/Books/CS_Degree/Notes/The_C_Programming_Language/Chapter_1NEW/.
Set variable: PATH=.;D:\CodeBlocks\MinGW\bin;D:\CodeBlocks\MinGW;C:\Program Files\Microsoft MPI\Bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Windows\System32\OpenSSH;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;D:\MATLAB\runtime\win64;D:\MATLAB\bin;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\dotnet;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Users\felip\AppData\Local\Programs\Python\Python36\Scripts;C:\Users\felip\AppData\Local\Programs\Python\Python36;C:\Users\felip\AppData\Local\Microsoft\WindowsApps;C:\Users\felip\AppData\Roaming\Dashlane\5.5.0.14947\ucrt;\;D:\Python;D:\Python\Scripts;D:\Microsoft VS Code\bin

[debug]Command-line: D:\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args D:/Programming_Education/Books/CS_Degree/Notes/The_C_Programming_Language/Chapter_1NEW/bin/Debug/Chapter_1NEW.exe
[debug]Working dir : D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW

Starting debugger: D:\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args D:/Programming_Education/Books/CS_Degree/Notes/The_C_Programming_Language/Chapter_1NEW/bin/Debug/Chapter_1NEW.exe
done

[debug]Reading symbols from D:/Programming_Education/Books/CS_Degree/Notes/The_C_Programming_Language/Chapter_1NEW/bin/Debug/Chapter_1NEW.exe...
[debug]done.
[debug](gdb)
[debug]> set prompt >>>>>>cb_gdb:

Setting breakpoints

[debug]>>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 8.1
[debug]Copyright (C) 2018 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "x86_64-w64-mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 8.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 200
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory D:/Programming_Education/Books/CS_Degree/Notes/The_C_Programming_Language/Chapter_1NEW/
[debug]Source directories searched: D:/Programming_Education/Books/CS_Degree/Notes/The_C_Programming_Language/Chapter_1NEW;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "D:/Programming_Education/Books/CS_Degree/Notes/The_C_Programming_Language/Chapter_1NEW/CharacterCounter152.c:10"
[debug]Breakpoint 2 at 0x401588: file D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW\CharacterCounter152.c, line 10.
[debug]>>>>>>cb_gdb:
[debug]> break "D:/Programming_Education/Books/CS_Degree/Notes/The_C_Programming_Language/Chapter_1NEW/CharacterCounter152.c:7"
[debug]Breakpoint 3 at 0x40155d: file D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW\CharacterCounter152.c, line 7.
[debug]>>>>>>cb_gdb:
[debug]> break "D:/Programming_Education/Books/CS_Degree/Notes/The_C_Programming_Language/Chapter_1NEW/CharacterCounter152.c:6"
[debug]Note: breakpoint 3 also set at pc 0x40155d.
[debug]Breakpoint 4 at 0x40155d: file D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW\CharacterCounter152.c, line 6.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW\bin\Debug\Chapter_1NEW.exe

Child process PID: 6208

[debug][New Thread 6208.0x1ba0]
[debug][New Thread 6208.0x3bb8]
[debug]Thread 1 hit Breakpoint 3, main () at D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW\CharacterCounter152.c:7
[debug]D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW\CharacterCounter152.c:7:95:beg:0x40155d
[debug]>>>>>>cb_gdb:

At D:\Programming_Education\Books\CS_Degree\Notes\The_C_Programming_Language\Chapter_1NEW\CharacterCounter152.c:7

[debug]> show language
[debug]The current source language is "auto; currently c".
[debug]>>>>>>cb_gdb:
[debug]> info locals
[debug]nc = 7.9050503334599447e-323
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> if 1
disassemble 0x40155d
info frame
end

[debug] >
[debug] > >
[debug]Dump of assembler code for function main:
[debug]   0x0000000000401550 <+0>: push   %rbp
[debug]   0x0000000000401551 <+1>: mov    %rsp,%rbp
[debug]   0x0000000000401554 <+4>: sub    $0x30,%rsp
[debug]   0x0000000000401558 <+8>: callq  0x401660 <__main>
[debug]=> 0x000000000040155d <+13>: pxor   %xmm0,%xmm0
[debug]   0x0000000000401561 <+17>: movsd  %xmm0,-0x8(%rbp)
[debug]   0x0000000000401566 <+22>: jmp    0x40157e <main+46>
[debug]   0x0000000000401568 <+24>: movsd  -0x8(%rbp),%xmm1
[debug]   0x000000000040156d <+29>: movsd  0x2a93(%rip),%xmm0        # 0x404008
[debug]   0x0000000000401575 <+37>: addsd  %xmm1,%xmm0
[debug]   0x0000000000401579 <+41>: movsd  %xmm0,-0x8(%rbp)
[debug]   0x000000000040157e <+46>: callq  0x402aa8 <getchar>
[debug]   0x0000000000401583 <+51>: cmp    $0xffffffff,%eax
[debug]   0x0000000000401586 <+54>: jne    0x401568 <main+24>
[debug]   0x0000000000401588 <+56>: movsd  -0x8(%rbp),%xmm1
[debug]   0x000000000040158d <+61>: movsd  -0x8(%rbp),%xmm0
[debug]   0x0000000000401592 <+66>: movq   %xmm0,%rdx
[debug]   0x0000000000401597 <+71>: lea    0x2a62(%rip),%rcx        # 0x404000
[debug]   0x000000000040159e <+78>: callq  0x402a90 <printf>
[debug]   0x00000000004015a3 <+83>: mov    $0x0,%eax
[debug]   0x00000000004015a8 <+88>: add    $0x30,%rsp
[debug]   0x00000000004015ac <+92>: pop    %rbp
[debug]   0x00000000004015ad <+93>: retq   
[debug]End of assembler dump.

Debugger finished with status 1

Title: Re: Debugging Exit with Error Code 1
Post by: BlueHazzard on May 17, 2020, 08:40:29 pm
You probably have a brocken gdb version...
here is probably some help for you:
http://forums.codeblocks.org/index.php/topic,23787.msg162208.html#msg162208