Use GDB to debug PHP programs

Source: Internet
Author: User

 

There is a PHP program. The command line execution is as follows:

[Root @ h10-vm08 demo] # PHP parsefile. php XXXX. ykml
* ** Glibc detected ** free (): Invalid Pointer: 0xb7869b7c ***
Aborted
[Root @ h10-vm08 demo] #

 

The so file of PHP extension called by this PHP program has an invalid access pointer error, but where does the error occur? It is most convenient to use GDB to locate such problems.

 

[Root @ h10-vm08 demo] # GDB PHP

(GDB) Run parsefile. php XXXX. ykml

Starting program:/home/y/bin/PHP parsefile. php XXXX. ykml
[Thread Debugging Using libthread_db enabled]
[New thread-1208723776 (lwp 3225)]
* ** Glibc detected ** free (): Invalid Pointer: 0xb783cbc4 ***

Program received signal SIGABRT, aborted.
[Switching to thread-1208723776 (lwp 3225)]
0x005847a2 in _ dl_sysinfo_int80 () from/lib/ld-linux.so.2
(GDB)

(GDB) BT
#0 0x005847a2 in _ dl_sysinfo_int80 () from/lib/ld-linux.so.2
#1 0x004477a5 in raise () from/lib/tls/libc. so.6
#2 0x00449209 in abort () from/lib/tls/libc. so.6
#3 0x0047b71a in _ libc_message () from/lib/tls/libc. so.6
#4 0x00481fbf in _ int_free () from/lib/tls/libc. so.6
#5 0x0048233a in free () from/lib/tls/libc. so.6
#6 0x02f37b56 in fbmlstylesheet: translateurl () from/home/y/lib/PHP/20060613/fbml. So
#7 0x02f0000a5 in cssparserimpl: parseurl () from/home/y/lib/PHP/20060613/fbml. So
#8 0x02f44585 in cssparserimpl: parsevariant () from/home/y/lib/PHP/20060613/fbml. So
#9 0x02f461c0 in cssparserimpl: parsesinglevalueproperty () from/home/y/lib/PHP/20060613/fbml. So

......

 

 

In this way, the stack trajectory is obtained and the function with an error is located.

 

 

Breakpoint:

(GDB) B 'cssparserimpl: parseurl (unsigned Int &, nscssvalue &)'

 

This function stops running the program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.