home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gdb.bug
- Path: sparky!uunet!cis.ohio-state.edu!iis.ethz.ch!kells
- From: kells@iis.ethz.ch (Kevin Kells)
- Subject: problems setting breakpoint in simple program (gdb-4.5)
- Message-ID: <kells.711976225@iis>
- Sender: gnulists@ai.mit.edu
- Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH
- Distribution: gnu
- Date: Fri, 24 Jul 1992 11:10:25 GMT
- Approved: bug-gdb@prep.ai.mit.edu
- Lines: 51
-
- On a Sun Sparc running SunOS 4.1.1, I have the following C++ program
- (compiled with g++ 2.0).
-
- 1 #include <stdio.h>
- 2
- 3 main()
- 4 {
- 5 int i;
- 6 for (i=0; i<10; i++)
- 7 {
- 8 if (i==i)
- 9 printf("%d\n",i);
- 10 }
- 11 printf("Aha! %d\n",i);
- 12 }
-
- In gdb 4.5, I can set a breakpoint at line 11 with "break 11". When I
- run the program, it prints 0 through 9 and then breaks. This is
- correct behavior.
-
- Now I have this program:
-
- 1 #include <stdio.h>
- 2
- 3 main()
- 4 {
- 5 int i;
- 6 for (i=0; i<10; i++)
- 7 if (i==i)
- 8 printf("%d\n",i);
- 9 printf("Aha! %d\n",i);
- 10 }
-
- I just took out the braces for the "for" loop. I would like once again
- to set a break point before printing "Aha!", so I say, "break 9".
- However, when I run the program, it prints 0 then breaks. When I hit
- "c", it prints 1 and then breaks. This continues as if gdb couldn't
- decide if the "Aha!" line was part of the loop or not (i.e., it breaks
- as if it were part, but does not execute it after I hit "c"). After
- finishing the count from 0 to 9, breaking after every number, it
- finally prints the "Aha!".
-
- Am I doing something wrong? (besides using older versions of the compiler
- and gdb?)
-
- Kevin
-
- --
- Kevin Kells <kells@iis.ethz.ch> telephone: +41-1-256-5746
- Integrated Systems Laboratory, ETH-Zentrum, CH-8092 Zurich, Switzerland
-
-