public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* RFC: include mod time and size in DWARF file name table
@ 2013-01-12 13:24 Martin Runge
  2013-01-13  4:19 ` John Gilmore
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Runge @ 2013-01-12 13:24 UTC (permalink / raw)
  To: gdb; +Cc: Martin Runge

Hi all,

The DWARF standard seems to have fields for the modification time and
file size of each source file that was used to build a binary.
Standard tools like readelf and objdump will display them but by
default, gcc fills the with zero (except for VMS targets):

readelf -wl dwarftest1

.....
 The File Name Table:
  Entry Dir     Time    Size    Name
  1     1       0       0       dwarftest1.cpp
  2     2       0       0       iostream
  3     2       0       0       cstddef
  4     2       0       0       cwchar
....

I patched gcc ( gas from binutils, to more precise ) to fill in
modification time and file size of the source files. The result:

readelf -wl dwarftest1

....
 The File Name Table:
  Entry Dir     Time    Size    Name
  1     1       1352976872      149     dwarftest1.cpp
  2     2       1353406399      2665    iostream
  3     3       1353406307      12542   stddef.h
  4     2       1353406399      1838    cstddef
  5     2       1353406399      6665    cwchar
....

This information can be used to check, if one is debugging the right
source file, or if the source file has changed since compilation,
which leads to displaced stepping and other strange errors.

It can also be used to detect errors like the following:
a program that links to a library and the library itself have been
compiled using different versions of the header files that specify the
library's interface, e.g. data types passed from one to the other.

So why do I post this in gdb ML since GCC/binutils fill in this information?

There are comments in the GCC sources that explain, that GCC fills in
zeros instead of time and size, because some debuggers stop working
correctly when this information is present.

Is this still valid? I think, for gdb and Linux targets its not true.
I have started developing a gdb patch that will check source files
based on the time and size information before setting breakpoints
there or displaying the source.

Does anybody see any problems with this approach that I just havn't
run into yet? And if it works, would the gdb developers support a
change request to GCC/binutils?

regards
Martin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-01-15 17:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-12 13:24 RFC: include mod time and size in DWARF file name table Martin Runge
2013-01-13  4:19 ` John Gilmore
2013-01-13  5:54   ` Joel Brobecker
2013-01-14 12:31     ` Martin Runge
2013-01-15 17:51       ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).