Page 1 of 2 12 LastLast
Results 1 to 20 of 27

Thread: How to access v8's debug API in QJSEngine

  1. #1
    Join Date
    May 2013
    Location
    Vienna, Austria
    Posts
    21
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default How to access v8's debug API in QJSEngine

    Hi,

    I was playing around with the new QJSEngine and wanted to access the v8's Debug interface (eider start the building debug agent, or pass debug commands directly to the engine using the C API), unfortunately it seams that the v8 symbols are not exported by the Qt Librarys.

    I was looking around in the code a little bit and found some files under: ...\Src\qtdeclarative\src\qml\debugger that are using the V8's C API to pass debug messages, but yet this classes also does not seam to be fully exported. Some are exported partialy (meaning the export declaration is there some static functions work OK, but some other cause linking errors, strange)

    Does anyone know how to get to the v8 Engine without having to recompile any Qt Librarys?

    Cheers
    David

  2. The following 2 users say thank you to DavidXanatos for this useful post:


  3. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    My understanding is that the V8 engine is considered an implementation detail of QJSEngine, i.e. it could be a different engine in the future.

    Maybe there is something like http://qt-project.org/doc/qt-5.0/qts...edebugger.html for QJSEngine

    Cheers,
    _

  4. #3
    Join Date
    May 2013
    Location
    Vienna, Austria
    Posts
    21
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    Well... there seem not to be,
    for qml scripts one can attach QtCreator for debugging when using a debug build.
    But this seam not to work for QJSEngine, also for many projects one would like to be able to debug scripts while using an otherwise release version.

    Scripts are often used to automatize or customize some final application.

    I like QScriptEngineDebugger very much it really helped me a lot with my projects. I made a modified version that allows to do remote debugging, respectively debug engines running in other threads in the same process, the original QScriptEngineDebugger head to be in the same thread as the debugged engine and at the same time in the GUI thread limiting its usability somewhat.

    Recently I wrote a new fronted class that connects to the V8 debugger agent and translates all relevant commands so that I can debug scripts running in a V8 engine using the nice debugged GUI from Qt. The project can be found here: https://gitorious.org/neoframework/neoscripttools

    And now I wold like to use it to debug also QJSEngine executed scripts since it is just a wrapper for the V8.
    Actually one could also put the V8DebugAdapter together with a modified remote debugger backed into a modified QtLibrary and have a QScriptEngineDebugger like debugger for the new JSEngine.

    Though it would be nicer not to have to rebuild the qt library's for that.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to access v8's debug API in QJSEngine

    You are aware V8 is going to be replaced with Qt's own JS engine called V4, right?

    http://blog.qt.digia.com/blog/2013/0...engine-part-1/
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    May 2013
    Location
    Vienna, Austria
    Posts
    21
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by wysota View Post
    You are aware V8 is going to be replaced with Qt's own JS engine called V4, right?

    http://blog.qt.digia.com/blog/2013/0...engine-part-1/

    Well, thats not relevant for a few reasons:
    1. This will not happen any time soon I guess, and for now a working solution is needed.
    2. I use a raw V8 and not Qt in the core of one of my projects (Qt only for GUI) so i needed a V8 debugger with a QtGUI
    3. In the other project where I first used QScriptEngineDebugger i use Qt every ware and need a nice script to automatize some parts, this part requiters ideally a lot of raw Java script performance, V4 will not be Superior to V8 in this regard so if QJSEngine should not keep v8 it may be better to also use here a naked v8 and do all the binding manually.
    4. The debugger probably can be also re purposed to plug into v4vm once its ready.

    Having a consistent in App script debugging is I believe a great feature worth pursuing.

    David X.

  7. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by DavidXanatos View Post
    Having a consistent in App script debugging is I believe a great feature worth pursuing.
    Sure, but the in app scripting facility is QtScript, which does have a debugger interface.

    Cheers,
    _

  8. #7
    Join Date
    May 2013
    Location
    Vienna, Austria
    Posts
    21
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by anda_skoa View Post
    Sure, but the in app scripting facility is QtScript, which does have a debugger interface.
    _
    Sure it is not deprecated?
    I thought QJSEngine & co was intended to replace QScriptEngine & co.

    Also My project that is currently using QScriptEngine would greatly benefit from the raw JS power of QJSEngine.

    David X.

  9. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by DavidXanatos View Post
    Sure it is not deprecated?
    I didn't find anything hinting at that in the QtScript documentation.

    Quote Originally Posted by DavidXanatos View Post
    I thought QJSEngine & co was intended to replace QScriptEngine & co.
    I initially thought that as well, but QJSEngine is part of qtdeclarative so at least for now it is not a stand-alone module and more an internals of the declarative engine and thus subject to its needs.

    And those needs, at least on some platforms, is to do without just-in-time compilation. Whether this will affect all platforms or only those which have such restrictions is unknown.

    Cheers,
    _

  10. #9
    Join Date
    May 2013
    Location
    Vienna, Austria
    Posts
    21
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by anda_skoa View Post
    I didn't find anything hinting at that in the QtScript documentation.
    well:

    http://qt-project.org/doc/qt-5.0/qtdoc/modules.html

    "Classes for making Qt applications scriptable. Provided for Qt 4.x compatibility. Please use the QJS* classes in the QtQml module for new code."

    In my dictionary this means QScriptEngine is deprecated.

    Now the question is what will happen to the QJS* classes once QT's own Engine is ready.

    Also about JustInTime compilation I believe Qt shouldn't do so much work (own engine) to solve a problem others most likely will, I can not really believe that Google will not want Chrome to run on windows RT.
    They will eider sue M$ or change V8 to be able to switch between compiler and interpreter mode.
    In booth cases, the problem will solve it self you just have to wait.

    David X.

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by DavidXanatos View Post
    They will eider sue M$
    Sue them over what? Can <put your favourite car company> sue Great Britain for their left-hand traffic?

    or change V8 to be able to switch between compiler and interpreter mode.
    Firstly this would mean completely rewriting V8. Secondly this does not solve some of the issues the QML engine has. I'm not a fan of changing javascript engines every 18 months but I can well understand the reasoning behind it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #11
    Join Date
    May 2013
    Location
    Vienna, Austria
    Posts
    21
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    Sue them over what?
    http://www.neowin.net/news/mozilla-n...m-restrictions

    Firstly this would mean completely rewriting V8.
    Google has certainly the resources to do it in no time if they would want to.

    Secondly this does not solve some of the issues the QML engine has.
    Is there an article that explains in a bit more detail how the performance issues origin? http://blog.qt.digia.com/blog/2013/0...engine-part-1/ does not really explain why there is this prformance issue and why there are 3 representations needed.
    I thought QML was just Java script plugged into Qt classes, but it seams there is more to it.

    Edit:
    Also Qt needs to keep v8 for webkit to have good web performance.
    And QJSEngine as far as I understand it does not use qml just normal js (qs) scripts, so there should be no performance advantage in switching to v4vm.
    And for webkit the JIT problem for windows RT will have to be solved anyways.

    Bottom line is I hope they will keep V8 at least as a replacement for the QtScript,
    and for now the question is how to properly connect to the v8 debugger interface.


    David X.
    Last edited by DavidXanatos; 31st May 2013 at 10:36.

  13. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by DavidXanatos View Post
    As far as I understand, that's unrelated to V8 problems. We're dealing with memory protection issues here.

    Google has certainly the resources to do it in no time if they would want to.
    The thing is why would they want it.

    Is there an article that explains in a bit more detail how the performance issues origin? http://blog.qt.digia.com/blog/2013/0...engine-part-1/ does not really explain why there is this prformance issue and why there are 3 representations needed.
    There are many articles you would have to read to understand it all.

    I thought QML was just Java script plugged into Qt classes, but it seams there is more to it.
    There is definitely more to it.

    Also Qt needs to keep v8 for webkit to have good web performance.
    That's an unrelated issue. QtWebKit is a separate module.

    And QJSEngine as far as I understand it does not use qml just normal js (qs) scripts, so there should be no performance advantage in switching to v4vm.
    QQmlEngine is derived from QJSEngine. Besides, QJSEngine "understands" QObject instances and the nature of QObject is part of the problem.

    And for webkit the JIT problem for windows RT will have to be solved anyways.
    It's a separate module which simply does't have to be deployed on this platform if no solution is found.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #13
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by DavidXanatos View Post
    http://qt-project.org/doc/qt-5.0/qtdoc/modules.html

    "Classes for making Qt applications scriptable. Provided for Qt 4.x compatibility. Please use the QJS* classes in the QtQml module for new code."

    In my dictionary this means QScriptEngine is deprecated.
    Ah, interesting. That would indeed hint at deprecation.
    Not sure though if that was the initial goal and is still valid after the decision to create V4.

    Quote Originally Posted by DavidXanatos View Post
    I thought QML was just Java script plugged into Qt classes, but it seams there is more to it.
    While it has a similar syntax to JSON, it is just a domain specific language for describing object trees and relations between those objects' properties.
    A QML document can include pieces of JavaScript code for helper functions, signal handlers, etc.


    Quote Originally Posted by DavidXanatos View Post
    They will eider sue M$ or change V8 to be able to switch between compiler and interpreter mode.
    They haven't done anything like that regarding iOS, which has the same restrictions but a way larger market share than WindowsRT.


    Quote Originally Posted by DavidXanatos View Post
    In booth cases, the problem will solve it self you just have to wait.
    There is no guarantee that it will solve itself, so this could be an infinite wait. And other frameworks do target a similar multiplatform approach so one can't wait too long.

    All speculation now, maybe QJSEngine will stay with V8 on all platforms but the restricted ones.

    Cheers,
    _

  15. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by anda_skoa View Post
    All speculation now, maybe QJSEngine will stay with V8 on all platforms but the restricted ones.
    That's unlikely as two different engines would have to be maintained simultaneously.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #15
    Join Date
    May 2013
    Location
    Vienna, Austria
    Posts
    21
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by wysota View Post
    That's unlikely as two different engines would have to be maintained simultaneously.
    Well, actually 3 if you count the old QScriptEngine that has the nice debug interface.

    I'm afraid that QScriptEngine will have to bite the dirt first and there will be no replacement in place that would provide decent in app debugging capabilities.

    Of cause one could hope they will get rid of QJSEngine all together, keep QScriptEngine for scripting and use v4vm only for QQmlEngine.

    on a side note: qml and webkit, i haven't looked into it in detail, but are they actually deploying v8 code twice once as part of qml and once as part of web kit? Thats not elegant, there should be a shared v8 library used by all modules.

    Than there would be still 3 engines but at least one for each separate module.

    Quote Originally Posted by wysota View Post
    There are many articles you would have to read to understand it all.
    links?

    David X.
    Last edited by DavidXanatos; 31st May 2013 at 19:08.

  17. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by DavidXanatos View Post
    Well, actually 3 if you count the old QScriptEngine that has the nice debug interface.
    It does not really be maintained as its functionality is finished. QML on the other hand is actively developed.


    Of cause one could hope they will get rid of QJSEngine all together, keep QScriptEngine for scripting and use v4vm only for QQmlEngine.
    QScriptEngine is likely to stay because of licensing policies (especially the commercial license).

    on a side note: qml and webkit, i haven't looked into it in detail, but are they actually deploying v8 code twice once as part of qml and once as part of web kit?
    Most probably yes.

    Thats not elegant, there should be a shared v8 library used by all modules.
    This would require both modules to be released together which is agains the policy introduced in Qt5 where independent modules can be released separately.

    links?
    I would start with the docs and DevDays videos on QML.
    Last edited by wysota; 31st May 2013 at 22:55.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. #17
    Join Date
    May 2013
    Location
    Vienna, Austria
    Posts
    21
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    QScriptEngine is likely to stay because of licensing policies (especially the commercial license).
    In which way does the licensing policies play here a role?

    This would require both modules to be released together
    No, they would use a shared library.
    They wouldn't have to be together just use the same shared v8.dll

    DevDays videos on QML.
    Are there no text articles describing the stuff, other than the docs themselves?

  19. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by DavidXanatos View Post
    In which way does the licensing policies play here a role?
    Hmm.. somehow I thought V8 was LGPL which would prevent statically compiling it into closed-source projects but it seems it is BSD.

    No, they would use a shared library.
    They wouldn't have to be together just use the same shared v8.dll
    The point is now QtWebKit and QtQml can use different versions of V8. Release schedules of QtWebKit and QtQml are quite different.


    Are there no text articles describing the stuff, other than the docs themselves?
    I don't have any specific links for you right now. Most that I've learn with regard to this subject was by studying QtQml internals myself. Nasty hacks to work around Qt's property system in QML is one of the example areas.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  20. #19
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    Quote Originally Posted by wysota View Post
    That's unlikely as two different engines would have to be maintained simultaneously.
    True, I also don't find that likely. Too bad though, having a high performance engine available would have been nice and that was probably even the original intent.

    Quote Originally Posted by DavidXanatos View Post
    I'm afraid that QScriptEngine will have to bite the dirt first and there will be no replacement in place that would provide decent in app debugging capabilities.
    Well, "first" in this context still means Qt6, it is more likely that QJSEngine's internals will change earlier than that.

    Ideally QQmlEngine would have used QJSEngine and so it could switch to something else while keeping QJSEngine and deprecating QScriptEngine.
    But alas it derives from it, so unless QJSEngine is two different things internally (very unlikely!), it will become an engine optimized for the QML use case.

    My take is that the needs for in-application scripting, especially due to the easy way of accessing application provided infrastructure from scripts, can easily be fulfilled by QScriptEngine.

    Quote Originally Posted by DavidXanatos View Post
    Of cause one could hope they will get rid of QJSEngine all together, keep QScriptEngine for scripting and use v4vm only for QQmlEngine.
    While they obviously can't get rid of QJSEngine as a class, my guess is that it will become an implemetation detail of QQml and QScriptEngine stays the main in-application scripting facility.

    Quote Originally Posted by DavidXanatos View Post
    on a side note: qml and webkit, i haven't looked into it in detail, but are they actually deploying v8 code twice once as part of qml and once as part of web kit? Thats not elegant, there should be a shared v8 library used by all modules.
    WebKit is special, its Qt "frontend" is part of the WebKit, not WebKit part of Qt. So it is more a separate project that is being worked on by some developers who also happen to be developers on Qt-Project.org

    WebKit might also switch to a different JS engine at some point.

    Regarding QML:

    a QML document describes a tree of element, much like XML but with less verbose syntax. Each element type is specified either by another QML document or a C++ class registered with the QML type system. The requirement for the latter is that the class derives, directly or indirectly, from QObject and that it can be created without arguments.

    As Qt developers we often create trees of QObjects, e.g. QWidget trees, QStateMachine with nested states, etc.
    QML can be used to do that in a less hard-coded fashion, e.g. if the tree in question needs to be changable without changing the binary.

    Since all nodes in such a tree are essentially QObject instances, they have the capability of signals, slots and properties. QML allows to call slots, connect to signals and read/write properties. One really nice feature is that properties can not only be assigned a fixed value but an expression containing other properties and that expression is automatically reevaluated whenever one of its contained properties changes its value.

    The latter is of course especially nice in UI code, where e.g. a button's enabled state often depends on some other UI element's content.
    But it can be useful for other object hierachies as well, it is mostly a matter of getting used to this form of state propagation.

    Cheers,
    _

  21. The following user says thank you to anda_skoa for this useful post:

    DavidXanatos (1st June 2013)

  22. #20
    Join Date
    May 2013
    Location
    Vienna, Austria
    Posts
    21
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to access v8's debug API in QJSEngine

    This clears up some things I think, thx.

    Assuming that QJSEngine may become an implemetation detail of QQml and QScriptEngine will stay for application scripting, it may be an interesting option to create a fork of the current v8 based QJSEngine with an exposed debug interface for in app debugging, and those use cases where a lot of JS performance is needed and the slow interface for QObject is not significant.

    But you are probably right that Qt wont maintain 2 scripting engines that basically do almost the same, just with different performance and platform compatibility.

    So if there is a need for such a thing it would have to be some extern component maintained by some 3rd party.

    Cheers

Similar Threads

  1. Replies: 1
    Last Post: 10th October 2012, 09:46
  2. Qt + Linux + Eclipse - debug using debug build?
    By will49 in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2012, 07:27
  3. Replies: 4
    Last Post: 30th September 2010, 11:31
  4. DEBUG macro not defined in debug build using vc++
    By piotr.dobrogost in forum Qt Programming
    Replies: 0
    Last Post: 21st July 2009, 14:07
  5. Replies: 11
    Last Post: 22nd March 2006, 20:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.