question on conditional breakpoint in using gdb
Hi, friends:
I'm trying to use GNU gdb to detect a floating exception in my code. That exception occurs only when my time step is 2520 and iteration step is 3. So I have to wait a very long time(one day) to reach that exception point. Seems there is a trick called "conditional breakpoint" in gdb. Below is a brief fram of my code: c------------------------- c program my_prog 1 do it=1, it_max 2 do iter=1,iter_max 3 4 some tri-diagonal solver stuff 5 6 some convergence creterion 7 enddo 8 enddo 9 end c------------------------- I launch the gdb, and run the program, then I want to use the following GDB command to put a conditional breakpoint on line 1: //-------- break 1 if it.ge.2520 //-------- it gives me back an error message saying: //---- No symbol "it" in current context. //---- Seems that the gdb doesn't recognize the variable "it" for me. What's the metter? I looked into some manu of gdb, saying that it's because "it" is out of the scope of something, but I don't quite understand and don't know how to get through. Thank you very much if you can give me a hand. wen long |
Re: question on conditional breakpoint in using gd
You are likely to get a much better response posting this to a gnu/gcc/cc/... newsgroup.
I do not use gdb (i.e. I do not know if your command syntax/semantics is OK) but your code looks like Fortran and the added line some C/Fortran hybrid? If you have not built a symbol table then the debugger will not be able to do much when you refer to "it". A symbol table is not usually built by default. Have you passed the "-g" flag when you compiled? I would suggest better options for understanding your problems are: (a) read the core file to find where and why the exception occurred. This is usually sufficient to find the odd underflow/overflow/divide_by_zero exceptions. (b) add exception handlers (routines to be called when an exception occurs). This is the most flexible solution enabling you to do pretty much whatever you want. |
Re: question on conditional breakpoint in using gd
Dear Andy:
Thanks for your reply. I did use -g option to enable the gdb. My code is purely Fortran, not easy to hook some exception handler onto it. There is a core file generated, but I don't know how to open it. Can you give more directions? Thanks again, Wen |
Re: question on conditional breakpoint in using gd
>> My code is purely Fortran, not easy to hook some exception handler onto it.
On the unix workstations that I have used it has always been very easy to add exception handlers to Fortran code. A quick google is a bit negative for g77 though: http://www.delorie.com/gnu/docs/g77/g77_630.html It looks doable but messy. >> There is a core file generated, but I don't know how to open it. Can you give more directions? "man gdb" says the command is "gdb -c core" |
Re: question on conditional breakpoint in using gd
Andy, Thanks a lot. Now I got the basic idea. The gdb I'm using doesn't support variables stored in common blocks or EQUIVALENCE. While I'm using many many common blocks.
That's why when I use "p it", it doesn't show me the value of variable "it" since it's in a common block. Wen |
All times are GMT -4. The time now is 23:56. |