This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

problem setting displays


Hi,

In a regular gdb 5.2.1 session on a Dec Alpha running the C-shell in TRUE64
Compaq unix and also in a gdb 5.0rh-15 session on my Linux RedHat 7.2 box
running the bash, I don't seem to understand how to set permanent watches
via the 'display' command. Can someone help me with the following example.
Here are two fortran files, which really do nothing harmfull or difficult:


########### file test.f runs from here ##################
      PROGRAM Test
      INTEGER i,j,k
      REAL x

      CALL MakeFun

      DO i=1,100
        x = REAL(i)
        IF (i.EQ.10) THEN
          x = x+1.
          WRITE(*,*) 'Joehoe!'
        ENDIF
      ENDDO
      END

      INCLUDE 'test2.f'
######## to here and file test2.f from here ##############
      SUBROUTINE MakeFun
      INTEGER i
      i = 5
      WRITE(*,*) 'Have fun!',i
      END
################### to here ##############################

I compiled the program with the gnu fortran compiler via:

g77 -g test.f -o test.exe

The resulting executable runs ok, and prints:

 Have fun! 5
 Joehoe!

Then I started gdb 5.2.1 on a Dec Alpha machine (at home gdb 5.0rh-15 on
RedHat 7.2 it gives more or less the same session, see below) via:

gdb -q -f

The following session took place. First I load test.exe, set a breakpoint
and a watch, run the executable and let it continue after it halted at the
breakpoint. Keep in mind that even though the ctags program suggests that
we have a main program body named "Test" (as I think it should, since I
called it that), the g77 compiler has renamed it to "MAIN__" (and in the
f2c-phase annoyingly added an underscore to all routine- and function
names):

##### (gdb) file test.exe
##### Reading symbols from test.exe...done.
##### (gdb) break test.f:9
##### Breakpoint 1 at 0x120001900: file test.f, line 9.
##### (gdb) display MAIN__::i
##### (gdb) run
##### Starting program: /home/mfo/vndijk/.neditutil/test.exe
##### Have fun! 5
#####
##### Breakpoint 1, MAIN__ () at test.f:9
#####/home/mfo/vndijk/.neditutil/test.f:9:122:beg:0x120001900
##### 1: MAIN__::i = 1
##### Current language: auto; currently fortran
##### (gdb) continue
##### Continuing.
#####
##### Breakpoint 1, MAIN__ () at test.f:9
#####/home/mfo/vndijk/.neditutil/test.f:9:122:beg:0x120001900
##### 1: MAIN__::i = 2




Now I want to add a second watch, for variable x:





##### (gdb) display MAIN__::x
##### A parse error in expression, near ':x'.




This is refused by gdb. Does gdb not want to discuss watches anymore? I
tried to inactivate the first watch:




##### (gdb) undisplay 1



No problem, watches are still negotiable for gdb. Can I re-activate the
watch that we just inactivated and which had worked the first time without
problems?




##### (gdb) display MAIN__::i
##### A parse error in expression, near ':i'.


No!
Now I just let the executable run to its end, to see if it mattered that it
was running. The first time when we successfully managed to set a watch for
variable "i", was before we gave the "run" command.




##### (gdb) clear test.f:9
##### Deleted breakpoint 1
##### (gdb) continue
##### Continuing.
##### Joehoe!
#####
##### Program exited normally.



Ok. Nothing is running now. Let's see if we can re-install the once
successful watch for "i":



##### (gdb) display MAIN__::i
##### A parse error in expression, near ':i'.


No!
What if we just reload the executable, even though there is already an
executable?



##### (gdb) file test.exe
##### Load new symbol table from "test.exe"? (y or n) y
##### Reading symbols from test.exe...done.
##### (gdb) display MAIN__::i
##### (gdb) display MAIN__::x
##### (gdb) break test.f:9
##### Breakpoint 2 at 0x120001900: file test.f, line 9.
##### (gdb) run
##### Starting program: /home/mfo/vndijk/.neditutil/test.exe
##### Have fun! 5
#####
##### Breakpoint 1, MAIN__ () at test.f:9
#####/home/mfo/vndijk/.neditutil/test.f:9:122:beg:0x120001900
##### 3: MAIN__::x = 1
##### 2: MAIN__::i = 1
##### Current language: auto; currently fortran
##### (gdb)




Now gdb all of a sudden has no problems with both i and x as watches!! This
was on the Dec Alpha. My Linux box still refuses the last watch, even after
a reload of the executable.

--> QUESTION: can someone help me here? I just want to follow watches and
be allowed to set them when they become of interest. This may well be while
the program is already running.

Thanks,

Arjan





Arjan van Dijk
Institute for Marine and Atmospheric Research Utrecht
Faculty of Physics and Astronomy
Utrecht University
Princetonplein 5
NL - 3584 CC  Utrecht
The Netherlands

phone: +31 30 2532815
fax:   +31 30 2543163
e-mail: mailto:A.vanDijk@phys.uu.nl
homepage: http://www.phys.uu.nl/~vndijk



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]