joyent/node — pull request #4274 by ackalker (2012-11-11 23:07:58+00:00)
Title: v8dbg_* symbols not available when NodeJS is statically linked with V8

When NodeJS is statically linked with libv8_base.a, which is the default, I've found that the v8dbg_* debug symbols generated by `deps/v8/tools/gen-postmortem-metadata.py` are not included in the node binaries. This makes debugging with GDB or writing DTrace or SystemTap probes more difficult than needed (see `tools/genv8constants.py`).

After some hunting around, I found that while debug-support.cc is being generated and compiled, the `debug-support.o` object file is never linked into the node binaries. This is because the linker decides that nothing in the node binary actually uses anything defined in debug-support.cc, and skips the object file entirely.

I've found a surprisingly trivial fix: instead of a C++ file, create a header file instead, then #include it somewhere which is certainly going to get linked into node.

Any comments and suggestions are very welcome.

Tested with gdb and SystemTap
```
$ gdb out/Debug/node
[...]
(gdb) p v8dbg_SmiTagMask
$1 = 1
```
```
# stap -e 'probe process.function("main") { printf("%s: %s(%d)\n", pp(), execname(), pid()); printf("v8dbg_SmiTagMask = %d\n", @var("v8dbg_SmiTagMask@v8.cc")) }' -c out/Debug/node
process("/home/miki/vcs/git/node/out/Debug/node").function("main@../src/node_main.cc:64"): node(10908)
v8dbg_SmiTagMask = 1
```