Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsStartDebugging on mutliple contexts (vs runtime) clarification #6740

Open
SoylentGraham opened this issue Sep 3, 2021 · 2 comments
Open
Labels

Comments

@SoylentGraham
Copy link

SoylentGraham commented Sep 3, 2021

Hello!
I'm using chakraRT (in windows), but I also sometimes use chakracore in osx and linux (as well as jscore, both ios/osx natively and the open source one)

I've recently re-enabled JsStartDebugging() and hurrah! visual studio 2017 now shows code! (It used to just show when there was an exception, but no source, debugging, no idea what made it start working)

I've also implemented modules, via multiple contexts (in jscore and chakra). It all seems to be working fine, except I can only enable debugging for my first script....
Subsequent calls to JsStartDebugging() when creating my new context (which is during script execution of the parent-context) returns JsErrorRuntimeInUse.
I've read on another issue, that's because a script is currently being executed... but I'm on a different current context (same vm), so should I really see the error?
Does it need to be called outside of any script execution in the VM?
the headers say Starts debugging in the current context. so I assume that's correct that debugging needs enabling per-context, not per-vm?

My flow;
Create VM
Create ContextA

  • Set ContextA active
  • Enable debugging (success)
  • Set no active context
    Bootup
  • Set ContextA active
  • Execute bootup.s script (imports ImportB.js)
    • Create ContextB
    • Set ContextB active
    • Enable debugging (fails JsErrorRuntimeInUse)
    • Execute ImportB.js
    • Set ContextA active (popped from stack)
    • Continue ContextA/script execution
  • Bootup.js/ContextA finishes - set no active context

Run pending async jobs (run on their respective contexts)

Visual studio only shows the bootup script in the debugger, so, I guess it is context specific...

I only ask as moving the debugger enabling is slightly awkward (but I can do it), but it does mean it's after the module initialisation, so I'd never be able to debug the actual import (but I can live with that)

But I'm also not sure if I'm setting up debugging correctly for multiple contexts (Info about debugging is extremely rare!)

Side note; if I'm doing multiple contexts incorrectly, do let me know! (should I switch active contexts this way?)
JavascriptCore is threadsafe for JS calls, but not script execution, chakra seems to be similar, and working so far :)

@SoylentGraham SoylentGraham changed the title JsStartDebugging context vs runtime clarification JsStartDebugging on mutliple contexts (vs runtime) clarification Sep 3, 2021
@rhuanjl
Copy link
Collaborator

rhuanjl commented Sep 3, 2021

I think JsStartDebugging is a ChakraFull API, note ChakraFull (also called chakra.dll) was the microsoft release of Chakra that used to be updated alongside new releases of windows. It is no longer updated.

ChakraCore (which is the same JS engine but without some propriety APIs and fully open source) is what we are trying to continue to develop in this repository.

Unfortunately if you use ChakraCore I don't think debugging will just work like that, we have a debug API but you basically have to make your own debugging tool to implement it - you could hook it up to Visual Studio but it would take quite a bit of work.

The ChakraCore debug API is documented in this header: https://github.com/chakra-core/ChakraCore/blob/master/lib/Jsrt/ChakraDebug.h

@SoylentGraham
Copy link
Author

SoylentGraham commented Sep 3, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants