Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: nadja on October 31, 2022, 09:15:57 am

Title: Debugger isn't working
Post by: nadja on October 31, 2022, 09:15:57 am
I've a problem with debugger in Code::Blocks. I add a breakpoint, start debugger but as soon as it takes input, it closes with following message:
Code
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: D:\NADJA\Zadaca_iz_programiranja\Nova\Stringovi\4\
Adding source dir: D:\NADJA\Zadaca_iz_programiranja\Nova\Stringovi\4\
Adding file: D:\NADJA\Zadaca_iz_programiranja\Nova\Stringovi\4\bin\Debug\4.exe
Changing directory to: D:/NADJA/Zadaca_iz_programiranja/Nova/Stringovi/4/.
Set variable: PATH=.;C:\MinGW\bin;C:\MinGW;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\EC\AppData\Local\Programs\Python\Python310\Scripts;C:\Users\EC\AppData\Local\Programs\Python\Python310;C:\Users\EC\AppData\Local\Microsoft\WindowsApps;C:\Users\EC\AppData\Local\GitHubDesktop\bin

[debug]Command-line: C:\Program Files (x86)\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args D:/NADJA/Zadaca_iz_programiranja/Nova/Stringovi/4/bin/Debug/4.exe
[debug]Working dir : D:\NADJA\Zadaca_iz_programiranja\Nova\Stringovi\4

Starting debugger: C:\Program Files (x86)\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args D:/NADJA/Zadaca_iz_programiranja/Nova/Stringovi/4/bin/Debug/4.exe
done

[debug]Reading symbols from D:\NADJA\Zadaca_iz_programiranja\Nova\Stringovi\4\bin\Debug\4.exe...(no debugging symbols found)...done.
[debug](gdb)
[debug]> set prompt >>>>>>cb_gdb:

Setting breakpoints

[debug]>>>>>>cb_gdb:
[debug]> show version

Reading symbols from D:\NADJA\Zadaca_iz_programiranja\Nova\Stringovi\4\bin\Debug\4.exe...(no debugging symbols found)...done.

[debug]GNU gdb (GDB) 7.6.1
[debug]Copyright (C) 2013 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 "mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.6.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]No symbol table is loaded.  Use the "file" command.
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory D:/NADJA/Zadaca_iz_programiranja/Nova/Stringovi/4/
[debug]Source directories searched: D:/NADJA/Zadaca_iz_programiranja/Nova/Stringovi/4;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "D:/NADJA/Zadaca_iz_programiranja/Nova/Stringovi/4/main.cpp:16"
[debug]No symbol table is loaded.  Use the "file" command.
[debug]Breakpoint 2 ("D:/NADJA/Zadaca_iz_programiranja/Nova/Stringovi/4/main.cpp:16") pending.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: D:/NADJA/Zadaca_iz_programiranja/Nova/Stringovi/4/bin/Debug/4.exe

Child process PID: 8668

[debug][New Thread 8668.0x46a8]
[debug][New Thread 8668.0x3988]
[debug][New Thread 8668.0x53b0]
[debug][New Thread 8668.0x2e3c]
[debug][Inferior 1 (process 8668) exited normally]
[debug]>>>>>>cb_gdb:

[Inferior 1 (process 8668) exited normally]

[debug]> quit

Debugger finished with status 0

This is the code:

(It's about finding the longest word in the sentence, and printing the length of it. Program works perfectly fine, but I just wanted to check if debugger works, and it doesn't)

Code
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string sentence;
    getline(cin,sentence);
    char word[50];
    int maxi=0,br=0,j;
    for(j=0;j<sentence.length();j++)
    {
        if(sentence[j]!=' ')
            br++;
        if(sentence[j]==' ' || j==sentence.length()-1)
        {
            if(br>maxi){
                maxi=br;
                sentence.copy(word,br,j-br+1);
                word[br]='\0';
            }
            br=0;
        }
    }
    cout<<maxi<<endl<<word;
    return 0;
}

-g flag is set. I typed the sentence and hit enter, but it just exited the debugger. I tried following several tutorials, but everything is set as it should be. It just doesn't work. Thank you in advance
Title: Re: Debugger isn't working
Post by: ollydbg on October 31, 2022, 03:39:52 pm
In the log message, I see this line:

"no debugging symbols found".

This means you are not using the "-g" option for the compiler, so you can't debug the output exe file.

Do you use the "Release" build?
Title: Re: Debugger isn't working
Post by: stahta01 on October 31, 2022, 09:59:09 pm
In the log message, I see this line:

"no debugging symbols found".

This means you are not using the "-g" option for the compiler, so you can't debug the output exe file.

Do you use the "Release" build?

I do not use the debugger, but, I think it can also mean the strip option is set I think that is "-s" but it might be something diffferrent.

Tim S.
Title: Re: Debugger isn't working
Post by: nadja on November 01, 2022, 08:15:33 pm
It suddenly started working, and I've just restarted my computer. Thank you nevertheless.