chakra-core / ChakraCore

ChakraCore is an open source Javascript engine with a C API.
MIT License
9.09k stars 1.19k forks source link

JsStartDebugging on mutliple contexts (vs runtime) clarification #6740

Open SoylentGraham opened 3 years ago

SoylentGraham commented 3 years ago

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

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 :)

rhuanjl commented 2 years ago

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 commented 2 years ago

Oh, so the internal debug system of chakrafull and chakracore are unrelated?

My mistake!

On Fri, 3 Sep 2021 at 10:45 pm, Richard @.***> wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chakra-core/ChakraCore/issues/6740#issuecomment-912827017, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQVIBJDTJ2GV5F3TZELHWTUAE6WDANCNFSM5DLRIOCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

--