danbev/learning-v8

lldb_commands.py not working on lldb 9.0

gengjiawen opened this issue · 10 comments

jlh not working. I did a little digging, looks the generated command is _v8_internal_Print_Object(*(v8::internal::Object**)(*(void*)(s)))

If you print this in lldb, you got error: cannot cast from type 'v8::Local<v8::String>' to pointer type 'void *'

image

Thanks for reporting this! I opened https://chromium-review.googlesource.com/c/v8/v8/+/2083477 to attempt to fix this issue but perhaps this does not work everywhere. I'll need to take a closer look next week.

Would you be able to double check that the following works for you (just to rule out any stale/older version of lldb_commands.py):

$ lldb ./hello-world
(lldb) command script import ./lldb_commands.py
(lldb) br s -f hello-world.cc -l 73
Breakpoint 2: where = hello-world`main + 279 at hello-world.cc:73:34, address = 0x000000000040295f
(lldb) r
(lldb) jlh global
0x3f9e081c0121: [ObjectTemplateInfo] in OldSpace
 - map: 0x3f9e080433c5 <Map[32]>
 - tag: 1
 - serial_number: 1
 - property_list: 0x3f9e0804030d <undefined>
 - property_accessors: 0x3f9e0804030d <undefined>
 - constructor: 0x3f9e0804030d <undefined>
 - embedder_field_count: 0
 - immutable_proto: false

Still not working.

image

I've updated the command to match the v8 pull request now. I also noticed that I had an additional semicolon after the call to GetError and I've fixed that now.

The lldb_commands.py that is shown in your output above does not match what was in this repository before this update or the in the latest v8 pull request. Which lldb_commands.py are you using?

The unknown error is actually something that should not be printed and is expected (though I admit a little odd) as commands that return void will return this.

The lldb_commands.py that is shown in your output above does not match what was in this repository before this update or the in the latest v8 pull request. Which lldb_commands.py are you using?

Copied from your gerrit pr.

Also my v8 is 7.9, not sure it's related.

Copied from your gerrit pr.

Ah, I did not recognize the addition of printing the error but after reading your comment I think you might have added this.

In the screenshot above it looks like you are trying to print s which is of type v8::Local<v8::String>. Using the hello_world example in this repo I can use jlh to print the source variable:

Local<String> source = String::NewFromUtf8(isolate, js, NewStringType::kNormal).ToLocalChecked();
(lldb) jlh source
"const age = 40; doit(age);"

I'm using lldb 9.0.0 on linux and wondering if you might be using macos, and perhaps I'm not seeing the same error?

Maybe a OS bug. I am trying debug on linux vm now, but I got no output (using https://github.com/vadimcn/vscode-lldb)

version
lldb version 10.0.0 (local revision aaae14ad1e80b489efe194b068b4b5d337ded6c8)
  clang revision aaae14ad1e80b489efe194b068b4b5d337ded6c8
  llvm revision aaae14ad1e80b489efe194b068b4b5d337ded6c8
  rust-enabled

image

on lldb 10 with error (Node.js doesn't export related symbol ?)

Failed to evaluate command _v8_internal_Print_Object(*((v8::internal::Object**)((void*)(s).val_))) :
error: <user expression 0>:1:44: no member named 'Object' in namespace 'v8::internal'
_v8_internal_Print_Object(*((v8::internal::Object**)((void*)(s).val_)))
                             ~~~~~~~~~~~~~~^
error: <user expression 0>:1:52: expected expression
_v8_internal_Print_Object(*((v8::internal::Object**)((void*)(s).val_))```

I got it works on linux :)
Still not a clue why macOS failed.

I still don't get it failed on macOS, any suggestion how should I debug it ?

I still don't get it failed on macOS, any suggestion how should I debug it ?

I'll see if I can reproduce this on my old mac. I did a quick test using Node.js and that worked, but I need to update my version of lldb.