Modify

Ticket #3589 (closed enhancement: wontfix)

Opened 6 years ago

Last modified 3 years ago

New compile-type: release-dbg

Reported by: anonymous Owned by: janne
Priority: minor Milestone: unknown
Component: MythTV - General Version: head
Severity: medium Keywords:
Cc: cardoe@… Ticket locked: no

Description (last modified by nigel) (diff)

The attached patch adds a new compile-type which I've called release-dbg. This is a release compile with debug (-g) and utilising the .gnu_debuglink tag. The objdump man page has the details but essentially what happens is:

  • everything is built with -g
  • after linking all the debug symbols are stripped out of the binary to a .dbg file
  • a .gnu_debuglink tag is added to the binary which points to the .dbg file

This should help analysis of core files and for those instances when you really need to run the release version under gdb.

Caveats:

  • The resulting binaries are a little bit bigger (about 7%) but still not as big as a debug build
  • The optimiser is still on so whilst source level debugging is definitely possible it can be a bit hard to follow sometimes
  • To actually use the .dbg files in gdb you need to copy them to the same location of the binaries. I haven't added any logic to do this during 'make install' partially because not everyone will need them all the time, but mostly because I am lazy.
  • I don't really know what I am doing with gmake - I just hacked this in. I'm sure in its current state this patch breaks other builds (e.g. mac).

Here a little proof that it works:

myth_master mythtv # objdump -e `which mythbackend`
objdump: /usr/local/bin/mythbackend: no recognized debugging information
myth_master mythtv # find . -name "*dbg" -type f -exec ln -s `pwd`/{} /usr/local/bin \;
myth_master mythtv # gdb `which mythbackend` `pidof mythbackend`
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
<...>
Loaded symbols for /lib/libnss_files.so.2
0x00002b5e926cc852 in select () from /lib/libc.so.6
(gdb) bt
#0  0x00002b5e926cc852 in select () from /lib/libc.so.6
#1  0x00002b5e913ed8e0 in QEventLoop::processEvents () from /usr/qt/3/lib/libqt-mt.so.3
#2  0x00002b5e9144b382 in QEventLoop::enterLoop () from /usr/qt/3/lib/libqt-mt.so.3
#3  0x00002b5e9144b232 in QEventLoop::exec () from /usr/qt/3/lib/libqt-mt.so.3
#4  0x0000000000443cfe in main (argc=6, argv=<value optimized out>) at main.cpp:670
#5  0x00002b5e92634134 in __libc_start_main () from /lib/libc.so.6
#6  0x0000000000411bb9 in _start ()
(gdb) frame 4
#4  0x0000000000443cfe in main (argc=6, argv=<value optimized out>) at main.cpp:670
670         a.exec();
(gdb) list
665             }
666         }
667
668         StorageGroup::CheckAllStorageGroupDirs();
669
670         a.exec();
671
672         gContext->LogEntry("mythbackend", LP_INFO, "MythBackend exiting", "");
673         cleanup();
674
(gdb)
[1]+  Stopped                 gdb `which mythbackend` `pidof mythbackend`
myth_master mythtv # ls -la /proc/`pidof gdb`/fd/
total 0
dr-x------ 2 root root  0 Jun  9 16:50 .
dr-xr-xr-x 5 root root  0 Jun  9 16:50 ..
lrwx------ 1 root root 64 Jun  9 16:50 0 -> /dev/pts/1
lrwx------ 1 root root 64 Jun  9 16:50 1 -> /dev/pts/1
lrwx------ 1 root root 64 Jun  9 16:50 2 -> /dev/pts/1
lr-x------ 1 root root 64 Jun  9 16:50 3 -> pipe:[224917]
l-wx------ 1 root root 64 Jun  9 16:50 4 -> pipe:[224917]
lr-x------ 1 root root 64 Jun  9 16:50 5 -> /usr/local/bin/mythbackend
lr-x------ 1 root root 64 Jun  9 16:50 7 -> /root/Software/mythtv/trunk/mythtv/programs/mythbackend/mythbackend.dbg
myth_master mythtv #

Attachments

patch_release-dbg.diff (1.3 KB) - added by rd.mora@… 6 years ago.
Patch for new "release-dbg" compile-type.
patch_release-dbg.2.diff (1.3 KB) - added by rd.mora@… 6 years ago.
Updated version of previous patch
updated_release_dbg.diff (2.7 KB) - added by rd.mora@… 6 years ago.
Sorry, attached the wrong file - this is the correct one.
compile-type-apport.diff (4.7 KB) - added by laga+mythtv@… 6 years ago.
Mixed debug/release compile type - for 0.20-FIXES!

