marylinh / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

Debugger Issue #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Enabling the debugger and running some js code.

What version of the product are you using? On what operating system?
OS: Ubuntu x86 2.6.31-20 kernel  
V8: v8r3960 
Boost: 1.42.0
PyV8: PyV8-0.9
Python: 2.6.4

This code:
import PyV8

class Global(PyV8.JSClass):
    def writeln(self,arg):
        print arg

js = 'writeln(1+2);'

PyV8.debugger.enabled = True
PyV8.debugger.onBeforeCompile = lambda event:debug_onBeforeCompile(event)
PyV8.debugger.onAfterCompile = lambda event: debug_onAfterCompile(event)
context = PyV8.JSContext( Global() )
context.enter()
context.eval(js)

def debug_onBeforeCompile(self,event):
    print "On Before Compile"     

def debug_onAfterCompile(self,event):
    print "On After Compile"      

Gives this error:

terminate called after throwing an instance of 
'boost::python::error_already_set'
Aborted

Sometimes it just segfaults without warning.

Original issue reported on code.google.com by ATM1...@gmail.com on 5 Aug 2010 at 6:07

GoogleCodeExporter commented 9 years ago
Sorry... I changed the location of the debug_onBeforeCompile and 
debug_onAfterCompile but the error occurs regardless.

Original comment by ATM1...@gmail.com on 5 Aug 2010 at 6:11

GoogleCodeExporter commented 9 years ago
Ok I tracked down this error a bit further.  Please disregard my first post, I 
did a bad copy/paste job.

Basically this works (debug_onBeforeCompile and debug_onAfterCompile are not 
part of my JSParser class):

def debug_onBeforeCompile(event):
    print event

def debug_onAfterCompile(event):
    print event

class JSParser:
    '''
    JavaScript Parser    
    '''
    def __init__(self):
        self.context = PyV8.JSContext( Global() )
        self.context.enter()
        PyV8.debugger.enabled = True
        PyV8.debugger.onBeforeCompile = lambda event: debug_onBeforeCompile(event)
        PyV8.debugger.onAfterCompile = lambda event: debug_onAfterCompile(event)
    def evaljs(self,js_to_eval):
        self.context.eval(js_to_eval)

This does not work: (debug_onBeforeCompile and debug_onAfterCompile ARE part of 
my JSParser class:

class JSParser:
    '''
    JavaScript Parser    
    '''
    def __init__(self):
        self.context = PyV8.JSContext( Global() )
        self.context.enter()
        PyV8.debugger.enabled = True
        PyV8.debugger.onBeforeCompile = lambda event: self.debug_onBeforeCompile(event)
        PyV8.debugger.onAfterCompile = lambda event: self.debug_onAfterCompile(event)

    def evaljs(self,js_to_eval):
        self.context.eval(js_to_eval)  

    def debug_onBeforeCompile(self,event):
        print "Before Compile"     

    def debug_onAfterCompile(self,event):
        print "After Compile"            

Original comment by ATM1...@gmail.com on 5 Aug 2010 at 6:32

GoogleCodeExporter commented 9 years ago
ok :)

Original comment by flier...@gmail.com on 6 Aug 2010 at 2:27