This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Enhanced debugging info request


Hello,

Firstly apologies for the massive crossposting, I'm not sure where this
question properly belongs.  Here is my problem - I recently wrote some
code that looked something like this:

-----
for( node = start; node; node = node->next )
{	...
	{	...
	}

	{	...
		void *foo;
		foo = malloc( bar );
		for( node = node->children; node; node = node->next )
		{	...
		}
		free( foo );
	}
}
return bar;
-----

Now, it should be obvious that there is a problem with this code. 
However, when you replace all the "..." with real C statements, the
problem is not so obvious.  The program would crash, leave a core file,
and gdb states the problem is at the "}" on the third to last line,
immediately following the free().

I understand why this is where it crashes knowing what the problem is,
but from a source file perspective it is wrong - gdb should report the
problem being in the outer for loop (trying to access a NULL
node[->next]).  I'm not sure if this information is there but gdb
doesn't handle it correctly, or if the information gcc provides for
debugging is insufficient for gdb to locate this.

Either way, it seems to be a deficiency I would like to bring to
everyone's attention; hopefully it is a problem that can be fixed
painlessly.  fwiw, I'm running Debian woody:

ccurtis@eclipse:~$ gcc --version
2.95.2
ccurtis@eclipse:~$ gdb --version
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or 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.
This GDB was configured as "i686-pc-linux-gnu".

Thanks,
Christopher

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]