Change History

Changed 6 years ago by rd.mora@…

Patch for new "release-dbg" compile-type.

comment:1 Changed 6 years ago by rd.mora@…

Sorry, apply s/gmake/qmake/ to the 4th caveat.

comment:2 Changed 6 years ago by rd.mora@…

I forgot to mention that this required binutils 2.15 or higher - the version can be extracted from objcopy itself:

[rmora]$ objcopy -V | awk '/GNU objcopy/ {print $3}' 2.15.92.0.2 [rmora]$

Unfortunately I don't know much about adding conditional rules to qmake files... :-(

comment:3 Changed 6 years ago by nigel

  • Description modified (diff)

comment:4 Changed 6 years ago by danielk

  • Owner changed from ijr to danielk

rd.mora, can you add the binutils test to ./configure and revert to "profile" for the compile type if "release-dbg" is not supported..

Changed 6 years ago by rd.mora@…

Updated version of previous patch

comment:5 Changed 6 years ago by rd.mora@…

I've updated the patch with a quick check in configure, as requested. Please feel free to update the patch or request further updates - I am unfamiliar with all the platforms myth is compiled on so I don't know all the things I should be testing for...

Note I also ran into a problem where dlopen() was seg-faulting when the filter-manager tried to load a .dbg file I had copied to the /usr/local/lib/mythtv/filters/ directory - the patch contains a fix for this. (Ironically the .dbg files allowed me to very quickly locate the problem :-) )

Changed 6 years ago by rd.mora@…

Sorry, attached the wrong file - this is the correct one.

comment:6 Changed 6 years ago by laga+mythtv@…

As per Daniel's request, I'm attaching my patch to compile a mixed release/debug build. I'll quote my email to the mythtv-dev mailing list:


Hi,

most ready-made MythTV packages are compiled with --compile-type=release. While this is great for the vast majority of users, it's impossible to debug segfaults properly with these packages because debug symbols are stripped. Even if dbg symbols were present, gcc optimizations would render backtraces generated from them useless.

On the other hand, packages created using --compile-type=debug are slower which makes them unsuitable for environment which lack CPU ressources or where HDTV is to be displayed.

It was suggested to me in #mythtv that only certain performance-critical parts of MythTV should be optimized while other parts remain fully debugable. I have created a small patch which adds --compile-type=apport [1]. With this patch, libavcodec, libavutil, filters, libmythmpeg2, libmythsamplerate and libmythsoundtouch are compiled with -O3. Janne suggested that libs/libmythtv/RTjpegN.cpp should be optimized as well, but I have yet to figure out how to do that.


Whole thread is here: http://www.gossamer-threads.com/lists/mythtv/dev/285464

Changed 6 years ago by laga+mythtv@…

Mixed debug/release compile type - for 0.20-FIXES!

comment:7 Changed 6 years ago by janne

  • Owner changed from danielk to janne

comment:8 Changed 6 years ago by janne

(In [14517]) Refs #3589. load only executable files as filters

comment:9 Changed 6 years ago by janne

(In [14622]) Refs #3589. reverts [14517] since shared libraries aren't generally marked as executable

comment:10 Changed 5 years ago by Doug Goldstein <cardoe@…>

Just to add some more feedback to how Gentoo does things. We build out stuff with -g always, then make install into a temp directory. In here we rip out all the debug symbols and such and use .gnu_debuglink. These are then stored in /usr/lib/debug/path/to/binary.debug, where gdb knows how to load them automatically. This works on 99.99% of the tree. MythTV is one of the few packages where it just falls apart. The main reason is that the make install step actually strips. Currently we're using the profile compile type to prevent the strip and then stripping on our own at the end.

Whoever has access, please CC me on this ticket.

comment:11 Changed 5 years ago by nigel

  • Cc cardoe@… added

comment:12 Changed 5 years ago by Dibblah

  • Status changed from new to assigned

comment:13 Changed 4 years ago by stuartm

  • Component changed from mythtv to MythTV - General

comment:14 Changed 3 years ago by robertm

  • Status changed from assigned to closed
  • Resolution set to wontfix

Untouched for years. Closing.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.