←Older revision |
Revision as of 11:39, 2 August 2017 |
Line 38: |
Line 38: |
| == Debugger == | | == Debugger == |
| | | |
- | The [[Truffle]] team master of [[debugger]] related tasks was Michael Van De Vanter - author of revolutionary article ''Debugging at Full Speed'' and many others. Michael had an implementation of [[debugger]] for [[Truffle]] implementation of [[Ruby]] and [[JavaScript]] running and also the implementation for [[R]] was sort of working. However the situation was similar to Matthias [[polyglot]] attempts - each language needed its own setup to turn the [[debugger]] on. In addition to that the way to start normal execution - e.g. via {{Truffle|com/oracle/truffle/api/vm|PolyglotEngine}} - was different than the way to start debugging. As a result one needed to decide ahead of time whether debugging will be needed or one wants just a plain execution. Of course this had to be unified. | + | The [[Truffle]] team master of [[debugger]] related tasks was Michael Van De Vanter - author of revolutionary article ''Debugging at Full Speed'' and many others. Michael had an implementation of [[debugger]] for [[Truffle]] implementation of [[Ruby]] and [[JavaScript]] running and also the implementation for [[R]] was sort of working. However the situation was similar to Matthias [[polyglot]] attempts - each language needed its own setup to turn the [[debugger]] on. In addition to that the way to start [[debugging]] was quite different than the way to start regular execution (e.g. via {{Truffle|com/oracle/truffle/api/vm|PolyglotEngine}}). As a result one needed to decide ahead of time whether debugging will be needed or whether one wants just a plain execution. Of course this had to be unified. |
| | | |
- | After a bit of struggling I managed to reverse the dependency - e.g. one could always start the execution with {{Truffle|com/oracle/truffle/api/vm|PolyglotEngine}} and, if the [[debugger]] was initialized, debugging started automatically. Moreover I added few hooks that could be triggered via '''JPDA''' [[debugger]] protocol and then Martin Entlicher (the [[NetBeans]] debugger guy) could implement [[TruffleNetBeansDebugger]]. Since then [[NetBeans]] became able to debug any [[Truffle]] based language, step through the sources (even without the IDE understanding them), see stack variable, etc. | + | After a bit of struggling I managed to reverse the dependency - e.g. one could always start the execution with {{Truffle|com/oracle/truffle/api/vm|PolyglotEngine}} and, if the [[debugger]] was initialized, debugging started automatically. Moreover I added few hooks that could be triggered via '''JPDA''' [[debugger]] protocol. Based on them Martin Entlicher (the [[NetBeans]] debugger guy) then implemented [[TruffleNetBeansDebugger]]. Since then [[NetBeans]] became able to debug any [[Truffle]] based language, step through the sources (even without the IDE understanding them), see stack variable, etc. |
| | | |
- | Of course the behavior was buggy and had to be tested. I was thinking of putting the test into [[TruffleTCK]], but except one trivial case (using [[debugger]] to kill long running execution) the tests seemed too language specific to be tested ''from bottom''. Thus I created '''SLDebugTest''' which verified that stepping over a factorial computation works, shows good values for local variables, etc. and asked other teams to copy the test and adopt it to their language. As far as I can tell then the consistency of debugger implementations increased. | + | Of course the behavior was buggy and had to be tested. I was thinking of putting the test into [[TruffleTCK]], but except one trivial case (using [[debugger]] to kill long running execution) the tests seemed too language specific to be tested ''from bottom''. Thus I created '''SLDebugTest''' which verified that stepping over a factorial computation works in our testing ''Simple Language'', shows proper values for local variables, etc. Other teams then copied the test and adopted it to their language. As far as I can tell then the consistency of debugger implementations increased. |
| | | |
| This all was achievable without [[Domain Expert]] knowledge of [[Truffle]]. However there were few problems that had to be addressed: | | This all was achievable without [[Domain Expert]] knowledge of [[Truffle]]. However there were few problems that had to be addressed: |
- | * The AST instrumentation API was found ineffective and real [[Truffle]] AST expert, Christian Humer had to be called to rewrite that | + | * The AST instrumentation API was found to need to much memory overhead and real [[Truffle]] AST expert, Christian Humer had to be called to rewrite that|* Initial evaluation (that talked to a debugger) was slow - after weeks of struggling and help from Christian I finally learned enough about partial evaluation tricks ({{Truffle|com/oracle/truffle/api|Assumption}}, {{Truffle|com/oracle/truffle/api/CompilerDirectives.CompilationFinal}}) to speed it up |
- | * Initial evaluation (that talked to a debugger) was slow - after weeks of struggling and help from Christian I finally learned enough about partial evaluation tricks to speed it up | + | * Debugger could only be attached when new {{Truffle|com/oracle/truffle/api/vm|PolyglotEngine}} evaluation was about to start - again, it needed Christian's new instrumentation API to fix that up |
- | * Debugger could only be attached when new {{Truffle|com/oracle/truffle/api/vm|PolyglotEngine}} was about to start - again, it needed Christian's new instrumentation API to fix that up | + | |
| These problems show the limits of [[design API as a service]] - designing an [[API]] worked, but making it fast required a lot of understanding of what happens under the cover. | | These problems show the limits of [[design API as a service]] - designing an [[API]] worked, but making it fast required a lot of understanding of what happens under the cover. |
| | | |