Author Topic: Condition Breakpoint and endless loop  (Read 236 times)

Offline battousai

  • Single posting newcomer
  • *
  • Posts: 3
Condition Breakpoint and endless loop
« on: July 30, 2020, 07:51:01 pm »


Code: [Select]
[/list]int main()
{

   for(int i=0;i<=10;i++)
    {
        printf("i=%d",i);
    }
    return 0;
}

If i want to start debug after n  iteration of the loop .
From above code . Suppose i want to start debug when i=7.
When i enter  i=7 in the "Break when expression is true" box .I got the endless loop.
How to fix this ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12739
    • Travis build status
Re: Condition Breakpoint and endless loop
« Reply #1 on: July 30, 2020, 09:49:32 pm »
Use i==7 or i>=7 for example?
You have to use C/C++ conditional in there, not assignments.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline battousai

  • Single posting newcomer
  • *
  • Posts: 3
Re: Condition Breakpoint and endless loop
« Reply #2 on: July 31, 2020, 05:52:59 am »
Use i==7 or i>=7 for example?
You have to use C/C++ conditional in there, not assignments.

When i use  i==7 or i>=7  in example .It start debug at i=0  not start at i=7 .

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12739
    • Travis build status
Re: Condition Breakpoint and endless loop
« Reply #3 on: July 31, 2020, 10:06:55 am »
Then you'll have to post the full log from the debugger. You have to enable it in the settings of the debugger.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline battousai

  • Single posting newcomer
  • *
  • Posts: 3
Re: Condition Breakpoint and endless loop
« Reply #4 on: July 31, 2020, 01:21:09 pm »
When  i=7  debug log is
Code: [Select]
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: D:\New folder\T1\
Adding source dir: D:\New folder\T1\
Adding file: D:\opt\bin\T1.exe
Changing directory to: "D:/New folder/T1/."
Set variable: PATH=.;C:\Program Files\CodeBlocks\MinGW\bin;C:\Program Files\CodeBlocks\MinGW;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Users\Battousai\AppData\Local\Microsoft\WindowsApps

[debug]Command-line: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args D:/opt/bin/T1.exe
[debug]Working dir : D:\New folder\T1

Starting debugger: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args D:/opt/bin/T1.exe
done

[debug]Reading symbols from D:/opt/bin/T1.exe...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:/New folder/T1/"
[debug]Source directories searched: D:/New folder/T1;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "D:/New folder/T1/main.c:37"
[debug]Breakpoint 2 at 0x40165a: file D:\New folder\T1\main.c, line 37.
[debug]>>>>>>cb_gdb:
[debug]> condition 2 i=7
[debug]>>>>>>cb_gdb:
[debug]> tbreak "D:/New folder/T1/main.c:36"
[debug]Temporary breakpoint 3 at 0x401651: file D:\New folder\T1\main.c, line 36.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: D:\opt\bin\T1.exe

Child process PID: 3888

[debug][New Thread 3888.0x388c]
[debug][New Thread 3888.0x3878]
[debug]Thread 1 hit Temporary breakpoint 3, main () at D:\New folder\T1\main.c:36
[debug]D:\New folder\T1\main.c:36:589:beg:0x401651
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> show language
[debug]The current source language is "auto; currently c".
[debug]>>>>>>cb_gdb:
[debug]> info locals
[debug]i = 0
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]Thread 1 hit Breakpoint 2, main () at D:\New folder\T1\main.c:38
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]Thread 1 hit Breakpoint 2, main () at D:\New folder\T1\main.c:38
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]Thread 1 hit Breakpoint 2, main () at D:\New folder\T1\main.c:38
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]Thread 1 hit Breakpoint 2, main () at D:\New folder\T1\main.c:38
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]Thread 1 hit Breakpoint 2, main () at D:\New folder\T1\main.c:38
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]Thread 1 hit Breakpoint 2, main () at D:\New folder\T1\main.c:38
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]Thread 1 hit Breakpoint 2, main () at D:\New folder\T1\main.c:38
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:

When i == 7 debug log is
Code: [Select]
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: D:\New folder\T1\
Adding source dir: D:\New folder\T1\
Adding file: D:\opt\bin\T1.exe
Changing directory to: "D:/New folder/T1/."
Set variable: PATH=.;C:\Program Files\CodeBlocks\MinGW\bin;C:\Program Files\CodeBlocks\MinGW;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Users\Battousai\AppData\Local\Microsoft\WindowsApps

[debug]Command-line: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args D:/opt/bin/T1.exe
[debug]Working dir : D:\New folder\T1

Starting debugger: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args D:/opt/bin/T1.exe
done

[debug]Reading symbols from D:/opt/bin/T1.exe...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:/New folder/T1/"
[debug]Source directories searched: D:/New folder/T1;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "D:/New folder/T1/main.c:37"
[debug]Breakpoint 2 at 0x40165a: file D:\New folder\T1\main.c, line 37.
[debug]>>>>>>cb_gdb:
[debug]> condition 2 i==7
[debug]>>>>>>cb_gdb:
[debug]> tbreak "D:/New folder/T1/main.c:36"
[debug]Temporary breakpoint 3 at 0x401651: file D:\New folder\T1\main.c, line 36.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: D:\opt\bin\T1.exe

Child process PID: 1620

[debug][New Thread 1620.0x3bd4]
[debug][New Thread 1620.0x2170]
[debug]Thread 1 hit Temporary breakpoint 3, main () at D:\New folder\T1\main.c:36
[debug]D:\New folder\T1\main.c:36:589:beg:0x401651
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> show language
[debug]The current source language is "auto; currently c".
[debug]>>>>>>cb_gdb:
[debug]> info locals
[debug]i = 0
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 0
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 0
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 1
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 1
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 2
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 2
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 3
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 3
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 4
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 4
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 5
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 5
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 6
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 6
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]Thread 1 hit Breakpoint 2, main () at D:\New folder\T1\main.c:38
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 7
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 8
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 8
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 9
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 9
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:38:623:beg:0x40165a
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:38

[debug]> info locals
[debug]i = 10
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:36:589:beg:0x40166b
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:36

[debug]> info locals
[debug]i = 10
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> step
[debug]D:\New folder\T1\main.c:40:657:beg:0x401675
[debug]>>>>>>cb_gdb:

At D:\New folder\T1\main.c:40

[debug]> info locals
[debug]No locals.
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb: