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

  1. Newsgroups: gnu.gdb.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!etherm.co.UK!mt00
  3. From: mt00@etherm.co.UK (Martin Tomes)
  4. Subject: Step/Next bug debugging single statement loops in g++
  5. Message-ID: <1247.9207220829@chough.eurotherm.co.uk>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Eurotherm Controls Limited.
  8. Distribution: gnu
  9. Date: Wed, 22 Jul 1992 08:29:13 GMT
  10. Approved: bug-gdb@prep.ai.mit.edu
  11. Lines: 109
  12.  
  13. If I compile this program:
  14.  
  15. ----------------------------------------
  16. main()
  17. {
  18.   int i;
  19.   for (i=0; i<10; i++)
  20.     printf("Hello World\n");
  21. }
  22. ----------------------------------------
  23.  
  24. With this command:
  25.  
  26. $ g++ -g -o hello hello.C
  27.  
  28. And run gdb:
  29.  
  30. GDB is free software and you are welcome to distribute copies of it
  31.  under certain conditions; type "show copying" to see the conditions.
  32. There is absolutely no warranty for GDB; type "show warranty" for details.
  33. GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
  34. (gdb) break main
  35. Breakpoint 1 at 0x196: file hello.C, line 3.
  36. (gdb) run
  37. Starting program: /chough/mt00/tmp/hello
  38.  
  39. Breakpoint 1, main () at hello.C:3
  40. 3         int i;
  41. Current Language:  auto; currently c++
  42. Type checking:     auto; currently off
  43. Range checking:    auto; currently off
  44. (gdb) next
  45. 4         for (i=0; i<10; i++)
  46. (gdb)
  47. 5           printf("Hello World\n");
  48. (gdb)
  49. Hello World
  50. Hello World
  51. Hello World
  52. Hello World
  53. Hello World
  54. Hello World
  55. Hello World
  56. Hello World
  57. Hello World
  58. Hello World
  59. 6       }
  60.  
  61. Both next and step go to the statement after the loop rather than
  62. stepping round each iteration.  If I change the code by adding {}
  63. thus:
  64.  
  65. ----------------------------------------
  66. main()
  67. {
  68.   int i;
  69.   for (i=0; i<10; i++) {
  70.     printf("Hello World\n");
  71.   }
  72. }
  73. ----------------------------------------
  74.  
  75. Compile and gdb again:
  76.  
  77. GDB is free software and you are welcome to distribute copies of it
  78.  under certain conditions; type "show copying" to see the conditions.
  79. There is absolutely no warranty for GDB; type "show warranty" for details.
  80. GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
  81. (gdb) break main
  82. Breakpoint 1 at 0x196: file hello.C, line 3.
  83. (gdb) run
  84. Starting program: /chough/mt00/tmp/hello
  85.  
  86. Breakpoint 1, main () at hello.C:3
  87. 3         int i;
  88. Current Language:  auto; currently c++
  89. Type checking:     auto; currently off
  90. Range checking:    auto; currently off
  91. (gdb) next
  92. 4         for (i=0; i<10; i++) {
  93. (gdb)
  94. 5           printf("Hello World\n");
  95. (gdb)
  96. Hello World
  97. 6         }
  98. (gdb)
  99. 5           printf("Hello World\n");
  100. (gdb)
  101. Hello World
  102. 6         }
  103.  
  104. It now works.
  105.  
  106. I am using the following:
  107.  
  108.     - An Intel 33MHz 486 EISA machine.
  109.     - ISC UNIX Version 3.0 with fix disk FD3.OS3.3
  110.     - gcc 2.2.2 untouched compiled out-of-the-box.
  111.     - gdb 4.6 with patches from the net to correct the following:
  112.         * Reading of core files.
  113.         * Mapping of the variable '.t' to 'this' so gdb can see the
  114.           this variable.
  115.  
  116. Martin Tomes
  117.  
  118. Janet:    mtomes@uk.co.eurotherm
  119. Internet: mtomes@eurotherm.co.uk
  120. UUCP:     {uknet,uunet}!etherm!mtomes
  121.  
  122.