Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bug fix; doc update

  • Loading branch information...
commit 94f9fa304e4452469f3cda5f4176e25f8d8a54aa 1 parent 526110b
U-brook-PC\brook authored
Showing with 57 additions and 33 deletions.
  1. +41 −8 README.markdown
  2. +16 −25 plugin/debugger.py
View
49 README.markdown
@@ -1,4 +1,4 @@
-This is a plugin to enable php debug in VIM with Xdebug, which originates from http://www.vim.org/scripts/script.php?script_id=1152.
+This is a plugin to enable php debug in VIM with Xdebug, which originates from http://www.vim.org/scripts/script.php?script\_id=1152.
But most of the code, especially the debugger engine has been rewritten.
@@ -8,7 +8,7 @@ But most of the code, especially the debugger engine has been rewritten.
So that VIM users do not need to wait for connection from apache server. No timeout things, users press F5 to start debugger engine, and uses his/her VIM normally. Debug engine won't stop users to interact with VIM. Users can press F6 to stop debugger engine anytime.
### Catch all connections from apache server.
-This is very important for a large website, especially for thoes pages who contain AJAX requests. In that case, one reload of a page may trigger dozens of http request, each of them goes to a different URL. The new debugger engine will catch all connections from apache server. Users can debugger all of them without missing anyone.
+This is very important for a large website, especially for thoes pages who contain AJAX requests. In that case, one reload of a page may trigger dozens of http request, each of them goes to a different URL. The new debugger engine will catch all connections from apache server. Users can debug all of them without missing anyone.
### Break only at breakpoints
@@ -36,6 +36,7 @@ In debuggin mode
<F5> => start debugging / run
<F6> => stop debugging
<F7> => evalute expression and display result. cursor is automatically move to watch window. type line and just press enter.
+ <F9> => toggle layout
<F11> => shows all variables
<F12> => shows variable on current cursor
@@ -47,6 +48,15 @@ In debuggin mode
### Status line for debugger engine
+ After user press <F5> to start debugger engine, a string like "PHP-bae-LISN" will show up at the right side of status line.
+
+ The status string looks like --
+
+ PHP-<bae|bap>-<LISN|PENDn|CONN|CLSD>
+
+ bae => means Break At Entry
+ bap => means Break only At breakPoints
+
LISN => means the debugger engine is listening.
PENDn => means there are n connections waiting for debugging.
CONN => means debug session has been established, and being debugged.
@@ -55,23 +65,41 @@ In debuggin mode
## Usage
-* Make sure your vim has python(above 2.3) supported.
+* Make sure your vim has python(at least 2.3) supported, in vim with command
+
+ <pre>
+ :version
+ </pre>
+
+ In case of your VIM don't support python, download VIM source package from http://www.vim.org/download.php, then build your own VIM with commands --
+
+ <pre>
+ ./configure --prefix=/opt/vim --enable-pythoninterp --with-python-config-dir=/usr/lib/python2.4/config
+ make
+ make install
+ </pre>
* Install xdebug for php, and edit php.ini
- zend_extension=<path_to_xdebug.so>
- xdebug.remote_enable=1
+ <pre>
+ zend\_extension=path\_to\_xdebug.so
+ xdebug.remote\_enable=1
+ </pre>
* Edit your ~/.vimrc
+ <pre>
let g:debuggerPort = 6789
let g:debuggerBreakAtEntry = 0
+ </pre>
* Edit your apche configure file
In your VirtualHost section, set debugger port same as the one in your vimrc
- php_value xdebug.remote_port 6789
+ <pre>
+ php\_value xdebug.remote\_port 6789
+ </pre>
* Save debugger.py and debugger.vim to your ~/.vimr/plugin
@@ -79,6 +107,11 @@ In debuggin mode
* Now, press F5 to start debugger engine
-* Back to your browser, add XDEBUG_SESSION_START=1 to your URL, for example, http://localhost/index.php?XDEBUG_SESSION_START=1. If you would like to debug from CLI, start your php script like
+* Back to your browser, add XDEBUG\_SESSION\_START=1 to your URL, for example, http://localhost/index.php?XDEBUG\_SESSION\_START=1. If you would like to debug from CLI, start your php script like
+
+ <pre>
+ php -dxdebug.remote\_autostart=1 -dxdebug.remote\_port 6789 test.php
+ </pre>
- php -dxdebug.remote_autostart=1 -dxdebug.remote_port 6789 test.php
+## Screenshot under Windows
+![windows screenshot](http://sharing-from-brook.16002.n6.nabble.com/file/n4930670/with_help.png)
View
41 plugin/debugger.py
@@ -380,6 +380,7 @@ def on_create(self):
class DebugUI:
""" DEBUGUI class """
+ (NORMAL, DEBUG) = (0,1)
def __init__(self, debug, stackwinHeight, watchwinWidth):
""" initialize object """
self.debug = debug
@@ -390,7 +391,7 @@ def __init__(self, debug, stackwinHeight, watchwinWidth):
self.helpwin = None
if self.debug:
self.tracewin = TraceWindow()
- self.mode = 0 # normal mode
+ self.mode = DebugUI.NORMAL
self.file = None
self.line = None
self.winbuf = {}
@@ -402,9 +403,9 @@ def __init__(self, debug, stackwinHeight, watchwinWidth):
def debug_mode(self):
""" change mode to debug """
- if self.mode == 1: # is debug mode ?
+ if self.mode == DebugUI.DEBUG:
return
- self.mode = 1
+ self.mode = DebugUI.DEBUG
# save session
vim.command('mksession! ' + self.sessfile)
for i in range(1, len(vim.windows)+1):
@@ -425,7 +426,7 @@ def debug_mode(self):
vim.command('call CreateFunctionKeys()')
def normal_mode(self):
""" restore mode to normal """
- if self.mode == 0: # is normal mode ?
+ if self.mode == DebugUI.NORMAL:
return
vim.command('call ClearFunctionKeys()')
@@ -446,7 +447,7 @@ def normal_mode(self):
self.winbuf.clear()
self.file = None
self.line = None
- self.mode = 0
+ self.mode = DebugUI.NORMAL
self.cursign = None
def create(self):
""" create windows """
@@ -495,21 +496,21 @@ def set_srcview(self, file, line):
if file == self.file and self.line == line:
return
- nextsign = self.next_sign()
-
if file != self.file:
self.file = file
self.go_srcview()
vim.command('silent edit ' + file)
- vim.command('sign place ' + nextsign + ' name=current line='+str(line)+' file='+file)
- vim.command('sign unplace ' + self.cursign)
-
- vim.command('sign jump ' + nextsign + ' file='+file)
- #vim.command('normal z.')
+ if self.mode == DebugUI.DEBUG:
+ nextsign = self.next_sign()
+ vim.command('sign place ' + nextsign + ' name=current line='+str(line)+' file='+file)
+ vim.command('sign unplace ' + self.cursign)
+ vim.command('sign jump ' + nextsign + ' file='+file)
+ self.cursign = nextsign
+ else:
+ vim.command(': ' + str(line))
self.line = line
- self.cursign = nextsign
class DbgSession:
def __init__(self, sock):
@@ -518,6 +519,8 @@ def __init__(self, sock):
self.sock = sock
self.bptsetlst = {}
self.bptsetids = {}
+ def jump(self, fn, line):
+ vim.command("e +"+str(line)+" "+str(fn))
def handle_response_breakpoint_set(self, res):
"""handle <response command=breakpoint_set> tag
<responsponse command="breakpoint_set" id="110180001" transaction_id="1"/>"""
@@ -987,7 +990,6 @@ def __init__(self):
self.statusline="%<%f\ %=%-10.(%l,%c%V%)\ %P\ %=%{'PHP-'}%{(g:debuggerBreakAtEntry==1)?'bae':'bap'}"
self.breakpt = BreakPoint()
self.ui = DebugUI(self.debug, 12, 60)
- self.mode = 0
def updateStatusLine(self,msg):
sl = self.statusline+"%{'"+msg+"'}"
@@ -1001,17 +1003,6 @@ def loadSettings(self):
self.max_data = vim.eval('debuggerMaxData')
self.max_depth = vim.eval('debuggerMaxDepth')
self.break_at_entry = int(vim.eval('debuggerBreakAtEntry'))
- def resize(self):
- self.mode = self.mode + 1
- if self.mode >= 3:
- self.mode = 0
-
- if self.mode == 0:
- vim.command("wincmd =")
- elif self.mode == 1:
- vim.command("wincmd |")
- if self.mode == 2:
- vim.command("wincmd _")
def handle_exception(self):
if debugger.debug:
self.ui.tracewin.write(sys.exc_info())
Please sign in to comment.
Something went wrong with that request. Please try again.