1 //===------------------------- UnwindLevel1.c -----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //
8 // Implements C++ ABI Exception Handling Level 1 as documented at:
9 //      http://mentorembedded.github.io/cxx-abi/abi-eh.html
10 // using libunwind
11 //
12 //===----------------------------------------------------------------------===//
13 
14 // ARM EHABI does not specify _Unwind_{Get,Set}{GR,IP}().  Thus, we are
15 // defining inline functions to delegate the function calls to
16 // _Unwind_VRS_{Get,Set}().  However, some applications might declare the
17 // function protetype directly (instead of including <unwind.h>), thus we need
18 // to export these functions from libunwind.so as well.
19 #define _LIBUNWIND_UNWIND_LEVEL1_EXTERNAL_LINKAGE 1
20 
21 #include <inttypes.h>
22 #include <stdint.h>
23 #include <stdbool.h>
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 
28 #include "libunwind.h"
29 #include "unwind.h"
30 #include "config.h"
31 
32 #if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
33 
34 #ifndef _LIBUNWIND_SUPPORT_SEH_UNWIND
35 
36 static _Unwind_Reason_Code
unwind_phase1(unw_context_t * uc,unw_cursor_t * cursor,_Unwind_Exception * exception_object)37 unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
38   unw_init_local(cursor, uc);
39 
40   // Walk each frame looking for a place to stop.
41   bool handlerNotFound = true;
42   while (handlerNotFound) {
43     // Ask libunwind to get next frame (skip over first which is
44     // _Unwind_RaiseException).
45     int stepResult = unw_step(cursor);
46     if (stepResult == 0) {
47       _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step() reached "
48                                  "bottom => _URC_END_OF_STACK",
49                                  (void *)exception_object);
50       return _URC_END_OF_STACK;
51     } else if (stepResult < 0) {
52       _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step failed => "
53                                  "_URC_FATAL_PHASE1_ERROR",
54                                  (void *)exception_object);
55       return _URC_FATAL_PHASE1_ERROR;
56     }
57 
58     // See if frame has code to run (has personality routine).
59     unw_proc_info_t frameInfo;
60     unw_word_t sp;
61     if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
62       _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_get_proc_info "
63                                  "failed => _URC_FATAL_PHASE1_ERROR",
64                                  (void *)exception_object);
65       return _URC_FATAL_PHASE1_ERROR;
66     }
67 
68     // When tracing, print state information.
69     if (_LIBUNWIND_TRACING_UNWINDING) {
70       char functionBuf[512];
71       const char *functionName = functionBuf;
72       unw_word_t offset;
73       if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
74                              &offset) != UNW_ESUCCESS) ||
75           (frameInfo.start_ip + offset > frameInfo.end_ip))
76         functionName = ".anonymous.";
77       unw_word_t pc;
78       unw_get_reg(cursor, UNW_REG_IP, &pc);
79       _LIBUNWIND_TRACE_UNWINDING(
80           "unwind_phase1(ex_ojb=%p): pc=0x%" PRIxPTR ", start_ip=0x%" PRIxPTR
81           ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR "",
82           (void *)exception_object, pc, frameInfo.start_ip, functionName,
83           frameInfo.lsda, frameInfo.handler);
84     }
85 
86     // If there is a personality routine, ask it if it will want to stop at
87     // this frame.
88     if (frameInfo.handler != 0) {
89       __personality_routine p =
90           (__personality_routine)(uintptr_t)(frameInfo.handler);
91       _LIBUNWIND_TRACE_UNWINDING(
92           "unwind_phase1(ex_ojb=%p): calling personality function %p",
93           (void *)exception_object, (void *)(uintptr_t)p);
94       _Unwind_Reason_Code personalityResult =
95           (*p)(1, _UA_SEARCH_PHASE, exception_object->exception_class,
96                exception_object, (struct _Unwind_Context *)(cursor));
97       switch (personalityResult) {
98       case _URC_HANDLER_FOUND:
99         // found a catch clause or locals that need destructing in this frame
100         // stop search and remember stack pointer at the frame
101         handlerNotFound = false;
102         unw_get_reg(cursor, UNW_REG_SP, &sp);
103         exception_object->private_2 = (uintptr_t)sp;
104         _LIBUNWIND_TRACE_UNWINDING(
105             "unwind_phase1(ex_ojb=%p): _URC_HANDLER_FOUND",
106             (void *)exception_object);
107         return _URC_NO_REASON;
108 
109       case _URC_CONTINUE_UNWIND:
110         _LIBUNWIND_TRACE_UNWINDING(
111             "unwind_phase1(ex_ojb=%p): _URC_CONTINUE_UNWIND",
112             (void *)exception_object);
113         // continue unwinding
114         break;
115 
116       default:
117         // something went wrong
118         _LIBUNWIND_TRACE_UNWINDING(
119             "unwind_phase1(ex_ojb=%p): _URC_FATAL_PHASE1_ERROR",
120             (void *)exception_object);
121         return _URC_FATAL_PHASE1_ERROR;
122       }
123     }
124   }
125   return _URC_NO_REASON;
126 }
127 
128 
129 static _Unwind_Reason_Code
unwind_phase2(unw_context_t * uc,unw_cursor_t * cursor,_Unwind_Exception * exception_object)130 unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
131   unw_init_local(cursor, uc);
132 
133   _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)",
134                              (void *)exception_object);
135 
136   // Walk each frame until we reach where search phase said to stop.
137   while (true) {
138 
139     // Ask libunwind to get next frame (skip over first which is
140     // _Unwind_RaiseException).
141     int stepResult = unw_step(cursor);
142     if (stepResult == 0) {
143       _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "
144                                  "bottom => _URC_END_OF_STACK",
145                                  (void *)exception_object);
146       return _URC_END_OF_STACK;
147     } else if (stepResult < 0) {
148       _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step failed => "
149                                  "_URC_FATAL_PHASE1_ERROR",
150                                  (void *)exception_object);
151       return _URC_FATAL_PHASE2_ERROR;
152     }
153 
154     // Get info about this frame.
155     unw_word_t sp;
156     unw_proc_info_t frameInfo;
157     unw_get_reg(cursor, UNW_REG_SP, &sp);
158     if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
159       _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_get_proc_info "
160                                  "failed => _URC_FATAL_PHASE1_ERROR",
161                                  (void *)exception_object);
162       return _URC_FATAL_PHASE2_ERROR;
163     }
164 
165     // When tracing, print state information.
166     if (_LIBUNWIND_TRACING_UNWINDING) {
167       char functionBuf[512];
168       const char *functionName = functionBuf;
169       unw_word_t offset;
170       if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
171                              &offset) != UNW_ESUCCESS) ||
172           (frameInfo.start_ip + offset > frameInfo.end_ip))
173         functionName = ".anonymous.";
174       _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): start_ip=0x%" PRIxPTR
175                                  ", func=%s, sp=0x%" PRIxPTR ", lsda=0x%" PRIxPTR
176                                  ", personality=0x%" PRIxPTR,
177                                  (void *)exception_object, frameInfo.start_ip,
178                                  functionName, sp, frameInfo.lsda,
179                                  frameInfo.handler);
180     }
181 
182     // If there is a personality routine, tell it we are unwinding.
183     if (frameInfo.handler != 0) {
184       __personality_routine p =
185           (__personality_routine)(uintptr_t)(frameInfo.handler);
186       _Unwind_Action action = _UA_CLEANUP_PHASE;
187       if (sp == exception_object->private_2) {
188         // Tell personality this was the frame it marked in phase 1.
189         action = (_Unwind_Action)(_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME);
190       }
191        _Unwind_Reason_Code personalityResult =
192           (*p)(1, action, exception_object->exception_class, exception_object,
193                (struct _Unwind_Context *)(cursor));
194       switch (personalityResult) {
195       case _URC_CONTINUE_UNWIND:
196         // Continue unwinding
197         _LIBUNWIND_TRACE_UNWINDING(
198             "unwind_phase2(ex_ojb=%p): _URC_CONTINUE_UNWIND",
199             (void *)exception_object);
200         if (sp == exception_object->private_2) {
201           // Phase 1 said we would stop at this frame, but we did not...
202           _LIBUNWIND_ABORT("during phase1 personality function said it would "
203                            "stop here, but now in phase2 it did not stop here");
204         }
205         break;
206       case _URC_INSTALL_CONTEXT:
207         _LIBUNWIND_TRACE_UNWINDING(
208             "unwind_phase2(ex_ojb=%p): _URC_INSTALL_CONTEXT",
209             (void *)exception_object);
210         // Personality routine says to transfer control to landing pad.
211         // We may get control back if landing pad calls _Unwind_Resume().
212         if (_LIBUNWIND_TRACING_UNWINDING) {
213           unw_word_t pc;
214           unw_get_reg(cursor, UNW_REG_IP, &pc);
215           unw_get_reg(cursor, UNW_REG_SP, &sp);
216           _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering "
217                                      "user code with ip=0x%" PRIxPTR
218                                      ", sp=0x%" PRIxPTR,
219                                      (void *)exception_object, pc, sp);
220         }
221         unw_resume(cursor);
222         // unw_resume() only returns if there was an error.
223         return _URC_FATAL_PHASE2_ERROR;
224       default:
225         // Personality routine returned an unknown result code.
226         _LIBUNWIND_DEBUG_LOG("personality function returned unknown result %d",
227                              personalityResult);
228         return _URC_FATAL_PHASE2_ERROR;
229       }
230     }
231   }
232 
233   // Clean up phase did not resume at the frame that the search phase
234   // said it would...
235   return _URC_FATAL_PHASE2_ERROR;
236 }
237 
238 static _Unwind_Reason_Code
unwind_phase2_forced(unw_context_t * uc,unw_cursor_t * cursor,_Unwind_Exception * exception_object,_Unwind_Stop_Fn stop,void * stop_parameter)239 unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
240                      _Unwind_Exception *exception_object,
241                      _Unwind_Stop_Fn stop, void *stop_parameter) {
242   unw_init_local(cursor, uc);
243 
244   // Walk each frame until we reach where search phase said to stop
245   while (unw_step(cursor) > 0) {
246 
247     // Update info about this frame.
248     unw_proc_info_t frameInfo;
249     if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
250       _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): unw_step "
251                                  "failed => _URC_END_OF_STACK",
252                                  (void *)exception_object);
253       return _URC_FATAL_PHASE2_ERROR;
254     }
255 
256     // When tracing, print state information.
257     if (_LIBUNWIND_TRACING_UNWINDING) {
258       char functionBuf[512];
259       const char *functionName = functionBuf;
260       unw_word_t offset;
261       if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
262                              &offset) != UNW_ESUCCESS) ||
263           (frameInfo.start_ip + offset > frameInfo.end_ip))
264         functionName = ".anonymous.";
265       _LIBUNWIND_TRACE_UNWINDING(
266           "unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIxPTR
267           ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR,
268           (void *)exception_object, frameInfo.start_ip, functionName,
269           frameInfo.lsda, frameInfo.handler);
270     }
271 
272     // Call stop function at each frame.
273     _Unwind_Action action =
274         (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE);
275     _Unwind_Reason_Code stopResult =
276         (*stop)(1, action, exception_object->exception_class, exception_object,
277                 (struct _Unwind_Context *)(cursor), stop_parameter);
278     _LIBUNWIND_TRACE_UNWINDING(
279         "unwind_phase2_forced(ex_ojb=%p): stop function returned %d",
280         (void *)exception_object, stopResult);
281     if (stopResult != _URC_NO_REASON) {
282       _LIBUNWIND_TRACE_UNWINDING(
283           "unwind_phase2_forced(ex_ojb=%p): stopped by stop function",
284           (void *)exception_object);
285       return _URC_FATAL_PHASE2_ERROR;
286     }
287 
288     // If there is a personality routine, tell it we are unwinding.
289     if (frameInfo.handler != 0) {
290       __personality_routine p =
291           (__personality_routine)(intptr_t)(frameInfo.handler);
292       _LIBUNWIND_TRACE_UNWINDING(
293           "unwind_phase2_forced(ex_ojb=%p): calling personality function %p",
294           (void *)exception_object, (void *)(uintptr_t)p);
295       _Unwind_Reason_Code personalityResult =
296           (*p)(1, action, exception_object->exception_class, exception_object,
297                (struct _Unwind_Context *)(cursor));
298       switch (personalityResult) {
299       case _URC_CONTINUE_UNWIND:
300         _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
301                                    "personality returned "
302                                    "_URC_CONTINUE_UNWIND",
303                                    (void *)exception_object);
304         // Destructors called, continue unwinding
305         break;
306       case _URC_INSTALL_CONTEXT:
307         _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
308                                    "personality returned "
309                                    "_URC_INSTALL_CONTEXT",
310                                    (void *)exception_object);
311         // We may get control back if landing pad calls _Unwind_Resume().
312         unw_resume(cursor);
313         break;
314       default:
315         // Personality routine returned an unknown result code.
316         _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
317                                    "personality returned %d, "
318                                    "_URC_FATAL_PHASE2_ERROR",
319                                    (void *)exception_object, personalityResult);
320         return _URC_FATAL_PHASE2_ERROR;
321       }
322     }
323   }
324 
325   // Call stop function one last time and tell it we've reached the end
326   // of the stack.
327   _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): calling stop "
328                              "function with _UA_END_OF_STACK",
329                              (void *)exception_object);
330   _Unwind_Action lastAction =
331       (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK);
332   (*stop)(1, lastAction, exception_object->exception_class, exception_object,
333           (struct _Unwind_Context *)(cursor), stop_parameter);
334 
335   // Clean up phase did not resume at the frame that the search phase said it
336   // would.
337   return _URC_FATAL_PHASE2_ERROR;
338 }
339 
340 
341 /// Called by __cxa_throw.  Only returns if there is a fatal error.
342 _LIBUNWIND_EXPORT _Unwind_Reason_Code
_Unwind_RaiseException(_Unwind_Exception * exception_object)343 _Unwind_RaiseException(_Unwind_Exception *exception_object) {
344   _LIBUNWIND_TRACE_API("_Unwind_RaiseException(ex_obj=%p)",
345                        (void *)exception_object);
346   unw_context_t uc;
347   unw_cursor_t cursor;
348   unw_getcontext(&uc);
349 
350   // Mark that this is a non-forced unwind, so _Unwind_Resume()
351   // can do the right thing.
352   exception_object->private_1 = 0;
353   exception_object->private_2 = 0;
354 
355   // phase 1: the search phase
356   _Unwind_Reason_Code phase1 = unwind_phase1(&uc, &cursor, exception_object);
357   if (phase1 != _URC_NO_REASON)
358     return phase1;
359 
360   // phase 2: the clean up phase
361   return unwind_phase2(&uc, &cursor, exception_object);
362 }
363 
364 
365 
366 /// When _Unwind_RaiseException() is in phase2, it hands control
367 /// to the personality function at each frame.  The personality
368 /// may force a jump to a landing pad in that function, the landing
369 /// pad code may then call _Unwind_Resume() to continue with the
370 /// unwinding.  Note: the call to _Unwind_Resume() is from compiler
371 /// geneated user code.  All other _Unwind_* routines are called
372 /// by the C++ runtime __cxa_* routines.
373 ///
374 /// Note: re-throwing an exception (as opposed to continuing the unwind)
375 /// is implemented by having the code call __cxa_rethrow() which
376 /// in turn calls _Unwind_Resume_or_Rethrow().
377 _LIBUNWIND_EXPORT void
_Unwind_Resume(_Unwind_Exception * exception_object)378 _Unwind_Resume(_Unwind_Exception *exception_object) {
379   _LIBUNWIND_TRACE_API("_Unwind_Resume(ex_obj=%p)", (void *)exception_object);
380   unw_context_t uc;
381   unw_cursor_t cursor;
382   unw_getcontext(&uc);
383 
384   if (exception_object->private_1 != 0)
385     unwind_phase2_forced(&uc, &cursor, exception_object,
386                          (_Unwind_Stop_Fn) exception_object->private_1,
387                          (void *)exception_object->private_2);
388   else
389     unwind_phase2(&uc, &cursor, exception_object);
390 
391   // Clients assume _Unwind_Resume() does not return, so all we can do is abort.
392   _LIBUNWIND_ABORT("_Unwind_Resume() can't return");
393 }
394 
395 
396 
397 /// Not used by C++.
398 /// Unwinds stack, calling "stop" function at each frame.
399 /// Could be used to implement longjmp().
400 _LIBUNWIND_EXPORT _Unwind_Reason_Code
_Unwind_ForcedUnwind(_Unwind_Exception * exception_object,_Unwind_Stop_Fn stop,void * stop_parameter)401 _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,
402                      _Unwind_Stop_Fn stop, void *stop_parameter) {
403   _LIBUNWIND_TRACE_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)",
404                        (void *)exception_object, (void *)(uintptr_t)stop);
405   unw_context_t uc;
406   unw_cursor_t cursor;
407   unw_getcontext(&uc);
408 
409   // Mark that this is a forced unwind, so _Unwind_Resume() can do
410   // the right thing.
411   exception_object->private_1 = (uintptr_t) stop;
412   exception_object->private_2 = (uintptr_t) stop_parameter;
413 
414   // do it
415   return unwind_phase2_forced(&uc, &cursor, exception_object, stop, stop_parameter);
416 }
417 
418 
419 /// Called by personality handler during phase 2 to get LSDA for current frame.
420 _LIBUNWIND_EXPORT uintptr_t
_Unwind_GetLanguageSpecificData(struct _Unwind_Context * context)421 _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
422   unw_cursor_t *cursor = (unw_cursor_t *)context;
423   unw_proc_info_t frameInfo;
424   uintptr_t result = 0;
425   if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
426     result = (uintptr_t)frameInfo.lsda;
427   _LIBUNWIND_TRACE_API(
428       "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIxPTR,
429       (void *)context, result);
430   if (result != 0) {
431     if (*((uint8_t *)result) != 0xFF)
432       _LIBUNWIND_DEBUG_LOG("lsda at 0x%" PRIxPTR " does not start with 0xFF",
433                            result);
434   }
435   return result;
436 }
437 
438 
439 /// Called by personality handler during phase 2 to find the start of the
440 /// function.
441 _LIBUNWIND_EXPORT uintptr_t
_Unwind_GetRegionStart(struct _Unwind_Context * context)442 _Unwind_GetRegionStart(struct _Unwind_Context *context) {
443   unw_cursor_t *cursor = (unw_cursor_t *)context;
444   unw_proc_info_t frameInfo;
445   uintptr_t result = 0;
446   if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
447     result = (uintptr_t)frameInfo.start_ip;
448   _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIxPTR,
449                        (void *)context, result);
450   return result;
451 }
452 
453 #endif // !_LIBUNWIND_SUPPORT_SEH_UNWIND
454 
455 /// Called by personality handler during phase 2 if a foreign exception
456 // is caught.
457 _LIBUNWIND_EXPORT void
_Unwind_DeleteException(_Unwind_Exception * exception_object)458 _Unwind_DeleteException(_Unwind_Exception *exception_object) {
459   _LIBUNWIND_TRACE_API("_Unwind_DeleteException(ex_obj=%p)",
460                        (void *)exception_object);
461   if (exception_object->exception_cleanup != NULL)
462     (*exception_object->exception_cleanup)(_URC_FOREIGN_EXCEPTION_CAUGHT,
463                                            exception_object);
464 }
465 
466 /// Called by personality handler during phase 2 to get register values.
467 _LIBUNWIND_EXPORT uintptr_t
_Unwind_GetGR(struct _Unwind_Context * context,int index)468 _Unwind_GetGR(struct _Unwind_Context *context, int index) {
469   unw_cursor_t *cursor = (unw_cursor_t *)context;
470   unw_word_t result;
471   unw_get_reg(cursor, index, &result);
472   _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d) => 0x%" PRIxPTR,
473                        (void *)context, index, result);
474   return (uintptr_t)result;
475 }
476 
477 /// Called by personality handler during phase 2 to alter register values.
_Unwind_SetGR(struct _Unwind_Context * context,int index,uintptr_t value)478 _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
479                                      uintptr_t value) {
480   _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%0" PRIxPTR
481                        ")",
482                        (void *)context, index, value);
483   unw_cursor_t *cursor = (unw_cursor_t *)context;
484   unw_set_reg(cursor, index, value);
485 }
486 
487 /// Called by personality handler during phase 2 to get instruction pointer.
_Unwind_GetIP(struct _Unwind_Context * context)488 _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
489   unw_cursor_t *cursor = (unw_cursor_t *)context;
490   unw_word_t result;
491   unw_get_reg(cursor, UNW_REG_IP, &result);
492   _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIxPTR,
493                        (void *)context, result);
494   return (uintptr_t)result;
495 }
496 
497 /// Called by personality handler during phase 2 to alter instruction pointer,
498 /// such as setting where the landing pad is, so _Unwind_Resume() will
499 /// start executing in the landing pad.
_Unwind_SetIP(struct _Unwind_Context * context,uintptr_t value)500 _LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,
501                                      uintptr_t value) {
502   _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%0" PRIxPTR ")",
503                        (void *)context, value);
504   unw_cursor_t *cursor = (unw_cursor_t *)context;
505   unw_set_reg(cursor, UNW_REG_IP, value);
506 }
507 
508 #endif // !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
509