Skip to content

Commit 459082f

Browse files
avpfacebook-github-bot
authored andcommitted
Fix HermesValueFormatter to work with SH
Summary: The tag values and HermesValue layout failed to format properly. Add the BigInt tag values and handle the new layout which contains a union in HermesValueBase. Reviewed By: tmikov Differential Revision: D42086121 fbshipit-source-id: 4cd7ce89cf59dd5f7317a1413d4fa12e0c68fd0c
1 parent c50f686 commit 459082f

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

lldb/HermesValueFormatter.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def __lldb_init_module(debugger, _):
1818
"""Installs a new debugger handle for formatting hermes values"""
1919
debugger.HandleCommand(
2020
"type summary add "
21+
'"hermes::vm::HermesValueBase" '
22+
'"hermes::vm::SHLegacyValue" '
2123
'"hermes::vm::HermesValue" '
2224
'"hermes::vm::PinnedHermesValue" '
2325
'"hermes::vm::GCHermesValue" '
@@ -33,10 +35,10 @@ class Tag:
3335
LAST_TAG = 0xFFFF
3436
EMPTY_INVALID_TAG = FIRST_TAG
3537
UNDEFINED_NULL_TAG = FIRST_TAG + 1
36-
BOOL_TAG = FIRST_TAG + 2
37-
SYMBOL_TAG = FIRST_TAG + 3
38-
NATIVE_VALUE_TAG = FIRST_TAG + 4
39-
STR_TAG = FIRST_TAG + 5
38+
BOOL_SYMBOL_TAG = FIRST_TAG + 2
39+
NATIVE_VALUE_TAG = FIRST_TAG + 3
40+
STR_TAG = FIRST_TAG + 4
41+
BIGINT_TAG = FIRST_TAG + 5
4042
OBJECT_TAG = FIRST_TAG + 6
4143

4244

@@ -45,12 +47,14 @@ class ExtendedTag:
4547
INVALID = Tag.EMPTY_INVALID_TAG * 2 + 1
4648
UNDEFINED = Tag.UNDEFINED_NULL_TAG * 2
4749
NULL = Tag.UNDEFINED_NULL_TAG * 2 + 1
48-
BOOL = Tag.BOOL_TAG * 2
49-
SYMBOL = Tag.SYMBOL_TAG * 2
50+
BOOL = Tag.BOOL_SYMBOL_TAG * 2
51+
SYMBOL = Tag.BOOL_SYMBOL_TAG * 2 + 1
5052
NATIVE1 = Tag.NATIVE_VALUE_TAG * 2
5153
NATIVE2 = Tag.NATIVE_VALUE_TAG * 2 + 1
5254
STR1 = Tag.STR_TAG * 2
5355
STR2 = Tag.STR_TAG * 2 + 1
56+
BIGINT1 = Tag.BIGINT_TAG * 2
57+
BIGINT2 = Tag.BIGINT_TAG * 2 + 1
5458
OBJECT1 = Tag.OBJECT_TAG * 2
5559
OBJECT2 = Tag.OBJECT_TAG * 2 + 1
5660

@@ -66,6 +70,8 @@ class ExtendedTag:
6670
NATIVE2: "NativeValue",
6771
STR1: "String",
6872
STR2: "String",
73+
BIGINT1: "BigInt",
74+
BIGINT2: "BigInt",
6975
OBJECT1: "Object",
7076
OBJECT2: "Object",
7177
}
@@ -146,7 +152,10 @@ def hv_type_format(valobj, _):
146152
"""This formats a HermesValue based on the same encoding API used by
147153
HermesValues. It should be kept up to date with any changes to that
148154
encoding."""
149-
raw_val = valobj.GetChildMemberWithName("raw_")
155+
# Use have to descend through GetChildAtIndex multiple times due to
156+
# the union. LLDB doesn't appear to lookup through unions when using
157+
# GetChildMemberWithName.
158+
raw_val = valobj.GetChildAtIndex(0).GetChildAtIndex(0).GetChildMemberWithName("raw")
150159
return str(HermesValue(raw_val.GetValueAsUnsigned()))
151160

152161

0 commit comments

Comments
 (0)