NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How to use dbg from command-line?


Joined: 29 Jul 2003
Posts: 4
Reply with quote
Hi there,

Trying to use dbg from command-line, using php-dbg-bage, php-dbg-server and pgp-dbg-client from Red Hat Linux 8.0. The output from phpinfo looks like dbg is active:

dbg
DBG php debugger, version 2.10pl3, Copyright 2001, Dmitri Dmitrienko, dd@cron.ru

Version 2.10pl3
Linked as a shared library.
Profiler compiled, disabled

Directive Local Value Master Value
debugger.enable_session_cookie
On On
debugger.enabled
On On
debugger.fail_silently
On On
debugger.ignore_nops
Off Off
debugger.JIT_enabled
On On
debugger.JIT_host
clienthost clienthost
debugger.JIT_level
3 3
debugger.JIT_port
7869 7869
debugger.profiler_enabled
Off Off
debugger.session_nocache
On On
debugger.timeout_seconds
300 300

But I cannot figure out how to start a debug session and run a php script step-by-step. Tried http://127.0.0.1/~fernando/TestePHP/info.php?DBGSESSID=1@clienthost:7869 but simply see the phpinfo page.

Tried also
$ cd ~/public_html/TestePHP
$ dbg
dbg>file info.php
Reading symbols from /home/fernando/public_html/TestePHP/info.php...done.
dbg>run
Starting program: `/home/fernando/public_html/TestePHP/info.php'

But it looks frozen. No reply from the browser, from the command-line or from telnet 127.0.0.1 7869 (connection refused).

Isn't there a quick start guide for dbg? I am used to gdb and jdb, php-dbg should't be so hard to get working! Sad
View user's profileFind all posts by lozanoSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
1. after you run dbg console you'd set HTTP mode by running
set mode on
2. setup what HTTP host to work with by running
set mapurlroot http://yourserverhost/
3. set proper document root of the HTTP host:
set mapremoteroot /your_remote_directory/
4. set proper root of the local copy of your project:
set maplocalroot /your_local_directory/

if you need CGI mode you'd run the following:
1. set mode off
2. set cgiexec /usr/local/bin/php

then you can run your script using run command.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 29 Jul 2003
Posts: 4
Reply with quote
Thanks for your help, now it looks like my script is being debugged. Here's the script:

<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Configura&ccedil;&atilde;o do PHP local</title>
</head>
<body>
<h1>Configuração do PHP local</h1>
<?php
$a = 10;
$b = "este é um teste";
echo "$b : $a";
$c = $a * 2;
phpinfo();
?>
</body>
</html>

And here's a debugging session:

[fernando@linux220 TestePHP]$ dbg
DBG php debugger, version 2.10rc2, Copyright 2001, Dmitri Dmitrienko, dd@cron.rudbg>set mode on
dbg>set mapurlroot http://127.0.0.1/~fernando
dbg>set mapremoteroot /home/fernando/public_html
dbg>set maplocalroot /home/fernando/public_html/
dbg>file info.php
Reading symbols from /home/fernando/public_html/TestePHP/info.php...done.
dbg>run
Starting program: `/home/fernando/public_html/TestePHP/info.php'
/home/fernando/public_html/TestePHP/info.php:9 </home/fernando/public_html/TestePHP/info.php::main()>
dbg>step
/home/fernando/public_html/TestePHP/info.php:10 </home/fernando/public_html/TestePHP/info.php::main()>
dbg>step
/home/fernando/public_html/TestePHP/info.php:11 </home/fernando/public_html/TestePHP/info.php::main()>
dbg>print $a
$1 = 10
dbg>step
/home/fernando/public_html/TestePHP/info.php:12 </home/fernando/public_html/TestePHP/info.php::main()>
dbg>print $b
$2 = "este é um teste"
dbg>print $c
3: Invalid expression (Undefined variable: c)
dbg>step
/home/fernando/public_html/TestePHP/info.php:13 </home/fernando/public_html/TestePHP/info.php::main()>
dbg>list
dbg>list main
dbg>list main()
dbg>list info.php
dbg>list info.php::main
dbg>cont

Now you see three problems:

1. I can't list any source line from inside dbg. Sure that's something I'm doing wrong, but I found no docs on that

2. I can't see any output from my script

3. After I use the "cont" command the debugger seems to freeze.

Thanks in advance for any hint.
View user's profileFind all posts by lozanoSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
list command is not imlemented
after you run cont you can press ctrl-C to unfreeze debugger
Displaying the output is not implemented either.

This console application is just a simplest sample that I was going to enhance but had to stopped because switched to GUI front-end.

Why don't you try phpED for Linux ?
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 29 Jul 2003
Posts: 4
Reply with quote
So I did evetything it was possible. Thanks.

Now I'm working for an organization that set rules on using open source software only, so I'll have to try all options before going to phpEd. But I work as an independent consultant and other projects do not have this restriction, I'll evaluate it as soon as time allows.

But what about the browser URL containing DBGSESSID=1@clienthost:7869, wouldn't it be possible to start a script from the browser and debug using the command-line? There isn't a way to get the output of the script debugged with DBG or DBG under DDD?
View user's profileFind all posts by lozanoSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
I was going to implement "listen" command but havn't finished it.
So, I'm sorry. No way to start script in a browser and debug it using command line debugger.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
How to use dbg from command-line?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic