Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
mdb_v8: fix symbols not loaded properly
Browse files Browse the repository at this point in the history
V8_CONSTANT_REMOVED_SINCE(major, minor) can be used to mark a constant
has being removed from V8 since V8 version major.minor.

Reviewed-By: Dave Pacheco <[email protected]>
Reviewed-By: Timothy J Fontaine <[email protected]>
  • Loading branch information
Julien Gilli committed Feb 5, 2015
1 parent ebfa7e3 commit 878c40e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
31 changes: 25 additions & 6 deletions deps/mdb_v8/mdb_v8.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ static intptr_t V8_FIELDINDEX_SHIFT;
static intptr_t V8_PROP_IDX_CONTENT;
static intptr_t V8_PROP_IDX_FIRST;
static intptr_t V8_PROP_TYPE_FIELD;
static intptr_t V8_PROP_FIRST_PHANTOM;
static intptr_t V8_PROP_TYPE_MASK;
static intptr_t V8_PROP_DESC_KEY;
static intptr_t V8_PROP_DESC_DETAILS;
Expand Down Expand Up @@ -220,6 +219,7 @@ static ssize_t V8_OFF_STRING_LENGTH;

#define V8_CONSTANT_OPTIONAL 1
#define V8_CONSTANT_HASFALLBACK 2
#define V8_CONSTANT_REMOVED 4

#define V8_CONSTANT_MAJORSHIFT 3
#define V8_CONSTANT_MAJORMASK ((1 << 4) - 1)
Expand All @@ -235,6 +235,10 @@ static ssize_t V8_OFF_STRING_LENGTH;
(V8_CONSTANT_OPTIONAL | V8_CONSTANT_HASFALLBACK | \
((maj) << V8_CONSTANT_MAJORSHIFT) | ((min) << V8_CONSTANT_MINORSHIFT))

#define V8_CONSTANT_REMOVED_SINCE(maj, min) \
(V8_CONSTANT_REMOVED | \
((maj) << V8_CONSTANT_MAJORSHIFT) | ((min) << V8_CONSTANT_MINORSHIFT))

/*
* Table of constants used directly by this file.
*/
Expand Down Expand Up @@ -264,8 +268,10 @@ static v8_constant_t v8_constants[] = {
{ &V8_SlicedStringTag, "v8dbg_SlicedStringTag",
V8_CONSTANT_FALLBACK(0, 0), 0x3 },
{ &V8_ExternalStringTag, "v8dbg_ExternalStringTag" },
{ &V8_FailureTag, "v8dbg_FailureTag" },
{ &V8_FailureTagMask, "v8dbg_FailureTagMask" },
{ &V8_FailureTag, "v8dbg_FailureTag",
V8_CONSTANT_REMOVED_SINCE(3, 28) },
{ &V8_FailureTagMask, "v8dbg_FailureTagMask",
V8_CONSTANT_REMOVED_SINCE(3, 28) },
{ &V8_HeapObjectTag, "v8dbg_HeapObjectTag" },
{ &V8_HeapObjectTagMask, "v8dbg_HeapObjectTagMask" },
{ &V8_SmiTag, "v8dbg_SmiTag" },
Expand Down Expand Up @@ -294,8 +300,7 @@ static v8_constant_t v8_constants[] = {
{ &V8_ISSHARED_SHIFT, "v8dbg_isshared_shift",
V8_CONSTANT_FALLBACK(3, 11), 0 },
{ &V8_PROP_IDX_FIRST, "v8dbg_prop_idx_first" },
{ &V8_PROP_TYPE_FIELD, "v8dbg_prop_type_field" },
{ &V8_PROP_FIRST_PHANTOM, "v8dbg_prop_type_first_phantom" },
{ &V8_PROP_TYPE_FIELD, "v8dbg_prop_type_field" },
{ &V8_PROP_TYPE_MASK, "v8dbg_prop_type_mask" },
{ &V8_PROP_IDX_CONTENT, "v8dbg_prop_idx_content",
V8_CONSTANT_OPTIONAL },
Expand Down Expand Up @@ -485,6 +490,18 @@ static int jsobj_print_jsarray(uintptr_t, jsobj_print_t *);
static int jsobj_print_jsfunction(uintptr_t, jsobj_print_t *);
static int jsobj_print_jsdate(uintptr_t, jsobj_print_t *);

/*
* Returns 1 if the V8 version v8_major.v8.minor is strictly older than
* the V8 version represented by "flags".
* Returns 0 otherwise.
*/
static int
v8_version_older(uintptr_t v8_major, uintptr_t v8_minor, uint32_t flags) {
return v8_major < V8_CONSTANT_MAJOR(flags) ||
(v8_major == V8_CONSTANT_MAJOR(flags) &&
v8_minor < V8_CONSTANT_MINOR(flags));
}

/*
* Invoked when this dmod is initially loaded to load the set of classes, enums,
* and other constants from the metadata in the target binary.
Expand Down Expand Up @@ -531,7 +548,9 @@ autoconfigure(v8_cfg_t *cfgp)
continue;
}

if (!(cnp->v8c_flags & V8_CONSTANT_OPTIONAL)) {
if (!(cnp->v8c_flags & V8_CONSTANT_OPTIONAL) &&
(!(cnp->v8c_flags & V8_CONSTANT_REMOVED) ||
v8_version_older(v8_major, v8_minor, cnp->v8c_flags))) {
mdb_warn("failed to read \"%s\"", cnp->v8c_symbol);
failed++;
continue;
Expand Down
5 changes: 4 additions & 1 deletion deps/mdb_v8/v8dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
* Determine whether a given pointer refers to a SMI, Failure, or HeapObject.
*/
#define V8_IS_SMI(ptr) (((ptr) & V8_SmiTagMask) == V8_SmiTag)
#define V8_IS_FAILURE(ptr) (((ptr) & V8_FailureTagMask) == V8_FailureTag)
#define V8_IS_FAILURE(ptr) (V8_FailureTagMask != -1 && \
V8_FailureTagMask != -1 && \
((ptr) & V8_FailureTagMask) == V8_FailureTag)

#define V8_IS_HEAPOBJECT(ptr) \
(((ptr) & V8_HeapObjectTagMask) == V8_HeapObjectTag)

Expand Down

0 comments on commit 878c40e

Please sign in to comment.