authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-19 16:54:00-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-19 16:54:00-04:00
logdab0cf6428d96af540399563f2e2d5a79c3a7d5e
treea2f005a5b62a49de15b00d78455f24663a1848c0
parent2117fbdae35dddf368c4ce5bb39cc73fa0f78d4c
signaturelock-open Commit is signed but in an unrecognized format.

update libunwind to llvm9

upstream commit 1931d3cb20a00da732c5210b123656632982fde0

27 files changed, 1242 insertions(+), 964 deletions(-)

lib/libunwind/LICENSE.TXT created+311
...@@ -0,0 +1,311 @@
1==============================================================================
2The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
3==============================================================================
4
5 Apache License
6 Version 2.0, January 2004
7 http://www.apache.org/licenses/
8
9 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
10
11 1. Definitions.
12
13 "License" shall mean the terms and conditions for use, reproduction,
14 and distribution as defined by Sections 1 through 9 of this document.
15
16 "Licensor" shall mean the copyright owner or entity authorized by
17 the copyright owner that is granting the License.
18
19 "Legal Entity" shall mean the union of the acting entity and all
20 other entities that control, are controlled by, or are under common
21 control with that entity. For the purposes of this definition,
22 "control" means (i) the power, direct or indirect, to cause the
23 direction or management of such entity, whether by contract or
24 otherwise, or (ii) ownership of fifty percent (50%) or more of the
25 outstanding shares, or (iii) beneficial ownership of such entity.
26
27 "You" (or "Your") shall mean an individual or Legal Entity
28 exercising permissions granted by this License.
29
30 "Source" form shall mean the preferred form for making modifications,
31 including but not limited to software source code, documentation
32 source, and configuration files.
33
34 "Object" form shall mean any form resulting from mechanical
35 transformation or translation of a Source form, including but
36 not limited to compiled object code, generated documentation,
37 and conversions to other media types.
38
39 "Work" shall mean the work of authorship, whether in Source or
40 Object form, made available under the License, as indicated by a
41 copyright notice that is included in or attached to the work
42 (an example is provided in the Appendix below).
43
44 "Derivative Works" shall mean any work, whether in Source or Object
45 form, that is based on (or derived from) the Work and for which the
46 editorial revisions, annotations, elaborations, or other modifications
47 represent, as a whole, an original work of authorship. For the purposes
48 of this License, Derivative Works shall not include works that remain
49 separable from, or merely link (or bind by name) to the interfaces of,
50 the Work and Derivative Works thereof.
51
52 "Contribution" shall mean any work of authorship, including
53 the original version of the Work and any modifications or additions
54 to that Work or Derivative Works thereof, that is intentionally
55 submitted to Licensor for inclusion in the Work by the copyright owner
56 or by an individual or Legal Entity authorized to submit on behalf of
57 the copyright owner. For the purposes of this definition, "submitted"
58 means any form of electronic, verbal, or written communication sent
59 to the Licensor or its representatives, including but not limited to
60 communication on electronic mailing lists, source code control systems,
61 and issue tracking systems that are managed by, or on behalf of, the
62 Licensor for the purpose of discussing and improving the Work, but
63 excluding communication that is conspicuously marked or otherwise
64 designated in writing by the copyright owner as "Not a Contribution."
65
66 "Contributor" shall mean Licensor and any individual or Legal Entity
67 on behalf of whom a Contribution has been received by Licensor and
68 subsequently incorporated within the Work.
69
70 2. Grant of Copyright License. Subject to the terms and conditions of
71 this License, each Contributor hereby grants to You a perpetual,
72 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73 copyright license to reproduce, prepare Derivative Works of,
74 publicly display, publicly perform, sublicense, and distribute the
75 Work and such Derivative Works in Source or Object form.
76
77 3. Grant of Patent License. Subject to the terms and conditions of
78 this License, each Contributor hereby grants to You a perpetual,
79 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
80 (except as stated in this section) patent license to make, have made,
81 use, offer to sell, sell, import, and otherwise transfer the Work,
82 where such license applies only to those patent claims licensable
83 by such Contributor that are necessarily infringed by their
84 Contribution(s) alone or by combination of their Contribution(s)
85 with the Work to which such Contribution(s) was submitted. If You
86 institute patent litigation against any entity (including a
87 cross-claim or counterclaim in a lawsuit) alleging that the Work
88 or a Contribution incorporated within the Work constitutes direct
89 or contributory patent infringement, then any patent licenses
90 granted to You under this License for that Work shall terminate
91 as of the date such litigation is filed.
92
93 4. Redistribution. You may reproduce and distribute copies of the
94 Work or Derivative Works thereof in any medium, with or without
95 modifications, and in Source or Object form, provided that You
96 meet the following conditions:
97
98 (a) You must give any other recipients of the Work or
99 Derivative Works a copy of this License; and
100
101 (b) You must cause any modified files to carry prominent notices
102 stating that You changed the files; and
103
104 (c) You must retain, in the Source form of any Derivative Works
105 that You distribute, all copyright, patent, trademark, and
106 attribution notices from the Source form of the Work,
107 excluding those notices that do not pertain to any part of
108 the Derivative Works; and
109
110 (d) If the Work includes a "NOTICE" text file as part of its
111 distribution, then any Derivative Works that You distribute must
112 include a readable copy of the attribution notices contained
113 within such NOTICE file, excluding those notices that do not
114 pertain to any part of the Derivative Works, in at least one
115 of the following places: within a NOTICE text file distributed
116 as part of the Derivative Works; within the Source form or
117 documentation, if provided along with the Derivative Works; or,
118 within a display generated by the Derivative Works, if and
119 wherever such third-party notices normally appear. The contents
120 of the NOTICE file are for informational purposes only and
121 do not modify the License. You may add Your own attribution
122 notices within Derivative Works that You distribute, alongside
123 or as an addendum to the NOTICE text from the Work, provided
124 that such additional attribution notices cannot be construed
125 as modifying the License.
126
127 You may add Your own copyright statement to Your modifications and
128 may provide additional or different license terms and conditions
129 for use, reproduction, or distribution of Your modifications, or
130 for any such Derivative Works as a whole, provided Your use,
131 reproduction, and distribution of the Work otherwise complies with
132 the conditions stated in this License.
133
134 5. Submission of Contributions. Unless You explicitly state otherwise,
135 any Contribution intentionally submitted for inclusion in the Work
136 by You to the Licensor shall be under the terms and conditions of
137 this License, without any additional terms or conditions.
138 Notwithstanding the above, nothing herein shall supersede or modify
139 the terms of any separate license agreement you may have executed
140 with Licensor regarding such Contributions.
141
142 6. Trademarks. This License does not grant permission to use the trade
143 names, trademarks, service marks, or product names of the Licensor,
144 except as required for reasonable and customary use in describing the
145 origin of the Work and reproducing the content of the NOTICE file.
146
147 7. Disclaimer of Warranty. Unless required by applicable law or
148 agreed to in writing, Licensor provides the Work (and each
149 Contributor provides its Contributions) on an "AS IS" BASIS,
150 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
151 implied, including, without limitation, any warranties or conditions
152 of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
153 PARTICULAR PURPOSE. You are solely responsible for determining the
154 appropriateness of using or redistributing the Work and assume any
155 risks associated with Your exercise of permissions under this License.
156
157 8. Limitation of Liability. In no event and under no legal theory,
158 whether in tort (including negligence), contract, or otherwise,
159 unless required by applicable law (such as deliberate and grossly
160 negligent acts) or agreed to in writing, shall any Contributor be
161 liable to You for damages, including any direct, indirect, special,
162 incidental, or consequential damages of any character arising as a
163 result of this License or out of the use or inability to use the
164 Work (including but not limited to damages for loss of goodwill,
165 work stoppage, computer failure or malfunction, or any and all
166 other commercial damages or losses), even if such Contributor
167 has been advised of the possibility of such damages.
168
169 9. Accepting Warranty or Additional Liability. While redistributing
170 the Work or Derivative Works thereof, You may choose to offer,
171 and charge a fee for, acceptance of support, warranty, indemnity,
172 or other liability obligations and/or rights consistent with this
173 License. However, in accepting such obligations, You may act only
174 on Your own behalf and on Your sole responsibility, not on behalf
175 of any other Contributor, and only if You agree to indemnify,
176 defend, and hold each Contributor harmless for any liability
177 incurred by, or claims asserted against, such Contributor by reason
178 of your accepting any such warranty or additional liability.
179
180 END OF TERMS AND CONDITIONS
181
182 APPENDIX: How to apply the Apache License to your work.
183
184 To apply the Apache License to your work, attach the following
185 boilerplate notice, with the fields enclosed by brackets "[]"
186 replaced with your own identifying information. (Don't include
187 the brackets!) The text should be enclosed in the appropriate
188 comment syntax for the file format. We also recommend that a
189 file or class name and description of purpose be included on the
190 same "printed page" as the copyright notice for easier
191 identification within third-party archives.
192
193 Copyright [yyyy] [name of copyright owner]
194
195 Licensed under the Apache License, Version 2.0 (the "License");
196 you may not use this file except in compliance with the License.
197 You may obtain a copy of the License at
198
199 http://www.apache.org/licenses/LICENSE-2.0
200
201 Unless required by applicable law or agreed to in writing, software
202 distributed under the License is distributed on an "AS IS" BASIS,
203 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
204 See the License for the specific language governing permissions and
205 limitations under the License.
206
207
208---- LLVM Exceptions to the Apache 2.0 License ----
209
210As an exception, if, as a result of your compiling your source code, portions
211of this Software are embedded into an Object form of such source code, you
212may redistribute such embedded portions in such Object form without complying
213with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
214
215In addition, if you combine or link compiled forms of this Software with
216software that is licensed under the GPLv2 ("Combined Software") and if a
217court of competent jurisdiction determines that the patent provision (Section
2183), the indemnity provision (Section 9) or other Section of the License
219conflicts with the conditions of the GPLv2, you may retroactively and
220prospectively choose to deem waived or otherwise exclude such Section(s) of
221the License, but only in their entirety and only with respect to the Combined
222Software.
223
224==============================================================================
225Software from third parties included in the LLVM Project:
226==============================================================================
227The LLVM Project contains third party software which is under different license
228terms. All such code will be identified clearly using at least one of two
229mechanisms:
2301) It will be in a separate directory tree with its own `LICENSE.txt` or
231 `LICENSE` file at the top containing the specific license and restrictions
232 which apply to that software, or
2332) It will contain specific license and restriction terms at the top of every
234 file.
235
236==============================================================================
237Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
238==============================================================================
239
240The libunwind library is dual licensed under both the University of Illinois
241"BSD-Like" license and the MIT license. As a user of this code you may choose
242to use it under either license. As a contributor, you agree to allow your code
243to be used under both.
244
245Full text of the relevant licenses is included below.
246
247==============================================================================
248
249University of Illinois/NCSA
250Open Source License
251
252Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT
253
254All rights reserved.
255
256Developed by:
257
258 LLVM Team
259
260 University of Illinois at Urbana-Champaign
261
262 http://llvm.org
263
264Permission is hereby granted, free of charge, to any person obtaining a copy of
265this software and associated documentation files (the "Software"), to deal with
266the Software without restriction, including without limitation the rights to
267use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
268of the Software, and to permit persons to whom the Software is furnished to do
269so, subject to the following conditions:
270
271 * Redistributions of source code must retain the above copyright notice,
272 this list of conditions and the following disclaimers.
273
274 * Redistributions in binary form must reproduce the above copyright notice,
275 this list of conditions and the following disclaimers in the
276 documentation and/or other materials provided with the distribution.
277
278 * Neither the names of the LLVM Team, University of Illinois at
279 Urbana-Champaign, nor the names of its contributors may be used to
280 endorse or promote products derived from this Software without specific
281 prior written permission.
282
283THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
284IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
285FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
286CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
287LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
288OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
289SOFTWARE.
290
291==============================================================================
292
293Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
294
295Permission is hereby granted, free of charge, to any person obtaining a copy
296of this software and associated documentation files (the "Software"), to deal
297in the Software without restriction, including without limitation the rights
298to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
299copies of the Software, and to permit persons to whom the Software is
300furnished to do so, subject to the following conditions:
301
302The above copyright notice and this permission notice shall be included in
303all copies or substantial portions of the Software.
304
305THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
306IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
307FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
308AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
309LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
310OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
311THE SOFTWARE.
lib/libunwind/include/__libunwind_config.h+3-4
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===------------------------- __libunwind_config.h -----------------------===//1//===------------------------- __libunwind_config.h -----------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
98
lib/libunwind/include/libunwind.h+4-31
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===---------------------------- libunwind.h -----------------------------===//1//===---------------------------- libunwind.h -----------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Compatible with libunwind API documented at:8// Compatible with libunwind API documented at:
...@@ -76,7 +75,7 @@ typedef struct unw_addr_space *unw_addr_space_t;...@@ -76,7 +75,7 @@ typedef struct unw_addr_space *unw_addr_space_t;
7675
77typedef int unw_regnum_t;76typedef int unw_regnum_t;
78typedef uintptr_t unw_word_t;77typedef uintptr_t unw_word_t;
79#if defined(__arm__)78#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
80typedef uint64_t unw_fpreg_t;79typedef uint64_t unw_fpreg_t;
81#else80#else
82typedef double unw_fpreg_t;81typedef double unw_fpreg_t;
...@@ -125,32 +124,6 @@ extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUN...@@ -125,32 +124,6 @@ extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUN
125124
126extern unw_addr_space_t unw_local_addr_space;125extern unw_addr_space_t unw_local_addr_space;
127126
128#ifdef UNW_REMOTE
129/*
130 * Mac OS X "remote" API for unwinding other processes on same machine
131 *
132 */
133extern unw_addr_space_t unw_create_addr_space_for_task(task_t);
134extern void unw_destroy_addr_space(unw_addr_space_t);
135extern int unw_init_remote_thread(unw_cursor_t *, unw_addr_space_t, thread_t *);
136#endif /* UNW_REMOTE */
137
138/*
139 * traditional libunwind "remote" API
140 * NOT IMPLEMENTED on Mac OS X
141 *
142 * extern int unw_init_remote(unw_cursor_t*, unw_addr_space_t,
143 * thread_t*);
144 * extern unw_accessors_t unw_get_accessors(unw_addr_space_t);
145 * extern unw_addr_space_t unw_create_addr_space(unw_accessors_t, int);
146 * extern void unw_flush_cache(unw_addr_space_t, unw_word_t,
147 * unw_word_t);
148 * extern int unw_set_caching_policy(unw_addr_space_t,
149 * unw_caching_policy_t);
150 * extern void _U_dyn_register(unw_dyn_info_t*);
151 * extern void _U_dyn_cancel(unw_dyn_info_t*);
152 */
153
154#ifdef __cplusplus127#ifdef __cplusplus
155}128}
156#endif129#endif
lib/libunwind/include/mach-o/compact_unwind_encoding.h+3-4
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===------------------ mach-o/compact_unwind_encoding.h ------------------===//1//===------------------ mach-o/compact_unwind_encoding.h ------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Darwin's alternative to DWARF based unwind encodings.8// Darwin's alternative to DWARF based unwind encodings.
lib/libunwind/include/unwind.h+4-5
...@@ -1,13 +1,12 @@...@@ -1,13 +1,12 @@
1//===------------------------------- unwind.h -----------------------------===//1//===------------------------------- unwind.h -----------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// C++ ABI Level 1 ABI documented at:8// C++ ABI Level 1 ABI documented at:
10// http://mentorembedded.github.io/cxx-abi/abi-eh.html9// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
11//10//
12//===----------------------------------------------------------------------===//11//===----------------------------------------------------------------------===//
1312
lib/libunwind/src/AddressSpace.hpp+13-136
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===------------------------- AddressSpace.hpp ---------------------------===//1//===------------------------- AddressSpace.hpp ---------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Abstracts accessing local vs remote address spaces.8// Abstracts accessing local vs remote address spaces.
...@@ -28,6 +27,9 @@...@@ -28,6 +27,9 @@
2827
29#if _LIBUNWIND_USE_DLADDR28#if _LIBUNWIND_USE_DLADDR
30#include <dlfcn.h>29#include <dlfcn.h>
30#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
31#pragma comment(lib, "dl")
32#endif
31#endif33#endif
3234
33#ifdef __APPLE__35#ifdef __APPLE__
...@@ -457,6 +459,8 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,...@@ -457,6 +459,8 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
457#elif defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32)459#elif defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32)
458 // Don't even bother, since Windows has functions that do all this stuff460 // Don't even bother, since Windows has functions that do all this stuff
459 // for us.461 // for us.
462 (void)targetAddr;
463 (void)info;
460 return true;464 return true;
461#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__) && \465#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__) && \
462 (__ANDROID_API__ < 21)466 (__ANDROID_API__ < 21)
...@@ -597,142 +601,15 @@ inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,...@@ -597,142 +601,15 @@ inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
597 return true;601 return true;
598 }602 }
599 }603 }
604#else
605 (void)addr;
606 (void)buf;
607 (void)bufLen;
608 (void)offset;
600#endif609#endif
601 return false;610 return false;
602}611}
603612
604
605
606#ifdef UNW_REMOTE
607
608/// RemoteAddressSpace is used as a template parameter to UnwindCursor when
609/// unwinding a thread in the another process. The other process can be a
610/// different endianness and a different pointer size which is handled by
611/// the P template parameter.
612template <typename P>
613class RemoteAddressSpace {
614public:
615 RemoteAddressSpace(task_t task) : fTask(task) {}
616
617 typedef typename P::uint_t pint_t;
618
619 uint8_t get8(pint_t addr);
620 uint16_t get16(pint_t addr);
621 uint32_t get32(pint_t addr);
622 uint64_t get64(pint_t addr);
623 pint_t getP(pint_t addr);
624 uint64_t getRegister(pint_t addr);
625 uint64_t getULEB128(pint_t &addr, pint_t end);
626 int64_t getSLEB128(pint_t &addr, pint_t end);
627 pint_t getEncodedP(pint_t &addr, pint_t end, uint8_t encoding,
628 pint_t datarelBase = 0);
629 bool findFunctionName(pint_t addr, char *buf, size_t bufLen,
630 unw_word_t *offset);
631 bool findUnwindSections(pint_t targetAddr, UnwindInfoSections &info);
632 bool findOtherFDE(pint_t targetAddr, pint_t &fde);
633private:
634 void *localCopy(pint_t addr);
635
636 task_t fTask;
637};
638
639template <typename P> uint8_t RemoteAddressSpace<P>::get8(pint_t addr) {
640 return *((uint8_t *)localCopy(addr));
641}
642
643template <typename P> uint16_t RemoteAddressSpace<P>::get16(pint_t addr) {
644 return P::E::get16(*(uint16_t *)localCopy(addr));
645}
646
647template <typename P> uint32_t RemoteAddressSpace<P>::get32(pint_t addr) {
648 return P::E::get32(*(uint32_t *)localCopy(addr));
649}
650
651template <typename P> uint64_t RemoteAddressSpace<P>::get64(pint_t addr) {
652 return P::E::get64(*(uint64_t *)localCopy(addr));
653}
654
655template <typename P>
656typename P::uint_t RemoteAddressSpace<P>::getP(pint_t addr) {
657 return P::getP(*(uint64_t *)localCopy(addr));
658}
659
660template <typename P>
661typename P::uint_t OtherAddressSpace<P>::getRegister(pint_t addr) {
662 return P::getRegister(*(uint64_t *)localCopy(addr));
663}
664
665template <typename P>
666uint64_t OtherAddressSpace<P>::getULEB128(pint_t &addr, pint_t end) {
667 uintptr_t size = (end - addr);
668 LocalAddressSpace::pint_t laddr = (LocalAddressSpace::pint_t) localCopy(addr);
669 LocalAddressSpace::pint_t sladdr = laddr;
670 uint64_t result = LocalAddressSpace::getULEB128(laddr, laddr + size);
671 addr += (laddr - sladdr);
672 return result;
673}
674
675template <typename P>
676int64_t RemoteAddressSpace<P>::getSLEB128(pint_t &addr, pint_t end) {
677 uintptr_t size = (end - addr);
678 LocalAddressSpace::pint_t laddr = (LocalAddressSpace::pint_t) localCopy(addr);
679 LocalAddressSpace::pint_t sladdr = laddr;
680 uint64_t result = LocalAddressSpace::getSLEB128(laddr, laddr + size);
681 addr += (laddr - sladdr);
682 return result;
683}
684
685template <typename P> void *RemoteAddressSpace<P>::localCopy(pint_t addr) {
686 // FIX ME
687}
688
689template <typename P>
690bool RemoteAddressSpace<P>::findFunctionName(pint_t addr, char *buf,
691 size_t bufLen,
692 unw_word_t *offset) {
693 // FIX ME
694}
695
696/// unw_addr_space is the base class that abstract unw_addr_space_t type in
697/// libunwind.h points to.
698struct unw_addr_space {
699 cpu_type_t cpuType;
700 task_t taskPort;
701};
702
703/// unw_addr_space_i386 is the concrete instance that a unw_addr_space_t points
704/// to when examining
705/// a 32-bit intel process.
706struct unw_addr_space_i386 : public unw_addr_space {
707 unw_addr_space_i386(task_t task) : oas(task) {}
708 RemoteAddressSpace<Pointer32<LittleEndian>> oas;
709};
710
711/// unw_addr_space_x86_64 is the concrete instance that a unw_addr_space_t
712/// points to when examining
713/// a 64-bit intel process.
714struct unw_addr_space_x86_64 : public unw_addr_space {
715 unw_addr_space_x86_64(task_t task) : oas(task) {}
716 RemoteAddressSpace<Pointer64<LittleEndian>> oas;
717};
718
719/// unw_addr_space_ppc is the concrete instance that a unw_addr_space_t points
720/// to when examining
721/// a 32-bit PowerPC process.
722struct unw_addr_space_ppc : public unw_addr_space {
723 unw_addr_space_ppc(task_t task) : oas(task) {}
724 RemoteAddressSpace<Pointer32<BigEndian>> oas;
725};
726
727/// unw_addr_space_ppc is the concrete instance that a unw_addr_space_t points
728/// to when examining a 64-bit PowerPC process.
729struct unw_addr_space_ppc64 : public unw_addr_space {
730 unw_addr_space_ppc64(task_t task) : oas(task) {}
731 RemoteAddressSpace<Pointer64<LittleEndian>> oas;
732};
733
734#endif // UNW_REMOTE
735
736} // namespace libunwind613} // namespace libunwind
737614
738#endif // __ADDRESSSPACE_HPP__615#endif // __ADDRESSSPACE_HPP__
lib/libunwind/src/CompactUnwinder.hpp+3-4
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===-------------------------- CompactUnwinder.hpp -----------------------===//1//===-------------------------- CompactUnwinder.hpp -----------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Does runtime stack unwinding using compact unwind encodings.8// Does runtime stack unwinding using compact unwind encodings.
lib/libunwind/src/DwarfInstructions.hpp+31-8
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===-------------------------- DwarfInstructions.hpp ---------------------===//1//===-------------------------- DwarfInstructions.hpp ---------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Processor specific interpretation of DWARF unwind info.8// Processor specific interpretation of DWARF unwind info.
...@@ -82,12 +81,11 @@ typename A::pint_t DwarfInstructions<A, R>::getSavedRegister(...@@ -82,12 +81,11 @@ typename A::pint_t DwarfInstructions<A, R>::getSavedRegister(
82 const RegisterLocation &savedReg) {81 const RegisterLocation &savedReg) {
83 switch (savedReg.location) {82 switch (savedReg.location) {
84 case CFI_Parser<A>::kRegisterInCFA:83 case CFI_Parser<A>::kRegisterInCFA:
85 return addressSpace.getRegister(cfa + (pint_t)savedReg.value);84 return (pint_t)addressSpace.getRegister(cfa + (pint_t)savedReg.value);
8685
87 case CFI_Parser<A>::kRegisterAtExpression:86 case CFI_Parser<A>::kRegisterAtExpression:
88 return addressSpace.getRegister(87 return (pint_t)addressSpace.getRegister(evaluateExpression(
89 evaluateExpression((pint_t)savedReg.value, addressSpace,88 (pint_t)savedReg.value, addressSpace, registers, cfa));
90 registers, cfa));
9189
92 case CFI_Parser<A>::kRegisterIsExpression:90 case CFI_Parser<A>::kRegisterIsExpression:
93 return evaluateExpression((pint_t)savedReg.value, addressSpace,91 return evaluateExpression((pint_t)savedReg.value, addressSpace,
...@@ -234,6 +232,31 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc,...@@ -234,6 +232,31 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc,
234 }232 }
235#endif233#endif
236234
235#if defined(_LIBUNWIND_TARGET_PPC64)
236#define PPC64_ELFV1_R2_LOAD_INST_ENCODING 0xe8410028u // ld r2,40(r1)
237#define PPC64_ELFV1_R2_OFFSET 40
238#define PPC64_ELFV2_R2_LOAD_INST_ENCODING 0xe8410018u // ld r2,24(r1)
239#define PPC64_ELFV2_R2_OFFSET 24
240 // If the instruction at return address is a TOC (r2) restore,
241 // then r2 was saved and needs to be restored.
242 // ELFv2 ABI specifies that the TOC Pointer must be saved at SP + 24,
243 // while in ELFv1 ABI it is saved at SP + 40.
244 if (R::getArch() == REGISTERS_PPC64 && returnAddress != 0) {
245 pint_t sp = newRegisters.getRegister(UNW_REG_SP);
246 pint_t r2 = 0;
247 switch (addressSpace.get32(returnAddress)) {
248 case PPC64_ELFV1_R2_LOAD_INST_ENCODING:
249 r2 = addressSpace.get64(sp + PPC64_ELFV1_R2_OFFSET);
250 break;
251 case PPC64_ELFV2_R2_LOAD_INST_ENCODING:
252 r2 = addressSpace.get64(sp + PPC64_ELFV2_R2_OFFSET);
253 break;
254 }
255 if (r2)
256 newRegisters.setRegister(UNW_PPC64_R2, r2);
257 }
258#endif
259
237 // Return address is address after call site instruction, so setting IP to260 // Return address is address after call site instruction, so setting IP to
238 // that does simualates a return.261 // that does simualates a return.
239 newRegisters.setIP(returnAddress);262 newRegisters.setIP(returnAddress);
lib/libunwind/src/DwarfParser.hpp+3-4
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===--------------------------- DwarfParser.hpp --------------------------===//1//===--------------------------- DwarfParser.hpp --------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Parses DWARF CFIs (FDEs and CIEs).8// Parses DWARF CFIs (FDEs and CIEs).
lib/libunwind/src/EHHeaderParser.hpp+3-4
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===------------------------- EHHeaderParser.hpp -------------------------===//1//===------------------------- EHHeaderParser.hpp -------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Parses ELF .eh_frame_hdr sections.8// Parses ELF .eh_frame_hdr sections.
lib/libunwind/src/RWMutex.hpp+43-6
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===----------------------------- Registers.hpp --------------------------===//1//===----------------------------- Registers.hpp --------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Abstract interface to shared reader/writer log, hiding platform and8// Abstract interface to shared reader/writer log, hiding platform and
...@@ -18,6 +17,9 @@...@@ -18,6 +17,9 @@
18#include <windows.h>17#include <windows.h>
19#elif !defined(_LIBUNWIND_HAS_NO_THREADS)18#elif !defined(_LIBUNWIND_HAS_NO_THREADS)
20#include <pthread.h>19#include <pthread.h>
20#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
21#pragma comment(lib, "pthread")
22#endif
21#endif23#endif
2224
23namespace libunwind {25namespace libunwind {
...@@ -57,11 +59,11 @@ private:...@@ -57,11 +59,11 @@ private:
57 SRWLOCK _lock = SRWLOCK_INIT;59 SRWLOCK _lock = SRWLOCK_INIT;
58};60};
5961
60#else62#elif !defined(LIBUNWIND_USE_WEAK_PTHREAD)
6163
62class _LIBUNWIND_HIDDEN RWMutex {64class _LIBUNWIND_HIDDEN RWMutex {
63public:65public:
64 bool lock_shared() { return pthread_rwlock_rdlock(&_lock) == 0; }66 bool lock_shared() { return pthread_rwlock_rdlock(&_lock) == 0; }
65 bool unlock_shared() { return pthread_rwlock_unlock(&_lock) == 0; }67 bool unlock_shared() { return pthread_rwlock_unlock(&_lock) == 0; }
66 bool lock() { return pthread_rwlock_wrlock(&_lock) == 0; }68 bool lock() { return pthread_rwlock_wrlock(&_lock) == 0; }
67 bool unlock() { return pthread_rwlock_unlock(&_lock) == 0; }69 bool unlock() { return pthread_rwlock_unlock(&_lock) == 0; }
...@@ -70,6 +72,41 @@ private:...@@ -70,6 +72,41 @@ private:
70 pthread_rwlock_t _lock = PTHREAD_RWLOCK_INITIALIZER;72 pthread_rwlock_t _lock = PTHREAD_RWLOCK_INITIALIZER;
71};73};
7274
75#else
76
77extern "C" int __attribute__((weak))
78pthread_create(pthread_t *thread, const pthread_attr_t *attr,
79 void *(*start_routine)(void *), void *arg);
80extern "C" int __attribute__((weak))
81pthread_rwlock_rdlock(pthread_rwlock_t *lock);
82extern "C" int __attribute__((weak))
83pthread_rwlock_wrlock(pthread_rwlock_t *lock);
84extern "C" int __attribute__((weak))
85pthread_rwlock_unlock(pthread_rwlock_t *lock);
86
87// Calls to the locking functions are gated on pthread_create, and not the
88// functions themselves, because the data structure should only be locked if
89// another thread has been created. This is what similar libraries do.
90
91class _LIBUNWIND_HIDDEN RWMutex {
92public:
93 bool lock_shared() {
94 return !pthread_create || (pthread_rwlock_rdlock(&_lock) == 0);
95 }
96 bool unlock_shared() {
97 return !pthread_create || (pthread_rwlock_unlock(&_lock) == 0);
98 }
99 bool lock() {
100 return !pthread_create || (pthread_rwlock_wrlock(&_lock) == 0);
101 }
102 bool unlock() {
103 return !pthread_create || (pthread_rwlock_unlock(&_lock) == 0);
104 }
105
106private:
107 pthread_rwlock_t _lock = PTHREAD_RWLOCK_INITIALIZER;
108};
109
73#endif110#endif
74111
75} // namespace libunwind112} // namespace libunwind
lib/libunwind/src/Registers.hpp+13-14
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===----------------------------- Registers.hpp --------------------------===//1//===----------------------------- Registers.hpp --------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Models register sets for supported processors.8// Models register sets for supported processors.
...@@ -2104,16 +2103,16 @@ private:...@@ -2104,16 +2103,16 @@ private:
2104 uint32_t __pc; // Program counter r152103 uint32_t __pc; // Program counter r15
2105 };2104 };
21062105
2107 static void saveVFPWithFSTMD(unw_fpreg_t*);2106 static void saveVFPWithFSTMD(void*);
2108 static void saveVFPWithFSTMX(unw_fpreg_t*);2107 static void saveVFPWithFSTMX(void*);
2109 static void saveVFPv3(unw_fpreg_t*);2108 static void saveVFPv3(void*);
2110 static void restoreVFPWithFLDMD(unw_fpreg_t*);2109 static void restoreVFPWithFLDMD(void*);
2111 static void restoreVFPWithFLDMX(unw_fpreg_t*);2110 static void restoreVFPWithFLDMX(void*);
2112 static void restoreVFPv3(unw_fpreg_t*);2111 static void restoreVFPv3(void*);
2113#if defined(__ARM_WMMX)2112#if defined(__ARM_WMMX)
2114 static void saveiWMMX(unw_fpreg_t*);2113 static void saveiWMMX(void*);
2115 static void saveiWMMXControl(uint32_t*);2114 static void saveiWMMXControl(uint32_t*);
2116 static void restoreiWMMX(unw_fpreg_t*);2115 static void restoreiWMMX(void*);
2117 static void restoreiWMMXControl(uint32_t*);2116 static void restoreiWMMXControl(uint32_t*);
2118#endif2117#endif
2119 void restoreCoreAndJumpTo();2118 void restoreCoreAndJumpTo();
...@@ -2155,7 +2154,7 @@ inline Registers_arm::Registers_arm(const void *registers)...@@ -2155,7 +2154,7 @@ inline Registers_arm::Registers_arm(const void *registers)
2155 _saved_vfp_d16_d31(false) {2154 _saved_vfp_d16_d31(false) {
2156 static_assert((check_fit<Registers_arm, unw_context_t>::does_fit),2155 static_assert((check_fit<Registers_arm, unw_context_t>::does_fit),
2157 "arm registers do not fit into unw_context_t");2156 "arm registers do not fit into unw_context_t");
2158 // See unw_getcontext() note about data.2157 // See __unw_getcontext() note about data.
2159 memcpy(&_registers, registers, sizeof(_registers));2158 memcpy(&_registers, registers, sizeof(_registers));
2160 memset(&_vfp_d0_d15_pad, 0, sizeof(_vfp_d0_d15_pad));2159 memset(&_vfp_d0_d15_pad, 0, sizeof(_vfp_d0_d15_pad));
2161 memset(&_vfp_d16_d31, 0, sizeof(_vfp_d16_d31));2160 memset(&_vfp_d16_d31, 0, sizeof(_vfp_d16_d31));
...@@ -2434,7 +2433,7 @@ inline const char *Registers_arm::getRegisterName(int regNum) {...@@ -2434,7 +2433,7 @@ inline const char *Registers_arm::getRegisterName(int regNum) {
24342433
2435inline bool Registers_arm::validFloatRegister(int regNum) const {2434inline bool Registers_arm::validFloatRegister(int regNum) const {
2436 // NOTE: Consider the intel MMX registers floating points so the2435 // NOTE: Consider the intel MMX registers floating points so the
2437 // unw_get_fpreg can be used to transmit the 64-bit data back.2436 // __unw_get_fpreg can be used to transmit the 64-bit data back.
2438 return ((regNum >= UNW_ARM_D0) && (regNum <= UNW_ARM_D31))2437 return ((regNum >= UNW_ARM_D0) && (regNum <= UNW_ARM_D31))
2439#if defined(__ARM_WMMX)2438#if defined(__ARM_WMMX)
2440 || ((regNum >= UNW_ARM_WR0) && (regNum <= UNW_ARM_WR15))2439 || ((regNum >= UNW_ARM_WR0) && (regNum <= UNW_ARM_WR15))
lib/libunwind/src/Unwind-EHABI.cpp+56-53
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===--------------------------- Unwind-EHABI.cpp -------------------------===//1//===--------------------------- Unwind-EHABI.cpp -------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Implements ARM zero-cost C++ exceptions8// Implements ARM zero-cost C++ exceptions
...@@ -21,8 +20,6 @@...@@ -21,8 +20,6 @@
21#include <stdlib.h>20#include <stdlib.h>
22#include <string.h>21#include <string.h>
2322
24#include <type_traits>
25
26#include "config.h"23#include "config.h"
27#include "libunwind.h"24#include "libunwind.h"
28#include "libunwind_ext.h"25#include "libunwind_ext.h"
...@@ -34,7 +31,11 @@ namespace {...@@ -34,7 +31,11 @@ namespace {
34// signinficant byte.31// signinficant byte.
35uint8_t getByte(const uint32_t* data, size_t offset) {32uint8_t getByte(const uint32_t* data, size_t offset) {
36 const uint8_t* byteData = reinterpret_cast<const uint8_t*>(data);33 const uint8_t* byteData = reinterpret_cast<const uint8_t*>(data);
34#ifdef __LITTLE_ENDIAN__
37 return byteData[(offset & ~(size_t)0x03) + (3 - (offset & (size_t)0x03))];35 return byteData[(offset & ~(size_t)0x03) + (3 - (offset & (size_t)0x03))];
36#else
37 return byteData[offset];
38#endif
38}39}
3940
40const char* getNextWord(const char* data, uint32_t* out) {41const char* getNextWord(const char* data, uint32_t* out) {
...@@ -182,7 +183,7 @@ static _Unwind_Reason_Code unwindOneFrame(_Unwind_State state,...@@ -182,7 +183,7 @@ static _Unwind_Reason_Code unwindOneFrame(_Unwind_State state,
182 if (result != _URC_CONTINUE_UNWIND)183 if (result != _URC_CONTINUE_UNWIND)
183 return result;184 return result;
184185
185 if (unw_step(reinterpret_cast<unw_cursor_t*>(context)) != UNW_STEP_SUCCESS)186 if (__unw_step(reinterpret_cast<unw_cursor_t *>(context)) != UNW_STEP_SUCCESS)
186 return _URC_FAILURE;187 return _URC_FAILURE;
187 return _URC_CONTINUE_UNWIND;188 return _URC_CONTINUE_UNWIND;
188}189}
...@@ -443,17 +444,18 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except...@@ -443,17 +444,18 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
443 // In this implementation, the phases don't share the VRS backing store.444 // In this implementation, the phases don't share the VRS backing store.
444 // Instead, they are passed the original |uc| and they create a new VRS445 // Instead, they are passed the original |uc| and they create a new VRS
445 // from scratch thus achieving the same effect.446 // from scratch thus achieving the same effect.
446 unw_init_local(cursor, uc);447 __unw_init_local(cursor, uc);
447448
448 // Walk each frame looking for a place to stop.449 // Walk each frame looking for a place to stop.
449 for (bool handlerNotFound = true; handlerNotFound;) {450 for (bool handlerNotFound = true; handlerNotFound;) {
450451
451 // See if frame has code to run (has personality routine).452 // See if frame has code to run (has personality routine).
452 unw_proc_info_t frameInfo;453 unw_proc_info_t frameInfo;
453 if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {454 if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
454 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_get_proc_info "455 _LIBUNWIND_TRACE_UNWINDING(
455 "failed => _URC_FATAL_PHASE1_ERROR",456 "unwind_phase1(ex_ojb=%p): __unw_get_proc_info "
456 static_cast<void *>(exception_object));457 "failed => _URC_FATAL_PHASE1_ERROR",
458 static_cast<void *>(exception_object));
457 return _URC_FATAL_PHASE1_ERROR;459 return _URC_FATAL_PHASE1_ERROR;
458 }460 }
459461
...@@ -462,12 +464,12 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except...@@ -462,12 +464,12 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
462 char functionBuf[512];464 char functionBuf[512];
463 const char *functionName = functionBuf;465 const char *functionName = functionBuf;
464 unw_word_t offset;466 unw_word_t offset;
465 if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),467 if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
466 &offset) != UNW_ESUCCESS) ||468 &offset) != UNW_ESUCCESS) ||
467 (frameInfo.start_ip + offset > frameInfo.end_ip))469 (frameInfo.start_ip + offset > frameInfo.end_ip))
468 functionName = ".anonymous.";470 functionName = ".anonymous.";
469 unw_word_t pc;471 unw_word_t pc;
470 unw_get_reg(cursor, UNW_REG_IP, &pc);472 __unw_get_reg(cursor, UNW_REG_IP, &pc);
471 _LIBUNWIND_TRACE_UNWINDING(473 _LIBUNWIND_TRACE_UNWINDING(
472 "unwind_phase1(ex_ojb=%p): pc=0x%" PRIxPTR ", start_ip=0x%" PRIxPTR ", func=%s, "474 "unwind_phase1(ex_ojb=%p): pc=0x%" PRIxPTR ", start_ip=0x%" PRIxPTR ", func=%s, "
473 "lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR,475 "lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR,
...@@ -537,7 +539,7 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor...@@ -537,7 +539,7 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor
537 _Unwind_Exception *exception_object,539 _Unwind_Exception *exception_object,
538 bool resume) {540 bool resume) {
539 // See comment at the start of unwind_phase1 regarding VRS integrity.541 // See comment at the start of unwind_phase1 regarding VRS integrity.
540 unw_init_local(cursor, uc);542 __unw_init_local(cursor, uc);
541543
542 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)",544 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)",
543 static_cast<void *>(exception_object));545 static_cast<void *>(exception_object));
...@@ -559,19 +561,20 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor...@@ -559,19 +561,20 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor
559 // for. After this, continue unwinding as if normal.561 // for. After this, continue unwinding as if normal.
560 //562 //
561 // See #7.4.6 for details.563 // See #7.4.6 for details.
562 unw_set_reg(cursor, UNW_REG_IP,564 __unw_set_reg(cursor, UNW_REG_IP,
563 exception_object->unwinder_cache.reserved2);565 exception_object->unwinder_cache.reserved2);
564 resume = false;566 resume = false;
565 }567 }
566568
567 // Get info about this frame.569 // Get info about this frame.
568 unw_word_t sp;570 unw_word_t sp;
569 unw_proc_info_t frameInfo;571 unw_proc_info_t frameInfo;
570 unw_get_reg(cursor, UNW_REG_SP, &sp);572 __unw_get_reg(cursor, UNW_REG_SP, &sp);
571 if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {573 if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
572 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_get_proc_info "574 _LIBUNWIND_TRACE_UNWINDING(
573 "failed => _URC_FATAL_PHASE2_ERROR",575 "unwind_phase2(ex_ojb=%p): __unw_get_proc_info "
574 static_cast<void *>(exception_object));576 "failed => _URC_FATAL_PHASE2_ERROR",
577 static_cast<void *>(exception_object));
575 return _URC_FATAL_PHASE2_ERROR;578 return _URC_FATAL_PHASE2_ERROR;
576 }579 }
577580
...@@ -580,8 +583,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor...@@ -580,8 +583,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor
580 char functionBuf[512];583 char functionBuf[512];
581 const char *functionName = functionBuf;584 const char *functionName = functionBuf;
582 unw_word_t offset;585 unw_word_t offset;
583 if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),586 if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
584 &offset) != UNW_ESUCCESS) ||587 &offset) != UNW_ESUCCESS) ||
585 (frameInfo.start_ip + offset > frameInfo.end_ip))588 (frameInfo.start_ip + offset > frameInfo.end_ip))
586 functionName = ".anonymous.";589 functionName = ".anonymous.";
587 _LIBUNWIND_TRACE_UNWINDING(590 _LIBUNWIND_TRACE_UNWINDING(
...@@ -625,8 +628,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor...@@ -625,8 +628,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor
625 // We may get control back if landing pad calls _Unwind_Resume().628 // We may get control back if landing pad calls _Unwind_Resume().
626 if (_LIBUNWIND_TRACING_UNWINDING) {629 if (_LIBUNWIND_TRACING_UNWINDING) {
627 unw_word_t pc;630 unw_word_t pc;
628 unw_get_reg(cursor, UNW_REG_IP, &pc);631 __unw_get_reg(cursor, UNW_REG_IP, &pc);
629 unw_get_reg(cursor, UNW_REG_SP, &sp);632 __unw_get_reg(cursor, UNW_REG_SP, &sp);
630 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering "633 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering "
631 "user code with ip=0x%" PRIxPTR ", sp=0x%" PRIxPTR,634 "user code with ip=0x%" PRIxPTR ", sp=0x%" PRIxPTR,
632 static_cast<void *>(exception_object),635 static_cast<void *>(exception_object),
...@@ -637,11 +640,11 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor...@@ -637,11 +640,11 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor
637 // EHABI #7.4.1 says we need to preserve pc for when _Unwind_Resume640 // EHABI #7.4.1 says we need to preserve pc for when _Unwind_Resume
638 // is called back, to find this same frame.641 // is called back, to find this same frame.
639 unw_word_t pc;642 unw_word_t pc;
640 unw_get_reg(cursor, UNW_REG_IP, &pc);643 __unw_get_reg(cursor, UNW_REG_IP, &pc);
641 exception_object->unwinder_cache.reserved2 = (uint32_t)pc;644 exception_object->unwinder_cache.reserved2 = (uint32_t)pc;
642 }645 }
643 unw_resume(cursor);646 __unw_resume(cursor);
644 // unw_resume() only returns if there was an error.647 // __unw_resume() only returns if there was an error.
645 return _URC_FATAL_PHASE2_ERROR;648 return _URC_FATAL_PHASE2_ERROR;
646649
647 // # EHABI #7.4.3650 // # EHABI #7.4.3
...@@ -670,7 +673,7 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) {...@@ -670,7 +673,7 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) {
670 static_cast<void *>(exception_object));673 static_cast<void *>(exception_object));
671 unw_context_t uc;674 unw_context_t uc;
672 unw_cursor_t cursor;675 unw_cursor_t cursor;
673 unw_getcontext(&uc);676 __unw_getcontext(&uc);
674677
675 // This field for is for compatibility with GCC to say this isn't a forced678 // This field for is for compatibility with GCC to say this isn't a forced
676 // unwind. EHABI #7.2679 // unwind. EHABI #7.2
...@@ -708,7 +711,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) {...@@ -708,7 +711,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) {
708 static_cast<void *>(exception_object));711 static_cast<void *>(exception_object));
709 unw_context_t uc;712 unw_context_t uc;
710 unw_cursor_t cursor;713 unw_cursor_t cursor;
711 unw_getcontext(&uc);714 __unw_getcontext(&uc);
712715
713 // _Unwind_RaiseException on EHABI will always set the reserved1 field to 0,716 // _Unwind_RaiseException on EHABI will always set the reserved1 field to 0,
714 // which is in the same position as private_1 below.717 // which is in the same position as private_1 below.
...@@ -725,7 +728,7 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {...@@ -725,7 +728,7 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
725 unw_cursor_t *cursor = (unw_cursor_t *)context;728 unw_cursor_t *cursor = (unw_cursor_t *)context;
726 unw_proc_info_t frameInfo;729 unw_proc_info_t frameInfo;
727 uintptr_t result = 0;730 uintptr_t result = 0;
728 if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)731 if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
729 result = (uintptr_t)frameInfo.lsda;732 result = (uintptr_t)frameInfo.lsda;
730 _LIBUNWIND_TRACE_API(733 _LIBUNWIND_TRACE_API(
731 "_Unwind_GetLanguageSpecificData(context=%p) => 0x%llx",734 "_Unwind_GetLanguageSpecificData(context=%p) => 0x%llx",
...@@ -765,8 +768,8 @@ _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,...@@ -765,8 +768,8 @@ _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
765 case _UVRSC_CORE:768 case _UVRSC_CORE:
766 if (representation != _UVRSD_UINT32 || regno > 15)769 if (representation != _UVRSD_UINT32 || regno > 15)
767 return _UVRSR_FAILED;770 return _UVRSR_FAILED;
768 return unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),771 return __unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),
769 *(unw_word_t *)valuep) == UNW_ESUCCESS772 *(unw_word_t *)valuep) == UNW_ESUCCESS
770 ? _UVRSR_OK773 ? _UVRSR_OK
771 : _UVRSR_FAILED;774 : _UVRSR_FAILED;
772 case _UVRSC_VFP:775 case _UVRSC_VFP:
...@@ -776,28 +779,28 @@ _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,...@@ -776,28 +779,28 @@ _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
776 // Can only touch d0-15 with FSTMFDX.779 // Can only touch d0-15 with FSTMFDX.
777 if (regno > 15)780 if (regno > 15)
778 return _UVRSR_FAILED;781 return _UVRSR_FAILED;
779 unw_save_vfp_as_X(cursor);782 __unw_save_vfp_as_X(cursor);
780 } else {783 } else {
781 if (regno > 31)784 if (regno > 31)
782 return _UVRSR_FAILED;785 return _UVRSR_FAILED;
783 }786 }
784 return unw_set_fpreg(cursor, (unw_regnum_t)(UNW_ARM_D0 + regno),787 return __unw_set_fpreg(cursor, (unw_regnum_t)(UNW_ARM_D0 + regno),
785 *(unw_fpreg_t *)valuep) == UNW_ESUCCESS788 *(unw_fpreg_t *)valuep) == UNW_ESUCCESS
786 ? _UVRSR_OK789 ? _UVRSR_OK
787 : _UVRSR_FAILED;790 : _UVRSR_FAILED;
788#if defined(__ARM_WMMX)791#if defined(__ARM_WMMX)
789 case _UVRSC_WMMXC:792 case _UVRSC_WMMXC:
790 if (representation != _UVRSD_UINT32 || regno > 3)793 if (representation != _UVRSD_UINT32 || regno > 3)
791 return _UVRSR_FAILED;794 return _UVRSR_FAILED;
792 return unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),795 return __unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
793 *(unw_word_t *)valuep) == UNW_ESUCCESS796 *(unw_word_t *)valuep) == UNW_ESUCCESS
794 ? _UVRSR_OK797 ? _UVRSR_OK
795 : _UVRSR_FAILED;798 : _UVRSR_FAILED;
796 case _UVRSC_WMMXD:799 case _UVRSC_WMMXD:
797 if (representation != _UVRSD_DOUBLE || regno > 31)800 if (representation != _UVRSD_DOUBLE || regno > 31)
798 return _UVRSR_FAILED;801 return _UVRSR_FAILED;
799 return unw_set_fpreg(cursor, (unw_regnum_t)(UNW_ARM_WR0 + regno),802 return __unw_set_fpreg(cursor, (unw_regnum_t)(UNW_ARM_WR0 + regno),
800 *(unw_fpreg_t *)valuep) == UNW_ESUCCESS803 *(unw_fpreg_t *)valuep) == UNW_ESUCCESS
801 ? _UVRSR_OK804 ? _UVRSR_OK
802 : _UVRSR_FAILED;805 : _UVRSR_FAILED;
803#else806#else
...@@ -819,8 +822,8 @@ _Unwind_VRS_Get_Internal(_Unwind_Context *context,...@@ -819,8 +822,8 @@ _Unwind_VRS_Get_Internal(_Unwind_Context *context,
819 case _UVRSC_CORE:822 case _UVRSC_CORE:
820 if (representation != _UVRSD_UINT32 || regno > 15)823 if (representation != _UVRSD_UINT32 || regno > 15)
821 return _UVRSR_FAILED;824 return _UVRSR_FAILED;
822 return unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),825 return __unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),
823 (unw_word_t *)valuep) == UNW_ESUCCESS826 (unw_word_t *)valuep) == UNW_ESUCCESS
824 ? _UVRSR_OK827 ? _UVRSR_OK
825 : _UVRSR_FAILED;828 : _UVRSR_FAILED;
826 case _UVRSC_VFP:829 case _UVRSC_VFP:
...@@ -830,28 +833,28 @@ _Unwind_VRS_Get_Internal(_Unwind_Context *context,...@@ -830,28 +833,28 @@ _Unwind_VRS_Get_Internal(_Unwind_Context *context,
830 // Can only touch d0-15 with FSTMFDX.833 // Can only touch d0-15 with FSTMFDX.
831 if (regno > 15)834 if (regno > 15)
832 return _UVRSR_FAILED;835 return _UVRSR_FAILED;
833 unw_save_vfp_as_X(cursor);836 __unw_save_vfp_as_X(cursor);
834 } else {837 } else {
835 if (regno > 31)838 if (regno > 31)
836 return _UVRSR_FAILED;839 return _UVRSR_FAILED;
837 }840 }
838 return unw_get_fpreg(cursor, (unw_regnum_t)(UNW_ARM_D0 + regno),841 return __unw_get_fpreg(cursor, (unw_regnum_t)(UNW_ARM_D0 + regno),
839 (unw_fpreg_t *)valuep) == UNW_ESUCCESS842 (unw_fpreg_t *)valuep) == UNW_ESUCCESS
840 ? _UVRSR_OK843 ? _UVRSR_OK
841 : _UVRSR_FAILED;844 : _UVRSR_FAILED;
842#if defined(__ARM_WMMX)845#if defined(__ARM_WMMX)
843 case _UVRSC_WMMXC:846 case _UVRSC_WMMXC:
844 if (representation != _UVRSD_UINT32 || regno > 3)847 if (representation != _UVRSD_UINT32 || regno > 3)
845 return _UVRSR_FAILED;848 return _UVRSR_FAILED;
846 return unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),849 return __unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
847 (unw_word_t *)valuep) == UNW_ESUCCESS850 (unw_word_t *)valuep) == UNW_ESUCCESS
848 ? _UVRSR_OK851 ? _UVRSR_OK
849 : _UVRSR_FAILED;852 : _UVRSR_FAILED;
850 case _UVRSC_WMMXD:853 case _UVRSC_WMMXD:
851 if (representation != _UVRSD_DOUBLE || regno > 31)854 if (representation != _UVRSD_DOUBLE || regno > 31)
852 return _UVRSR_FAILED;855 return _UVRSR_FAILED;
853 return unw_get_fpreg(cursor, (unw_regnum_t)(UNW_ARM_WR0 + regno),856 return __unw_get_fpreg(cursor, (unw_regnum_t)(UNW_ARM_WR0 + regno),
854 (unw_fpreg_t *)valuep) == UNW_ESUCCESS857 (unw_fpreg_t *)valuep) == UNW_ESUCCESS
855 ? _UVRSR_OK858 ? _UVRSR_OK
856 : _UVRSR_FAILED;859 : _UVRSR_FAILED;
857#else860#else
...@@ -960,7 +963,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {...@@ -960,7 +963,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {
960 unw_cursor_t *cursor = (unw_cursor_t *)context;963 unw_cursor_t *cursor = (unw_cursor_t *)context;
961 unw_proc_info_t frameInfo;964 unw_proc_info_t frameInfo;
962 uintptr_t result = 0;965 uintptr_t result = 0;
963 if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)966 if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
964 result = (uintptr_t)frameInfo.start_ip;967 result = (uintptr_t)frameInfo.start_ip;
965 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%llX",968 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%llX",
966 static_cast<void *>(context), (long long)result);969 static_cast<void *>(context), (long long)result);
...@@ -983,7 +986,7 @@ extern "C" _LIBUNWIND_EXPORT _Unwind_Reason_Code...@@ -983,7 +986,7 @@ extern "C" _LIBUNWIND_EXPORT _Unwind_Reason_Code
983__gnu_unwind_frame(_Unwind_Exception *exception_object,986__gnu_unwind_frame(_Unwind_Exception *exception_object,
984 struct _Unwind_Context *context) {987 struct _Unwind_Context *context) {
985 unw_cursor_t *cursor = (unw_cursor_t *)context;988 unw_cursor_t *cursor = (unw_cursor_t *)context;
986 if (unw_step(cursor) != UNW_STEP_SUCCESS)989 if (__unw_step(cursor) != UNW_STEP_SUCCESS)
987 return _URC_FAILURE;990 return _URC_FAILURE;
988 return _URC_OK;991 return _URC_OK;
989}992}
lib/libunwind/src/Unwind-EHABI.h+3-4
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===------------------------- Unwind-EHABI.hpp ---------------------------===//1//===------------------------- Unwind-EHABI.hpp ---------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
lib/libunwind/src/Unwind-seh.cpp+55-45
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===--------------------------- Unwind-seh.cpp ---------------------------===//1//===--------------------------- Unwind-seh.cpp ---------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
9//8//
...@@ -53,14 +52,16 @@ static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0...@@ -53,14 +52,16 @@ static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0
53/// Exception cleanup routine used by \c _GCC_specific_handler to52/// Exception cleanup routine used by \c _GCC_specific_handler to
54/// free foreign exceptions.53/// free foreign exceptions.
55static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) {54static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) {
55 (void)urc;
56 if (exc->exception_class != kSEHExceptionClass)56 if (exc->exception_class != kSEHExceptionClass)
57 _LIBUNWIND_ABORT("SEH cleanup called on non-SEH exception");57 _LIBUNWIND_ABORT("SEH cleanup called on non-SEH exception");
58 free(exc);58 free(exc);
59}59}
6060
61static int _unw_init_seh(unw_cursor_t *cursor, CONTEXT *ctx);61static int __unw_init_seh(unw_cursor_t *cursor, CONTEXT *ctx);
62static DISPATCHER_CONTEXT *_unw_seh_get_disp_ctx(unw_cursor_t *cursor);62static DISPATCHER_CONTEXT *__unw_seh_get_disp_ctx(unw_cursor_t *cursor);
63static void _unw_seh_set_disp_ctx(unw_cursor_t *cursor, DISPATCHER_CONTEXT *disp);63static void __unw_seh_set_disp_ctx(unw_cursor_t *cursor,
64 DISPATCHER_CONTEXT *disp);
6465
65/// Common implementation of SEH-style handler functions used by Itanium-66/// Common implementation of SEH-style handler functions used by Itanium-
66/// style frames. Depending on how and why it was called, it may do one of:67/// style frames. Depending on how and why it was called, it may do one of:
...@@ -69,7 +70,6 @@ static void _unw_seh_set_disp_ctx(unw_cursor_t *cursor, DISPATCHER_CONTEXT *disp...@@ -69,7 +70,6 @@ static void _unw_seh_set_disp_ctx(unw_cursor_t *cursor, DISPATCHER_CONTEXT *disp
69_LIBUNWIND_EXPORT EXCEPTION_DISPOSITION70_LIBUNWIND_EXPORT EXCEPTION_DISPOSITION
70_GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,71_GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
71 DISPATCHER_CONTEXT *disp, __personality_routine pers) {72 DISPATCHER_CONTEXT *disp, __personality_routine pers) {
72 unw_context_t uc;
73 unw_cursor_t cursor;73 unw_cursor_t cursor;
74 _Unwind_Exception *exc;74 _Unwind_Exception *exc;
75 _Unwind_Action action;75 _Unwind_Action action;
...@@ -78,7 +78,9 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,...@@ -78,7 +78,9 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
78 uintptr_t retval, target;78 uintptr_t retval, target;
79 bool ours = false;79 bool ours = false;
8080
81 _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler(%#010x(%x), %p)", ms_exc->ExceptionCode, ms_exc->ExceptionFlags, frame);81 _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler(%#010lx(%lx), %p)",
82 ms_exc->ExceptionCode, ms_exc->ExceptionFlags,
83 (void *)frame);
82 if (ms_exc->ExceptionCode == STATUS_GCC_UNWIND) {84 if (ms_exc->ExceptionCode == STATUS_GCC_UNWIND) {
83 if (IS_TARGET_UNWIND(ms_exc->ExceptionFlags)) {85 if (IS_TARGET_UNWIND(ms_exc->ExceptionFlags)) {
84 // Set up the upper return value (the lower one and the target PC86 // Set up the upper return value (the lower one and the target PC
...@@ -112,9 +114,9 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,...@@ -112,9 +114,9 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
112 memset(exc->private_, 0, sizeof(exc->private_));114 memset(exc->private_, 0, sizeof(exc->private_));
113 }115 }
114 if (!ctx) {116 if (!ctx) {
115 _unw_init_seh(&cursor, disp->ContextRecord);117 __unw_init_seh(&cursor, disp->ContextRecord);
116 _unw_seh_set_disp_ctx(&cursor, disp);118 __unw_seh_set_disp_ctx(&cursor, disp);
117 unw_set_reg(&cursor, UNW_REG_IP, disp->ControlPc-1);119 __unw_set_reg(&cursor, UNW_REG_IP, disp->ControlPc - 1);
118 ctx = (struct _Unwind_Context *)&cursor;120 ctx = (struct _Unwind_Context *)&cursor;
119121
120 if (!IS_UNWINDING(ms_exc->ExceptionFlags)) {122 if (!IS_UNWINDING(ms_exc->ExceptionFlags)) {
...@@ -130,7 +132,10 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,...@@ -130,7 +132,10 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
130 }132 }
131 }133 }
132134
133 _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() calling personality function %p(1, %d, %llx, %p, %p)", pers, action, exc->exception_class, exc, ctx);135 _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() calling personality "
136 "function %p(1, %d, %llx, %p, %p)",
137 (void *)pers, action, exc->exception_class,
138 (void *)exc, (void *)ctx);
134 urc = pers(1, action, exc->exception_class, exc, ctx);139 urc = pers(1, action, exc->exception_class, exc, ctx);
135 _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() personality returned %d", urc);140 _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() personality returned %d", urc);
136 switch (urc) {141 switch (urc) {
...@@ -168,18 +173,18 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,...@@ -168,18 +173,18 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
168 _LIBUNWIND_ABORT("Personality installed context during phase 1!");173 _LIBUNWIND_ABORT("Personality installed context during phase 1!");
169#ifdef __x86_64__174#ifdef __x86_64__
170 exc->private_[2] = disp->TargetIp;175 exc->private_[2] = disp->TargetIp;
171 unw_get_reg(&cursor, UNW_X86_64_RAX, &retval);176 __unw_get_reg(&cursor, UNW_X86_64_RAX, &retval);
172 unw_get_reg(&cursor, UNW_X86_64_RDX, &exc->private_[3]);177 __unw_get_reg(&cursor, UNW_X86_64_RDX, &exc->private_[3]);
173#elif defined(__arm__)178#elif defined(__arm__)
174 exc->private_[2] = disp->TargetPc;179 exc->private_[2] = disp->TargetPc;
175 unw_get_reg(&cursor, UNW_ARM_R0, &retval);180 __unw_get_reg(&cursor, UNW_ARM_R0, &retval);
176 unw_get_reg(&cursor, UNW_ARM_R1, &exc->private_[3]);181 __unw_get_reg(&cursor, UNW_ARM_R1, &exc->private_[3]);
177#elif defined(__aarch64__)182#elif defined(__aarch64__)
178 exc->private_[2] = disp->TargetPc;183 exc->private_[2] = disp->TargetPc;
179 unw_get_reg(&cursor, UNW_ARM64_X0, &retval);184 __unw_get_reg(&cursor, UNW_ARM64_X0, &retval);
180 unw_get_reg(&cursor, UNW_ARM64_X1, &exc->private_[3]);185 __unw_get_reg(&cursor, UNW_ARM64_X1, &exc->private_[3]);
181#endif186#endif
182 unw_get_reg(&cursor, UNW_REG_IP, &target);187 __unw_get_reg(&cursor, UNW_REG_IP, &target);
183 ms_exc->ExceptionCode = STATUS_GCC_UNWIND;188 ms_exc->ExceptionCode = STATUS_GCC_UNWIND;
184#ifdef __x86_64__189#ifdef __x86_64__
185 ms_exc->ExceptionInformation[2] = disp->TargetIp;190 ms_exc->ExceptionInformation[2] = disp->TargetIp;
...@@ -199,7 +204,7 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,...@@ -199,7 +204,7 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
199 }204 }
200}205}
201206
202/// Personality function returned by \c unw_get_proc_info() in SEH contexts.207/// Personality function returned by \c __unw_get_proc_info() in SEH contexts.
203/// This is a wrapper that calls the real SEH handler function, which in208/// This is a wrapper that calls the real SEH handler function, which in
204/// turn (at least, for Itanium-style frames) calls the real Itanium209/// turn (at least, for Itanium-style frames) calls the real Itanium
205/// personality function (see \c _GCC_specific_handler()).210/// personality function (see \c _GCC_specific_handler()).
...@@ -207,6 +212,8 @@ extern "C" _Unwind_Reason_Code...@@ -207,6 +212,8 @@ extern "C" _Unwind_Reason_Code
207__libunwind_seh_personality(int version, _Unwind_Action state,212__libunwind_seh_personality(int version, _Unwind_Action state,
208 uint64_t klass, _Unwind_Exception *exc,213 uint64_t klass, _Unwind_Exception *exc,
209 struct _Unwind_Context *context) {214 struct _Unwind_Context *context) {
215 (void)version;
216 (void)klass;
210 EXCEPTION_RECORD ms_exc;217 EXCEPTION_RECORD ms_exc;
211 bool phase2 = (state & (_UA_SEARCH_PHASE|_UA_CLEANUP_PHASE)) == _UA_CLEANUP_PHASE;218 bool phase2 = (state & (_UA_SEARCH_PHASE|_UA_CLEANUP_PHASE)) == _UA_CLEANUP_PHASE;
212 ms_exc.ExceptionCode = STATUS_GCC_THROW;219 ms_exc.ExceptionCode = STATUS_GCC_THROW;
...@@ -215,7 +222,8 @@ __libunwind_seh_personality(int version, _Unwind_Action state,...@@ -215,7 +222,8 @@ __libunwind_seh_personality(int version, _Unwind_Action state,
215 ms_exc.ExceptionInformation[0] = (ULONG_PTR)exc;222 ms_exc.ExceptionInformation[0] = (ULONG_PTR)exc;
216 ms_exc.ExceptionInformation[1] = (ULONG_PTR)context;223 ms_exc.ExceptionInformation[1] = (ULONG_PTR)context;
217 ms_exc.ExceptionInformation[2] = state;224 ms_exc.ExceptionInformation[2] = state;
218 DISPATCHER_CONTEXT *disp_ctx = _unw_seh_get_disp_ctx((unw_cursor_t *)context);225 DISPATCHER_CONTEXT *disp_ctx =
226 __unw_seh_get_disp_ctx((unw_cursor_t *)context);
219 EXCEPTION_DISPOSITION ms_act = disp_ctx->LanguageHandler(&ms_exc,227 EXCEPTION_DISPOSITION ms_act = disp_ctx->LanguageHandler(&ms_exc,
220 (PVOID)disp_ctx->EstablisherFrame,228 (PVOID)disp_ctx->EstablisherFrame,
221 disp_ctx->ContextRecord,229 disp_ctx->ContextRecord,
...@@ -234,15 +242,15 @@ unwind_phase2_forced(unw_context_t *uc,...@@ -234,15 +242,15 @@ unwind_phase2_forced(unw_context_t *uc,
234 _Unwind_Exception *exception_object,242 _Unwind_Exception *exception_object,
235 _Unwind_Stop_Fn stop, void *stop_parameter) {243 _Unwind_Stop_Fn stop, void *stop_parameter) {
236 unw_cursor_t cursor2;244 unw_cursor_t cursor2;
237 unw_init_local(&cursor2, uc);245 __unw_init_local(&cursor2, uc);
238246
239 // Walk each frame until we reach where search phase said to stop247 // Walk each frame until we reach where search phase said to stop
240 while (unw_step(&cursor2) > 0) {248 while (__unw_step(&cursor2) > 0) {
241249
242 // Update info about this frame.250 // Update info about this frame.
243 unw_proc_info_t frameInfo;251 unw_proc_info_t frameInfo;
244 if (unw_get_proc_info(&cursor2, &frameInfo) != UNW_ESUCCESS) {252 if (__unw_get_proc_info(&cursor2, &frameInfo) != UNW_ESUCCESS) {
245 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): unw_step "253 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): __unw_step "
246 "failed => _URC_END_OF_STACK",254 "failed => _URC_END_OF_STACK",
247 (void *)exception_object);255 (void *)exception_object);
248 return _URC_FATAL_PHASE2_ERROR;256 return _URC_FATAL_PHASE2_ERROR;
...@@ -253,8 +261,8 @@ unwind_phase2_forced(unw_context_t *uc,...@@ -253,8 +261,8 @@ unwind_phase2_forced(unw_context_t *uc,
253 char functionBuf[512];261 char functionBuf[512];
254 const char *functionName = functionBuf;262 const char *functionName = functionBuf;
255 unw_word_t offset;263 unw_word_t offset;
256 if ((unw_get_proc_name(&cursor2, functionBuf, sizeof(functionBuf),264 if ((__unw_get_proc_name(&cursor2, functionBuf, sizeof(functionBuf),
257 &offset) != UNW_ESUCCESS) ||265 &offset) != UNW_ESUCCESS) ||
258 (frameInfo.start_ip + offset > frameInfo.end_ip))266 (frameInfo.start_ip + offset > frameInfo.end_ip))
259 functionName = ".anonymous.";267 functionName = ".anonymous.";
260 _LIBUNWIND_TRACE_UNWINDING(268 _LIBUNWIND_TRACE_UNWINDING(
...@@ -304,7 +312,7 @@ unwind_phase2_forced(unw_context_t *uc,...@@ -304,7 +312,7 @@ unwind_phase2_forced(unw_context_t *uc,
304 "_URC_INSTALL_CONTEXT",312 "_URC_INSTALL_CONTEXT",
305 (void *)exception_object);313 (void *)exception_object);
306 // We may get control back if landing pad calls _Unwind_Resume().314 // We may get control back if landing pad calls _Unwind_Resume().
307 unw_resume(&cursor2);315 __unw_resume(&cursor2);
308 break;316 break;
309 default:317 default:
310 // Personality routine returned an unknown result code.318 // Personality routine returned an unknown result code.
...@@ -369,7 +377,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) {...@@ -369,7 +377,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) {
369 if (exception_object->private_[0] != 0) {377 if (exception_object->private_[0] != 0) {
370 unw_context_t uc;378 unw_context_t uc;
371379
372 unw_getcontext(&uc);380 __unw_getcontext(&uc);
373 unwind_phase2_forced(&uc, exception_object,381 unwind_phase2_forced(&uc, exception_object,
374 (_Unwind_Stop_Fn) exception_object->private_[0],382 (_Unwind_Stop_Fn) exception_object->private_[0],
375 (void *)exception_object->private_[4]);383 (void *)exception_object->private_[4]);
...@@ -407,7 +415,7 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,...@@ -407,7 +415,7 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,
407 _LIBUNWIND_TRACE_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)",415 _LIBUNWIND_TRACE_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)",
408 (void *)exception_object, (void *)(uintptr_t)stop);416 (void *)exception_object, (void *)(uintptr_t)stop);
409 unw_context_t uc;417 unw_context_t uc;
410 unw_getcontext(&uc);418 __unw_getcontext(&uc);
411419
412 // Mark that this is a forced unwind, so _Unwind_Resume() can do420 // Mark that this is a forced unwind, so _Unwind_Resume() can do
413 // the right thing.421 // the right thing.
...@@ -421,7 +429,8 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,...@@ -421,7 +429,8 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,
421/// Called by personality handler during phase 2 to get LSDA for current frame.429/// Called by personality handler during phase 2 to get LSDA for current frame.
422_LIBUNWIND_EXPORT uintptr_t430_LIBUNWIND_EXPORT uintptr_t
423_Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {431_Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
424 uintptr_t result = (uintptr_t)_unw_seh_get_disp_ctx((unw_cursor_t *)context)->HandlerData;432 uintptr_t result =
433 (uintptr_t)__unw_seh_get_disp_ctx((unw_cursor_t *)context)->HandlerData;
425 _LIBUNWIND_TRACE_API(434 _LIBUNWIND_TRACE_API(
426 "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIxPTR,435 "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIxPTR,
427 (void *)context, result);436 (void *)context, result);
...@@ -432,30 +441,32 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {...@@ -432,30 +441,32 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
432/// function.441/// function.
433_LIBUNWIND_EXPORT uintptr_t442_LIBUNWIND_EXPORT uintptr_t
434_Unwind_GetRegionStart(struct _Unwind_Context *context) {443_Unwind_GetRegionStart(struct _Unwind_Context *context) {
435 DISPATCHER_CONTEXT *disp = _unw_seh_get_disp_ctx((unw_cursor_t *)context);444 DISPATCHER_CONTEXT *disp = __unw_seh_get_disp_ctx((unw_cursor_t *)context);
436 uintptr_t result = (uintptr_t)disp->FunctionEntry->BeginAddress + disp->ImageBase;445 uintptr_t result = (uintptr_t)disp->FunctionEntry->BeginAddress + disp->ImageBase;
437 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIxPTR,446 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIxPTR,
438 (void *)context, result);447 (void *)context, result);
439 return result;448 return result;
440}449}
441450
442static int451static int __unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) {
443_unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) {
444#ifdef _LIBUNWIND_TARGET_X86_64452#ifdef _LIBUNWIND_TARGET_X86_64
445 new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_x86_64>(453 new (reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_x86_64> *>(cursor))
446 context, LocalAddressSpace::sThisAddressSpace);454 UnwindCursor<LocalAddressSpace, Registers_x86_64>(
455 context, LocalAddressSpace::sThisAddressSpace);
447 auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor);456 auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor);
448 co->setInfoBasedOnIPRegister();457 co->setInfoBasedOnIPRegister();
449 return UNW_ESUCCESS;458 return UNW_ESUCCESS;
450#elif defined(_LIBUNWIND_TARGET_ARM)459#elif defined(_LIBUNWIND_TARGET_ARM)
451 new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_arm>(460 new (reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_arm> *>(cursor))
452 context, LocalAddressSpace::sThisAddressSpace);461 UnwindCursor<LocalAddressSpace, Registers_arm>(
462 context, LocalAddressSpace::sThisAddressSpace);
453 auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor);463 auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor);
454 co->setInfoBasedOnIPRegister();464 co->setInfoBasedOnIPRegister();
455 return UNW_ESUCCESS;465 return UNW_ESUCCESS;
456#elif defined(_LIBUNWIND_TARGET_AARCH64)466#elif defined(_LIBUNWIND_TARGET_AARCH64)
457 new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_arm64>(467 new (reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_arm64> *>(cursor))
458 context, LocalAddressSpace::sThisAddressSpace);468 UnwindCursor<LocalAddressSpace, Registers_arm64>(
469 context, LocalAddressSpace::sThisAddressSpace);
459 auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor);470 auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor);
460 co->setInfoBasedOnIPRegister();471 co->setInfoBasedOnIPRegister();
461 return UNW_ESUCCESS;472 return UNW_ESUCCESS;
...@@ -464,8 +475,7 @@ _unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) {...@@ -464,8 +475,7 @@ _unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) {
464#endif475#endif
465}476}
466477
467static DISPATCHER_CONTEXT *478static DISPATCHER_CONTEXT *__unw_seh_get_disp_ctx(unw_cursor_t *cursor) {
468_unw_seh_get_disp_ctx(unw_cursor_t *cursor) {
469#ifdef _LIBUNWIND_TARGET_X86_64479#ifdef _LIBUNWIND_TARGET_X86_64
470 return reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_x86_64> *>(cursor)->getDispatcherContext();480 return reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_x86_64> *>(cursor)->getDispatcherContext();
471#elif defined(_LIBUNWIND_TARGET_ARM)481#elif defined(_LIBUNWIND_TARGET_ARM)
...@@ -477,8 +487,8 @@ _unw_seh_get_disp_ctx(unw_cursor_t *cursor) {...@@ -477,8 +487,8 @@ _unw_seh_get_disp_ctx(unw_cursor_t *cursor) {
477#endif487#endif
478}488}
479489
480static void490static void __unw_seh_set_disp_ctx(unw_cursor_t *cursor,
481_unw_seh_set_disp_ctx(unw_cursor_t *cursor, DISPATCHER_CONTEXT *disp) {491 DISPATCHER_CONTEXT *disp) {
482#ifdef _LIBUNWIND_TARGET_X86_64492#ifdef _LIBUNWIND_TARGET_X86_64
483 reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_x86_64> *>(cursor)->setDispatcherContext(disp);493 reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_x86_64> *>(cursor)->setDispatcherContext(disp);
484#elif defined(_LIBUNWIND_TARGET_ARM)494#elif defined(_LIBUNWIND_TARGET_ARM)
lib/libunwind/src/Unwind-sjlj.c+66-54
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===--------------------------- Unwind-sjlj.c ----------------------------===//1//===--------------------------- Unwind-sjlj.c ----------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Implements setjump-longjump based C++ exceptions8// Implements setjump-longjump based C++ exceptions
...@@ -12,6 +11,7 @@...@@ -12,6 +11,7 @@
1211
13#include <unwind.h>12#include <unwind.h>
1413
14#include <inttypes.h>
15#include <stdint.h>15#include <stdint.h>
16#include <stdbool.h>16#include <stdbool.h>
17#include <stdlib.h>17#include <stdlib.h>
...@@ -52,7 +52,7 @@ struct _Unwind_FunctionContext {...@@ -52,7 +52,7 @@ struct _Unwind_FunctionContext {
52#else52#else
53# if __STDC_VERSION__ >= 201112L53# if __STDC_VERSION__ >= 201112L
54# define _LIBUNWIND_THREAD_LOCAL _Thread_local54# define _LIBUNWIND_THREAD_LOCAL _Thread_local
55# elif defined(_WIN32)55# elif defined(_MSC_VER)
56# define _LIBUNWIND_THREAD_LOCAL __declspec(thread)56# define _LIBUNWIND_THREAD_LOCAL __declspec(thread)
57# elif defined(__GNUC__) || defined(__clang__)57# elif defined(__GNUC__) || defined(__clang__)
58# define _LIBUNWIND_THREAD_LOCAL __thread58# define _LIBUNWIND_THREAD_LOCAL __thread
...@@ -108,7 +108,8 @@ _Unwind_SjLj_Unregister(struct _Unwind_FunctionContext *fc) {...@@ -108,7 +108,8 @@ _Unwind_SjLj_Unregister(struct _Unwind_FunctionContext *fc) {
108static _Unwind_Reason_Code108static _Unwind_Reason_Code
109unwind_phase1(struct _Unwind_Exception *exception_object) {109unwind_phase1(struct _Unwind_Exception *exception_object) {
110 _Unwind_FunctionContext_t c = __Unwind_SjLj_GetTopOfFunctionStack();110 _Unwind_FunctionContext_t c = __Unwind_SjLj_GetTopOfFunctionStack();
111 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: initial function-context=%p", c);111 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: initial function-context=%p",
112 (void *)c);
112113
113 // walk each frame looking for a place to stop114 // walk each frame looking for a place to stop
114 for (bool handlerNotFound = true; handlerNotFound; c = c->prev) {115 for (bool handlerNotFound = true; handlerNotFound; c = c->prev) {
...@@ -117,17 +118,18 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {...@@ -117,17 +118,18 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {
117 if (c == NULL) {118 if (c == NULL) {
118 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): reached "119 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): reached "
119 "bottom => _URC_END_OF_STACK",120 "bottom => _URC_END_OF_STACK",
120 exception_object);121 (void *)exception_object);
121 return _URC_END_OF_STACK;122 return _URC_END_OF_STACK;
122 }123 }
123124
124 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: function-context=%p", c);125 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: function-context=%p", (void *)c);
125 // if there is a personality routine, ask it if it will want to stop at this126 // if there is a personality routine, ask it if it will want to stop at this
126 // frame127 // frame
127 if (c->personality != NULL) {128 if (c->personality != NULL) {
128 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): calling "129 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): calling "
129 "personality function %p",130 "personality function %p",
130 exception_object, c->personality);131 (void *)exception_object,
132 (void *)c->personality);
131 _Unwind_Reason_Code personalityResult = (*c->personality)(133 _Unwind_Reason_Code personalityResult = (*c->personality)(
132 1, _UA_SEARCH_PHASE, exception_object->exception_class,134 1, _UA_SEARCH_PHASE, exception_object->exception_class,
133 exception_object, (struct _Unwind_Context *)c);135 exception_object, (struct _Unwind_Context *)c);
...@@ -138,12 +140,14 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {...@@ -138,12 +140,14 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {
138 handlerNotFound = false;140 handlerNotFound = false;
139 exception_object->private_2 = (uintptr_t) c;141 exception_object->private_2 = (uintptr_t) c;
140 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): "142 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): "
141 "_URC_HANDLER_FOUND", exception_object);143 "_URC_HANDLER_FOUND",
144 (void *)exception_object);
142 return _URC_NO_REASON;145 return _URC_NO_REASON;
143146
144 case _URC_CONTINUE_UNWIND:147 case _URC_CONTINUE_UNWIND:
145 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): "148 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): "
146 "_URC_CONTINUE_UNWIND", exception_object);149 "_URC_CONTINUE_UNWIND",
150 (void *)exception_object);
147 // continue unwinding151 // continue unwinding
148 break;152 break;
149153
...@@ -151,7 +155,7 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {...@@ -151,7 +155,7 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {
151 // something went wrong155 // something went wrong
152 _LIBUNWIND_TRACE_UNWINDING(156 _LIBUNWIND_TRACE_UNWINDING(
153 "unwind_phase1(ex_ojb=%p): _URC_FATAL_PHASE1_ERROR",157 "unwind_phase1(ex_ojb=%p): _URC_FATAL_PHASE1_ERROR",
154 exception_object);158 (void *)exception_object);
155 return _URC_FATAL_PHASE1_ERROR;159 return _URC_FATAL_PHASE1_ERROR;
156 }160 }
157 }161 }
...@@ -162,19 +166,21 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {...@@ -162,19 +166,21 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {
162166
163static _Unwind_Reason_Code167static _Unwind_Reason_Code
164unwind_phase2(struct _Unwind_Exception *exception_object) {168unwind_phase2(struct _Unwind_Exception *exception_object) {
165 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)", exception_object);169 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)",
170 (void *)exception_object);
166171
167 // walk each frame until we reach where search phase said to stop172 // walk each frame until we reach where search phase said to stop
168 _Unwind_FunctionContext_t c = __Unwind_SjLj_GetTopOfFunctionStack();173 _Unwind_FunctionContext_t c = __Unwind_SjLj_GetTopOfFunctionStack();
169 while (true) {174 while (true) {
170 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2s(ex_ojb=%p): context=%p",175 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2s(ex_ojb=%p): context=%p",
171 exception_object, c);176 (void *)exception_object, (void *)c);
172177
173 // check for no more frames178 // check for no more frames
174 if (c == NULL) {179 if (c == NULL) {
175 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "180 _LIBUNWIND_TRACE_UNWINDING(
176 "bottom => _URC_END_OF_STACK",181 "unwind_phase2(ex_ojb=%p): __unw_step() reached "
177 exception_object);182 "bottom => _URC_END_OF_STACK",
183 (void *)exception_object);
178 return _URC_END_OF_STACK;184 return _URC_END_OF_STACK;
179 }185 }
180186
...@@ -194,7 +200,7 @@ unwind_phase2(struct _Unwind_Exception *exception_object) {...@@ -194,7 +200,7 @@ unwind_phase2(struct _Unwind_Exception *exception_object) {
194 // continue unwinding200 // continue unwinding
195 _LIBUNWIND_TRACE_UNWINDING(201 _LIBUNWIND_TRACE_UNWINDING(
196 "unwind_phase2(ex_ojb=%p): _URC_CONTINUE_UNWIND",202 "unwind_phase2(ex_ojb=%p): _URC_CONTINUE_UNWIND",
197 exception_object);203 (void *)exception_object);
198 if ((uintptr_t) c == exception_object->private_2) {204 if ((uintptr_t) c == exception_object->private_2) {
199 // phase 1 said we would stop at this frame, but we did not...205 // phase 1 said we would stop at this frame, but we did not...
200 _LIBUNWIND_ABORT("during phase1 personality function said it would "206 _LIBUNWIND_ABORT("during phase1 personality function said it would "
...@@ -203,14 +209,14 @@ unwind_phase2(struct _Unwind_Exception *exception_object) {...@@ -203,14 +209,14 @@ unwind_phase2(struct _Unwind_Exception *exception_object) {
203 break;209 break;
204 case _URC_INSTALL_CONTEXT:210 case _URC_INSTALL_CONTEXT:
205 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): "211 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): "
206 "_URC_INSTALL_CONTEXT, will resume at "212 "_URC_INSTALL_CONTEXT, will resume at "
207 "landing pad %p",213 "landing pad %p",
208 exception_object, c->jbuf[1]);214 (void *)exception_object, c->jbuf[1]);
209 // personality routine says to transfer control to landing pad215 // personality routine says to transfer control to landing pad
210 // we may get control back if landing pad calls _Unwind_Resume()216 // we may get control back if landing pad calls _Unwind_Resume()
211 __Unwind_SjLj_SetTopOfFunctionStack(c);217 __Unwind_SjLj_SetTopOfFunctionStack(c);
212 __builtin_longjmp(c->jbuf, 1);218 __builtin_longjmp(c->jbuf, 1);
213 // unw_resume() only returns if there was an error219 // __unw_resume() only returns if there was an error
214 return _URC_FATAL_PHASE2_ERROR;220 return _URC_FATAL_PHASE2_ERROR;
215 default:221 default:
216 // something went wrong222 // something went wrong
...@@ -237,9 +243,10 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,...@@ -237,9 +243,10 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
237243
238 // get next frame (skip over first which is _Unwind_RaiseException)244 // get next frame (skip over first which is _Unwind_RaiseException)
239 if (c == NULL) {245 if (c == NULL) {
240 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "246 _LIBUNWIND_TRACE_UNWINDING(
241 "bottom => _URC_END_OF_STACK",247 "unwind_phase2(ex_ojb=%p): __unw_step() reached "
242 exception_object);248 "bottom => _URC_END_OF_STACK",
249 (void *)exception_object);
243 return _URC_END_OF_STACK;250 return _URC_END_OF_STACK;
244 }251 }
245252
...@@ -251,11 +258,11 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,...@@ -251,11 +258,11 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
251 (struct _Unwind_Context *)c, stop_parameter);258 (struct _Unwind_Context *)c, stop_parameter);
252 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "259 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
253 "stop function returned %d",260 "stop function returned %d",
254 exception_object, stopResult);261 (void *)exception_object, stopResult);
255 if (stopResult != _URC_NO_REASON) {262 if (stopResult != _URC_NO_REASON) {
256 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "263 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
257 "stopped by stop function",264 "stopped by stop function",
258 exception_object);265 (void *)exception_object);
259 return _URC_FATAL_PHASE2_ERROR;266 return _URC_FATAL_PHASE2_ERROR;
260 }267 }
261268
...@@ -264,7 +271,7 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,...@@ -264,7 +271,7 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
264 __personality_routine p = (__personality_routine) c->personality;271 __personality_routine p = (__personality_routine) c->personality;
265 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "272 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
266 "calling personality function %p",273 "calling personality function %p",
267 exception_object, p);274 (void *)exception_object, (void *)p);
268 _Unwind_Reason_Code personalityResult =275 _Unwind_Reason_Code personalityResult =
269 (*p)(1, action, exception_object->exception_class, exception_object,276 (*p)(1, action, exception_object->exception_class, exception_object,
270 (struct _Unwind_Context *)c);277 (struct _Unwind_Context *)c);
...@@ -272,13 +279,13 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,...@@ -272,13 +279,13 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
272 case _URC_CONTINUE_UNWIND:279 case _URC_CONTINUE_UNWIND:
273 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "280 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
274 "personality returned _URC_CONTINUE_UNWIND",281 "personality returned _URC_CONTINUE_UNWIND",
275 exception_object);282 (void *)exception_object);
276 // destructors called, continue unwinding283 // destructors called, continue unwinding
277 break;284 break;
278 case _URC_INSTALL_CONTEXT:285 case _URC_INSTALL_CONTEXT:
279 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "286 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
280 "personality returned _URC_INSTALL_CONTEXT",287 "personality returned _URC_INSTALL_CONTEXT",
281 exception_object);288 (void *)exception_object);
282 // we may get control back if landing pad calls _Unwind_Resume()289 // we may get control back if landing pad calls _Unwind_Resume()
283 __Unwind_SjLj_SetTopOfFunctionStack(c);290 __Unwind_SjLj_SetTopOfFunctionStack(c);
284 __builtin_longjmp(c->jbuf, 1);291 __builtin_longjmp(c->jbuf, 1);
...@@ -288,7 +295,7 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,...@@ -288,7 +295,7 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
288 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "295 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
289 "personality returned %d, "296 "personality returned %d, "
290 "_URC_FATAL_PHASE2_ERROR",297 "_URC_FATAL_PHASE2_ERROR",
291 exception_object, personalityResult);298 (void *)exception_object, personalityResult);
292 return _URC_FATAL_PHASE2_ERROR;299 return _URC_FATAL_PHASE2_ERROR;
293 }300 }
294 }301 }
...@@ -298,8 +305,8 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,...@@ -298,8 +305,8 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
298 // call stop function one last time and tell it we've reached the end of the305 // call stop function one last time and tell it we've reached the end of the
299 // stack306 // stack
300 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): calling stop "307 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): calling stop "
301 "function with _UA_END_OF_STACK",308 "function with _UA_END_OF_STACK",
302 exception_object);309 (void *)exception_object);
303 _Unwind_Action lastAction =310 _Unwind_Action lastAction =
304 (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK);311 (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK);
305 (*stop)(1, lastAction, exception_object->exception_class, exception_object,312 (*stop)(1, lastAction, exception_object->exception_class, exception_object,
...@@ -314,7 +321,8 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,...@@ -314,7 +321,8 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
314/// Called by __cxa_throw. Only returns if there is a fatal error321/// Called by __cxa_throw. Only returns if there is a fatal error
315_LIBUNWIND_EXPORT _Unwind_Reason_Code322_LIBUNWIND_EXPORT _Unwind_Reason_Code
316_Unwind_SjLj_RaiseException(struct _Unwind_Exception *exception_object) {323_Unwind_SjLj_RaiseException(struct _Unwind_Exception *exception_object) {
317 _LIBUNWIND_TRACE_API("_Unwind_SjLj_RaiseException(ex_obj=%p)", exception_object);324 _LIBUNWIND_TRACE_API("_Unwind_SjLj_RaiseException(ex_obj=%p)",
325 (void *)exception_object);
318326
319 // mark that this is a non-forced unwind, so _Unwind_Resume() can do the right327 // mark that this is a non-forced unwind, so _Unwind_Resume() can do the right
320 // thing328 // thing
...@@ -344,7 +352,8 @@ _Unwind_SjLj_RaiseException(struct _Unwind_Exception *exception_object) {...@@ -344,7 +352,8 @@ _Unwind_SjLj_RaiseException(struct _Unwind_Exception *exception_object) {
344/// __cxa_rethrow() which in turn calls _Unwind_Resume_or_Rethrow()352/// __cxa_rethrow() which in turn calls _Unwind_Resume_or_Rethrow()
345_LIBUNWIND_EXPORT void353_LIBUNWIND_EXPORT void
346_Unwind_SjLj_Resume(struct _Unwind_Exception *exception_object) {354_Unwind_SjLj_Resume(struct _Unwind_Exception *exception_object) {
347 _LIBUNWIND_TRACE_API("_Unwind_SjLj_Resume(ex_obj=%p)", exception_object);355 _LIBUNWIND_TRACE_API("_Unwind_SjLj_Resume(ex_obj=%p)",
356 (void *)exception_object);
348357
349 if (exception_object->private_1 != 0)358 if (exception_object->private_1 != 0)
350 unwind_phase2_forced(exception_object,359 unwind_phase2_forced(exception_object,
...@@ -362,8 +371,8 @@ _Unwind_SjLj_Resume(struct _Unwind_Exception *exception_object) {...@@ -362,8 +371,8 @@ _Unwind_SjLj_Resume(struct _Unwind_Exception *exception_object) {
362_LIBUNWIND_EXPORT _Unwind_Reason_Code371_LIBUNWIND_EXPORT _Unwind_Reason_Code
363_Unwind_SjLj_Resume_or_Rethrow(struct _Unwind_Exception *exception_object) {372_Unwind_SjLj_Resume_or_Rethrow(struct _Unwind_Exception *exception_object) {
364 _LIBUNWIND_TRACE_API("__Unwind_SjLj_Resume_or_Rethrow(ex_obj=%p), "373 _LIBUNWIND_TRACE_API("__Unwind_SjLj_Resume_or_Rethrow(ex_obj=%p), "
365 "private_1=%ld",374 "private_1=%" PRIuPTR,
366 exception_object, exception_object->private_1);375 (void *)exception_object, exception_object->private_1);
367 // If this is non-forced and a stopping place was found, then this is a376 // If this is non-forced and a stopping place was found, then this is a
368 // re-throw.377 // re-throw.
369 // Call _Unwind_RaiseException() as if this was a new exception.378 // Call _Unwind_RaiseException() as if this was a new exception.
...@@ -386,7 +395,8 @@ _LIBUNWIND_EXPORT uintptr_t...@@ -386,7 +395,8 @@ _LIBUNWIND_EXPORT uintptr_t
386_Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {395_Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
387 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;396 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
388 _LIBUNWIND_TRACE_API("_Unwind_GetLanguageSpecificData(context=%p) "397 _LIBUNWIND_TRACE_API("_Unwind_GetLanguageSpecificData(context=%p) "
389 "=> 0x%0lX", context, ufc->lsda);398 "=> 0x%" PRIuPTR,
399 (void *)context, ufc->lsda);
390 return ufc->lsda;400 return ufc->lsda;
391}401}
392402
...@@ -394,8 +404,8 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {...@@ -394,8 +404,8 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
394/// Called by personality handler during phase 2 to get register values.404/// Called by personality handler during phase 2 to get register values.
395_LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context,405_LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context,
396 int index) {406 int index) {
397 _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d)",407 _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d)", (void *)context,
398 context, index);408 index);
399 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;409 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
400 return ufc->resumeParameters[index];410 return ufc->resumeParameters[index];
401}411}
...@@ -404,8 +414,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context,...@@ -404,8 +414,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context,
404/// Called by personality handler during phase 2 to alter register values.414/// Called by personality handler during phase 2 to alter register values.
405_LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,415_LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
406 uintptr_t new_value) {416 uintptr_t new_value) {
407 _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%0lX)"417 _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%" PRIuPTR
408 , context, index, new_value);418 ")",
419 (void *)context, index, new_value);
409 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;420 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
410 ufc->resumeParameters[index] = new_value;421 ufc->resumeParameters[index] = new_value;
411}422}
...@@ -414,8 +425,8 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,...@@ -414,8 +425,8 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
414/// Called by personality handler during phase 2 to get instruction pointer.425/// Called by personality handler during phase 2 to get instruction pointer.
415_LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {426_LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
416 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;427 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
417 _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%lX", context,428 _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIu32,
418 ufc->resumeLocation + 1);429 (void *)context, ufc->resumeLocation + 1);
419 return ufc->resumeLocation + 1;430 return ufc->resumeLocation + 1;
420}431}
421432
...@@ -427,8 +438,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,...@@ -427,8 +438,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,
427 int *ipBefore) {438 int *ipBefore) {
428 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;439 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
429 *ipBefore = 0;440 *ipBefore = 0;
430 _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%lX",441 _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%" PRIu32,
431 context, ipBefore, ufc->resumeLocation + 1);442 (void *)context, (void *)ipBefore,
443 ufc->resumeLocation + 1);
432 return ufc->resumeLocation + 1;444 return ufc->resumeLocation + 1;
433}445}
434446
...@@ -436,8 +448,8 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,...@@ -436,8 +448,8 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,
436/// Called by personality handler during phase 2 to alter instruction pointer.448/// Called by personality handler during phase 2 to alter instruction pointer.
437_LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,449_LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,
438 uintptr_t new_value) {450 uintptr_t new_value) {
439 _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%0lX)",451 _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%" PRIuPTR ")",
440 context, new_value);452 (void *)context, new_value);
441 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;453 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
442 ufc->resumeLocation = new_value - 1;454 ufc->resumeLocation = new_value - 1;
443}455}
...@@ -449,7 +461,7 @@ _LIBUNWIND_EXPORT uintptr_t...@@ -449,7 +461,7 @@ _LIBUNWIND_EXPORT uintptr_t
449_Unwind_GetRegionStart(struct _Unwind_Context *context) {461_Unwind_GetRegionStart(struct _Unwind_Context *context) {
450 // Not supported or needed for sjlj based unwinding462 // Not supported or needed for sjlj based unwinding
451 (void)context;463 (void)context;
452 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p)", context);464 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p)", (void *)context);
453 return 0;465 return 0;
454}466}
455467
...@@ -459,7 +471,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {...@@ -459,7 +471,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {
459_LIBUNWIND_EXPORT void471_LIBUNWIND_EXPORT void
460_Unwind_DeleteException(struct _Unwind_Exception *exception_object) {472_Unwind_DeleteException(struct _Unwind_Exception *exception_object) {
461 _LIBUNWIND_TRACE_API("_Unwind_DeleteException(ex_obj=%p)",473 _LIBUNWIND_TRACE_API("_Unwind_DeleteException(ex_obj=%p)",
462 exception_object);474 (void *)exception_object);
463 if (exception_object->exception_cleanup != NULL)475 if (exception_object->exception_cleanup != NULL)
464 (*exception_object->exception_cleanup)(_URC_FOREIGN_EXCEPTION_CAUGHT,476 (*exception_object->exception_cleanup)(_URC_FOREIGN_EXCEPTION_CAUGHT,
465 exception_object);477 exception_object);
...@@ -473,7 +485,7 @@ _LIBUNWIND_EXPORT uintptr_t...@@ -473,7 +485,7 @@ _LIBUNWIND_EXPORT uintptr_t
473_Unwind_GetDataRelBase(struct _Unwind_Context *context) {485_Unwind_GetDataRelBase(struct _Unwind_Context *context) {
474 // Not supported or needed for sjlj based unwinding486 // Not supported or needed for sjlj based unwinding
475 (void)context;487 (void)context;
476 _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", context);488 _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", (void *)context);
477 _LIBUNWIND_ABORT("_Unwind_GetDataRelBase() not implemented");489 _LIBUNWIND_ABORT("_Unwind_GetDataRelBase() not implemented");
478}490}
479491
...@@ -484,14 +496,14 @@ _LIBUNWIND_EXPORT uintptr_t...@@ -484,14 +496,14 @@ _LIBUNWIND_EXPORT uintptr_t
484_Unwind_GetTextRelBase(struct _Unwind_Context *context) {496_Unwind_GetTextRelBase(struct _Unwind_Context *context) {
485 // Not supported or needed for sjlj based unwinding497 // Not supported or needed for sjlj based unwinding
486 (void)context;498 (void)context;
487 _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", context);499 _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", (void *)context);
488 _LIBUNWIND_ABORT("_Unwind_GetTextRelBase() not implemented");500 _LIBUNWIND_ABORT("_Unwind_GetTextRelBase() not implemented");
489}501}
490502
491503
492/// Called by personality handler to get "Call Frame Area" for current frame.504/// Called by personality handler to get "Call Frame Area" for current frame.
493_LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) {505_LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) {
494 _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p)", context);506 _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p)", (void *)context);
495 if (context != NULL) {507 if (context != NULL) {
496 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;508 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
497 // Setjmp/longjmp based exceptions don't have a true CFA.509 // Setjmp/longjmp based exceptions don't have a true CFA.
lib/libunwind/src/UnwindCursor.hpp+42-11
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===------------------------- UnwindCursor.hpp ---------------------------===//1//===------------------------- UnwindCursor.hpp ---------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// C++ interface to lower levels of libunwind8// C++ interface to lower levels of libunwind
...@@ -12,7 +11,6 @@...@@ -12,7 +11,6 @@
12#ifndef __UNWINDCURSOR_HPP__11#ifndef __UNWINDCURSOR_HPP__
13#define __UNWINDCURSOR_HPP__12#define __UNWINDCURSOR_HPP__
1413
15#include <algorithm>
16#include <stdint.h>14#include <stdint.h>
17#include <stdio.h>15#include <stdio.h>
18#include <stdlib.h>16#include <stdlib.h>
...@@ -106,7 +104,6 @@ private:...@@ -106,7 +104,6 @@ private:
106 static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide);104 static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide);
107 static bool _registeredForDyldUnloads;105 static bool _registeredForDyldUnloads;
108#endif106#endif
109 // Can't use std::vector<> here because this code is below libc++.
110 static entry *_buffer;107 static entry *_buffer;
111 static entry *_bufferUsed;108 static entry *_bufferUsed;
112 static entry *_bufferEnd;109 static entry *_bufferEnd;
...@@ -485,6 +482,10 @@ public:...@@ -485,6 +482,10 @@ public:
485 DISPATCHER_CONTEXT *getDispatcherContext() { return &_dispContext; }482 DISPATCHER_CONTEXT *getDispatcherContext() { return &_dispContext; }
486 void setDispatcherContext(DISPATCHER_CONTEXT *disp) { _dispContext = *disp; }483 void setDispatcherContext(DISPATCHER_CONTEXT *disp) { _dispContext = *disp; }
487484
485 // libunwind does not and should not depend on C++ library which means that we
486 // need our own defition of inline placement new.
487 static void *operator new(size_t, UnwindCursor<A, R> *p) { return p; }
488
488private:489private:
489490
490 pint_t getLastPC() const { return _dispContext.ControlPc; }491 pint_t getLastPC() const { return _dispContext.ControlPc; }
...@@ -789,6 +790,8 @@ bool UnwindCursor<A, R>::validFloatReg(int regNum) {...@@ -789,6 +790,8 @@ bool UnwindCursor<A, R>::validFloatReg(int regNum) {
789 if (regNum >= UNW_ARM_D0 && regNum <= UNW_ARM_D31) return true;790 if (regNum >= UNW_ARM_D0 && regNum <= UNW_ARM_D31) return true;
790#elif defined(_LIBUNWIND_TARGET_AARCH64)791#elif defined(_LIBUNWIND_TARGET_AARCH64)
791 if (regNum >= UNW_ARM64_D0 && regNum <= UNW_ARM64_D31) return true;792 if (regNum >= UNW_ARM64_D0 && regNum <= UNW_ARM64_D31) return true;
793#else
794 (void)regNum;
792#endif795#endif
793 return false;796 return false;
794}797}
...@@ -816,6 +819,7 @@ unw_fpreg_t UnwindCursor<A, R>::getFloatReg(int regNum) {...@@ -816,6 +819,7 @@ unw_fpreg_t UnwindCursor<A, R>::getFloatReg(int regNum) {
816#elif defined(_LIBUNWIND_TARGET_AARCH64)819#elif defined(_LIBUNWIND_TARGET_AARCH64)
817 return _msContext.V[regNum - UNW_ARM64_D0].D[0];820 return _msContext.V[regNum - UNW_ARM64_D0].D[0];
818#else821#else
822 (void)regNum;
819 _LIBUNWIND_ABORT("float registers unimplemented");823 _LIBUNWIND_ABORT("float registers unimplemented");
820#endif824#endif
821}825}
...@@ -843,6 +847,8 @@ void UnwindCursor<A, R>::setFloatReg(int regNum, unw_fpreg_t value) {...@@ -843,6 +847,8 @@ void UnwindCursor<A, R>::setFloatReg(int regNum, unw_fpreg_t value) {
843#elif defined(_LIBUNWIND_TARGET_AARCH64)847#elif defined(_LIBUNWIND_TARGET_AARCH64)
844 _msContext.V[regNum - UNW_ARM64_D0].D[0] = value;848 _msContext.V[regNum - UNW_ARM64_D0].D[0] = value;
845#else849#else
850 (void)regNum;
851 (void)value;
846 _LIBUNWIND_ABORT("float registers unimplemented");852 _LIBUNWIND_ABORT("float registers unimplemented");
847#endif853#endif
848}854}
...@@ -892,6 +898,10 @@ public:...@@ -892,6 +898,10 @@ public:
892 virtual void saveVFPAsX();898 virtual void saveVFPAsX();
893#endif899#endif
894900
901 // libunwind does not and should not depend on C++ library which means that we
902 // need our own defition of inline placement new.
903 static void *operator new(size_t, UnwindCursor<A, R> *p) { return p; }
904
895private:905private:
896906
897#if defined(_LIBUNWIND_ARM_EHABI)907#if defined(_LIBUNWIND_ARM_EHABI)
...@@ -1221,7 +1231,6 @@ template<typename A>...@@ -1221,7 +1231,6 @@ template<typename A>
1221struct EHABISectionIterator {1231struct EHABISectionIterator {
1222 typedef EHABISectionIterator _Self;1232 typedef EHABISectionIterator _Self;
12231233
1224 typedef std::random_access_iterator_tag iterator_category;
1225 typedef typename A::pint_t value_type;1234 typedef typename A::pint_t value_type;
1226 typedef typename A::pint_t* pointer;1235 typedef typename A::pint_t* pointer;
1227 typedef typename A::pint_t& reference;1236 typedef typename A::pint_t& reference;
...@@ -1275,6 +1284,29 @@ struct EHABISectionIterator {...@@ -1275,6 +1284,29 @@ struct EHABISectionIterator {
1275 const UnwindInfoSections* _sects;1284 const UnwindInfoSections* _sects;
1276};1285};
12771286
1287namespace {
1288
1289template <typename A>
1290EHABISectionIterator<A> EHABISectionUpperBound(
1291 EHABISectionIterator<A> first,
1292 EHABISectionIterator<A> last,
1293 typename A::pint_t value) {
1294 size_t len = last - first;
1295 while (len > 0) {
1296 size_t l2 = len / 2;
1297 EHABISectionIterator<A> m = first + l2;
1298 if (value < *m) {
1299 len = l2;
1300 } else {
1301 first = ++m;
1302 len -= l2 + 1;
1303 }
1304 }
1305 return first;
1306}
1307
1308}
1309
1278template <typename A, typename R>1310template <typename A, typename R>
1279bool UnwindCursor<A, R>::getInfoFromEHABISection(1311bool UnwindCursor<A, R>::getInfoFromEHABISection(
1280 pint_t pc,1312 pint_t pc,
...@@ -1286,7 +1318,7 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection(...@@ -1286,7 +1318,7 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection(
1286 if (begin == end)1318 if (begin == end)
1287 return false;1319 return false;
12881320
1289 EHABISectionIterator<A> itNextPC = std::upper_bound(begin, end, pc);1321 EHABISectionIterator<A> itNextPC = EHABISectionUpperBound(begin, end, pc);
1290 if (itNextPC == begin)1322 if (itNextPC == begin)
1291 return false;1323 return false;
1292 EHABISectionIterator<A> itThisPC = itNextPC - 1;1324 EHABISectionIterator<A> itThisPC = itNextPC - 1;
...@@ -1296,8 +1328,7 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection(...@@ -1296,8 +1328,7 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection(
1296 // in the table, we don't really know the function extent and have to choose a1328 // in the table, we don't really know the function extent and have to choose a
1297 // value for nextPC. Choosing max() will allow the range check during trace to1329 // value for nextPC. Choosing max() will allow the range check during trace to
1298 // succeed.1330 // succeed.
1299 pint_t nextPC = (itNextPC == end) ? std::numeric_limits<pint_t>::max()1331 pint_t nextPC = (itNextPC == end) ? UINTPTR_MAX : itNextPC.functionAddress();
1300 : itNextPC.functionAddress();
1301 pint_t indexDataAddr = itThisPC.dataAddress();1332 pint_t indexDataAddr = itThisPC.dataAddress();
13021333
1303 if (indexDataAddr == 0)1334 if (indexDataAddr == 0)
...@@ -1709,7 +1740,7 @@ bool UnwindCursor<A, R>::getInfoFromCompactEncodingSection(pint_t pc,...@@ -1709,7 +1740,7 @@ bool UnwindCursor<A, R>::getInfoFromCompactEncodingSection(pint_t pc,
1709 --personalityIndex; // change 1-based to zero-based index1740 --personalityIndex; // change 1-based to zero-based index
1710 if (personalityIndex > sectionHeader.personalityArrayCount()) {1741 if (personalityIndex > sectionHeader.personalityArrayCount()) {
1711 _LIBUNWIND_DEBUG_LOG("found encoding 0x%08X with personality index %d, "1742 _LIBUNWIND_DEBUG_LOG("found encoding 0x%08X with personality index %d, "
1712 "but personality table has only %d entires",1743 "but personality table has only %d entries",
1713 encoding, personalityIndex,1744 encoding, personalityIndex,
1714 sectionHeader.personalityArrayCount());1745 sectionHeader.personalityArrayCount());
1715 return false;1746 return false;
lib/libunwind/src/UnwindLevel1-gcc-ext.c+20-21
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===--------------------- UnwindLevel1-gcc-ext.c -------------------------===//1//===--------------------- UnwindLevel1-gcc-ext.c -------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Implements gcc extensions to the C++ ABI Exception Handling Level 1.8// Implements gcc extensions to the C++ ABI Exception Handling Level 1.
...@@ -94,10 +93,10 @@ _LIBUNWIND_EXPORT void *_Unwind_FindEnclosingFunction(void *pc) {...@@ -94,10 +93,10 @@ _LIBUNWIND_EXPORT void *_Unwind_FindEnclosingFunction(void *pc) {
94 unw_cursor_t cursor;93 unw_cursor_t cursor;
95 unw_context_t uc;94 unw_context_t uc;
96 unw_proc_info_t info;95 unw_proc_info_t info;
97 unw_getcontext(&uc);96 __unw_getcontext(&uc);
98 unw_init_local(&cursor, &uc);97 __unw_init_local(&cursor, &uc);
99 unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t) pc);98 __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc);
100 if (unw_get_proc_info(&cursor, &info) == UNW_ESUCCESS)99 if (__unw_get_proc_info(&cursor, &info) == UNW_ESUCCESS)
101 return (void *)(intptr_t) info.start_ip;100 return (void *)(intptr_t) info.start_ip;
102 else101 else
103 return NULL;102 return NULL;
...@@ -109,8 +108,8 @@ _LIBUNWIND_EXPORT _Unwind_Reason_Code...@@ -109,8 +108,8 @@ _LIBUNWIND_EXPORT _Unwind_Reason_Code
109_Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {108_Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
110 unw_cursor_t cursor;109 unw_cursor_t cursor;
111 unw_context_t uc;110 unw_context_t uc;
112 unw_getcontext(&uc);111 __unw_getcontext(&uc);
113 unw_init_local(&cursor, &uc);112 __unw_init_local(&cursor, &uc);
114113
115 _LIBUNWIND_TRACE_API("_Unwind_Backtrace(callback=%p)",114 _LIBUNWIND_TRACE_API("_Unwind_Backtrace(callback=%p)",
116 (void *)(uintptr_t)callback);115 (void *)(uintptr_t)callback);
...@@ -129,7 +128,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {...@@ -129,7 +128,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
129#if !defined(_LIBUNWIND_ARM_EHABI)128#if !defined(_LIBUNWIND_ARM_EHABI)
130 // ask libunwind to get next frame (skip over first frame which is129 // ask libunwind to get next frame (skip over first frame which is
131 // _Unwind_Backtrace())130 // _Unwind_Backtrace())
132 if (unw_step(&cursor) <= 0) {131 if (__unw_step(&cursor) <= 0) {
133 _LIBUNWIND_TRACE_UNWINDING(" _backtrace: ended because cursor reached "132 _LIBUNWIND_TRACE_UNWINDING(" _backtrace: ended because cursor reached "
134 "bottom of stack, returning %d",133 "bottom of stack, returning %d",
135 _URC_END_OF_STACK);134 _URC_END_OF_STACK);
...@@ -138,7 +137,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {...@@ -138,7 +137,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
138#else137#else
139 // Get the information for this frame.138 // Get the information for this frame.
140 unw_proc_info_t frameInfo;139 unw_proc_info_t frameInfo;
141 if (unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) {140 if (__unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) {
142 return _URC_END_OF_STACK;141 return _URC_END_OF_STACK;
143 }142 }
144143
...@@ -165,8 +164,8 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {...@@ -165,8 +164,8 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
165 char functionName[512];164 char functionName[512];
166 unw_proc_info_t frame;165 unw_proc_info_t frame;
167 unw_word_t offset;166 unw_word_t offset;
168 unw_get_proc_name(&cursor, functionName, 512, &offset);167 __unw_get_proc_name(&cursor, functionName, 512, &offset);
169 unw_get_proc_info(&cursor, &frame);168 __unw_get_proc_info(&cursor, &frame);
170 _LIBUNWIND_TRACE_UNWINDING(169 _LIBUNWIND_TRACE_UNWINDING(
171 " _backtrace: start_ip=0x%" PRIxPTR ", func=%s, lsda=0x%" PRIxPTR ", context=%p",170 " _backtrace: start_ip=0x%" PRIxPTR ", func=%s, lsda=0x%" PRIxPTR ", context=%p",
172 frame.start_ip, functionName, frame.lsda,171 frame.start_ip, functionName, frame.lsda,
...@@ -192,10 +191,10 @@ _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc,...@@ -192,10 +191,10 @@ _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc,
192 unw_cursor_t cursor;191 unw_cursor_t cursor;
193 unw_context_t uc;192 unw_context_t uc;
194 unw_proc_info_t info;193 unw_proc_info_t info;
195 unw_getcontext(&uc);194 __unw_getcontext(&uc);
196 unw_init_local(&cursor, &uc);195 __unw_init_local(&cursor, &uc);
197 unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t) pc);196 __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc);
198 unw_get_proc_info(&cursor, &info);197 __unw_get_proc_info(&cursor, &info);
199 bases->tbase = (uintptr_t)info.extra;198 bases->tbase = (uintptr_t)info.extra;
200 bases->dbase = 0; // dbase not used on Mac OS X199 bases->dbase = 0; // dbase not used on Mac OS X
201 bases->func = (uintptr_t)info.start_ip;200 bases->func = (uintptr_t)info.start_ip;
...@@ -209,7 +208,7 @@ _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc,...@@ -209,7 +208,7 @@ _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc,
209_LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) {208_LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) {
210 unw_cursor_t *cursor = (unw_cursor_t *)context;209 unw_cursor_t *cursor = (unw_cursor_t *)context;
211 unw_word_t result;210 unw_word_t result;
212 unw_get_reg(cursor, UNW_REG_SP, &result);211 __unw_get_reg(cursor, UNW_REG_SP, &result);
213 _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p) => 0x%" PRIxPTR,212 _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p) => 0x%" PRIxPTR,
214 (void *)context, result);213 (void *)context, result);
215 return (uintptr_t)result;214 return (uintptr_t)result;
...@@ -234,7 +233,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,...@@ -234,7 +233,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,
234/// was broken until 10.6.233/// was broken until 10.6.
235_LIBUNWIND_EXPORT void __register_frame(const void *fde) {234_LIBUNWIND_EXPORT void __register_frame(const void *fde) {
236 _LIBUNWIND_TRACE_API("__register_frame(%p)", fde);235 _LIBUNWIND_TRACE_API("__register_frame(%p)", fde);
237 _unw_add_dynamic_fde((unw_word_t)(uintptr_t) fde);236 __unw_add_dynamic_fde((unw_word_t)(uintptr_t)fde);
238}237}
239238
240239
...@@ -244,7 +243,7 @@ _LIBUNWIND_EXPORT void __register_frame(const void *fde) {...@@ -244,7 +243,7 @@ _LIBUNWIND_EXPORT void __register_frame(const void *fde) {
244/// was broken until 10.6.243/// was broken until 10.6.
245_LIBUNWIND_EXPORT void __deregister_frame(const void *fde) {244_LIBUNWIND_EXPORT void __deregister_frame(const void *fde) {
246 _LIBUNWIND_TRACE_API("__deregister_frame(%p)", fde);245 _LIBUNWIND_TRACE_API("__deregister_frame(%p)", fde);
247 _unw_remove_dynamic_fde((unw_word_t)(uintptr_t) fde);246 __unw_remove_dynamic_fde((unw_word_t)(uintptr_t)fde);
248}247}
249248
250249
lib/libunwind/src/UnwindLevel1.c+63-57
...@@ -1,13 +1,12 @@...@@ -1,13 +1,12 @@
1//===------------------------- UnwindLevel1.c -----------------------------===//1//===------------------------- UnwindLevel1.c -----------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Implements C++ ABI Exception Handling Level 1 as documented at:8// Implements C++ ABI Exception Handling Level 1 as documented at:
10// http://mentorembedded.github.io/cxx-abi/abi-eh.html9// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
11// using libunwind10// using libunwind
12//11//
13//===----------------------------------------------------------------------===//12//===----------------------------------------------------------------------===//
...@@ -26,9 +25,10 @@...@@ -26,9 +25,10 @@
26#include <stdio.h>25#include <stdio.h>
27#include <string.h>26#include <string.h>
2827
28#include "config.h"
29#include "libunwind.h"29#include "libunwind.h"
30#include "libunwind_ext.h"
30#include "unwind.h"31#include "unwind.h"
31#include "config.h"
3232
33#if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)33#if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
3434
...@@ -36,33 +36,36 @@...@@ -36,33 +36,36 @@
3636
37static _Unwind_Reason_Code37static _Unwind_Reason_Code
38unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {38unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
39 unw_init_local(cursor, uc);39 __unw_init_local(cursor, uc);
4040
41 // Walk each frame looking for a place to stop.41 // Walk each frame looking for a place to stop.
42 bool handlerNotFound = true;42 bool handlerNotFound = true;
43 while (handlerNotFound) {43 while (handlerNotFound) {
44 // Ask libunwind to get next frame (skip over first which is44 // Ask libunwind to get next frame (skip over first which is
45 // _Unwind_RaiseException).45 // _Unwind_RaiseException).
46 int stepResult = unw_step(cursor);46 int stepResult = __unw_step(cursor);
47 if (stepResult == 0) {47 if (stepResult == 0) {
48 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step() reached "48 _LIBUNWIND_TRACE_UNWINDING(
49 "bottom => _URC_END_OF_STACK",49 "unwind_phase1(ex_ojb=%p): __unw_step() reached "
50 (void *)exception_object);50 "bottom => _URC_END_OF_STACK",
51 (void *)exception_object);
51 return _URC_END_OF_STACK;52 return _URC_END_OF_STACK;
52 } else if (stepResult < 0) {53 } else if (stepResult < 0) {
53 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step failed => "54 _LIBUNWIND_TRACE_UNWINDING(
54 "_URC_FATAL_PHASE1_ERROR",55 "unwind_phase1(ex_ojb=%p): __unw_step failed => "
55 (void *)exception_object);56 "_URC_FATAL_PHASE1_ERROR",
57 (void *)exception_object);
56 return _URC_FATAL_PHASE1_ERROR;58 return _URC_FATAL_PHASE1_ERROR;
57 }59 }
5860
59 // See if frame has code to run (has personality routine).61 // See if frame has code to run (has personality routine).
60 unw_proc_info_t frameInfo;62 unw_proc_info_t frameInfo;
61 unw_word_t sp;63 unw_word_t sp;
62 if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {64 if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
63 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_get_proc_info "65 _LIBUNWIND_TRACE_UNWINDING(
64 "failed => _URC_FATAL_PHASE1_ERROR",66 "unwind_phase1(ex_ojb=%p): __unw_get_proc_info "
65 (void *)exception_object);67 "failed => _URC_FATAL_PHASE1_ERROR",
68 (void *)exception_object);
66 return _URC_FATAL_PHASE1_ERROR;69 return _URC_FATAL_PHASE1_ERROR;
67 }70 }
6871
...@@ -71,12 +74,12 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except...@@ -71,12 +74,12 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
71 char functionBuf[512];74 char functionBuf[512];
72 const char *functionName = functionBuf;75 const char *functionName = functionBuf;
73 unw_word_t offset;76 unw_word_t offset;
74 if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),77 if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
75 &offset) != UNW_ESUCCESS) ||78 &offset) != UNW_ESUCCESS) ||
76 (frameInfo.start_ip + offset > frameInfo.end_ip))79 (frameInfo.start_ip + offset > frameInfo.end_ip))
77 functionName = ".anonymous.";80 functionName = ".anonymous.";
78 unw_word_t pc;81 unw_word_t pc;
79 unw_get_reg(cursor, UNW_REG_IP, &pc);82 __unw_get_reg(cursor, UNW_REG_IP, &pc);
80 _LIBUNWIND_TRACE_UNWINDING(83 _LIBUNWIND_TRACE_UNWINDING(
81 "unwind_phase1(ex_ojb=%p): pc=0x%" PRIxPTR ", start_ip=0x%" PRIxPTR84 "unwind_phase1(ex_ojb=%p): pc=0x%" PRIxPTR ", start_ip=0x%" PRIxPTR
82 ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR "",85 ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR "",
...@@ -100,7 +103,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except...@@ -100,7 +103,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
100 // found a catch clause or locals that need destructing in this frame103 // found a catch clause or locals that need destructing in this frame
101 // stop search and remember stack pointer at the frame104 // stop search and remember stack pointer at the frame
102 handlerNotFound = false;105 handlerNotFound = false;
103 unw_get_reg(cursor, UNW_REG_SP, &sp);106 __unw_get_reg(cursor, UNW_REG_SP, &sp);
104 exception_object->private_2 = (uintptr_t)sp;107 exception_object->private_2 = (uintptr_t)sp;
105 _LIBUNWIND_TRACE_UNWINDING(108 _LIBUNWIND_TRACE_UNWINDING(
106 "unwind_phase1(ex_ojb=%p): _URC_HANDLER_FOUND",109 "unwind_phase1(ex_ojb=%p): _URC_HANDLER_FOUND",
...@@ -129,7 +132,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except...@@ -129,7 +132,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
129132
130static _Unwind_Reason_Code133static _Unwind_Reason_Code
131unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {134unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
132 unw_init_local(cursor, uc);135 __unw_init_local(cursor, uc);
133136
134 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)",137 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)",
135 (void *)exception_object);138 (void *)exception_object);
...@@ -139,27 +142,30 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except...@@ -139,27 +142,30 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
139142
140 // Ask libunwind to get next frame (skip over first which is143 // Ask libunwind to get next frame (skip over first which is
141 // _Unwind_RaiseException).144 // _Unwind_RaiseException).
142 int stepResult = unw_step(cursor);145 int stepResult = __unw_step(cursor);
143 if (stepResult == 0) {146 if (stepResult == 0) {
144 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "147 _LIBUNWIND_TRACE_UNWINDING(
145 "bottom => _URC_END_OF_STACK",148 "unwind_phase2(ex_ojb=%p): __unw_step() reached "
146 (void *)exception_object);149 "bottom => _URC_END_OF_STACK",
150 (void *)exception_object);
147 return _URC_END_OF_STACK;151 return _URC_END_OF_STACK;
148 } else if (stepResult < 0) {152 } else if (stepResult < 0) {
149 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step failed => "153 _LIBUNWIND_TRACE_UNWINDING(
150 "_URC_FATAL_PHASE1_ERROR",154 "unwind_phase2(ex_ojb=%p): __unw_step failed => "
151 (void *)exception_object);155 "_URC_FATAL_PHASE1_ERROR",
156 (void *)exception_object);
152 return _URC_FATAL_PHASE2_ERROR;157 return _URC_FATAL_PHASE2_ERROR;
153 }158 }
154159
155 // Get info about this frame.160 // Get info about this frame.
156 unw_word_t sp;161 unw_word_t sp;
157 unw_proc_info_t frameInfo;162 unw_proc_info_t frameInfo;
158 unw_get_reg(cursor, UNW_REG_SP, &sp);163 __unw_get_reg(cursor, UNW_REG_SP, &sp);
159 if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {164 if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
160 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_get_proc_info "165 _LIBUNWIND_TRACE_UNWINDING(
161 "failed => _URC_FATAL_PHASE1_ERROR",166 "unwind_phase2(ex_ojb=%p): __unw_get_proc_info "
162 (void *)exception_object);167 "failed => _URC_FATAL_PHASE1_ERROR",
168 (void *)exception_object);
163 return _URC_FATAL_PHASE2_ERROR;169 return _URC_FATAL_PHASE2_ERROR;
164 }170 }
165171
...@@ -168,8 +174,8 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except...@@ -168,8 +174,8 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
168 char functionBuf[512];174 char functionBuf[512];
169 const char *functionName = functionBuf;175 const char *functionName = functionBuf;
170 unw_word_t offset;176 unw_word_t offset;
171 if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),177 if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
172 &offset) != UNW_ESUCCESS) ||178 &offset) != UNW_ESUCCESS) ||
173 (frameInfo.start_ip + offset > frameInfo.end_ip))179 (frameInfo.start_ip + offset > frameInfo.end_ip))
174 functionName = ".anonymous.";180 functionName = ".anonymous.";
175 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): start_ip=0x%" PRIxPTR181 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): start_ip=0x%" PRIxPTR
...@@ -212,15 +218,15 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except...@@ -212,15 +218,15 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
212 // We may get control back if landing pad calls _Unwind_Resume().218 // We may get control back if landing pad calls _Unwind_Resume().
213 if (_LIBUNWIND_TRACING_UNWINDING) {219 if (_LIBUNWIND_TRACING_UNWINDING) {
214 unw_word_t pc;220 unw_word_t pc;
215 unw_get_reg(cursor, UNW_REG_IP, &pc);221 __unw_get_reg(cursor, UNW_REG_IP, &pc);
216 unw_get_reg(cursor, UNW_REG_SP, &sp);222 __unw_get_reg(cursor, UNW_REG_SP, &sp);
217 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering "223 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering "
218 "user code with ip=0x%" PRIxPTR224 "user code with ip=0x%" PRIxPTR
219 ", sp=0x%" PRIxPTR,225 ", sp=0x%" PRIxPTR,
220 (void *)exception_object, pc, sp);226 (void *)exception_object, pc, sp);
221 }227 }
222 unw_resume(cursor);228 __unw_resume(cursor);
223 // unw_resume() only returns if there was an error.229 // __unw_resume() only returns if there was an error.
224 return _URC_FATAL_PHASE2_ERROR;230 return _URC_FATAL_PHASE2_ERROR;
225 default:231 default:
226 // Personality routine returned an unknown result code.232 // Personality routine returned an unknown result code.
...@@ -240,15 +246,15 @@ static _Unwind_Reason_Code...@@ -240,15 +246,15 @@ static _Unwind_Reason_Code
240unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,246unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
241 _Unwind_Exception *exception_object,247 _Unwind_Exception *exception_object,
242 _Unwind_Stop_Fn stop, void *stop_parameter) {248 _Unwind_Stop_Fn stop, void *stop_parameter) {
243 unw_init_local(cursor, uc);249 __unw_init_local(cursor, uc);
244250
245 // Walk each frame until we reach where search phase said to stop251 // Walk each frame until we reach where search phase said to stop
246 while (unw_step(cursor) > 0) {252 while (__unw_step(cursor) > 0) {
247253
248 // Update info about this frame.254 // Update info about this frame.
249 unw_proc_info_t frameInfo;255 unw_proc_info_t frameInfo;
250 if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {256 if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
251 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): unw_step "257 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): __unw_step "
252 "failed => _URC_END_OF_STACK",258 "failed => _URC_END_OF_STACK",
253 (void *)exception_object);259 (void *)exception_object);
254 return _URC_FATAL_PHASE2_ERROR;260 return _URC_FATAL_PHASE2_ERROR;
...@@ -259,8 +265,8 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,...@@ -259,8 +265,8 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
259 char functionBuf[512];265 char functionBuf[512];
260 const char *functionName = functionBuf;266 const char *functionName = functionBuf;
261 unw_word_t offset;267 unw_word_t offset;
262 if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),268 if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
263 &offset) != UNW_ESUCCESS) ||269 &offset) != UNW_ESUCCESS) ||
264 (frameInfo.start_ip + offset > frameInfo.end_ip))270 (frameInfo.start_ip + offset > frameInfo.end_ip))
265 functionName = ".anonymous.";271 functionName = ".anonymous.";
266 _LIBUNWIND_TRACE_UNWINDING(272 _LIBUNWIND_TRACE_UNWINDING(
...@@ -310,7 +316,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,...@@ -310,7 +316,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
310 "_URC_INSTALL_CONTEXT",316 "_URC_INSTALL_CONTEXT",
311 (void *)exception_object);317 (void *)exception_object);
312 // We may get control back if landing pad calls _Unwind_Resume().318 // We may get control back if landing pad calls _Unwind_Resume().
313 unw_resume(cursor);319 __unw_resume(cursor);
314 break;320 break;
315 default:321 default:
316 // Personality routine returned an unknown result code.322 // Personality routine returned an unknown result code.
...@@ -346,7 +352,7 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) {...@@ -346,7 +352,7 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) {
346 (void *)exception_object);352 (void *)exception_object);
347 unw_context_t uc;353 unw_context_t uc;
348 unw_cursor_t cursor;354 unw_cursor_t cursor;
349 unw_getcontext(&uc);355 __unw_getcontext(&uc);
350356
351 // Mark that this is a non-forced unwind, so _Unwind_Resume()357 // Mark that this is a non-forced unwind, so _Unwind_Resume()
352 // can do the right thing.358 // can do the right thing.
...@@ -380,7 +386,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) {...@@ -380,7 +386,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) {
380 _LIBUNWIND_TRACE_API("_Unwind_Resume(ex_obj=%p)", (void *)exception_object);386 _LIBUNWIND_TRACE_API("_Unwind_Resume(ex_obj=%p)", (void *)exception_object);
381 unw_context_t uc;387 unw_context_t uc;
382 unw_cursor_t cursor;388 unw_cursor_t cursor;
383 unw_getcontext(&uc);389 __unw_getcontext(&uc);
384390
385 if (exception_object->private_1 != 0)391 if (exception_object->private_1 != 0)
386 unwind_phase2_forced(&uc, &cursor, exception_object,392 unwind_phase2_forced(&uc, &cursor, exception_object,
...@@ -405,7 +411,7 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,...@@ -405,7 +411,7 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,
405 (void *)exception_object, (void *)(uintptr_t)stop);411 (void *)exception_object, (void *)(uintptr_t)stop);
406 unw_context_t uc;412 unw_context_t uc;
407 unw_cursor_t cursor;413 unw_cursor_t cursor;
408 unw_getcontext(&uc);414 __unw_getcontext(&uc);
409415
410 // Mark that this is a forced unwind, so _Unwind_Resume() can do416 // Mark that this is a forced unwind, so _Unwind_Resume() can do
411 // the right thing.417 // the right thing.
...@@ -423,7 +429,7 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {...@@ -423,7 +429,7 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
423 unw_cursor_t *cursor = (unw_cursor_t *)context;429 unw_cursor_t *cursor = (unw_cursor_t *)context;
424 unw_proc_info_t frameInfo;430 unw_proc_info_t frameInfo;
425 uintptr_t result = 0;431 uintptr_t result = 0;
426 if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)432 if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
427 result = (uintptr_t)frameInfo.lsda;433 result = (uintptr_t)frameInfo.lsda;
428 _LIBUNWIND_TRACE_API(434 _LIBUNWIND_TRACE_API(
429 "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIxPTR,435 "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIxPTR,
...@@ -444,7 +450,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {...@@ -444,7 +450,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {
444 unw_cursor_t *cursor = (unw_cursor_t *)context;450 unw_cursor_t *cursor = (unw_cursor_t *)context;
445 unw_proc_info_t frameInfo;451 unw_proc_info_t frameInfo;
446 uintptr_t result = 0;452 uintptr_t result = 0;
447 if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)453 if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
448 result = (uintptr_t)frameInfo.start_ip;454 result = (uintptr_t)frameInfo.start_ip;
449 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIxPTR,455 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIxPTR,
450 (void *)context, result);456 (void *)context, result);
...@@ -469,7 +475,7 @@ _LIBUNWIND_EXPORT uintptr_t...@@ -469,7 +475,7 @@ _LIBUNWIND_EXPORT uintptr_t
469_Unwind_GetGR(struct _Unwind_Context *context, int index) {475_Unwind_GetGR(struct _Unwind_Context *context, int index) {
470 unw_cursor_t *cursor = (unw_cursor_t *)context;476 unw_cursor_t *cursor = (unw_cursor_t *)context;
471 unw_word_t result;477 unw_word_t result;
472 unw_get_reg(cursor, index, &result);478 __unw_get_reg(cursor, index, &result);
473 _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d) => 0x%" PRIxPTR,479 _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d) => 0x%" PRIxPTR,
474 (void *)context, index, result);480 (void *)context, index, result);
475 return (uintptr_t)result;481 return (uintptr_t)result;
...@@ -482,14 +488,14 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,...@@ -482,14 +488,14 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
482 ")",488 ")",
483 (void *)context, index, value);489 (void *)context, index, value);
484 unw_cursor_t *cursor = (unw_cursor_t *)context;490 unw_cursor_t *cursor = (unw_cursor_t *)context;
485 unw_set_reg(cursor, index, value);491 __unw_set_reg(cursor, index, value);
486}492}
487493
488/// Called by personality handler during phase 2 to get instruction pointer.494/// Called by personality handler during phase 2 to get instruction pointer.
489_LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {495_LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
490 unw_cursor_t *cursor = (unw_cursor_t *)context;496 unw_cursor_t *cursor = (unw_cursor_t *)context;
491 unw_word_t result;497 unw_word_t result;
492 unw_get_reg(cursor, UNW_REG_IP, &result);498 __unw_get_reg(cursor, UNW_REG_IP, &result);
493 _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIxPTR,499 _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIxPTR,
494 (void *)context, result);500 (void *)context, result);
495 return (uintptr_t)result;501 return (uintptr_t)result;
...@@ -503,7 +509,7 @@ _LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,...@@ -503,7 +509,7 @@ _LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,
503 _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%0" PRIxPTR ")",509 _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%0" PRIxPTR ")",
504 (void *)context, value);510 (void *)context, value);
505 unw_cursor_t *cursor = (unw_cursor_t *)context;511 unw_cursor_t *cursor = (unw_cursor_t *)context;
506 unw_set_reg(cursor, UNW_REG_IP, value);512 __unw_set_reg(cursor, UNW_REG_IP, value);
507}513}
508514
509#endif // !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)515#endif // !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
lib/libunwind/src/UnwindRegistersRestore.S+148-141
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===-------------------- UnwindRegistersRestore.S ------------------------===//1//===-------------------- UnwindRegistersRestore.S ------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
98
...@@ -14,7 +13,7 @@...@@ -14,7 +13,7 @@
14#if !defined(__USING_SJLJ_EXCEPTIONS__)13#if !defined(__USING_SJLJ_EXCEPTIONS__)
1514
16#if defined(__i386__)15#if defined(__i386__)
17DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)16DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
18#17#
19# void libunwind::Registers_x86::jumpto()18# void libunwind::Registers_x86::jumpto()
20#19#
...@@ -61,7 +60,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)...@@ -61,7 +60,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
6160
62#elif defined(__x86_64__)61#elif defined(__x86_64__)
6362
64DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv)63DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv)
65#64#
66# void libunwind::Registers_x86_64::jumpto()65# void libunwind::Registers_x86_64::jumpto()
67#66#
...@@ -130,7 +129,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv)...@@ -130,7 +129,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv)
130129
131#elif defined(__powerpc64__)130#elif defined(__powerpc64__)
132131
133DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv)132DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv)
134//133//
135// void libunwind::Registers_ppc64::jumpto()134// void libunwind::Registers_ppc64::jumpto()
136//135//
...@@ -395,120 +394,120 @@ Lnovec:...@@ -395,120 +394,120 @@ Lnovec:
395394
396#elif defined(__ppc__)395#elif defined(__ppc__)
397396
398DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)397DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
399;398//
400; void libunwind::Registers_ppc::jumpto()399// void libunwind::Registers_ppc::jumpto()
401;400//
402; On entry:401// On entry:
403; thread_state pointer is in r3402// thread_state pointer is in r3
404;403//
405404
406 ; restore integral registerrs405 // restore integral registerrs
407 ; skip r0 for now406 // skip r0 for now
408 ; skip r1 for now407 // skip r1 for now
409 lwz r2, 16(r3)408 lwz %r2, 16(%r3)
410 ; skip r3 for now409 // skip r3 for now
411 ; skip r4 for now410 // skip r4 for now
412 ; skip r5 for now411 // skip r5 for now
413 lwz r6, 32(r3)412 lwz %r6, 32(%r3)
414 lwz r7, 36(r3)413 lwz %r7, 36(%r3)
415 lwz r8, 40(r3)414 lwz %r8, 40(%r3)
416 lwz r9, 44(r3)415 lwz %r9, 44(%r3)
417 lwz r10, 48(r3)416 lwz %r10, 48(%r3)
418 lwz r11, 52(r3)417 lwz %r11, 52(%r3)
419 lwz r12, 56(r3)418 lwz %r12, 56(%r3)
420 lwz r13, 60(r3)419 lwz %r13, 60(%r3)
421 lwz r14, 64(r3)420 lwz %r14, 64(%r3)
422 lwz r15, 68(r3)421 lwz %r15, 68(%r3)
423 lwz r16, 72(r3)422 lwz %r16, 72(%r3)
424 lwz r17, 76(r3)423 lwz %r17, 76(%r3)
425 lwz r18, 80(r3)424 lwz %r18, 80(%r3)
426 lwz r19, 84(r3)425 lwz %r19, 84(%r3)
427 lwz r20, 88(r3)426 lwz %r20, 88(%r3)
428 lwz r21, 92(r3)427 lwz %r21, 92(%r3)
429 lwz r22, 96(r3)428 lwz %r22, 96(%r3)
430 lwz r23,100(r3)429 lwz %r23,100(%r3)
431 lwz r24,104(r3)430 lwz %r24,104(%r3)
432 lwz r25,108(r3)431 lwz %r25,108(%r3)
433 lwz r26,112(r3)432 lwz %r26,112(%r3)
434 lwz r27,116(r3)433 lwz %r27,116(%r3)
435 lwz r28,120(r3)434 lwz %r28,120(%r3)
436 lwz r29,124(r3)435 lwz %r29,124(%r3)
437 lwz r30,128(r3)436 lwz %r30,128(%r3)
438 lwz r31,132(r3)437 lwz %r31,132(%r3)
439438
440 ; restore float registers439 // restore float registers
441 lfd f0, 160(r3)440 lfd %f0, 160(%r3)
442 lfd f1, 168(r3)441 lfd %f1, 168(%r3)
443 lfd f2, 176(r3)442 lfd %f2, 176(%r3)
444 lfd f3, 184(r3)443 lfd %f3, 184(%r3)
445 lfd f4, 192(r3)444 lfd %f4, 192(%r3)
446 lfd f5, 200(r3)445 lfd %f5, 200(%r3)
447 lfd f6, 208(r3)446 lfd %f6, 208(%r3)
448 lfd f7, 216(r3)447 lfd %f7, 216(%r3)
449 lfd f8, 224(r3)448 lfd %f8, 224(%r3)
450 lfd f9, 232(r3)449 lfd %f9, 232(%r3)
451 lfd f10,240(r3)450 lfd %f10,240(%r3)
452 lfd f11,248(r3)451 lfd %f11,248(%r3)
453 lfd f12,256(r3)452 lfd %f12,256(%r3)
454 lfd f13,264(r3)453 lfd %f13,264(%r3)
455 lfd f14,272(r3)454 lfd %f14,272(%r3)
456 lfd f15,280(r3)455 lfd %f15,280(%r3)
457 lfd f16,288(r3)456 lfd %f16,288(%r3)
458 lfd f17,296(r3)457 lfd %f17,296(%r3)
459 lfd f18,304(r3)458 lfd %f18,304(%r3)
460 lfd f19,312(r3)459 lfd %f19,312(%r3)
461 lfd f20,320(r3)460 lfd %f20,320(%r3)
462 lfd f21,328(r3)461 lfd %f21,328(%r3)
463 lfd f22,336(r3)462 lfd %f22,336(%r3)
464 lfd f23,344(r3)463 lfd %f23,344(%r3)
465 lfd f24,352(r3)464 lfd %f24,352(%r3)
466 lfd f25,360(r3)465 lfd %f25,360(%r3)
467 lfd f26,368(r3)466 lfd %f26,368(%r3)
468 lfd f27,376(r3)467 lfd %f27,376(%r3)
469 lfd f28,384(r3)468 lfd %f28,384(%r3)
470 lfd f29,392(r3)469 lfd %f29,392(%r3)
471 lfd f30,400(r3)470 lfd %f30,400(%r3)
472 lfd f31,408(r3)471 lfd %f31,408(%r3)
473
474 ; restore vector registers if any are in use
475 lwz r5,156(r3) ; test VRsave
476 cmpwi r5,0
477 beq Lnovec
478
479 subi r4,r1,16
480 rlwinm r4,r4,0,0,27 ; mask low 4-bits
481 ; r4 is now a 16-byte aligned pointer into the red zone
482 ; the _vectorRegisters may not be 16-byte aligned so copy via red zone temp buffer
483472
473 // restore vector registers if any are in use
474 lwz %r5, 156(%r3) // test VRsave
475 cmpwi %r5, 0
476 beq Lnovec
477
478 subi %r4, %r1, 16
479 rlwinm %r4, %r4, 0, 0, 27 // mask low 4-bits
480 // r4 is now a 16-byte aligned pointer into the red zone
481 // the _vectorRegisters may not be 16-byte aligned so copy via red zone temp buffer
482
484483
485#define LOAD_VECTOR_UNALIGNEDl(_index) \484#define LOAD_VECTOR_UNALIGNEDl(_index) \
486 andis. r0,r5,(1<<(15-_index)) @\485 andis. %r0, %r5, (1<<(15-_index)) SEPARATOR \
487 beq Ldone ## _index @\486 beq Ldone ## _index SEPARATOR \
488 lwz r0, 424+_index*16(r3) @\487 lwz %r0, 424+_index*16(%r3) SEPARATOR \
489 stw r0, 0(r4) @\488 stw %r0, 0(%r4) SEPARATOR \
490 lwz r0, 424+_index*16+4(r3) @\489 lwz %r0, 424+_index*16+4(%r3) SEPARATOR \
491 stw r0, 4(r4) @\490 stw %r0, 4(%r4) SEPARATOR \
492 lwz r0, 424+_index*16+8(r3) @\491 lwz %r0, 424+_index*16+8(%r3) SEPARATOR \
493 stw r0, 8(r4) @\492 stw %r0, 8(%r4) SEPARATOR \
494 lwz r0, 424+_index*16+12(r3)@\493 lwz %r0, 424+_index*16+12(%r3) SEPARATOR \
495 stw r0, 12(r4) @\494 stw %r0, 12(%r4) SEPARATOR \
496 lvx v ## _index,0,r4 @\495 lvx %v ## _index, 0, %r4 SEPARATOR \
497Ldone ## _index:496 Ldone ## _index:
498497
499#define LOAD_VECTOR_UNALIGNEDh(_index) \498#define LOAD_VECTOR_UNALIGNEDh(_index) \
500 andi. r0,r5,(1<<(31-_index)) @\499 andi. %r0, %r5, (1<<(31-_index)) SEPARATOR \
501 beq Ldone ## _index @\500 beq Ldone ## _index SEPARATOR \
502 lwz r0, 424+_index*16(r3) @\501 lwz %r0, 424+_index*16(%r3) SEPARATOR \
503 stw r0, 0(r4) @\502 stw %r0, 0(%r4) SEPARATOR \
504 lwz r0, 424+_index*16+4(r3) @\503 lwz %r0, 424+_index*16+4(%r3) SEPARATOR \
505 stw r0, 4(r4) @\504 stw %r0, 4(%r4) SEPARATOR \
506 lwz r0, 424+_index*16+8(r3) @\505 lwz %r0, 424+_index*16+8(%r3) SEPARATOR \
507 stw r0, 8(r4) @\506 stw %r0, 8(%r4) SEPARATOR \
508 lwz r0, 424+_index*16+12(r3)@\507 lwz %r0, 424+_index*16+12(%r3) SEPARATOR \
509 stw r0, 12(r4) @\508 stw %r0, 12(%r4) SEPARATOR \
510 lvx v ## _index,0,r4 @\509 lvx %v ## _index, 0, %r4 SEPARATOR \
511 Ldone ## _index:510 Ldone ## _index:
512511
513512
514 LOAD_VECTOR_UNALIGNEDl(0)513 LOAD_VECTOR_UNALIGNEDl(0)
...@@ -545,17 +544,17 @@ Ldone ## _index:...@@ -545,17 +544,17 @@ Ldone ## _index:
545 LOAD_VECTOR_UNALIGNEDh(31)544 LOAD_VECTOR_UNALIGNEDh(31)
546545
547Lnovec:546Lnovec:
548 lwz r0, 136(r3) ; __cr547 lwz %r0, 136(%r3) // __cr
549 mtocrf 255,r0548 mtcr %r0
550 lwz r0, 148(r3) ; __ctr549 lwz %r0, 148(%r3) // __ctr
551 mtctr r0550 mtctr %r0
552 lwz r0, 0(r3) ; __ssr0551 lwz %r0, 0(%r3) // __ssr0
553 mtctr r0552 mtctr %r0
554 lwz r0, 8(r3) ; do r0 now553 lwz %r0, 8(%r3) // do r0 now
555 lwz r5,28(r3) ; do r5 now554 lwz %r5, 28(%r3) // do r5 now
556 lwz r4,24(r3) ; do r4 now555 lwz %r4, 24(%r3) // do r4 now
557 lwz r1,12(r3) ; do sp now556 lwz %r1, 12(%r3) // do sp now
558 lwz r3,20(r3) ; do r3 last557 lwz %r3, 20(%r3) // do r3 last
559 bctr558 bctr
560559
561#elif defined(__arm64__) || defined(__aarch64__)560#elif defined(__arm64__) || defined(__aarch64__)
...@@ -567,7 +566,7 @@ Lnovec:...@@ -567,7 +566,7 @@ Lnovec:
567// thread_state pointer is in x0566// thread_state pointer is in x0
568//567//
569 .p2align 2568 .p2align 2
570DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)569DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
571 // skip restore of x0,x1 for now570 // skip restore of x0,x1 for now
572 ldp x2, x3, [x0, #0x010]571 ldp x2, x3, [x0, #0x010]
573 ldp x4, x5, [x0, #0x020]572 ldp x4, x5, [x0, #0x020]
...@@ -576,7 +575,8 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)...@@ -576,7 +575,8 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
576 ldp x10,x11, [x0, #0x050]575 ldp x10,x11, [x0, #0x050]
577 ldp x12,x13, [x0, #0x060]576 ldp x12,x13, [x0, #0x060]
578 ldp x14,x15, [x0, #0x070]577 ldp x14,x15, [x0, #0x070]
579 ldp x16,x17, [x0, #0x080]578 // x16 and x17 were clobbered by the call into the unwinder, so no point in
579 // restoring them.
580 ldp x18,x19, [x0, #0x090]580 ldp x18,x19, [x0, #0x090]
581 ldp x20,x21, [x0, #0x0A0]581 ldp x20,x21, [x0, #0x0A0]
582 ldp x22,x23, [x0, #0x0B0]582 ldp x22,x23, [x0, #0x0B0]
...@@ -584,8 +584,6 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)...@@ -584,8 +584,6 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
584 ldp x26,x27, [x0, #0x0D0]584 ldp x26,x27, [x0, #0x0D0]
585 ldp x28,x29, [x0, #0x0E0]585 ldp x28,x29, [x0, #0x0E0]
586 ldr x30, [x0, #0x100] // restore pc into lr586 ldr x30, [x0, #0x100] // restore pc into lr
587 ldr x1, [x0, #0x0F8]
588 mov sp,x1 // restore sp
589587
590 ldp d0, d1, [x0, #0x110]588 ldp d0, d1, [x0, #0x110]
591 ldp d2, d3, [x0, #0x120]589 ldp d2, d3, [x0, #0x120]
...@@ -605,12 +603,21 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)...@@ -605,12 +603,21 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
605 ldr d30, [x0, #0x200]603 ldr d30, [x0, #0x200]
606 ldr d31, [x0, #0x208]604 ldr d31, [x0, #0x208]
607605
606 // Finally, restore sp. This must be done after the the last read from the
607 // context struct, because it is allocated on the stack, and an exception
608 // could clobber the de-allocated portion of the stack after sp has been
609 // restored.
610 ldr x16, [x0, #0x0F8]
608 ldp x0, x1, [x0, #0x000] // restore x0,x1611 ldp x0, x1, [x0, #0x000] // restore x0,x1
612 mov sp,x16 // restore sp
609 ret x30 // jump to pc613 ret x30 // jump to pc
610614
611#elif defined(__arm__) && !defined(__APPLE__)615#elif defined(__arm__) && !defined(__APPLE__)
612616
613#if !defined(__ARM_ARCH_ISA_ARM)617#if !defined(__ARM_ARCH_ISA_ARM)
618#if (__ARM_ARCH_ISA_THUMB == 2)
619 .syntax unified
620#endif
614 .thumb621 .thumb
615#endif622#endif
616623
...@@ -621,7 +628,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)...@@ -621,7 +628,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
621@ thread_state pointer is in r0628@ thread_state pointer is in r0
622@629@
623 .p2align 2630 .p2align 2
624DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJumpToEv)631DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJumpToEv)
625#if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1632#if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1
626 @ r8-r11: ldm into r1-r4, then mov to r8-r11633 @ r8-r11: ldm into r1-r4, then mov to r8-r11
627 adds r0, #0x20634 adds r0, #0x20
...@@ -659,7 +666,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJu...@@ -659,7 +666,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJu
659#if defined(__ELF__)666#if defined(__ELF__)
660 .fpu vfpv3-d16667 .fpu vfpv3-d16
661#endif668#endif
662DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMDEPy)669DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMDEPv)
663 @ VFP and iwMMX instructions are only available when compiling with the flags670 @ VFP and iwMMX instructions are only available when compiling with the flags
664 @ that enable them. We do not want to do that in the library (because we do not671 @ that enable them. We do not want to do that in the library (because we do not
665 @ want the compiler to generate instructions that access those) but this is672 @ want the compiler to generate instructions that access those) but this is
...@@ -680,7 +687,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFL...@@ -680,7 +687,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFL
680#if defined(__ELF__)687#if defined(__ELF__)
681 .fpu vfpv3-d16688 .fpu vfpv3-d16
682#endif689#endif
683DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMXEPy)690DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMXEPv)
684 vldmia r0, {d0-d15} @ fldmiax is deprecated in ARMv7+ and now behaves like vldmia691 vldmia r0, {d0-d15} @ fldmiax is deprecated in ARMv7+ and now behaves like vldmia
685 JMP(lr)692 JMP(lr)
686693
...@@ -694,7 +701,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFL...@@ -694,7 +701,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFL
694#if defined(__ELF__)701#if defined(__ELF__)
695 .fpu vfpv3702 .fpu vfpv3
696#endif703#endif
697DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreVFPv3EPy)704DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm12restoreVFPv3EPv)
698 vldmia r0, {d16-d31}705 vldmia r0, {d16-d31}
699 JMP(lr)706 JMP(lr)
700707
...@@ -710,7 +717,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreVFPv3EPy)...@@ -710,7 +717,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreVFPv3EPy)
710#if defined(__ELF__)717#if defined(__ELF__)
711 .arch armv5te718 .arch armv5te
712#endif719#endif
713DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPy)720DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPv)
714 ldcl p1, cr0, [r0], #8 @ wldrd wR0, [r0], #8721 ldcl p1, cr0, [r0], #8 @ wldrd wR0, [r0], #8
715 ldcl p1, cr1, [r0], #8 @ wldrd wR1, [r0], #8722 ldcl p1, cr1, [r0], #8 @ wldrd wR1, [r0], #8
716 ldcl p1, cr2, [r0], #8 @ wldrd wR2, [r0], #8723 ldcl p1, cr2, [r0], #8 @ wldrd wR2, [r0], #8
...@@ -739,7 +746,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPy)...@@ -739,7 +746,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPy)
739#if defined(__ELF__)746#if defined(__ELF__)
740 .arch armv5te747 .arch armv5te
741#endif748#endif
742DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXControlEPj)749DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXControlEPj)
743 ldc2 p1, cr8, [r0], #4 @ wldrw wCGR0, [r0], #4750 ldc2 p1, cr8, [r0], #4 @ wldrw wCGR0, [r0], #4
744 ldc2 p1, cr9, [r0], #4 @ wldrw wCGR1, [r0], #4751 ldc2 p1, cr9, [r0], #4 @ wldrw wCGR1, [r0], #4
745 ldc2 p1, cr10, [r0], #4 @ wldrw wCGR2, [r0], #4752 ldc2 p1, cr10, [r0], #4 @ wldrw wCGR2, [r0], #4
...@@ -750,7 +757,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXCont...@@ -750,7 +757,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXCont
750757
751#elif defined(__or1k__)758#elif defined(__or1k__)
752759
753DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv)760DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv)
754#761#
755# void libunwind::Registers_or1k::jumpto()762# void libunwind::Registers_or1k::jumpto()
756#763#
...@@ -809,7 +816,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv)...@@ -809,7 +816,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv)
809// On entry:816// On entry:
810// thread state pointer is in a0 ($4)817// thread state pointer is in a0 ($4)
811//818//
812DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv)819DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv)
813 .set push820 .set push
814 .set noat821 .set noat
815 .set noreorder822 .set noreorder
...@@ -918,7 +925,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv)...@@ -918,7 +925,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv)
918// On entry:925// On entry:
919// thread state pointer is in a0 ($4)926// thread state pointer is in a0 ($4)
920//927//
921DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv)928DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv)
922 .set push929 .set push
923 .set noat930 .set noat
924 .set noreorder931 .set noreorder
...@@ -1008,7 +1015,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv)...@@ -1008,7 +1015,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv)
1008// On entry:1015// On entry:
1009// thread_state pointer is in o01016// thread_state pointer is in o0
1010//1017//
1011DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_sparc6jumptoEv)1018DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_sparc6jumptoEv)
1012 ta 31019 ta 3
1013 ldd [%o0 + 64], %l01020 ldd [%o0 + 64], %l0
1014 ldd [%o0 + 72], %l21021 ldd [%o0 + 72], %l2
lib/libunwind/src/UnwindRegistersSave.S+171-166
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===------------------------ UnwindRegistersSave.S -----------------------===//1//===------------------------ UnwindRegistersSave.S -----------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
98
...@@ -16,7 +15,7 @@...@@ -16,7 +15,7 @@
16#if defined(__i386__)15#if defined(__i386__)
1716
18#17#
19# extern int unw_getcontext(unw_context_t* thread_state)18# extern int __unw_getcontext(unw_context_t* thread_state)
20#19#
21# On entry:20# On entry:
22# + +21# + +
...@@ -27,7 +26,7 @@...@@ -27,7 +26,7 @@
27# +-----------------------+ <-- SP26# +-----------------------+ <-- SP
28# + +27# + +
29#28#
30DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)29DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
31 push %eax30 push %eax
32 movl 8(%esp), %eax31 movl 8(%esp), %eax
33 movl %ebx, 4(%eax)32 movl %ebx, 4(%eax)
...@@ -57,12 +56,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)...@@ -57,12 +56,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
57#elif defined(__x86_64__)56#elif defined(__x86_64__)
5857
59#58#
60# extern int unw_getcontext(unw_context_t* thread_state)59# extern int __unw_getcontext(unw_context_t* thread_state)
61#60#
62# On entry:61# On entry:
63# thread_state pointer is in rdi62# thread_state pointer is in rdi
64#63#
65DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)64DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
66#if defined(_WIN64)65#if defined(_WIN64)
67#define PTR %rcx66#define PTR %rcx
68#define TMP %rdx67#define TMP %rdx
...@@ -119,12 +118,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)...@@ -119,12 +118,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
119#elif defined(__mips__) && defined(_ABIO32) && _MIPS_SIM == _ABIO32118#elif defined(__mips__) && defined(_ABIO32) && _MIPS_SIM == _ABIO32
120119
121#120#
122# extern int unw_getcontext(unw_context_t* thread_state)121# extern int __unw_getcontext(unw_context_t* thread_state)
123#122#
124# On entry:123# On entry:
125# thread_state pointer is in a0 ($4)124# thread_state pointer is in a0 ($4)
126#125#
127DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)126DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
128 .set push127 .set push
129 .set noat128 .set noat
130 .set noreorder129 .set noreorder
...@@ -228,12 +227,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)...@@ -228,12 +227,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
228#elif defined(__mips64)227#elif defined(__mips64)
229228
230#229#
231# extern int unw_getcontext(unw_context_t* thread_state)230# extern int __unw_getcontext(unw_context_t* thread_state)
232#231#
233# On entry:232# On entry:
234# thread_state pointer is in a0 ($4)233# thread_state pointer is in a0 ($4)
235#234#
236DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)235DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
237 .set push236 .set push
238 .set noat237 .set noat
239 .set noreorder238 .set noreorder
...@@ -318,21 +317,21 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)...@@ -318,21 +317,21 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
318# elif defined(__mips__)317# elif defined(__mips__)
319318
320#319#
321# extern int unw_getcontext(unw_context_t* thread_state)320# extern int __unw_getcontext(unw_context_t* thread_state)
322#321#
323# Just trap for the time being.322# Just trap for the time being.
324DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)323DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
325 teq $0, $0324 teq $0, $0
326325
327#elif defined(__powerpc64__)326#elif defined(__powerpc64__)
328327
329//328//
330// extern int unw_getcontext(unw_context_t* thread_state)329// extern int __unw_getcontext(unw_context_t* thread_state)
331//330//
332// On entry:331// On entry:
333// thread_state pointer is in r3332// thread_state pointer is in r3
334//333//
335DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)334DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
336335
337// store register (GPR)336// store register (GPR)
338#define PPC64_STR(n) \337#define PPC64_STR(n) \
...@@ -557,157 +556,157 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)...@@ -557,157 +556,157 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
557556
558#elif defined(__ppc__)557#elif defined(__ppc__)
559558
560;559//
561; extern int unw_getcontext(unw_context_t* thread_state)560// extern int unw_getcontext(unw_context_t* thread_state)
562;561//
563; On entry:562// On entry:
564; thread_state pointer is in r3563// thread_state pointer is in r3
565;564//
566DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)565DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
567 stw r0, 8(r3)566 stw %r0, 8(%r3)
568 mflr r0567 mflr %r0
569 stw r0, 0(r3) ; store lr as ssr0568 stw %r0, 0(%r3) // store lr as ssr0
570 stw r1, 12(r3)569 stw %r1, 12(%r3)
571 stw r2, 16(r3)570 stw %r2, 16(%r3)
572 stw r3, 20(r3)571 stw %r3, 20(%r3)
573 stw r4, 24(r3)572 stw %r4, 24(%r3)
574 stw r5, 28(r3)573 stw %r5, 28(%r3)
575 stw r6, 32(r3)574 stw %r6, 32(%r3)
576 stw r7, 36(r3)575 stw %r7, 36(%r3)
577 stw r8, 40(r3)576 stw %r8, 40(%r3)
578 stw r9, 44(r3)577 stw %r9, 44(%r3)
579 stw r10, 48(r3)578 stw %r10, 48(%r3)
580 stw r11, 52(r3)579 stw %r11, 52(%r3)
581 stw r12, 56(r3)580 stw %r12, 56(%r3)
582 stw r13, 60(r3)581 stw %r13, 60(%r3)
583 stw r14, 64(r3)582 stw %r14, 64(%r3)
584 stw r15, 68(r3)583 stw %r15, 68(%r3)
585 stw r16, 72(r3)584 stw %r16, 72(%r3)
586 stw r17, 76(r3)585 stw %r17, 76(%r3)
587 stw r18, 80(r3)586 stw %r18, 80(%r3)
588 stw r19, 84(r3)587 stw %r19, 84(%r3)
589 stw r20, 88(r3)588 stw %r20, 88(%r3)
590 stw r21, 92(r3)589 stw %r21, 92(%r3)
591 stw r22, 96(r3)590 stw %r22, 96(%r3)
592 stw r23,100(r3)591 stw %r23,100(%r3)
593 stw r24,104(r3)592 stw %r24,104(%r3)
594 stw r25,108(r3)593 stw %r25,108(%r3)
595 stw r26,112(r3)594 stw %r26,112(%r3)
596 stw r27,116(r3)595 stw %r27,116(%r3)
597 stw r28,120(r3)596 stw %r28,120(%r3)
598 stw r29,124(r3)597 stw %r29,124(%r3)
599 stw r30,128(r3)598 stw %r30,128(%r3)
600 stw r31,132(r3)599 stw %r31,132(%r3)
601600
602 ; save VRSave register601 // save VRSave register
603 mfspr r0,256602 mfspr %r0, 256
604 stw r0,156(r3)603 stw %r0, 156(%r3)
605 ; save CR registers604 // save CR registers
606 mfcr r0605 mfcr %r0
607 stw r0,136(r3)606 stw %r0, 136(%r3)
608 ; save CTR register607 // save CTR register
609 mfctr r0608 mfctr %r0
610 stw r0,148(r3)609 stw %r0, 148(%r3)
611610
612 ; save float registers611 // save float registers
613 stfd f0, 160(r3)612 stfd %f0, 160(%r3)
614 stfd f1, 168(r3)613 stfd %f1, 168(%r3)
615 stfd f2, 176(r3)614 stfd %f2, 176(%r3)
616 stfd f3, 184(r3)615 stfd %f3, 184(%r3)
617 stfd f4, 192(r3)616 stfd %f4, 192(%r3)
618 stfd f5, 200(r3)617 stfd %f5, 200(%r3)
619 stfd f6, 208(r3)618 stfd %f6, 208(%r3)
620 stfd f7, 216(r3)619 stfd %f7, 216(%r3)
621 stfd f8, 224(r3)620 stfd %f8, 224(%r3)
622 stfd f9, 232(r3)621 stfd %f9, 232(%r3)
623 stfd f10,240(r3)622 stfd %f10,240(%r3)
624 stfd f11,248(r3)623 stfd %f11,248(%r3)
625 stfd f12,256(r3)624 stfd %f12,256(%r3)
626 stfd f13,264(r3)625 stfd %f13,264(%r3)
627 stfd f14,272(r3)626 stfd %f14,272(%r3)
628 stfd f15,280(r3)627 stfd %f15,280(%r3)
629 stfd f16,288(r3)628 stfd %f16,288(%r3)
630 stfd f17,296(r3)629 stfd %f17,296(%r3)
631 stfd f18,304(r3)630 stfd %f18,304(%r3)
632 stfd f19,312(r3)631 stfd %f19,312(%r3)
633 stfd f20,320(r3)632 stfd %f20,320(%r3)
634 stfd f21,328(r3)633 stfd %f21,328(%r3)
635 stfd f22,336(r3)634 stfd %f22,336(%r3)
636 stfd f23,344(r3)635 stfd %f23,344(%r3)
637 stfd f24,352(r3)636 stfd %f24,352(%r3)
638 stfd f25,360(r3)637 stfd %f25,360(%r3)
639 stfd f26,368(r3)638 stfd %f26,368(%r3)
640 stfd f27,376(r3)639 stfd %f27,376(%r3)
641 stfd f28,384(r3)640 stfd %f28,384(%r3)
642 stfd f29,392(r3)641 stfd %f29,392(%r3)
643 stfd f30,400(r3)642 stfd %f30,400(%r3)
644 stfd f31,408(r3)643 stfd %f31,408(%r3)
645644
646645
647 ; save vector registers646 // save vector registers
648647
649 subi r4,r1,16648 subi %r4, %r1, 16
650 rlwinm r4,r4,0,0,27 ; mask low 4-bits649 rlwinm %r4, %r4, 0, 0, 27 // mask low 4-bits
651 ; r4 is now a 16-byte aligned pointer into the red zone650 // r4 is now a 16-byte aligned pointer into the red zone
652651
653#define SAVE_VECTOR_UNALIGNED(_vec, _offset) \652#define SAVE_VECTOR_UNALIGNED(_vec, _offset) \
654 stvx _vec,0,r4 @\653 stvx _vec, 0, %r4 SEPARATOR \
655 lwz r5, 0(r4) @\654 lwz %r5, 0(%r4) SEPARATOR \
656 stw r5, _offset(r3) @\655 stw %r5, _offset(%r3) SEPARATOR \
657 lwz r5, 4(r4) @\656 lwz %r5, 4(%r4) SEPARATOR \
658 stw r5, _offset+4(r3) @\657 stw %r5, _offset+4(%r3) SEPARATOR \
659 lwz r5, 8(r4) @\658 lwz %r5, 8(%r4) SEPARATOR \
660 stw r5, _offset+8(r3) @\659 stw %r5, _offset+8(%r3) SEPARATOR \
661 lwz r5, 12(r4) @\660 lwz %r5, 12(%r4) SEPARATOR \
662 stw r5, _offset+12(r3)661 stw %r5, _offset+12(%r3)
663662
664 SAVE_VECTOR_UNALIGNED( v0, 424+0x000)663 SAVE_VECTOR_UNALIGNED( %v0, 424+0x000)
665 SAVE_VECTOR_UNALIGNED( v1, 424+0x010)664 SAVE_VECTOR_UNALIGNED( %v1, 424+0x010)
666 SAVE_VECTOR_UNALIGNED( v2, 424+0x020)665 SAVE_VECTOR_UNALIGNED( %v2, 424+0x020)
667 SAVE_VECTOR_UNALIGNED( v3, 424+0x030)666 SAVE_VECTOR_UNALIGNED( %v3, 424+0x030)
668 SAVE_VECTOR_UNALIGNED( v4, 424+0x040)667 SAVE_VECTOR_UNALIGNED( %v4, 424+0x040)
669 SAVE_VECTOR_UNALIGNED( v5, 424+0x050)668 SAVE_VECTOR_UNALIGNED( %v5, 424+0x050)
670 SAVE_VECTOR_UNALIGNED( v6, 424+0x060)669 SAVE_VECTOR_UNALIGNED( %v6, 424+0x060)
671 SAVE_VECTOR_UNALIGNED( v7, 424+0x070)670 SAVE_VECTOR_UNALIGNED( %v7, 424+0x070)
672 SAVE_VECTOR_UNALIGNED( v8, 424+0x080)671 SAVE_VECTOR_UNALIGNED( %v8, 424+0x080)
673 SAVE_VECTOR_UNALIGNED( v9, 424+0x090)672 SAVE_VECTOR_UNALIGNED( %v9, 424+0x090)
674 SAVE_VECTOR_UNALIGNED(v10, 424+0x0A0)673 SAVE_VECTOR_UNALIGNED(%v10, 424+0x0A0)
675 SAVE_VECTOR_UNALIGNED(v11, 424+0x0B0)674 SAVE_VECTOR_UNALIGNED(%v11, 424+0x0B0)
676 SAVE_VECTOR_UNALIGNED(v12, 424+0x0C0)675 SAVE_VECTOR_UNALIGNED(%v12, 424+0x0C0)
677 SAVE_VECTOR_UNALIGNED(v13, 424+0x0D0)676 SAVE_VECTOR_UNALIGNED(%v13, 424+0x0D0)
678 SAVE_VECTOR_UNALIGNED(v14, 424+0x0E0)677 SAVE_VECTOR_UNALIGNED(%v14, 424+0x0E0)
679 SAVE_VECTOR_UNALIGNED(v15, 424+0x0F0)678 SAVE_VECTOR_UNALIGNED(%v15, 424+0x0F0)
680 SAVE_VECTOR_UNALIGNED(v16, 424+0x100)679 SAVE_VECTOR_UNALIGNED(%v16, 424+0x100)
681 SAVE_VECTOR_UNALIGNED(v17, 424+0x110)680 SAVE_VECTOR_UNALIGNED(%v17, 424+0x110)
682 SAVE_VECTOR_UNALIGNED(v18, 424+0x120)681 SAVE_VECTOR_UNALIGNED(%v18, 424+0x120)
683 SAVE_VECTOR_UNALIGNED(v19, 424+0x130)682 SAVE_VECTOR_UNALIGNED(%v19, 424+0x130)
684 SAVE_VECTOR_UNALIGNED(v20, 424+0x140)683 SAVE_VECTOR_UNALIGNED(%v20, 424+0x140)
685 SAVE_VECTOR_UNALIGNED(v21, 424+0x150)684 SAVE_VECTOR_UNALIGNED(%v21, 424+0x150)
686 SAVE_VECTOR_UNALIGNED(v22, 424+0x160)685 SAVE_VECTOR_UNALIGNED(%v22, 424+0x160)
687 SAVE_VECTOR_UNALIGNED(v23, 424+0x170)686 SAVE_VECTOR_UNALIGNED(%v23, 424+0x170)
688 SAVE_VECTOR_UNALIGNED(v24, 424+0x180)687 SAVE_VECTOR_UNALIGNED(%v24, 424+0x180)
689 SAVE_VECTOR_UNALIGNED(v25, 424+0x190)688 SAVE_VECTOR_UNALIGNED(%v25, 424+0x190)
690 SAVE_VECTOR_UNALIGNED(v26, 424+0x1A0)689 SAVE_VECTOR_UNALIGNED(%v26, 424+0x1A0)
691 SAVE_VECTOR_UNALIGNED(v27, 424+0x1B0)690 SAVE_VECTOR_UNALIGNED(%v27, 424+0x1B0)
692 SAVE_VECTOR_UNALIGNED(v28, 424+0x1C0)691 SAVE_VECTOR_UNALIGNED(%v28, 424+0x1C0)
693 SAVE_VECTOR_UNALIGNED(v29, 424+0x1D0)692 SAVE_VECTOR_UNALIGNED(%v29, 424+0x1D0)
694 SAVE_VECTOR_UNALIGNED(v30, 424+0x1E0)693 SAVE_VECTOR_UNALIGNED(%v30, 424+0x1E0)
695 SAVE_VECTOR_UNALIGNED(v31, 424+0x1F0)694 SAVE_VECTOR_UNALIGNED(%v31, 424+0x1F0)
696695
697 li r3, 0 ; return UNW_ESUCCESS696 li %r3, 0 // return UNW_ESUCCESS
698 blr697 blr
699698
700699
701#elif defined(__arm64__) || defined(__aarch64__)700#elif defined(__arm64__) || defined(__aarch64__)
702701
703//702//
704// extern int unw_getcontext(unw_context_t* thread_state)703// extern int __unw_getcontext(unw_context_t* thread_state)
705//704//
706// On entry:705// On entry:
707// thread_state pointer is in x0706// thread_state pointer is in x0
708//707//
709 .p2align 2708 .p2align 2
710DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)709DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
711 stp x0, x1, [x0, #0x000]710 stp x0, x1, [x0, #0x000]
712 stp x2, x3, [x0, #0x010]711 stp x2, x3, [x0, #0x010]
713 stp x4, x5, [x0, #0x020]712 stp x4, x5, [x0, #0x020]
...@@ -751,11 +750,14 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)...@@ -751,11 +750,14 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
751#elif defined(__arm__) && !defined(__APPLE__)750#elif defined(__arm__) && !defined(__APPLE__)
752751
753#if !defined(__ARM_ARCH_ISA_ARM)752#if !defined(__ARM_ARCH_ISA_ARM)
753#if (__ARM_ARCH_ISA_THUMB == 2)
754 .syntax unified
755#endif
754 .thumb756 .thumb
755#endif757#endif
756758
757@759@
758@ extern int unw_getcontext(unw_context_t* thread_state)760@ extern int __unw_getcontext(unw_context_t* thread_state)
759@761@
760@ On entry:762@ On entry:
761@ thread_state pointer is in r0763@ thread_state pointer is in r0
...@@ -764,10 +766,10 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)...@@ -764,10 +766,10 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
764@ EHABI #7.4.5 notes that in general all VRS registers should be restored766@ EHABI #7.4.5 notes that in general all VRS registers should be restored
765@ however this is very hard to do for VFP registers because it is unknown767@ however this is very hard to do for VFP registers because it is unknown
766@ to the library how many registers are implemented by the architecture.768@ to the library how many registers are implemented by the architecture.
767@ Instead, VFP registers are demand saved by logic external to unw_getcontext.769@ Instead, VFP registers are demand saved by logic external to __unw_getcontext.
768@770@
769 .p2align 2771 .p2align 2
770DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)772DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
771#if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1773#if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1
772 stm r0!, {r0-r7}774 stm r0!, {r0-r7}
773 mov r1, r8775 mov r1, r8
...@@ -808,7 +810,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)...@@ -808,7 +810,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
808#if defined(__ELF__)810#if defined(__ELF__)
809 .fpu vfpv3-d16811 .fpu vfpv3-d16
810#endif812#endif
811DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMDEPy)813DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMDEPv)
812 vstmia r0, {d0-d15}814 vstmia r0, {d0-d15}
813 JMP(lr)815 JMP(lr)
814816
...@@ -822,7 +824,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMD...@@ -822,7 +824,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMD
822#if defined(__ELF__)824#if defined(__ELF__)
823 .fpu vfpv3-d16825 .fpu vfpv3-d16
824#endif826#endif
825DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMXEPy)827DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMXEPv)
826 vstmia r0, {d0-d15} @ fstmiax is deprecated in ARMv7+ and now behaves like vstmia828 vstmia r0, {d0-d15} @ fstmiax is deprecated in ARMv7+ and now behaves like vstmia
827 JMP(lr)829 JMP(lr)
828830
...@@ -836,7 +838,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMX...@@ -836,7 +838,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMX
836#if defined(__ELF__)838#if defined(__ELF__)
837 .fpu vfpv3839 .fpu vfpv3
838#endif840#endif
839DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPy)841DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPv)
840 @ VFP and iwMMX instructions are only available when compiling with the flags842 @ VFP and iwMMX instructions are only available when compiling with the flags
841 @ that enable them. We do not want to do that in the library (because we do not843 @ that enable them. We do not want to do that in the library (because we do not
842 @ want the compiler to generate instructions that access those) but this is844 @ want the compiler to generate instructions that access those) but this is
...@@ -859,7 +861,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPy)...@@ -859,7 +861,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPy)
859#if defined(__ELF__)861#if defined(__ELF__)
860 .arch armv5te862 .arch armv5te
861#endif863#endif
862DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPy)864DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPv)
863 stcl p1, cr0, [r0], #8 @ wstrd wR0, [r0], #8865 stcl p1, cr0, [r0], #8 @ wstrd wR0, [r0], #8
864 stcl p1, cr1, [r0], #8 @ wstrd wR1, [r0], #8866 stcl p1, cr1, [r0], #8 @ wstrd wR1, [r0], #8
865 stcl p1, cr2, [r0], #8 @ wstrd wR2, [r0], #8867 stcl p1, cr2, [r0], #8 @ wstrd wR2, [r0], #8
...@@ -888,7 +890,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPy)...@@ -888,7 +890,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPy)
888#if defined(__ELF__)890#if defined(__ELF__)
889 .arch armv5te891 .arch armv5te
890#endif892#endif
891DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj)893DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj)
892 stc2 p1, cr8, [r0], #4 @ wstrw wCGR0, [r0], #4894 stc2 p1, cr8, [r0], #4 @ wstrw wCGR0, [r0], #4
893 stc2 p1, cr9, [r0], #4 @ wstrw wCGR1, [r0], #4895 stc2 p1, cr9, [r0], #4 @ wstrw wCGR1, [r0], #4
894 stc2 p1, cr10, [r0], #4 @ wstrw wCGR2, [r0], #4896 stc2 p1, cr10, [r0], #4 @ wstrw wCGR2, [r0], #4
...@@ -900,12 +902,12 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControl...@@ -900,12 +902,12 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControl
900#elif defined(__or1k__)902#elif defined(__or1k__)
901903
902#904#
903# extern int unw_getcontext(unw_context_t* thread_state)905# extern int __unw_getcontext(unw_context_t* thread_state)
904#906#
905# On entry:907# On entry:
906# thread_state pointer is in r3908# thread_state pointer is in r3
907#909#
908DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)910DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
909 l.sw 0(r3), r0911 l.sw 0(r3), r0
910 l.sw 4(r3), r1912 l.sw 4(r3), r1
911 l.sw 8(r3), r2913 l.sw 8(r3), r2
...@@ -946,12 +948,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)...@@ -946,12 +948,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
946#elif defined(__sparc__)948#elif defined(__sparc__)
947949
948#950#
949# extern int unw_getcontext(unw_context_t* thread_state)951# extern int __unw_getcontext(unw_context_t* thread_state)
950#952#
951# On entry:953# On entry:
952# thread_state pointer is in o0954# thread_state pointer is in o0
953#955#
954DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)956DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
955 ta 3957 ta 3
956 add %o7, 8, %o7958 add %o7, 8, %o7
957 std %g0, [%o0 + 0]959 std %g0, [%o0 + 0]
...@@ -973,6 +975,9 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)...@@ -973,6 +975,9 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
973 jmp %o7975 jmp %o7
974 clr %o0 // return UNW_ESUCCESS976 clr %o0 // return UNW_ESUCCESS
975#endif977#endif
978
979 WEAK_ALIAS(__unw_getcontext, unw_getcontext)
980
976#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */981#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */
977982
978NO_EXEC_STACK_DIRECTIVE983NO_EXEC_STACK_DIRECTIVE
lib/libunwind/src/Unwind_AppleExtras.cpp+3-4
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===--------------------- Unwind_AppleExtras.cpp -------------------------===//1//===--------------------- Unwind_AppleExtras.cpp -------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
lib/libunwind/src/assembly.h+54-20
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1/* ===-- assembly.h - libUnwind assembler support macros -------------------===1/* ===-- assembly.h - libUnwind assembler support macros -------------------===
2 *2 *
3 * The LLVM Compiler Infrastructure3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 *4 * See https://llvm.org/LICENSE.txt for license information.
5 * This file is dual licensed under the MIT and the University of Illinois Open5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 * Source Licenses. See LICENSE.TXT for details.
7 *6 *
8 * ===----------------------------------------------------------------------===7 * ===----------------------------------------------------------------------===
9 *8 *
...@@ -29,14 +28,26 @@...@@ -29,14 +28,26 @@
29#ifdef _ARCH_PWR828#ifdef _ARCH_PWR8
30#define PPC64_HAS_VMX29#define PPC64_HAS_VMX
31#endif30#endif
32#elif defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__)
33#define SEPARATOR @
34#elif defined(__arm64__)31#elif defined(__arm64__)
35#define SEPARATOR %%32#define SEPARATOR %%
36#else33#else
37#define SEPARATOR ;34#define SEPARATOR ;
38#endif35#endif
3936
37#if defined(__powerpc64__) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
38#define PPC64_OPD1 .section .opd,"aw",@progbits SEPARATOR
39#define PPC64_OPD2 SEPARATOR \
40 .p2align 3 SEPARATOR \
41 .quad .Lfunc_begin0 SEPARATOR \
42 .quad .TOC.@tocbase SEPARATOR \
43 .quad 0 SEPARATOR \
44 .text SEPARATOR \
45.Lfunc_begin0:
46#else
47#define PPC64_OPD1
48#define PPC64_OPD2
49#endif
50
40#define GLUE2(a, b) a ## b51#define GLUE2(a, b) a ## b
41#define GLUE(a, b) GLUE2(a, b)52#define GLUE(a, b) GLUE2(a, b)
42#define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)53#define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
...@@ -46,6 +57,12 @@...@@ -46,6 +57,12 @@
46#define SYMBOL_IS_FUNC(name)57#define SYMBOL_IS_FUNC(name)
47#define EXPORT_SYMBOL(name)58#define EXPORT_SYMBOL(name)
48#define HIDDEN_SYMBOL(name) .private_extern name59#define HIDDEN_SYMBOL(name) .private_extern name
60#define WEAK_SYMBOL(name) .weak_reference name
61#define WEAK_ALIAS(name, aliasname) \
62 .globl SYMBOL_NAME(aliasname) SEPARATOR \
63 WEAK_SYMBOL(aliasname) SEPARATOR \
64 SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
65
49#define NO_EXEC_STACK_DIRECTIVE66#define NO_EXEC_STACK_DIRECTIVE
5067
51#elif defined(__ELF__)68#elif defined(__ELF__)
...@@ -57,6 +74,10 @@...@@ -57,6 +74,10 @@
57#endif74#endif
58#define EXPORT_SYMBOL(name)75#define EXPORT_SYMBOL(name)
59#define HIDDEN_SYMBOL(name) .hidden name76#define HIDDEN_SYMBOL(name) .hidden name
77#define WEAK_SYMBOL(name) .weak name
78#define WEAK_ALIAS(name, aliasname) \
79 WEAK_SYMBOL(aliasname) SEPARATOR \
80 SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
6081
61#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \82#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
62 defined(__linux__)83 defined(__linux__)
...@@ -72,9 +93,9 @@...@@ -72,9 +93,9 @@
72 .scl 2 SEPARATOR \93 .scl 2 SEPARATOR \
73 .type 32 SEPARATOR \94 .type 32 SEPARATOR \
74 .endef95 .endef
75#define EXPORT_SYMBOL2(name) \96#define EXPORT_SYMBOL2(name) \
76 .section .drectve,"yn" SEPARATOR \97 .section .drectve,"yn" SEPARATOR \
77 .ascii "-export:", #name, "\0" SEPARATOR \98 .ascii "-export:", #name, "\0" SEPARATOR \
78 .text99 .text
79#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)100#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
80#define EXPORT_SYMBOL(name)101#define EXPORT_SYMBOL(name)
...@@ -83,6 +104,23 @@...@@ -83,6 +104,23 @@
83#endif104#endif
84#define HIDDEN_SYMBOL(name)105#define HIDDEN_SYMBOL(name)
85106
107#if defined(__MINGW32__)
108#define WEAK_ALIAS(name, aliasname) \
109 .globl SYMBOL_NAME(aliasname) SEPARATOR \
110 EXPORT_SYMBOL(aliasname) SEPARATOR \
111 SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
112#else
113#define WEAK_ALIAS3(name, aliasname) \
114 .section .drectve,"yn" SEPARATOR \
115 .ascii "-alternatename:", #aliasname, "=", #name, "\0" SEPARATOR \
116 .text
117#define WEAK_ALIAS2(name, aliasname) \
118 WEAK_ALIAS3(name, aliasname)
119#define WEAK_ALIAS(name, aliasname) \
120 EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR \
121 WEAK_ALIAS2(SYMBOL_NAME(name), SYMBOL_NAME(aliasname))
122#endif
123
86#define NO_EXEC_STACK_DIRECTIVE124#define NO_EXEC_STACK_DIRECTIVE
87125
88#elif defined(__sparc__)126#elif defined(__sparc__)
...@@ -93,17 +131,13 @@...@@ -93,17 +131,13 @@
93131
94#endif132#endif
95133
96#define DEFINE_LIBUNWIND_FUNCTION(name) \134#define DEFINE_LIBUNWIND_FUNCTION(name) \
97 .globl SYMBOL_NAME(name) SEPARATOR \135 .globl SYMBOL_NAME(name) SEPARATOR \
98 EXPORT_SYMBOL(name) SEPARATOR \136 HIDDEN_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \
99 SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \137 SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
100 SYMBOL_NAME(name):138 PPC64_OPD1 \
101139 SYMBOL_NAME(name): \
102#define DEFINE_LIBUNWIND_PRIVATE_FUNCTION(name) \140 PPC64_OPD2
103 .globl SYMBOL_NAME(name) SEPARATOR \
104 HIDDEN_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \
105 SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
106 SYMBOL_NAME(name):
107141
108#if defined(__arm__)142#if defined(__arm__)
109#if !defined(__ARM_ARCH)143#if !defined(__ARM_ARCH)
lib/libunwind/src/config.h+32-4
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===----------------------------- config.h -------------------------------===//1//===----------------------------- config.h -------------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Defines macros used within libunwind project.8// Defines macros used within libunwind project.
...@@ -63,6 +62,35 @@...@@ -63,6 +62,35 @@
63 #endif62 #endif
64#endif63#endif
6564
65#define STR(a) #a
66#define XSTR(a) STR(a)
67#define SYMBOL_NAME(name) XSTR(__USER_LABEL_PREFIX__) #name
68
69#if defined(__APPLE__)
70#define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
71 __asm__(".globl " SYMBOL_NAME(aliasname)); \
72 __asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name)); \
73 extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname \
74 __attribute__((weak_import));
75#elif defined(__ELF__)
76#define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
77 extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname \
78 __attribute__((weak, alias(#name)));
79#elif defined(_WIN32)
80#if defined(__MINGW32__)
81#define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
82 extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname \
83 __attribute__((alias(#name)));
84#else
85#define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
86 __pragma(comment(linker, "/alternatename:" SYMBOL_NAME(aliasname) "=" \
87 SYMBOL_NAME(name))) \
88 extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname;
89#endif
90#else
91#error Unsupported target
92#endif
93
66#if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__)94#if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__)
67#define _LIBUNWIND_BUILD_SJLJ_APIS95#define _LIBUNWIND_BUILD_SJLJ_APIS
68#endif96#endif
lib/libunwind/src/dwarf2.h+3-4
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===------------------------------- dwarf2.h -----------------------------===//1//===------------------------------- dwarf2.h -----------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
98
lib/libunwind/src/libunwind.cpp+64-150
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===--------------------------- libunwind.cpp ----------------------------===//1//===--------------------------- libunwind.cpp ----------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Implements unw_* functions from <libunwind.h>8// Implements unw_* functions from <libunwind.h>
...@@ -12,12 +11,6 @@...@@ -12,12 +11,6 @@
1211
13#include <libunwind.h>12#include <libunwind.h>
1413
15#ifndef NDEBUG
16#include <cstdlib> // getenv
17#endif
18#include <new>
19#include <algorithm>
20
21#include "libunwind_ext.h"14#include "libunwind_ext.h"
22#include "config.h"15#include "config.h"
2316
...@@ -36,15 +29,11 @@ LocalAddressSpace LocalAddressSpace::sThisAddressSpace;...@@ -36,15 +29,11 @@ LocalAddressSpace LocalAddressSpace::sThisAddressSpace;
36_LIBUNWIND_EXPORT unw_addr_space_t unw_local_addr_space =29_LIBUNWIND_EXPORT unw_addr_space_t unw_local_addr_space =
37 (unw_addr_space_t)&LocalAddressSpace::sThisAddressSpace;30 (unw_addr_space_t)&LocalAddressSpace::sThisAddressSpace;
3831
39/// record the registers and stack position of the caller
40extern int unw_getcontext(unw_context_t *);
41// note: unw_getcontext() implemented in assembly
42
43/// Create a cursor of a thread in this process given 'context' recorded by32/// Create a cursor of a thread in this process given 'context' recorded by
44/// unw_getcontext().33/// __unw_getcontext().
45_LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cursor,34_LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor,
46 unw_context_t *context) {35 unw_context_t *context) {
47 _LIBUNWIND_TRACE_API("unw_init_local(cursor=%p, context=%p)",36 _LIBUNWIND_TRACE_API("__unw_init_local(cursor=%p, context=%p)",
48 static_cast<void *>(cursor),37 static_cast<void *>(cursor),
49 static_cast<void *>(context));38 static_cast<void *>(context));
50#if defined(__i386__)39#if defined(__i386__)
...@@ -73,101 +62,21 @@ _LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cursor,...@@ -73,101 +62,21 @@ _LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cursor,
73# error Architecture not supported62# error Architecture not supported
74#endif63#endif
75 // Use "placement new" to allocate UnwindCursor in the cursor buffer.64 // Use "placement new" to allocate UnwindCursor in the cursor buffer.
76 new ((void *)cursor) UnwindCursor<LocalAddressSpace, REGISTER_KIND>(65 new (reinterpret_cast<UnwindCursor<LocalAddressSpace, REGISTER_KIND> *>(cursor))
77 context, LocalAddressSpace::sThisAddressSpace);66 UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
67 context, LocalAddressSpace::sThisAddressSpace);
78#undef REGISTER_KIND68#undef REGISTER_KIND
79 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;69 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
80 co->setInfoBasedOnIPRegister();70 co->setInfoBasedOnIPRegister();
8171
82 return UNW_ESUCCESS;72 return UNW_ESUCCESS;
83}73}
8474_LIBUNWIND_WEAK_ALIAS(__unw_init_local, unw_init_local)
85#ifdef UNW_REMOTE
86/// Create a cursor into a thread in another process.
87_LIBUNWIND_EXPORT int unw_init_remote_thread(unw_cursor_t *cursor,
88 unw_addr_space_t as,
89 void *arg) {
90 // special case: unw_init_remote(xx, unw_local_addr_space, xx)
91 if (as == (unw_addr_space_t)&LocalAddressSpace::sThisAddressSpace)
92 return unw_init_local(cursor, NULL); //FIXME
93
94 // use "placement new" to allocate UnwindCursor in the cursor buffer
95 switch (as->cpuType) {
96 case CPU_TYPE_I386:
97 new ((void *)cursor)
98 UnwindCursor<RemoteAddressSpace<Pointer32<LittleEndian>>,
99 Registers_x86>(((unw_addr_space_i386 *)as)->oas, arg);
100 break;
101 case CPU_TYPE_X86_64:
102 new ((void *)cursor)
103 UnwindCursor<RemoteAddressSpace<Pointer64<LittleEndian>>,
104 Registers_x86_64>(((unw_addr_space_x86_64 *)as)->oas, arg);
105 break;
106 case CPU_TYPE_POWERPC:
107 new ((void *)cursor)
108 UnwindCursor<RemoteAddressSpace<Pointer32<BigEndian>>,
109 Registers_ppc>(((unw_addr_space_ppc *)as)->oas, arg);
110 break;
111 default:
112 return UNW_EUNSPEC;
113 }
114 return UNW_ESUCCESS;
115}
116
117
118static bool is64bit(task_t task) {
119 return false; // FIXME
120}
121
122/// Create an address_space object for use in examining another task.
123_LIBUNWIND_EXPORT unw_addr_space_t unw_create_addr_space_for_task(task_t task) {
124#if __i386__
125 if (is64bit(task)) {
126 unw_addr_space_x86_64 *as = new unw_addr_space_x86_64(task);
127 as->taskPort = task;
128 as->cpuType = CPU_TYPE_X86_64;
129 //as->oas
130 } else {
131 unw_addr_space_i386 *as = new unw_addr_space_i386(task);
132 as->taskPort = task;
133 as->cpuType = CPU_TYPE_I386;
134 //as->oas
135 }
136#else
137// FIXME
138#endif
139}
140
141
142/// Delete an address_space object.
143_LIBUNWIND_EXPORT void unw_destroy_addr_space(unw_addr_space_t asp) {
144 switch (asp->cpuType) {
145#if __i386__ || __x86_64__
146 case CPU_TYPE_I386: {
147 unw_addr_space_i386 *as = (unw_addr_space_i386 *)asp;
148 delete as;
149 }
150 break;
151 case CPU_TYPE_X86_64: {
152 unw_addr_space_x86_64 *as = (unw_addr_space_x86_64 *)asp;
153 delete as;
154 }
155 break;
156#endif
157 case CPU_TYPE_POWERPC: {
158 unw_addr_space_ppc *as = (unw_addr_space_ppc *)asp;
159 delete as;
160 }
161 break;
162 }
163}
164#endif // UNW_REMOTE
165
16675
167/// Get value of specified register at cursor position in stack frame.76/// Get value of specified register at cursor position in stack frame.
168_LIBUNWIND_EXPORT int unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum,77_LIBUNWIND_HIDDEN int __unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
169 unw_word_t *value) {78 unw_word_t *value) {
170 _LIBUNWIND_TRACE_API("unw_get_reg(cursor=%p, regNum=%d, &value=%p)",79 _LIBUNWIND_TRACE_API("__unw_get_reg(cursor=%p, regNum=%d, &value=%p)",
171 static_cast<void *>(cursor), regNum,80 static_cast<void *>(cursor), regNum,
172 static_cast<void *>(value));81 static_cast<void *>(value));
173 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;82 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
...@@ -177,12 +86,13 @@ _LIBUNWIND_EXPORT int unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum,...@@ -177,12 +86,13 @@ _LIBUNWIND_EXPORT int unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
177 }86 }
178 return UNW_EBADREG;87 return UNW_EBADREG;
179}88}
18089_LIBUNWIND_WEAK_ALIAS(__unw_get_reg, unw_get_reg)
18190
182/// Set value of specified register at cursor position in stack frame.91/// Set value of specified register at cursor position in stack frame.
183_LIBUNWIND_EXPORT int unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,92_LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
184 unw_word_t value) {93 unw_word_t value) {
185 _LIBUNWIND_TRACE_API("unw_set_reg(cursor=%p, regNum=%d, value=0x%" PRIxPTR ")",94 _LIBUNWIND_TRACE_API("__unw_set_reg(cursor=%p, regNum=%d, value=0x%" PRIxPTR
95 ")",
186 static_cast<void *>(cursor), regNum, value);96 static_cast<void *>(cursor), regNum, value);
187 typedef LocalAddressSpace::pint_t pint_t;97 typedef LocalAddressSpace::pint_t pint_t;
188 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;98 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
...@@ -208,12 +118,12 @@ _LIBUNWIND_EXPORT int unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,...@@ -208,12 +118,12 @@ _LIBUNWIND_EXPORT int unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
208 }118 }
209 return UNW_EBADREG;119 return UNW_EBADREG;
210}120}
211121_LIBUNWIND_WEAK_ALIAS(__unw_set_reg, unw_set_reg)
212122
213/// Get value of specified float register at cursor position in stack frame.123/// Get value of specified float register at cursor position in stack frame.
214_LIBUNWIND_EXPORT int unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,124_LIBUNWIND_HIDDEN int __unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
215 unw_fpreg_t *value) {125 unw_fpreg_t *value) {
216 _LIBUNWIND_TRACE_API("unw_get_fpreg(cursor=%p, regNum=%d, &value=%p)",126 _LIBUNWIND_TRACE_API("__unw_get_fpreg(cursor=%p, regNum=%d, &value=%p)",
217 static_cast<void *>(cursor), regNum,127 static_cast<void *>(cursor), regNum,
218 static_cast<void *>(value));128 static_cast<void *>(value));
219 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;129 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
...@@ -223,16 +133,16 @@ _LIBUNWIND_EXPORT int unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,...@@ -223,16 +133,16 @@ _LIBUNWIND_EXPORT int unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
223 }133 }
224 return UNW_EBADREG;134 return UNW_EBADREG;
225}135}
226136_LIBUNWIND_WEAK_ALIAS(__unw_get_fpreg, unw_get_fpreg)
227137
228/// Set value of specified float register at cursor position in stack frame.138/// Set value of specified float register at cursor position in stack frame.
229_LIBUNWIND_EXPORT int unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,139_LIBUNWIND_HIDDEN int __unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
230 unw_fpreg_t value) {140 unw_fpreg_t value) {
231#if defined(_LIBUNWIND_ARM_EHABI)141#if defined(_LIBUNWIND_ARM_EHABI)
232 _LIBUNWIND_TRACE_API("unw_set_fpreg(cursor=%p, regNum=%d, value=%llX)",142 _LIBUNWIND_TRACE_API("__unw_set_fpreg(cursor=%p, regNum=%d, value=%llX)",
233 static_cast<void *>(cursor), regNum, value);143 static_cast<void *>(cursor), regNum, value);
234#else144#else
235 _LIBUNWIND_TRACE_API("unw_set_fpreg(cursor=%p, regNum=%d, value=%g)",145 _LIBUNWIND_TRACE_API("__unw_set_fpreg(cursor=%p, regNum=%d, value=%g)",
236 static_cast<void *>(cursor), regNum, value);146 static_cast<void *>(cursor), regNum, value);
237#endif147#endif
238 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;148 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
...@@ -242,20 +152,20 @@ _LIBUNWIND_EXPORT int unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,...@@ -242,20 +152,20 @@ _LIBUNWIND_EXPORT int unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
242 }152 }
243 return UNW_EBADREG;153 return UNW_EBADREG;
244}154}
245155_LIBUNWIND_WEAK_ALIAS(__unw_set_fpreg, unw_set_fpreg)
246156
247/// Move cursor to next frame.157/// Move cursor to next frame.
248_LIBUNWIND_EXPORT int unw_step(unw_cursor_t *cursor) {158_LIBUNWIND_HIDDEN int __unw_step(unw_cursor_t *cursor) {
249 _LIBUNWIND_TRACE_API("unw_step(cursor=%p)", static_cast<void *>(cursor));159 _LIBUNWIND_TRACE_API("__unw_step(cursor=%p)", static_cast<void *>(cursor));
250 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;160 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
251 return co->step();161 return co->step();
252}162}
253163_LIBUNWIND_WEAK_ALIAS(__unw_step, unw_step)
254164
255/// Get unwind info at cursor position in stack frame.165/// Get unwind info at cursor position in stack frame.
256_LIBUNWIND_EXPORT int unw_get_proc_info(unw_cursor_t *cursor,166_LIBUNWIND_HIDDEN int __unw_get_proc_info(unw_cursor_t *cursor,
257 unw_proc_info_t *info) {167 unw_proc_info_t *info) {
258 _LIBUNWIND_TRACE_API("unw_get_proc_info(cursor=%p, &info=%p)",168 _LIBUNWIND_TRACE_API("__unw_get_proc_info(cursor=%p, &info=%p)",
259 static_cast<void *>(cursor), static_cast<void *>(info));169 static_cast<void *>(cursor), static_cast<void *>(info));
260 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;170 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
261 co->getInfo(info);171 co->getInfo(info);
...@@ -264,21 +174,21 @@ _LIBUNWIND_EXPORT int unw_get_proc_info(unw_cursor_t *cursor,...@@ -264,21 +174,21 @@ _LIBUNWIND_EXPORT int unw_get_proc_info(unw_cursor_t *cursor,
264 else174 else
265 return UNW_ESUCCESS;175 return UNW_ESUCCESS;
266}176}
267177_LIBUNWIND_WEAK_ALIAS(__unw_get_proc_info, unw_get_proc_info)
268178
269/// Resume execution at cursor position (aka longjump).179/// Resume execution at cursor position (aka longjump).
270_LIBUNWIND_EXPORT int unw_resume(unw_cursor_t *cursor) {180_LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
271 _LIBUNWIND_TRACE_API("unw_resume(cursor=%p)", static_cast<void *>(cursor));181 _LIBUNWIND_TRACE_API("__unw_resume(cursor=%p)", static_cast<void *>(cursor));
272 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;182 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
273 co->jumpto();183 co->jumpto();
274 return UNW_EUNSPEC;184 return UNW_EUNSPEC;
275}185}
276186_LIBUNWIND_WEAK_ALIAS(__unw_resume, unw_resume)
277187
278/// Get name of function at cursor position in stack frame.188/// Get name of function at cursor position in stack frame.
279_LIBUNWIND_EXPORT int unw_get_proc_name(unw_cursor_t *cursor, char *buf,189_LIBUNWIND_HIDDEN int __unw_get_proc_name(unw_cursor_t *cursor, char *buf,
280 size_t bufLen, unw_word_t *offset) {190 size_t bufLen, unw_word_t *offset) {
281 _LIBUNWIND_TRACE_API("unw_get_proc_name(cursor=%p, &buf=%p, bufLen=%lu)",191 _LIBUNWIND_TRACE_API("__unw_get_proc_name(cursor=%p, &buf=%p, bufLen=%lu)",
282 static_cast<void *>(cursor), static_cast<void *>(buf),192 static_cast<void *>(cursor), static_cast<void *>(buf),
283 static_cast<unsigned long>(bufLen));193 static_cast<unsigned long>(bufLen));
284 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;194 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
...@@ -287,58 +197,62 @@ _LIBUNWIND_EXPORT int unw_get_proc_name(unw_cursor_t *cursor, char *buf,...@@ -287,58 +197,62 @@ _LIBUNWIND_EXPORT int unw_get_proc_name(unw_cursor_t *cursor, char *buf,
287 else197 else
288 return UNW_EUNSPEC;198 return UNW_EUNSPEC;
289}199}
290200_LIBUNWIND_WEAK_ALIAS(__unw_get_proc_name, unw_get_proc_name)
291201
292/// Checks if a register is a floating-point register.202/// Checks if a register is a floating-point register.
293_LIBUNWIND_EXPORT int unw_is_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum) {203_LIBUNWIND_HIDDEN int __unw_is_fpreg(unw_cursor_t *cursor,
294 _LIBUNWIND_TRACE_API("unw_is_fpreg(cursor=%p, regNum=%d)",204 unw_regnum_t regNum) {
205 _LIBUNWIND_TRACE_API("__unw_is_fpreg(cursor=%p, regNum=%d)",
295 static_cast<void *>(cursor), regNum);206 static_cast<void *>(cursor), regNum);
296 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;207 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
297 return co->validFloatReg(regNum);208 return co->validFloatReg(regNum);
298}209}
299210_LIBUNWIND_WEAK_ALIAS(__unw_is_fpreg, unw_is_fpreg)
300211
301/// Checks if a register is a floating-point register.212/// Checks if a register is a floating-point register.
302_LIBUNWIND_EXPORT const char *unw_regname(unw_cursor_t *cursor,213_LIBUNWIND_HIDDEN const char *__unw_regname(unw_cursor_t *cursor,
303 unw_regnum_t regNum) {214 unw_regnum_t regNum) {
304 _LIBUNWIND_TRACE_API("unw_regname(cursor=%p, regNum=%d)",215 _LIBUNWIND_TRACE_API("__unw_regname(cursor=%p, regNum=%d)",
305 static_cast<void *>(cursor), regNum);216 static_cast<void *>(cursor), regNum);
306 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;217 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
307 return co->getRegisterName(regNum);218 return co->getRegisterName(regNum);
308}219}
309220_LIBUNWIND_WEAK_ALIAS(__unw_regname, unw_regname)
310221
311/// Checks if current frame is signal trampoline.222/// Checks if current frame is signal trampoline.
312_LIBUNWIND_EXPORT int unw_is_signal_frame(unw_cursor_t *cursor) {223_LIBUNWIND_HIDDEN int __unw_is_signal_frame(unw_cursor_t *cursor) {
313 _LIBUNWIND_TRACE_API("unw_is_signal_frame(cursor=%p)",224 _LIBUNWIND_TRACE_API("__unw_is_signal_frame(cursor=%p)",
314 static_cast<void *>(cursor));225 static_cast<void *>(cursor));
315 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;226 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
316 return co->isSignalFrame();227 return co->isSignalFrame();
317}228}
229_LIBUNWIND_WEAK_ALIAS(__unw_is_signal_frame, unw_is_signal_frame)
318230
319#ifdef __arm__231#ifdef __arm__
320// Save VFP registers d0-d15 using FSTMIADX instead of FSTMIADD232// Save VFP registers d0-d15 using FSTMIADX instead of FSTMIADD
321_LIBUNWIND_EXPORT void unw_save_vfp_as_X(unw_cursor_t *cursor) {233_LIBUNWIND_HIDDEN void __unw_save_vfp_as_X(unw_cursor_t *cursor) {
322 _LIBUNWIND_TRACE_API("unw_fpreg_save_vfp_as_X(cursor=%p)",234 _LIBUNWIND_TRACE_API("__unw_get_fpreg_save_vfp_as_X(cursor=%p)",
323 static_cast<void *>(cursor));235 static_cast<void *>(cursor));
324 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;236 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
325 return co->saveVFPAsX();237 return co->saveVFPAsX();
326}238}
239_LIBUNWIND_WEAK_ALIAS(__unw_save_vfp_as_X, unw_save_vfp_as_X)
327#endif240#endif
328241
329242
330#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)243#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
331/// SPI: walks cached DWARF entries244/// SPI: walks cached DWARF entries
332_LIBUNWIND_EXPORT void unw_iterate_dwarf_unwind_cache(void (*func)(245_LIBUNWIND_HIDDEN void __unw_iterate_dwarf_unwind_cache(void (*func)(
333 unw_word_t ip_start, unw_word_t ip_end, unw_word_t fde, unw_word_t mh)) {246 unw_word_t ip_start, unw_word_t ip_end, unw_word_t fde, unw_word_t mh)) {
334 _LIBUNWIND_TRACE_API("unw_iterate_dwarf_unwind_cache(func=%p)",247 _LIBUNWIND_TRACE_API("__unw_iterate_dwarf_unwind_cache(func=%p)",
335 reinterpret_cast<void *>(func));248 reinterpret_cast<void *>(func));
336 DwarfFDECache<LocalAddressSpace>::iterateCacheEntries(func);249 DwarfFDECache<LocalAddressSpace>::iterateCacheEntries(func);
337}250}
338251_LIBUNWIND_WEAK_ALIAS(__unw_iterate_dwarf_unwind_cache,
252 unw_iterate_dwarf_unwind_cache)
339253
340/// IPI: for __register_frame()254/// IPI: for __register_frame()
341void _unw_add_dynamic_fde(unw_word_t fde) {255void __unw_add_dynamic_fde(unw_word_t fde) {
342 CFI_Parser<LocalAddressSpace>::FDE_Info fdeInfo;256 CFI_Parser<LocalAddressSpace>::FDE_Info fdeInfo;
343 CFI_Parser<LocalAddressSpace>::CIE_Info cieInfo;257 CFI_Parser<LocalAddressSpace>::CIE_Info cieInfo;
344 const char *message = CFI_Parser<LocalAddressSpace>::decodeFDE(258 const char *message = CFI_Parser<LocalAddressSpace>::decodeFDE(
...@@ -352,12 +266,12 @@ void _unw_add_dynamic_fde(unw_word_t fde) {...@@ -352,12 +266,12 @@ void _unw_add_dynamic_fde(unw_word_t fde) {
352 fdeInfo.pcStart, fdeInfo.pcEnd,266 fdeInfo.pcStart, fdeInfo.pcEnd,
353 fdeInfo.fdeStart);267 fdeInfo.fdeStart);
354 } else {268 } else {
355 _LIBUNWIND_DEBUG_LOG("_unw_add_dynamic_fde: bad fde: %s", message);269 _LIBUNWIND_DEBUG_LOG("__unw_add_dynamic_fde: bad fde: %s", message);
356 }270 }
357}271}
358272
359/// IPI: for __deregister_frame()273/// IPI: for __deregister_frame()
360void _unw_remove_dynamic_fde(unw_word_t fde) {274void __unw_remove_dynamic_fde(unw_word_t fde) {
361 // fde is own mh_group275 // fde is own mh_group
362 DwarfFDECache<LocalAddressSpace>::removeAllIn((LocalAddressSpace::pint_t)fde);276 DwarfFDECache<LocalAddressSpace>::removeAllIn((LocalAddressSpace::pint_t)fde);
363}277}
lib/libunwind/src/libunwind_ext.h+28-10
...@@ -1,9 +1,8 @@...@@ -1,9 +1,8 @@
1//===------------------------ libunwind_ext.h -----------------------------===//1//===------------------------ libunwind_ext.h -----------------------------===//
2//2//
3// The LLVM Compiler Infrastructure3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4//4// See https://llvm.org/LICENSE.txt for license information.
5// This file is dual licensed under the MIT and the University of Illinois Open5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6// Source Licenses. See LICENSE.TXT for details.
7//6//
8//7//
9// Extensions to libunwind API.8// Extensions to libunwind API.
...@@ -23,15 +22,34 @@...@@ -23,15 +22,34 @@
23#ifdef __cplusplus22#ifdef __cplusplus
24extern "C" {23extern "C" {
25#endif24#endif
25
26extern int __unw_getcontext(unw_context_t *);
27extern int __unw_init_local(unw_cursor_t *, unw_context_t *);
28extern int __unw_step(unw_cursor_t *);
29extern int __unw_get_reg(unw_cursor_t *, unw_regnum_t, unw_word_t *);
30extern int __unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *);
31extern int __unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t);
32extern int __unw_set_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t);
33extern int __unw_resume(unw_cursor_t *);
34
35#ifdef __arm__
36/* Save VFP registers in FSTMX format (instead of FSTMD). */
37extern void __unw_save_vfp_as_X(unw_cursor_t *);
38#endif
39
40extern const char *__unw_regname(unw_cursor_t *, unw_regnum_t);
41extern int __unw_get_proc_info(unw_cursor_t *, unw_proc_info_t *);
42extern int __unw_is_fpreg(unw_cursor_t *, unw_regnum_t);
43extern int __unw_is_signal_frame(unw_cursor_t *);
44extern int __unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *);
45
26// SPI46// SPI
27extern void unw_iterate_dwarf_unwind_cache(void (*func)(unw_word_t ip_start,47extern void __unw_iterate_dwarf_unwind_cache(void (*func)(
28 unw_word_t ip_end,48 unw_word_t ip_start, unw_word_t ip_end, unw_word_t fde, unw_word_t mh));
29 unw_word_t fde,
30 unw_word_t mh));
3149
32// IPI50// IPI
33extern void _unw_add_dynamic_fde(unw_word_t fde);51extern void __unw_add_dynamic_fde(unw_word_t fde);
34extern void _unw_remove_dynamic_fde(unw_word_t fde);52extern void __unw_remove_dynamic_fde(unw_word_t fde);
3553
36#if defined(_LIBUNWIND_ARM_EHABI)54#if defined(_LIBUNWIND_ARM_EHABI)
37extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*);55extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*);