Changes between Version 21 and Version 22 of AndreesStuff


Ignore:
Timestamp:
Jan 25, 2007, 4:42:39 AM (13 years ago)
Author:
andree
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AndreesStuff

    v21 v22  
    163163tools/svn2build "mondo-doc mindi mondo"
    164164}}}
    165 
    166 = Creating Backtraces =
    167 
    168 Backtraces can be very helpful when trouble-shooting issues like segmentation faults. To create a useful backtrace, you need gdb (the GNU Debugger) installed and an application (and possibly libraries) with debugging symbols built in. The following will explain how to do this.
    169 
    170 == gdb ==
    171 
    172 gdb should be part of your distribution just use your favourite way to install the package, e.g.
    173 
    174 {{{
    175 apt-get install gdb
    176 }}}
    177 
    178 for Debian and friends (such as Ubuntu) or
    179 
    180 {{{
    181 yum install gdb
    182 }}}
    183 
    184 for Fedora/RedHat/Mandriva
    185 
    186 
    187 == mondoarchive/mondorescue with debugging symbols ==
    188 
    189 To get '''mondoarchive''' and '''mondorescue''' with debugging symbols built in, you need to build from the source.
    190 
    191 Get the latest stable mondo source package from '''ftp://ftp.mondorescue.org/src/''', e.g. '''mondo-2.0.9.tar.gz''', unpack:
    192 
    193 {{{
    194 tar xvzf mondo-2.0.9.tar.gz
    195 }}}
    196 
    197 enter into the new directory and build using make:
    198 
    199 {{{
    200 cd mondo-2.0.9
    201 ./configure --prefix=/usr
    202 make
    203 }}}
    204 
    205 You will end up with binary in the following locations which are non-stripped, i.e. they contain debugging symbols:
    206 {{{
    207 file mondo/mondoarchive/mondoarchive
    208 mondo/mondoarchive/mondoarchive: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), not stripped
    209 }}}
    210 
    211 and
    212 
    213 {{{
    214 file mondo/mondorestore/mondorestore
    215 mondo/mondorestore/mondorestore: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), not stripped
    216 }}}
    217 
    218 Make backups of the original '''mondoarchive''' and '''mondorestore''' binaries and copy they newly created over the original ones.
    219 
    220 == Trouble-Shooting mondoarchive ==
    221 
    222 The best approach is to run the '''mondoarchive''' binary you just created with debugging symbols built in from its location in the built directory under gdb. So:
    223 
    224 {{{
    225 cd mondo/mondoarchive
    226 gdb ./mondoarchive
    227 run <usual arguments you use>
    228 }}}
    229 
    230 '''Note:''' Running it from within its build directory makes it so that more valuable information about source lines will be avilable in the backtrace.
    231 
    232 When the segmentation fault happens, enter:
    233 
    234 {{{
    235 bt
    236 }}}
    237 
    238 and send the output to the list.
    239 
    240 == Trouble-Shooting mondorestore ==
    241 
    242 If you do partial restore onto a live system, the same approach as described for '''mondoarchive''' can be used.
    243 
    244 However, more likely you will experience a segmentation fault during restore. To run a backtrace in that situation proceeed as follows:
    245 
    246 First, you need a '''mondorestore''' binary with debugging symbols. This should already been taken care of if you copied the newly compiled binaries as described above. Next, you need to make sure that gdb is available on your restore media. To achieve this, add this to '''/etc/mindi/deplist.txt''' before doing a mondoarchive run:
    247 
    248 {{{
    249 gdb
    250 libthread_db.so.1
    251 }}}
    252 
    253 Boot the restore media into '''expert''' mode. Then start '''mondorestore''' like this:
    254 
    255 {{{
    256 gdb /usr/sbin/mondorestore
    257 run
    258 }}}
    259 
    260 As described previously, once the segmentation fault happens, do:
    261 
    262 {{{
    263 bt
    264 }}}
    265 
    266 and send the output to the list. (If you can't get the backtrace copied as text, you can use a photo of the screen as the last resort.
    267 
    268 == Advanced Topics ==
    269 
    270 === Attaching to Running Processes ===
    271 
    272 You can attach to a running process using:
    273 
    274 {{{
    275 gdb /usr/sbin/mondorestore <pid>
    276 }}}
    277 
    278 where <pid> is the process ID.
    279 
    280 This can be particulary useful when running '''mondoarchive''' with the '-g' or when running '''mondorestore'''.
    281 
    282 === Using libraries with debugging symbols ===
    283 
    284 The libraries used by a binary can be determined using the ldd command, e.g.:
    285 
    286 {{{
    287 ldd /usr/sbin/mondoarchive
    288                 libmondo.so.2 => /usr/lib/libmondo.so.2 (0xb7f8d000)
    289         libmondo-newt.so.1 => /usr/lib/libmondo-newt.so.1 (0xb7f82000)
    290         libnewt.so.0.51 => /usr/lib/libnewt.so.0.51 (0xb7f71000)
    291         libdl.so.2 => /lib/tls/libdl.so.2 (0xb7f6e000)
    292         libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7f5f000)
    293         libc.so.6 => /lib/tls/libc.so.6 (0xb7e2a000)
    294         libslang.so.1-UTF8 => /lib/libslang.so.1-UTF8 (0xb7db7000)
    295         libm.so.6 => /lib/tls/libm.so.6 (0xb7d94000)
    296         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb7fea000)
    297 }}}
    298 
    299 some of those libraries may come with debugging symbols built in as an alternative package, others can be buiolt from scratch and installed with debugging sysmbols installed. Using your distribtuion's standard built process is probably a good idea for this.
    300 
    301 = Getting the entire kernel log on restore media =
    302 
    303 The kernel ring buffer that '''dmesg''' reads defaults to 32k on recent kernels. This is not enough to capture the entire sequence of kernel message when Mondo Rescue boots off a restore media.
    304 
    305 To increase the kernel ring buffer to 128k at boot time (and without recompilation) add the following kernel boot parameter:
    306 {{{
    307 log_buf_len=128k
    308 }}}
    309 e.g.
    310 {{{
    311 expert log_buf_len=128k
    312 }}}
    313 '''dmesg''' needs to be told what buffer size to use to ensure that everything is displayed from the start. The '''-s''' parameter can be used for this like this:
    314 {{{
    315 dmesg -s 131072 | less
    316 }}}
    317 
    318 = Worthwhile gcc Flags =
    319 -Wextra -Wshadow -Wstack-protector -fstack-protector