tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: .debug objects build rule need some care



On Sun, Jul 18, 2010 at 08:20:51AM +0000, Julio M. Merino Vidal wrote:
> On Wed, May 26, 2010 at 05:28:57PM +0200, Nicolas Joly wrote:
> > 
> > Hi,
> > 
> > After some closer examination to the debug objects build rule, i do
> > see the following problems :
> > 
> > 1) The generated .debug objects needs to have a newer timestamp than
> >    the sources. Which currently cannot be guaranteed due to source
> >    being modified after target generation.
> > 
> > 2) The second objcopy call, if failing, will mostly remains unnoticed
> >    because of the rm call which will return a `good' status.
> > 
> > Do the attached patch, which aims at fixing both, look acceptable ?
> 
> The touch call seems a gross hack.  What I think you should do is change all
> commands to create and work on a ${target-name}.tmp file and, as the very
> last command, do a "mv ${target-name}.tmp ${target-name}".  This way you
> ensure that the target file is never in an inconsistent state -- only the
> .tmp file (or whatever you wanna call it) can be bogus.

Ack, but i now rembember why i did it that way ...

With the following construct, it won't work as the .gnu_debuglink
section will record the file name to be opened for loading the debug
symbols ... x.debug.tmp instead of installed x.debug file.

${_PROGDEBUG.${_P}}: ${_P}
        ${_MKTARGET_CREATE}
        ${OBJCOPY} --only-keep-debug ${_P} ${_PROGDEBUG.${_P}}.tmp
        ${OBJCOPY} --strip-debug \
            -R .gnu_debuglink
        --add-gnu-debuglink=${_PROGDEBUG.${_P}}.tmp ${_P}
        mv ${_PROGDEBUG.${_P}}.tmp ${_PROGDEBUG.${_P}}

njoly@lanfeust [~]> objdump -s /bin/df
Contents of section .gnu_debuglink:
 0000 64662e64 65627567 2e746d70 00000000  df.debug.tmp....
 0010 fd548672                             .T.r            

njoly@lanfeust [~]> ktrace -di gdb df
[...]
njoly@lanfeust [~]> kdump
[...]
  8389      1 gdb      CALL  open(0x7f7fffffd770,0,0)
  8389      1 gdb      NAMI  "/bin/df.debug.tmp"
  8389      1 gdb      RET   open -1 errno 2 No such file or directory
  8389      1 gdb      CALL  open(0x7f7fffffd770,0,0)
  8389      1 gdb      NAMI  "/bin/.debug/df.debug.tmp"
  8389      1 gdb      RET   open -1 errno 2 No such file or directory
  8389      1 gdb      CALL  open(0x7f7fffffd770,0,0)
  8389      1 gdb      NAMI  "/usr/libdata/debug//bin/df.debug.tmp"
  8389      1 gdb      RET   open -1 errno 2 No such file or directory

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.


Home | Main Index | Thread Index | Old Index