home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gdb.bug
- Path: sparky!uunet!cis.ohio-state.edu!etherm.co.UK!mt00
- From: mt00@etherm.co.UK (Martin Tomes)
- Subject: Step/Next bug debugging single statement loops in g++
- Message-ID: <1247.9207220829@chough.eurotherm.co.uk>
- Sender: gnulists@ai.mit.edu
- Organization: Eurotherm Controls Limited.
- Distribution: gnu
- Date: Wed, 22 Jul 1992 08:29:13 GMT
- Approved: bug-gdb@prep.ai.mit.edu
- Lines: 109
-
- If I compile this program:
-
- ----------------------------------------
- main()
- {
- int i;
- for (i=0; i<10; i++)
- printf("Hello World\n");
- }
- ----------------------------------------
-
- With this command:
-
- $ g++ -g -o hello hello.C
-
- And run gdb:
-
- GDB is free software and you are welcome to distribute copies of it
- under certain conditions; type "show copying" to see the conditions.
- There is absolutely no warranty for GDB; type "show warranty" for details.
- GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
- (gdb) break main
- Breakpoint 1 at 0x196: file hello.C, line 3.
- (gdb) run
- Starting program: /chough/mt00/tmp/hello
-
- Breakpoint 1, main () at hello.C:3
- 3 int i;
- Current Language: auto; currently c++
- Type checking: auto; currently off
- Range checking: auto; currently off
- (gdb) next
- 4 for (i=0; i<10; i++)
- (gdb)
- 5 printf("Hello World\n");
- (gdb)
- Hello World
- Hello World
- Hello World
- Hello World
- Hello World
- Hello World
- Hello World
- Hello World
- Hello World
- Hello World
- 6 }
-
- Both next and step go to the statement after the loop rather than
- stepping round each iteration. If I change the code by adding {}
- thus:
-
- ----------------------------------------
- main()
- {
- int i;
- for (i=0; i<10; i++) {
- printf("Hello World\n");
- }
- }
- ----------------------------------------
-
- Compile and gdb again:
-
- GDB is free software and you are welcome to distribute copies of it
- under certain conditions; type "show copying" to see the conditions.
- There is absolutely no warranty for GDB; type "show warranty" for details.
- GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
- (gdb) break main
- Breakpoint 1 at 0x196: file hello.C, line 3.
- (gdb) run
- Starting program: /chough/mt00/tmp/hello
-
- Breakpoint 1, main () at hello.C:3
- 3 int i;
- Current Language: auto; currently c++
- Type checking: auto; currently off
- Range checking: auto; currently off
- (gdb) next
- 4 for (i=0; i<10; i++) {
- (gdb)
- 5 printf("Hello World\n");
- (gdb)
- Hello World
- 6 }
- (gdb)
- 5 printf("Hello World\n");
- (gdb)
- Hello World
- 6 }
-
- It now works.
-
- I am using the following:
-
- - An Intel 33MHz 486 EISA machine.
- - ISC UNIX Version 3.0 with fix disk FD3.OS3.3
- - gcc 2.2.2 untouched compiled out-of-the-box.
- - gdb 4.6 with patches from the net to correct the following:
- * Reading of core files.
- * Mapping of the variable '.t' to 'this' so gdb can see the
- this variable.
-
- Martin Tomes
-
- Janet: mtomes@uk.co.eurotherm
- Internet: mtomes@eurotherm.co.uk
- UUCP: {uknet,uunet}!etherm!mtomes
-
-