Closed Bug 1069704 Opened 5 years ago Closed 5 years ago

Add an easy way to get an object's address

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla35

People

(Reporter: billm, Assigned: billm)

Details

Attachments

(1 file)

Attached patch object-addressSplinter Review
This is really useful when debugging chrome code since toString() doesn't allow you to distinguish two objects. It won't work properly with moving GC so I made it nightly-only to ensure that we only use it for development. Hopefully developers won't mind if the address occasionally changes.

I used to use dumpObject to get the address, but this function is a lot easier.
Attachment #8491953 - Flags: review?(sphink)
Comment on attachment 8491953 [details] [diff] [review]
object-address

Review of attachment 8491953 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/builtin/TestingFunctions.cpp
@@ +1677,5 @@
> +
> +    char buffer[64];
> +    JS_snprintf(buffer, sizeof(buffer), "%p", &args[0].toObject());
> +
> +    JSString *str = JS_NewStringCopyZ(cx, buffer);

For OOM-fuzzing, please return false if !str.

@@ +2331,5 @@
>  
> +#ifdef NIGHTLY_BUILD
> +    JS_FN_HELP("objectAddress", ObjectAddress, 1, 0,
> +"objectAddress(obj)",
> +"  Return the current address of the object."),

Bump up the scare factor a little. "  Return the current address of the object. For debugging only; this address may change during a minor or compacting GC."

It looks like we don't wall off fuzzing-unsafe functions in this file. I'm not sure how that works. But I think this should probably return "0" ifdef JS_MORE_DETERMINISTIC.
Attachment #8491953 - Flags: review?(sphink) → review+
https://hg.mozilla.org/mozilla-central/rev/752ce35b166b
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla35
Unified_cpp_js_src7.o
Unified_cpp_js_src8.o
In file included from /Users/skywalker/Desktop/shell-cache/js-dbg-opt-64-dm-nsprBuild-darwin-752ce35b166b/objdir-js/js/src/Unified_cpp_js_src0.cpp:158:
/Users/skywalker/trees/mozilla-central/js/src/builtin/TestingFunctions.cpp:1711:17: error: no member named 'setInt' in 'JS::MutableHandle<JS::Value>'
    args.rval().setInt(0);
    ~~~~~~~~~~~ ^
1 error generated.

===

> https://hg.mozilla.org/mozilla-central/rev/752ce35b166b

This landing broke deterministic builds, I spoke to :billm on IRC and he has a quick fix on the way...
Flags: needinfo?(wmccloskey)
This fixes the compile error with deterministic builds.
https://hg.mozilla.org/integration/mozilla-inbound/rev/e6e63113336d
Flags: needinfo?(wmccloskey)
You need to log in before you can comment on or make changes to this bug.