Re: [PATCH 2/3] Consistently use BFD's time

Tom Tromey
2020-07-21T19:39:32Z

>>>>> "Pedro" == Pedro Alves via Gdb-patches <gdb-patches@sourceware.org> writes:

Pedro> Can you clarify what do you see not work? I tried rebasing it
Pedro> here, and it seems to work.

I don't remember any more. It doesn't seem important anyway.

Pedro> I've also added an #error in case something pulls in sys/stat.h
Pedro> before we get to defs.h. I think that if that happens due to
Pedro> some include in common-defs.h pulling sys/stat.h (say,
Pedro> libiberty.h ever exports some API using struct stat), then it
Pedro> would likely be exposing a problem similar to the bfd.h one, in
Pedro> that we should be calling such an API with the stat that
Pedro> libiberty was built against.

I think we still have the problem where we must to be careful to avoid
comparing mtime-from-bfd against mtime-from-gnulib. I think this does
occur in gdb. In particular in source-cache.c:

if (mtime && mtime < st.st_mtime)
warning (_("Source file is more recent than executable."));

mtime comes from BFD, but st.st_mtime comes from gnulib.

Pedro> Hopefully that won't
Pedro> happen -- external interfaces using "struct stat" are a really bad idea,
Pedro> as this whole thread shows...

I think it's more a self-caused problem, in that gnulib assumes that it
can freely replace anything, but on the other hand gdb relies on
libraries that do not follow this same model.

Tom