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

Want Map object output #82

Open
richardkiene opened this issue Nov 16, 2016 · 1 comment
Open

Want Map object output #82

richardkiene opened this issue Nov 16, 2016 · 1 comment

Comments

@richardkiene
Copy link

Currently mdb_v8 shows the following when inspecting a core dump containing a Map object:

<unknown JavaScript object type "JSMap">

Ideally mdb_v8 will output the contents of the Map object so that it's keys and values are available for debugging.

I encountered this issue using mdb_v8 version 1.1.3 and a core dump from NodeJS v4.6.0.

@arekinath
Copy link

arekinath commented Feb 17, 2017

FWIW you can dump out the guts of a Map like this today:

    "cache": fd411eb9: {
        "admin_ips": a0a22965: <unknown JavaScript object type "JSMap">,
        "owners": a0a22975: <unknown JavaScript object type "JSMap">,
        "vms": a0a22985: <unknown JavaScript object type "JSMap">,
    },
> a0a22975::v8print
a0a22975 JSMap {
    a0a22975 JSCollection {
        a0a22975 JSObject {
            a0a22975 JSReceiver {
                a0a22975 HeapObject < Object  {
                    a0a22974 map = 99409db9 (Map)
                }
            }
            a0a22978 properties = ad108099 (FixedArray)
            a0a2297c elements = ad108099 (FixedArray)
        }
        a0a22980 table = 93860a6d (FixedArray)
    }
}

Take that value of the table field:

> 93860a6d::v8array | ::jsprint
8: 4
a: 5
0: 0
fffffffe: 2147483647
8: 4
6: 3
fffffffe: 2147483647
938f6221: "8a70155f-752f-eb91-a755-f4edbee5c99f"
93849041: {
    "vms": 9385fa89: <unknown JavaScript object type "JSMap">,
}
fffffffe: 2147483647
938f69b1: "a11af3cb-1549-c860-e29e-c3d4e1e6f4b2"
93849051: {
    "vms": 9385fa99: <unknown JavaScript object type "JSMap">,
}
fffffffe: 2147483647
938f78f1: "50f60f7d-8c7d-ec4e-f4ba-978ca56ee281"
93849061: {
    "vms": 9385faa9: <unknown JavaScript object type "JSMap">,
}
0: 0
938f7ac9: "08339468-4f60-6ba2-cfe2-b2ba71bfd7c4"
93849071: {
    "vms": 9385fab9: <unknown JavaScript object type "JSMap">,
}
4: 2
938f815d: "930896af-bf8c-48d4-885c-6573a94b1853"
93849081: {
    "vms": 9385fac9: <unknown JavaScript object type "JSMap">,
}
2: 1
ad1080dd: undefined
ad1080dd: undefined
ad1080dd: undefined
ad1080dd: undefined                   
ad1080dd: undefined
ad1080dd: undefined
ad1080dd: undefined
ad1080dd: undefined
ad1080dd: undefined

The format of the Map table data in the V8Array is found in v8/src/collection.js and v8/src/macros.py. The first three array indices (0,1,2) are ORDERED_HASH_TABLE_BUCKET_COUNT, ORDERED_HASH_TABLE_ELEMENT_COUNT and ORDERED_HASH_TABLE_DELETED_COUNT. From 3 onwards are the actual contents of the Map -- first the primary values in each hash bucket, then followed by a complex scheme of "chains" for subsequent values in each bucket. I haven't completely untangled how to read the chains yet, but you can see the first value in each bucket easily (and if ELEMENT_COUNT < BUCKET_COUNT then you're done anyway)

It does usually look like the contents of the chains are in there at indices as plain pointers, so using ::jsprint on the entire V8Array should get you all the values, and it looks like the keys are always in the index before each value.

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

No branches or pull requests

2 participants