我通過在命令行鍵入php -a
以交互方式使用PHP。我修改了/etc/php5/cli/php.ini來加載我使用SWIG構建的擴展模塊。在交互式會話中詳細運行PHP
當我終止交互式會話,我得到一個分段錯誤:
[email protected]:~$ php -a
Interactive shell
php > ^DSegmentation fault
[email protected]:~$
我想在詳細模式下運行PHP的,這樣我可以看到,導致了賽格故障的電話。有沒有辦法在交互模式下運行php?例如,使用Python,可以運行python -v
以獲取詳細的診斷信息。有沒有PHP的等價物?
[更新]
這裏是一個堆棧跟蹤使用的valgrind時:
[email protected]:~$ USE_ZEND_ALLOC=0 valgrind php -a
==16414== Memcheck, a memory error detector
==16414== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==16414== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==16414== Command: php -a
==16414==
valgrind: Fatal error at startup: a function redirection
valgrind: which is mandatory for this platform-tool combination
valgrind: cannot be set up. Details of the redirection are:
valgrind:
valgrind: A must-be-redirected function
valgrind: whose name matches the pattern: strlen
valgrind: in an object with soname matching: ld-linux-x86-64.so.2
valgrind: was not found whilst processing
valgrind: symbols from the object with soname: ld-linux-x86-64.so.2
valgrind:
valgrind: Possible fixes: (1, short term): install glibc's debuginfo
valgrind: package on this machine. (2, longer term): ask the packagers
valgrind: for your Linux distribution to please in future ship a non-
valgrind: stripped ld.so (or whatever the dynamic linker .so is called)
valgrind: that exports the above-named function using the standard
valgrind: calling conventions for this platform. The package you need
valgrind: to install for fix (1) is called
valgrind:
valgrind: On Debian, Ubuntu: libc6-dbg
valgrind: On SuSE, openSuSE, Fedora, RHEL: glibc-debuginfo
valgrind:
valgrind: Cannot continue -- exiting now. Sorry.
對於有用的信息+1。我現在使用gdb,但我想使用valgrind。我已經接受了你的回答,但是當我按照建議運行valgrind時,更新了我得到的錯誤。請在有空的時候看看並回復。謝謝。 –
@HomunculusReticulli你應該嘗試一下錯誤信息的建議,例如'sudo apt-get install libc6-dbg'(如果在Ubuntu上)。似乎你錯過了某種調試符號(雖然我不知道它到底需要什麼)。 – NikiC
k,謝謝。我會嘗試的。 –