[phc-general] Debugging plugins
Paul Biggar
paul.biggar at gmail.com
Thu Aug 3 17:54:24 CEST 2006
Hi Satyam,
On 8/3/06, Satyam <Satyam at satyam.com.ar> wrote:
> After years absolutely spoiled by fancy IDEs, I wonder if gdb is the best
> there is and, even if so, how could I go onto debug a plugin which is not
> loaded at the time the program starts. I can get used to gdb, like in the
> good old days of command lines (after all I even punched cards) but how
> could I put breakpoints in my plugin before it is plugged escapes me. And
> all these is assuming the symbols are being generated, which I don't know if
> they are or how to do it if they are not.
Assuming both the application and the plugins are compiled with
debugging symbols, there is no reason you can't use gdb. phc is
compiled with -g (enable debugging symbols) by default. To enable this
in your plugins, follow this example to debug the
source_vs_semantic_values test plugin, distributed with phc in the
plugins/tests/ directory:
./phc_compile_plugin -g -o source_vs_semantic_values.so
source_vs_semantic_values.cpp
Here is a sample gdb session:
pbiggar at godiva ~/svn/postgrad/projects/phc/trunk/src $ gdb phc
GNU gdb 6.4-debian
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...Using host libthread_db
library "/lib/tls/i686/cmov/libthread_db.so.1".
(gdb) b source_vs_semantic_values.cpp:33
No source file named source_vs_semantic_values.cpp.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (source_vs_semantic_values.cpp:33) pending.
(gdb) run --run plugins/tests/source_vs_semantic_values.so
tests/subjects/general/variable_name.php
Starting program:
/home/pbiggar/svn/postgrad/projects/phc/trunk/src/phc --run
plugins/tests/source_vs_semantic_values.so
tests/subjects/general/variable_name.php
[Thread debugging using libthread_db enabled]
[New Thread -1225374016 (LWP 7507)]
warning: Lowest section in /usr/lib/libicudata.so.34 is .hash at 00000094
Breakpoint 2 at 0xb7efb26c: file source_vs_semantic_values.cpp, line 33.
Pending breakpoint "source_vs_semantic_values.cpp:33" resolved
<?php
$success = true;
[Switching to Thread -1225374016 (LWP 7507)]
Breakpoint 2, Get_source_and_semantic_values::print_comparison (this=0xbfe1210c,
type=0x8241148, value=0x8265130, source=0x8258010)
at source_vs_semantic_values.cpp:41
41 source->c_str(),
source->c_str(), source->c_str());
(gdb)
Note that gdb is incredible, and defers the breakpoint until the
plugin is loaded.
> By the way, if anyone has any sugestion for debugger, I have a Debian Linux
> on a i86 machine.
Eclipse has a very nice debugger, and it can use gdb if you use the
CDT tools. I havent used this with phc, but I tried briefly debugging
gcc with it, which proved more than my machine could take. It
shouldn't have any problem with phc, however. I'm not sure what
version is in the debian repositories, but it's probably worth using
the calisto release 3.2 of eclipse, rather than an older version
through apt.
Another alternative is ddd, which uses gdb aswell.
Paul
--
Paul Biggar
paul.biggar at gmail.com
More information about the phc-general
mailing list