Отладка с gdb и strace

IDE, VCS и прочее

Модератор: Модераторы разделов

IMB
Сообщения: 2567
ОС: Debian

Отладка с gdb и strace

Сообщение IMB »

Доболго дня!
Есть программа:

user@localhost

$ file onvif onvif: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped

При обычном запуске я получаю Segmentation fault.

strace

..................................... open("accesspolicy.gsoap", O_RDONLY|O_LARGEFILE) = 3 read(3, "<?xml version=\"1.0\" encoding=\"UTF"..., 65536) = 2115 read(3, ""..., 63421) = 0 close(3) = 0 open("certificates.gsoap", O_RDONLY|O_LARGEFILE) = 3 read(3, "<?xml version=\"1.0\" encoding=\"UTF"..., 65536) = 2113 read(3, ""..., 63423) = 0 close(3) = 0 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++

gdb

# ./gdb ./onvif -n Could not find platform independent libraries <prefix> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] 'import site' failed; use -v for traceback GNU gdb (GDB) 7.0.1 Copyright © 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "arm-linux". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /opt/onvif...done. (gdb) run Starting program: /opt/onvif warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. Program exited normally.

Почему при запуске из gdb я вижу Program exited normally?
Спасибо.
Спасибо сказали:
Аватара пользователя
Portnov
Модератор
Сообщения: 1786
Статус: Матёрый линуксоид
ОС: Debian testing/unstable

Re: Отладка с gdb и strace

Сообщение Portnov »

Прогоните ещё valgrind на ней. Скорее всего, в программе происходит считывание из неинициализированной памяти, отсюда всякий undefined behaivour (в т.ч. сегфолт). А отладчики перед загрузкой программы инициализируют отводимую ей память нулями.
Работа: Ubuntu 9.10
Дом: Debian testing/unstable и на всякий случай winxp в virtualbox.
Для разнообразия: моя домашняя страница -http://iportnov.ru
Спасибо сказали: