ahmadov / v8_inspector_example

V8 Inspector example
MIT License
47 stars 8 forks source link

How to use Debugger.getStackTrace to retrieve runtime function call stack traces when debugging JS on V8 #9

Open wxfSEU opened 1 year ago

wxfSEU commented 1 year ago

Hi ahmadov, before seeking advice from you on my technical challenge related to the Google V8 engine, I would like to express my gratitude for your expertise and willingness to assist. I've embed newest v8 engine into my c++ project to execute and debug JavaScript, when I was debugging JavaScript, to get runtime function call stack traces, according to the google's v8 debugging doc: "https://chromedevtools.github.io/devtools-protocol/v8/Debugger/" , I tried to send a Debugger.getStackTrace command to v8 engine, and there is an example of what Debugger.getStackTrace command looks like :

{
"id": 43,
"method": "Debugger.getStackTrace",
"params": {
    "stackTraceId": {
        "id": "6352323678",
    }
}

}

But the "id": "6352323678" in above JSON string is fabricated by me and not real. I don't know how to get the real value of properties "id" in stackTraceId obejct. Is there any c++ interfaces I can use to get current stackTraceId in v8 engine source,or is there any CDP v8 debugging command I can send to v8 engine to get current stackTraceId?

Thank you for your kindness again.

Best regards Joe