Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading contents of an Array/ArrayBufferView #89

Closed
joyeecheung opened this issue May 31, 2017 · 7 comments · Fixed by #116
Closed

Reading contents of an Array/ArrayBufferView #89

joyeecheung opened this issue May 31, 2017 · 7 comments · Fixed by #116

Comments

@joyeecheung
Copy link
Member

joyeecheung commented May 31, 2017

Hi, at the moment when doing v8 inspect <address-of-an-array> llnode would only print the length (and offset & backstore address) of an Array (ArrayBufferView). Are there any support for reading the elements of an Array/ArrayBufferView? Thanks.

@bnoordhuis
Copy link
Member

Do you mean Array or ArrayBuffer? If the latter: not at the moment. You can take the address of the backing store and print that like you would with normal memory.

We could pretty-print ArrayBuffers but we'd need to do something sensible for large arrays, like print only the first 100 elements.

If you want to work on it, the logic is in JSArrayBuffer::Inspect() and JSArrayBufferView::Inspect() in src/llv8.cc. Questions? I'll try to answer them.

@joyeecheung
Copy link
Member Author

joyeecheung commented May 31, 2017

@bnoordhuis Thanks for the answer, I actually meant both, but I just realized it does support arrays, I guess the arrays that I've tried somehow errorred in one of the steps of JSObject::InspectElements so the elements didn't show up.

I think we could do a new command for array-like objects (or a new flag to inspect) which also takes indexes/ranges as operand? I'd be happy to work on it.

EDIT: just realized there is v8 inspect --string-length num which is somewhat related, so I think making this a new flag would be more suitable.

@bnoordhuis
Copy link
Member

A flag sounds good but the default should probably be conservative for large arraybuffers because those can easily be 100s of MBs and you don't usually want to see every last byte printed.

As well, it would be nice if typed arrays printed their values as their natural types (uint8, int32, float64, etc.) instead of simply dumping out the .buffer property but that's a bigger undertaking.

@bnoordhuis
Copy link
Member

@joyeecheung Just curious, were you able to make any progress on this?

@joyeecheung
Copy link
Member Author

@bnoordhuis I have implemented --array-length for normal arrays but have not found the time to do the same for array buffers. I will open a PR for what have been done, can probably implement the other parts this weekend.

@joyeecheung
Copy link
Member Author

@hhellyer The implementation for ArrayBuffer and ArrayBufferView has not been completed yet, reopening..

@joyeecheung joyeecheung reopened this Jun 29, 2017
@hhellyer
Copy link
Contributor

@joyeecheung - Ah, I suspect that's because the commit comment referenced this with "Fix", sorry about that!

hhellyer added a commit that referenced this issue Aug 14, 2017
Fixes: #89
PR-URL: #116
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants