MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / ProcessDescriptors

Function ProcessDescriptors

system/lib/libunwind/src/Unwind-EHABI.cpp:73–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71};
72
73_Unwind_Reason_Code ProcessDescriptors(
74 _Unwind_State state,
75 _Unwind_Control_Block* ucbp,
76 struct _Unwind_Context* context,
77 Descriptor::Format format,
78 const char* descriptorStart,
79 uint32_t flags) {
80
81 // EHT is inlined in the index using compact form. No descriptors. #5
82 if (flags & 0x1)
83 return _URC_CONTINUE_UNWIND;
84
85 // TODO: We should check the state here, and determine whether we need to
86 // perform phase1 or phase2 unwinding.
87 (void)state;
88
89 const char* descriptor = descriptorStart;
90 uint32_t descriptorWord;
91 getNextWord(descriptor, &descriptorWord);
92 while (descriptorWord) {
93 // Read descriptor based on # 9.2.
94 uint32_t length;
95 uint32_t offset;
96 switch (format) {
97 case Descriptor::LU32:
98 descriptor = getNextWord(descriptor, &length);
99 descriptor = getNextWord(descriptor, &offset);
100 break;
101 case Descriptor::LU16:
102 descriptor = getNextNibble(descriptor, &length);
103 descriptor = getNextNibble(descriptor, &offset);
104 break;
105 default:
106 assert(false);
107 return _URC_FAILURE;
108 }
109
110 // See # 9.2 table for decoding the kind of descriptor. It's a 2-bit value.
111 Descriptor::Kind kind =
112 static_cast<Descriptor::Kind>((length & 0x1) | ((offset & 0x1) << 1));
113
114 // Clear off flag from last bit.
115 length &= ~1u;
116 offset &= ~1u;
117 uintptr_t scopeStart = ucbp->pr_cache.fnstart + offset;
118 uintptr_t scopeEnd = scopeStart + length;
119 uintptr_t pc = _Unwind_GetIP(context);
120 bool isInScope = (scopeStart <= pc) && (pc < scopeEnd);
121
122 switch (kind) {
123 case Descriptor::CLEANUP: {
124 // TODO(ajwong): Handle cleanup descriptors.
125 break;
126 }
127 case Descriptor::FUNC: {
128 // TODO(ajwong): Handle function descriptors.
129 break;
130 }

Callers 1

unwindOneFrameFunction · 0.85

Calls 5

getNextWordFunction · 0.85
getNextNibbleFunction · 0.85
signExtendPrel31Function · 0.85
_Unwind_GetIPFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected