Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ where the path supplied is vdebug's doc directory. This should enable vdebug's h
Clone or download a tarball of the plugin and move its content in your
`~/.vim/` directory.

Your `~/.vim/plugins/` directory should now contain vdebug.vim and a directory
Your `~/.vim/plugin/` directory should now contain vdebug.vim and a directory
called "python".

## Using git and Pathogen
Expand Down
Empty file modified build.sh
100755 → 100644
Empty file.
8 changes: 8 additions & 0 deletions plugin/python/start_vdebug.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ def handle_visual_eval(self):
except Exception as e:
self.handle_exception(e)

def handle_trace(self,args):
"""Trace a code snippet specified by args.
"""
try:
return self.runner.trace(args)
except Exception as e:
self.handle_exception(e)

def handle_eval(self,args):
"""Evaluate a code snippet specified by args.
"""
Expand Down
11 changes: 11 additions & 0 deletions plugin/python/vdebug/dbgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ def names(self):
names[int(c.get('id'))] = c.get('name')
return names

class TraceResponse(Response):
"""Response object returned by the trace command."""

def __str__(self):
return self.as_xml().get('trace')


class StatusResponse(Response):
"""Response object returned by the status command."""

Expand Down Expand Up @@ -695,3 +702,7 @@ class ResponseError(Exception):
"""An error caused by an unexpected response from the
debugger (e.g. invalid format XML)."""
pass

class TraceError(Exception):
"""Raised when trace is out of domain."""
pass
38 changes: 35 additions & 3 deletions plugin/python/vdebug/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Runner:
an interface that Vim can use to send commands.
"""

prev_trace_code_value = ''
def __init__(self):
self.api = None
vdebug.opts.Options.set(vim.eval('g:vdebug_options'))
Expand Down Expand Up @@ -89,9 +90,9 @@ def set_features(self):

def refresh(self,status):
"""The main action performed after a deubugger step.

Updates the status window, current stack, source
file and line and watch window."""
file and line and watch window."""
if not self.is_alive():
self.ui.error("Cannot update: no connection")
else:
Expand Down Expand Up @@ -125,6 +126,7 @@ def refresh(self,status):

def get_context(self,context_id = 0):
self.ui.watchwin.clean()
self.ui.tracewin.clean()
name = self.context_names[context_id]
vdebug.log.Log("Getting %s variables" % name)
context_res = self.api.context_get(context_id)
Expand All @@ -133,6 +135,21 @@ def get_context(self,context_id = 0):
%(name,self.ui.sourcewin.file,self.cur_lineno),\
self.context_names, context_id)
self.ui.watchwin.accept_renderer(rend)
try:
if self.ui.tracewin.reserve_trace_code:
context_res = self.api.eval(self.ui.tracewin.reserve_trace_code)
rend = vdebug.ui.vimui.ContextGetResponseRenderer(\
context_res,"Trace of: '%s'" \
%context_res.get_code())
rendered = rend.render()
self.ui.tracewin.accept_value(rendered)
self.ui.tracewin.last_context_rendered = rendered
except vdebug.dbgp.EvalError:
if self.ui.tracewin.last_context_rendered:
self.ui.tracewin.accept_value('(prev)'+str(self.ui.tracewin.last_context_rendered))
else:
self.ui.tracewin.accept_value(str(self.ui.tracewin.reserve_trace_code))


def toggle_breakpoint_window(self):
"""Open or close the breakpoint window.
Expand Down Expand Up @@ -222,6 +239,21 @@ def set_breakpoint(self,args):
return
self.breakpoints.add_breakpoint(bp)

def trace(self,code):
"""Evaluate a snippet of code and show the response on the watch window.
"""
self.ui.tracewin.clean()
try:
vdebug.log.Log("Tracing code: "+code)
context_res = self.api.eval(code)
rend = vdebug.ui.vimui.ContextGetResponseRenderer(\
context_res,"Eval of: '%s'" \
%context_res.get_code())
self.ui.tracewin.accept_renderer(rend)
except vdebug.dbgp.EvalError:
self.ui.tracewin.accept_value('(invalid expression yet)')
self.ui.tracewin.reserve_trace_code = code

def eval(self,code):
"""Evaluate a snippet of code and show the response on the watch window.
"""
Expand Down Expand Up @@ -269,7 +301,7 @@ def listen(self,server,port,timeout):
check_ide_key = True
if len(ide_key) == 0:
check_ide_key = False

connection = vdebug.dbgp.Connection(server,port,\
timeout,vdebug.util.InputStream())

Expand Down
7 changes: 4 additions & 3 deletions plugin/python/vdebug/ui/interface.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
class Ui():
"""Abstract for the UI, used by the debugger
"""
watchwin = None
stackwin = None
watchwin = None
stackwin = None
statuswin = None
logwin = None
logwin = None
sourcewin = None
tracewin = None

def __init__(self):
self.is_open = False
Expand Down
22 changes: 19 additions & 3 deletions plugin/python/vdebug/ui/vimui.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def open(self):

srcwin_name = self.__get_srcwin_name()

self.watchwin = WatchWindow(self,'vertical belowright new')
self.tracewin = TraceWindow(self,'vertical belowright new')
self.tracewin.create()

self.watchwin = WatchWindow(self,'belowright new')
self.watchwin.create()

self.stackwin = StackWindow(self,'belowright new')
Expand All @@ -60,6 +63,7 @@ def open(self):

self.watchwin.set_height(20)
self.statuswin.set_height(5)
self.tracewin.set_height(5)

logwin = LogWindow(self,'rightbelow 6new')
vdebug.log.Log.set_logger(\
Expand Down Expand Up @@ -178,10 +182,13 @@ def close(self):
self.stackwin.destroy()
if self.statuswin:
self.statuswin.destroy()
if self.tracewin:
self.tracewin.destroy()

self.watchwin = None
self.stackwin = None
self.watchwin = None
self.stackwin = None
self.statuswin = None
self.tracewin = None


def __get_srcwin_name(self):
Expand Down Expand Up @@ -260,6 +267,7 @@ class Window(vdebug.ui.interface.Window):
open_cmd = "new"
creation_count = 0

context_sav = None
def __init__(self,ui,open_cmd):
self.buffer = None
self.ui = ui
Expand Down Expand Up @@ -364,6 +372,9 @@ def command(self, cmd):
def accept_renderer(self,renderer):
self.write(renderer.render())

def accept_value(self,value):
self.write(value)

class BreakpointWindow(Window):
name = "DebuggerBreakpoints"
is_visible = False
Expand Down Expand Up @@ -472,6 +483,11 @@ def on_create(self):
def set_status(self,status):
self.insert("Status: "+str(status),0,True)

class TraceWindow(WatchWindow):
name = "TraceWindow"
reserve_trace_code = None
last_context_rendered = None


class ResponseRenderer:
def __init__(self,response):
Expand Down
1 change: 1 addition & 0 deletions plugin/vdebug.vim
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ command! -nargs=? BreakpointRemove python debugger.remove_breakpoint(<q-args>)
command! BreakpointWindow python debugger.toggle_breakpoint_window()
command! -nargs=? VdebugEval python debugger.handle_eval(<q-args>)
command! -nargs=+ -complete=customlist,s:OptionNames VdebugOpt python debugger.handle_opt(<f-args>)
command! -nargs=? VdebugTrace python debugger.handle_trace(<q-args>)

" Signs and highlighted lines for breakpoints, etc.
sign define current text=-> texthl=DbgCurrentSign linehl=DbgCurrentLine
Expand Down