简体   繁体   中英

How can i attach a debugger to google v8?

In my application (Windows 10 VC2017) i enabled the possibility to write and execute scripts using google v8 and v8pp .

v8pp calls a script like this:

v8::Local<v8::Value> context::run_script(std::string const& source, std::string const& filename)
{
    v8::EscapableHandleScope scope(isolate_);
v8::Local<v8::Context> context = isolate_->GetCurrentContext();

v8::ScriptOrigin origin(to_v8(isolate_, filename));
v8::Local<v8::Script> script;
bool const is_valid = v8::Script::Compile(context,
    to_v8(isolate_, source), &origin).ToLocal(&script);

v8::Local<v8::Value> result;
if (!script.IsEmpty())
{
    auto res1 = script->Run(context); // 
    if(! res1.IsEmpty())
         result = res1.ToLocalChecked();
    }
    return scope.Escape(result);
}

How can i attach a debugger (chrome debug) to my code?

I found googles description at https://v8.dev/docs/inspector - But this leaves some things blank and consists mostly of js code?

And i found the implementation for v8toolkit at https://github.com/xaxxon/v8toolkit/blob/master/src/debugger.cpp . But this seems to run not for windows.

What is a easy way to attach chrome debug to js code? The code is typically not a file but rather is stored in a data base and then stored in a std::string.

I finally got done a windows version of v8inspector that works well with my stand alone windows application with integrated v8.

I made a own fork including descriptions where to find/build the required 3rd party libraries (or where to find prebuilds). I also did a number of changes/additions: https://github.com/StefanWoe/v8inspector

In the meanwhile this has also been merged into the parent project: https://github.com/hsharsha/v8inspector

EDIT: In the meanwhile ive been pointed to another implementation built with boost::beast and no other dependencies. Much simpler and more robust etc.: https://github.com/ahmadov/v8_inspector_example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM