[quickjs-devel] Re: Getting filename, calling function name and line number from a C native function

  • From: Koushik Dutta <koush@xxxxxxxxxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Wed, 8 Jan 2020 23:39:09 -0800

I had to add this to add debugger support. This is available in my quickjs
fork.

https://github.com/koush/quickjs/blob/master/quickjs-debugger.h#L82

To get a JSON stack trace:

JSValue stack_trace = js_debugger_build_backtrace(ctx,
ctx->current_stack_frame->cur_pc);
Can also pull that function out and add it to your own build. As far as I
know, it's not natively available, short of parsing an Error stack trace.

On Wed, Jan 8, 2020 at 11:28 PM Eduard Suica <dmarc-noreply@xxxxxxxxxxxxx>
wrote:

Hello,

It is possible to get the current filename, function name and line number
from a C native function? I can get this info from an exception (call
stack), but how can I get this from a native function, without an exception?

I need something like console.log to display something like:
[foo] test.js:4: hello

Thank you,
GE.

Other related posts: