home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / gdb / bug / 895 < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.8 KB  |  64 lines

  1. Newsgroups: gnu.gdb.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!iis.ethz.ch!kells
  3. From: kells@iis.ethz.ch (Kevin Kells)
  4. Subject: problems setting breakpoint in simple program (gdb-4.5)
  5. Message-ID: <kells.711976225@iis>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH
  8. Distribution: gnu
  9. Date: Fri, 24 Jul 1992 11:10:25 GMT
  10. Approved: bug-gdb@prep.ai.mit.edu
  11. Lines: 51
  12.  
  13. On a Sun Sparc running SunOS 4.1.1, I have the following C++ program
  14. (compiled with g++ 2.0).
  15.  
  16.      1  #include <stdio.h>
  17.      2
  18.      3  main()
  19.      4  {
  20.      5    int i;
  21.      6    for (i=0; i<10; i++)
  22.      7      {
  23.      8        if (i==i)
  24.      9          printf("%d\n",i);
  25.     10      }
  26.     11    printf("Aha! %d\n",i);
  27.     12  }
  28.  
  29. In gdb 4.5, I can set a breakpoint at line 11 with "break 11". When I
  30. run the program, it prints 0 through 9 and then breaks. This is
  31. correct behavior. 
  32.  
  33. Now I have this program:
  34.  
  35.      1  #include <stdio.h>
  36.      2
  37.      3  main()
  38.      4  {
  39.      5    int i;
  40.      6    for (i=0; i<10; i++)
  41.      7      if (i==i)
  42.      8        printf("%d\n",i);
  43.      9    printf("Aha! %d\n",i);
  44.     10  }
  45.  
  46. I just took out the braces for the "for" loop. I would like once again
  47. to set a break point before printing "Aha!", so I say, "break 9".
  48. However, when I run the program, it prints 0 then breaks. When I hit
  49. "c", it prints 1 and then breaks. This continues as if gdb couldn't
  50. decide if the "Aha!" line was part of the loop or not (i.e., it breaks
  51. as if it were part, but does not execute it after I hit "c"). After
  52. finishing the count from 0 to 9, breaking after every number, it
  53. finally prints the "Aha!".
  54.  
  55. Am I doing something wrong? (besides using older versions of the compiler
  56. and gdb?) 
  57.  
  58. Kevin
  59.  
  60. --
  61. Kevin Kells <kells@iis.ethz.ch>         telephone: +41-1-256-5746
  62. Integrated Systems Laboratory, ETH-Zentrum, CH-8092 Zurich, Switzerland
  63.  
  64.