C++Guns – RoboBlog

13.09.2018

FORTRAN: GDB conditional watchpoint

Filed under: Allgemein — Tags: — Thomas @ 13:09

To set a conditional watchpoint on local variable i.
Example Code:

subroutine func
  integer :: i

  do i=1, 100
    write(*,*) i
  end do
end subroutine

program test
  implicit none

  call func()
end program

Compile with -ggdb
Set a breakpoint on subroutine "func". After the debugger stop on this point, the local variable "i" is in scope so one can set a watchpoint.

$ gdb ./example
(gdb) break func
Breakpoint 1 at 0x8bb: file gdb.F90, line 4.

ODER
(gdb) break example.F90:4

(gdb) run
Starting program: /home/kater/example
Breakpoint 1, func () at example.F90:4
4 do i=1, 100
(gdb) watch i if i.gt.10
Hardware watchpoint 2: i
(gdb) c
continuing.
1
2
3
4
5
6
7
8
9
10

Hardware watchpoint 2: i

Old value = 10
New value = 11
0x0000555555554948 in func () at gdb.F90:4
4 do i=1, 100

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress