Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!IVY.UCDAVIS.EDU!how From: how@IVY.UCDAVIS.EDU (W. Wilson Ho) Newsgroups: gnu.gdb.bug Subject: error with one line function Message-ID: <8909151937.AA27107@ivy.ucdavis.edu> Date: 15 Sep 89 19:37:47 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 96 Consider the following one line program: ---------------------------------------------------------------------- how@ivy:55> cat test.c main () {printf ("hello world \n");} how@ivy:56> gcc -g test.c how@ivy:57> gdb a.out GDB 3.2, Copyright (C) 1988 Free Software Foundation, Inc. There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details. GDB is free software and you are welcome to distribute copies of it under certain conditions; type "info copying" to see the conditions. Reading symbol data from /usr/home/how/work/a.out...done. Type "help" for a list of commands. (gdb) list Reading in symbols for test.c...done. 1 main () {printf ("hello world \n");} (gdb) b main Breakpoint 1 at 0x20c0: file test.c, line 1. (gdb) run Starting program: /usr/home/how/work/a.out Bpt 1, 0x20c0 in mswitchfp_ () (gdb) step Current function has no line number information. Single stepping until function exit. 0x20d8 in mswitchfp_ () (gdb) step Current function has no line number information. Single stepping until function exit. 0x2046 in start () (gdb) cont Continuing. hello world Program exited normally. (gdb) quit how@ivy:58> ---------------------------------------------------------------------- Obviously gdb loses track of relationship between the line number in the source file and the actual memory address in the inferior process. The error happens on both Sun's and Vaxes. But dbx handles this correctly. However, only for the Sun's, if I compile the program with /bin/cc, both gdb and dbx work correctly. When I rewrite the program by splitting it into several lines, gdb works ok: ---------------------------------------------------------------------- how@ivy:59> cat test.c main () { printf ("hello world \n"); } how@ivy:60> gcc -g test.c how@ivy:61> gdb a.out GDB 3.2, Copyright (C) 1988 Free Software Foundation, Inc. There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details. GDB is free software and you are welcome to distribute copies of it under certain conditions; type "info copying" to see the conditions. Reading symbol data from /usr/home/how/work/a.out...done. Type "help" for a list of commands. (gdb) list Reading in symbols for test.c...done. 1 main () { 2 printf ("hello world \n"); 3 } (gdb) b main Breakpoint 1 at 0x20b2: file test.c, line 2. (gdb) r Starting program: /usr/home/how/work/a.out Bpt 1, main () (test.c line 2) 2 printf ("hello world \n"); (gdb) s hello world 3 } (gdb) s 0x20be in main () (test.c line 3) 3 } (gdb) cont Continuing. Program exited normally. (gdb) quit ---------------------------------------------------------------------- It seems that either gcc is not generating the correct debugging symbol table information, or there is a bug in gdb. Wilson Ho