absuu
absuu

Reputation: 377

V8 Embedding. Cannot print out the `v8::Local` object

In Short

I was trying to print out the v8::Local object content, with either of v8/tools/gdbinit and v8/tools/lldb_commands.py helper scripts, I got Empty Line OR Syntax Error messages. Is there anything I've missed? So my question is how can we print the v8::Local object content?


Most of configurations are from official embed tutorial (https://v8.dev/docs/embed), without any single line of modification. Here are some details:

GDB ouput: (ubuntu18.04)

###  Compile & Link
$ g++ -I. -Iinclude samples/hello-world.cc -o hello_world -lv8_monolith -ldl -Lout.gn/x64.release.sample/obj/ -pthread -std=c++14 -DV8_COMPRESS_POINTERS -g

###  Debug
$ gdb -x tools/gdbinit ./hello_world

(gdb) p result
$1 = {val_ = 0x55d4f7a35408}
(gdb) jlh result
A syntax error in expression, near `)(result).val_))'.

LLDB ouput: (macos10.14)

###  Compile & Link
$ g++ -I. -Iinclude samples/hello-world.cc -o hello_world -lv8_monolith -Lout.gn/x64.release.sample/obj/ -pthread -std=c++14 -DV8_COMPRESS_POINTERS -g

###  Debug
$ lldb ./hello_world

(lldb) command script import tools/lldb_commands.py
(lldb) b hello-world.cc:56
(lldb) r
(lldb) p *utf8
(char *) $0 = 0x0000000102302590 "Hello, World!"
(lldb) p result
(v8::Local<v8::Value>) $1 = (val_ = 0x0000000102815668)
(lldb) jlh result

(lldb)

Upvotes: 0

Views: 445

Answers (1)

jmrk
jmrk

Reputation: 40561

For debugging, try using a debug build: use gn args <your_output_dir> to set is_debug = true, then recompile.

If you insist on debugging release-mode binaries, you can enable jlh and friends with the v8_enable_object_print = true GN arg, but your experience will likely be weird in other ways (e.g. stepping and breakpoints won't be reliable, many values will be <optimized out>, etc.).

Upvotes: 1

Related Questions