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 @@
11//===------------------------- __libunwind_config.h -----------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//===----------------------------------------------------------------------===//
98
lib/libunwind/include/libunwind.h+4-31
......@@ -1,9 +1,8 @@
11//===---------------------------- libunwind.h -----------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Compatible with libunwind API documented at:
......@@ -76,7 +75,7 @@ typedef struct unw_addr_space *unw_addr_space_t;
7675
7776typedef int unw_regnum_t;
7877typedef uintptr_t unw_word_t;
79#if defined(__arm__)
78#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
8079typedef uint64_t unw_fpreg_t;
8180#else
8281typedef double unw_fpreg_t;
......@@ -125,32 +124,6 @@ extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUN
125124
126125extern 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
154127#ifdef __cplusplus
155128}
156129#endif
lib/libunwind/include/mach-o/compact_unwind_encoding.h+3-4
......@@ -1,9 +1,8 @@
11//===------------------ mach-o/compact_unwind_encoding.h ------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Darwin's alternative to DWARF based unwind encodings.
lib/libunwind/include/unwind.h+4-5
......@@ -1,13 +1,12 @@
11//===------------------------------- unwind.h -----------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// C++ ABI Level 1 ABI documented at:
10// http://mentorembedded.github.io/cxx-abi/abi-eh.html
9// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
1110//
1211//===----------------------------------------------------------------------===//
1312
lib/libunwind/src/AddressSpace.hpp+13-136
......@@ -1,9 +1,8 @@
11//===------------------------- AddressSpace.hpp ---------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Abstracts accessing local vs remote address spaces.
......@@ -28,6 +27,9 @@
2827
2928#if _LIBUNWIND_USE_DLADDR
3029#include <dlfcn.h>
30#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
31#pragma comment(lib, "dl")
32#endif
3133#endif
3234
3335#ifdef __APPLE__
......@@ -457,6 +459,8 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
457459#elif defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32)
458460 // Don't even bother, since Windows has functions that do all this stuff
459461 // for us.
462 (void)targetAddr;
463 (void)info;
460464 return true;
461465#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__) && \
462466 (__ANDROID_API__ < 21)
......@@ -597,142 +601,15 @@ inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
597601 return true;
598602 }
599603 }
604#else
605 (void)addr;
606 (void)buf;
607 (void)bufLen;
608 (void)offset;
600609#endif
601610 return false;
602611}
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
736613} // namespace libunwind
737614
738615#endif // __ADDRESSSPACE_HPP__
lib/libunwind/src/CompactUnwinder.hpp+3-4
......@@ -1,9 +1,8 @@
11//===-------------------------- CompactUnwinder.hpp -----------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Does runtime stack unwinding using compact unwind encodings.
lib/libunwind/src/DwarfInstructions.hpp+31-8
......@@ -1,9 +1,8 @@
11//===-------------------------- DwarfInstructions.hpp ---------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Processor specific interpretation of DWARF unwind info.
......@@ -82,12 +81,11 @@ typename A::pint_t DwarfInstructions<A, R>::getSavedRegister(
8281 const RegisterLocation &savedReg) {
8382 switch (savedReg.location) {
8483 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
8786 case CFI_Parser<A>::kRegisterAtExpression:
88 return addressSpace.getRegister(
89 evaluateExpression((pint_t)savedReg.value, addressSpace,
90 registers, cfa));
87 return (pint_t)addressSpace.getRegister(evaluateExpression(
88 (pint_t)savedReg.value, addressSpace, registers, cfa));
9189
9290 case CFI_Parser<A>::kRegisterIsExpression:
9391 return evaluateExpression((pint_t)savedReg.value, addressSpace,
......@@ -234,6 +232,31 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc,
234232 }
235233#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
237260 // Return address is address after call site instruction, so setting IP to
238261 // that does simualates a return.
239262 newRegisters.setIP(returnAddress);
lib/libunwind/src/DwarfParser.hpp+3-4
......@@ -1,9 +1,8 @@
11//===--------------------------- DwarfParser.hpp --------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Parses DWARF CFIs (FDEs and CIEs).
lib/libunwind/src/EHHeaderParser.hpp+3-4
......@@ -1,9 +1,8 @@
11//===------------------------- EHHeaderParser.hpp -------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Parses ELF .eh_frame_hdr sections.
lib/libunwind/src/RWMutex.hpp+43-6
......@@ -1,9 +1,8 @@
11//===----------------------------- Registers.hpp --------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Abstract interface to shared reader/writer log, hiding platform and
......@@ -18,6 +17,9 @@
1817#include <windows.h>
1918#elif !defined(_LIBUNWIND_HAS_NO_THREADS)
2019#include <pthread.h>
20#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
21#pragma comment(lib, "pthread")
22#endif
2123#endif
2224
2325namespace libunwind {
......@@ -57,11 +59,11 @@ private:
5759 SRWLOCK _lock = SRWLOCK_INIT;
5860};
5961
60#else
62#elif !defined(LIBUNWIND_USE_WEAK_PTHREAD)
6163
6264class _LIBUNWIND_HIDDEN RWMutex {
6365public:
64 bool lock_shared() { return pthread_rwlock_rdlock(&_lock) == 0; }
66 bool lock_shared() { return pthread_rwlock_rdlock(&_lock) == 0; }
6567 bool unlock_shared() { return pthread_rwlock_unlock(&_lock) == 0; }
6668 bool lock() { return pthread_rwlock_wrlock(&_lock) == 0; }
6769 bool unlock() { return pthread_rwlock_unlock(&_lock) == 0; }
......@@ -70,6 +72,41 @@ private:
7072 pthread_rwlock_t _lock = PTHREAD_RWLOCK_INITIALIZER;
7173};
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
73110#endif
74111
75112} // namespace libunwind
lib/libunwind/src/Registers.hpp+13-14
......@@ -1,9 +1,8 @@
11//===----------------------------- Registers.hpp --------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Models register sets for supported processors.
......@@ -2104,16 +2103,16 @@ private:
21042103 uint32_t __pc; // Program counter r15
21052104 };
21062105
2107 static void saveVFPWithFSTMD(unw_fpreg_t*);
2108 static void saveVFPWithFSTMX(unw_fpreg_t*);
2109 static void saveVFPv3(unw_fpreg_t*);
2110 static void restoreVFPWithFLDMD(unw_fpreg_t*);
2111 static void restoreVFPWithFLDMX(unw_fpreg_t*);
2112 static void restoreVFPv3(unw_fpreg_t*);
2106 static void saveVFPWithFSTMD(void*);
2107 static void saveVFPWithFSTMX(void*);
2108 static void saveVFPv3(void*);
2109 static void restoreVFPWithFLDMD(void*);
2110 static void restoreVFPWithFLDMX(void*);
2111 static void restoreVFPv3(void*);
21132112#if defined(__ARM_WMMX)
2114 static void saveiWMMX(unw_fpreg_t*);
2113 static void saveiWMMX(void*);
21152114 static void saveiWMMXControl(uint32_t*);
2116 static void restoreiWMMX(unw_fpreg_t*);
2115 static void restoreiWMMX(void*);
21172116 static void restoreiWMMXControl(uint32_t*);
21182117#endif
21192118 void restoreCoreAndJumpTo();
......@@ -2155,7 +2154,7 @@ inline Registers_arm::Registers_arm(const void *registers)
21552154 _saved_vfp_d16_d31(false) {
21562155 static_assert((check_fit<Registers_arm, unw_context_t>::does_fit),
21572156 "arm registers do not fit into unw_context_t");
2158 // See unw_getcontext() note about data.
2157 // See __unw_getcontext() note about data.
21592158 memcpy(&_registers, registers, sizeof(_registers));
21602159 memset(&_vfp_d0_d15_pad, 0, sizeof(_vfp_d0_d15_pad));
21612160 memset(&_vfp_d16_d31, 0, sizeof(_vfp_d16_d31));
......@@ -2434,7 +2433,7 @@ inline const char *Registers_arm::getRegisterName(int regNum) {
24342433
24352434inline bool Registers_arm::validFloatRegister(int regNum) const {
24362435 // 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.
24382437 return ((regNum >= UNW_ARM_D0) && (regNum <= UNW_ARM_D31))
24392438#if defined(__ARM_WMMX)
24402439 || ((regNum >= UNW_ARM_WR0) && (regNum <= UNW_ARM_WR15))
lib/libunwind/src/Unwind-EHABI.cpp+56-53
......@@ -1,9 +1,8 @@
11//===--------------------------- Unwind-EHABI.cpp -------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Implements ARM zero-cost C++ exceptions
......@@ -21,8 +20,6 @@
2120#include <stdlib.h>
2221#include <string.h>
2322
24#include <type_traits>
25
2623#include "config.h"
2724#include "libunwind.h"
2825#include "libunwind_ext.h"
......@@ -34,7 +31,11 @@ namespace {
3431// signinficant byte.
3532uint8_t getByte(const uint32_t* data, size_t offset) {
3633 const uint8_t* byteData = reinterpret_cast<const uint8_t*>(data);
34#ifdef __LITTLE_ENDIAN__
3735 return byteData[(offset & ~(size_t)0x03) + (3 - (offset & (size_t)0x03))];
36#else
37 return byteData[offset];
38#endif
3839}
3940
4041const char* getNextWord(const char* data, uint32_t* out) {
......@@ -182,7 +183,7 @@ static _Unwind_Reason_Code unwindOneFrame(_Unwind_State state,
182183 if (result != _URC_CONTINUE_UNWIND)
183184 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)
186187 return _URC_FAILURE;
187188 return _URC_CONTINUE_UNWIND;
188189}
......@@ -443,17 +444,18 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
443444 // In this implementation, the phases don't share the VRS backing store.
444445 // Instead, they are passed the original |uc| and they create a new VRS
445446 // from scratch thus achieving the same effect.
446 unw_init_local(cursor, uc);
447 __unw_init_local(cursor, uc);
447448
448449 // Walk each frame looking for a place to stop.
449450 for (bool handlerNotFound = true; handlerNotFound;) {
450451
451452 // See if frame has code to run (has personality routine).
452453 unw_proc_info_t frameInfo;
453 if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
454 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_get_proc_info "
455 "failed => _URC_FATAL_PHASE1_ERROR",
456 static_cast<void *>(exception_object));
454 if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
455 _LIBUNWIND_TRACE_UNWINDING(
456 "unwind_phase1(ex_ojb=%p): __unw_get_proc_info "
457 "failed => _URC_FATAL_PHASE1_ERROR",
458 static_cast<void *>(exception_object));
457459 return _URC_FATAL_PHASE1_ERROR;
458460 }
459461
......@@ -462,12 +464,12 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
462464 char functionBuf[512];
463465 const char *functionName = functionBuf;
464466 unw_word_t offset;
465 if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
466 &offset) != UNW_ESUCCESS) ||
467 if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
468 &offset) != UNW_ESUCCESS) ||
467469 (frameInfo.start_ip + offset > frameInfo.end_ip))
468470 functionName = ".anonymous.";
469471 unw_word_t pc;
470 unw_get_reg(cursor, UNW_REG_IP, &pc);
472 __unw_get_reg(cursor, UNW_REG_IP, &pc);
471473 _LIBUNWIND_TRACE_UNWINDING(
472474 "unwind_phase1(ex_ojb=%p): pc=0x%" PRIxPTR ", start_ip=0x%" PRIxPTR ", func=%s, "
473475 "lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR,
......@@ -537,7 +539,7 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor
537539 _Unwind_Exception *exception_object,
538540 bool resume) {
539541 // See comment at the start of unwind_phase1 regarding VRS integrity.
540 unw_init_local(cursor, uc);
542 __unw_init_local(cursor, uc);
541543
542544 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)",
543545 static_cast<void *>(exception_object));
......@@ -559,19 +561,20 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor
559561 // for. After this, continue unwinding as if normal.
560562 //
561563 // See #7.4.6 for details.
562 unw_set_reg(cursor, UNW_REG_IP,
563 exception_object->unwinder_cache.reserved2);
564 __unw_set_reg(cursor, UNW_REG_IP,
565 exception_object->unwinder_cache.reserved2);
564566 resume = false;
565567 }
566568
567569 // Get info about this frame.
568570 unw_word_t sp;
569571 unw_proc_info_t frameInfo;
570 unw_get_reg(cursor, UNW_REG_SP, &sp);
571 if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
572 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_get_proc_info "
573 "failed => _URC_FATAL_PHASE2_ERROR",
574 static_cast<void *>(exception_object));
572 __unw_get_reg(cursor, UNW_REG_SP, &sp);
573 if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
574 _LIBUNWIND_TRACE_UNWINDING(
575 "unwind_phase2(ex_ojb=%p): __unw_get_proc_info "
576 "failed => _URC_FATAL_PHASE2_ERROR",
577 static_cast<void *>(exception_object));
575578 return _URC_FATAL_PHASE2_ERROR;
576579 }
577580
......@@ -580,8 +583,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor
580583 char functionBuf[512];
581584 const char *functionName = functionBuf;
582585 unw_word_t offset;
583 if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
584 &offset) != UNW_ESUCCESS) ||
586 if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
587 &offset) != UNW_ESUCCESS) ||
585588 (frameInfo.start_ip + offset > frameInfo.end_ip))
586589 functionName = ".anonymous.";
587590 _LIBUNWIND_TRACE_UNWINDING(
......@@ -625,8 +628,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor
625628 // We may get control back if landing pad calls _Unwind_Resume().
626629 if (_LIBUNWIND_TRACING_UNWINDING) {
627630 unw_word_t pc;
628 unw_get_reg(cursor, UNW_REG_IP, &pc);
629 unw_get_reg(cursor, UNW_REG_SP, &sp);
631 __unw_get_reg(cursor, UNW_REG_IP, &pc);
632 __unw_get_reg(cursor, UNW_REG_SP, &sp);
630633 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering "
631634 "user code with ip=0x%" PRIxPTR ", sp=0x%" PRIxPTR,
632635 static_cast<void *>(exception_object),
......@@ -637,11 +640,11 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor
637640 // EHABI #7.4.1 says we need to preserve pc for when _Unwind_Resume
638641 // is called back, to find this same frame.
639642 unw_word_t pc;
640 unw_get_reg(cursor, UNW_REG_IP, &pc);
643 __unw_get_reg(cursor, UNW_REG_IP, &pc);
641644 exception_object->unwinder_cache.reserved2 = (uint32_t)pc;
642645 }
643 unw_resume(cursor);
644 // unw_resume() only returns if there was an error.
646 __unw_resume(cursor);
647 // __unw_resume() only returns if there was an error.
645648 return _URC_FATAL_PHASE2_ERROR;
646649
647650 // # EHABI #7.4.3
......@@ -670,7 +673,7 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) {
670673 static_cast<void *>(exception_object));
671674 unw_context_t uc;
672675 unw_cursor_t cursor;
673 unw_getcontext(&uc);
676 __unw_getcontext(&uc);
674677
675678 // This field for is for compatibility with GCC to say this isn't a forced
676679 // unwind. EHABI #7.2
......@@ -708,7 +711,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) {
708711 static_cast<void *>(exception_object));
709712 unw_context_t uc;
710713 unw_cursor_t cursor;
711 unw_getcontext(&uc);
714 __unw_getcontext(&uc);
712715
713716 // _Unwind_RaiseException on EHABI will always set the reserved1 field to 0,
714717 // which is in the same position as private_1 below.
......@@ -725,7 +728,7 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
725728 unw_cursor_t *cursor = (unw_cursor_t *)context;
726729 unw_proc_info_t frameInfo;
727730 uintptr_t result = 0;
728 if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
731 if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
729732 result = (uintptr_t)frameInfo.lsda;
730733 _LIBUNWIND_TRACE_API(
731734 "_Unwind_GetLanguageSpecificData(context=%p) => 0x%llx",
......@@ -765,8 +768,8 @@ _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
765768 case _UVRSC_CORE:
766769 if (representation != _UVRSD_UINT32 || regno > 15)
767770 return _UVRSR_FAILED;
768 return unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),
769 *(unw_word_t *)valuep) == UNW_ESUCCESS
771 return __unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),
772 *(unw_word_t *)valuep) == UNW_ESUCCESS
770773 ? _UVRSR_OK
771774 : _UVRSR_FAILED;
772775 case _UVRSC_VFP:
......@@ -776,28 +779,28 @@ _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
776779 // Can only touch d0-15 with FSTMFDX.
777780 if (regno > 15)
778781 return _UVRSR_FAILED;
779 unw_save_vfp_as_X(cursor);
782 __unw_save_vfp_as_X(cursor);
780783 } else {
781784 if (regno > 31)
782785 return _UVRSR_FAILED;
783786 }
784 return unw_set_fpreg(cursor, (unw_regnum_t)(UNW_ARM_D0 + regno),
785 *(unw_fpreg_t *)valuep) == UNW_ESUCCESS
787 return __unw_set_fpreg(cursor, (unw_regnum_t)(UNW_ARM_D0 + regno),
788 *(unw_fpreg_t *)valuep) == UNW_ESUCCESS
786789 ? _UVRSR_OK
787790 : _UVRSR_FAILED;
788791#if defined(__ARM_WMMX)
789792 case _UVRSC_WMMXC:
790793 if (representation != _UVRSD_UINT32 || regno > 3)
791794 return _UVRSR_FAILED;
792 return unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
793 *(unw_word_t *)valuep) == UNW_ESUCCESS
795 return __unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
796 *(unw_word_t *)valuep) == UNW_ESUCCESS
794797 ? _UVRSR_OK
795798 : _UVRSR_FAILED;
796799 case _UVRSC_WMMXD:
797800 if (representation != _UVRSD_DOUBLE || regno > 31)
798801 return _UVRSR_FAILED;
799 return unw_set_fpreg(cursor, (unw_regnum_t)(UNW_ARM_WR0 + regno),
800 *(unw_fpreg_t *)valuep) == UNW_ESUCCESS
802 return __unw_set_fpreg(cursor, (unw_regnum_t)(UNW_ARM_WR0 + regno),
803 *(unw_fpreg_t *)valuep) == UNW_ESUCCESS
801804 ? _UVRSR_OK
802805 : _UVRSR_FAILED;
803806#else
......@@ -819,8 +822,8 @@ _Unwind_VRS_Get_Internal(_Unwind_Context *context,
819822 case _UVRSC_CORE:
820823 if (representation != _UVRSD_UINT32 || regno > 15)
821824 return _UVRSR_FAILED;
822 return unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),
823 (unw_word_t *)valuep) == UNW_ESUCCESS
825 return __unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_R0 + regno),
826 (unw_word_t *)valuep) == UNW_ESUCCESS
824827 ? _UVRSR_OK
825828 : _UVRSR_FAILED;
826829 case _UVRSC_VFP:
......@@ -830,28 +833,28 @@ _Unwind_VRS_Get_Internal(_Unwind_Context *context,
830833 // Can only touch d0-15 with FSTMFDX.
831834 if (regno > 15)
832835 return _UVRSR_FAILED;
833 unw_save_vfp_as_X(cursor);
836 __unw_save_vfp_as_X(cursor);
834837 } else {
835838 if (regno > 31)
836839 return _UVRSR_FAILED;
837840 }
838 return unw_get_fpreg(cursor, (unw_regnum_t)(UNW_ARM_D0 + regno),
839 (unw_fpreg_t *)valuep) == UNW_ESUCCESS
841 return __unw_get_fpreg(cursor, (unw_regnum_t)(UNW_ARM_D0 + regno),
842 (unw_fpreg_t *)valuep) == UNW_ESUCCESS
840843 ? _UVRSR_OK
841844 : _UVRSR_FAILED;
842845#if defined(__ARM_WMMX)
843846 case _UVRSC_WMMXC:
844847 if (representation != _UVRSD_UINT32 || regno > 3)
845848 return _UVRSR_FAILED;
846 return unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
847 (unw_word_t *)valuep) == UNW_ESUCCESS
849 return __unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
850 (unw_word_t *)valuep) == UNW_ESUCCESS
848851 ? _UVRSR_OK
849852 : _UVRSR_FAILED;
850853 case _UVRSC_WMMXD:
851854 if (representation != _UVRSD_DOUBLE || regno > 31)
852855 return _UVRSR_FAILED;
853 return unw_get_fpreg(cursor, (unw_regnum_t)(UNW_ARM_WR0 + regno),
854 (unw_fpreg_t *)valuep) == UNW_ESUCCESS
856 return __unw_get_fpreg(cursor, (unw_regnum_t)(UNW_ARM_WR0 + regno),
857 (unw_fpreg_t *)valuep) == UNW_ESUCCESS
855858 ? _UVRSR_OK
856859 : _UVRSR_FAILED;
857860#else
......@@ -960,7 +963,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {
960963 unw_cursor_t *cursor = (unw_cursor_t *)context;
961964 unw_proc_info_t frameInfo;
962965 uintptr_t result = 0;
963 if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
966 if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
964967 result = (uintptr_t)frameInfo.start_ip;
965968 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%llX",
966969 static_cast<void *>(context), (long long)result);
......@@ -983,7 +986,7 @@ extern "C" _LIBUNWIND_EXPORT _Unwind_Reason_Code
983986__gnu_unwind_frame(_Unwind_Exception *exception_object,
984987 struct _Unwind_Context *context) {
985988 unw_cursor_t *cursor = (unw_cursor_t *)context;
986 if (unw_step(cursor) != UNW_STEP_SUCCESS)
989 if (__unw_step(cursor) != UNW_STEP_SUCCESS)
987990 return _URC_FAILURE;
988991 return _URC_OK;
989992}
lib/libunwind/src/Unwind-EHABI.h+3-4
......@@ -1,9 +1,8 @@
11//===------------------------- Unwind-EHABI.hpp ---------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98//===----------------------------------------------------------------------===//
lib/libunwind/src/Unwind-seh.cpp+55-45
......@@ -1,9 +1,8 @@
11//===--------------------------- Unwind-seh.cpp ---------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//===----------------------------------------------------------------------===//
98//
......@@ -53,14 +52,16 @@ static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0
5352/// Exception cleanup routine used by \c _GCC_specific_handler to
5453/// free foreign exceptions.
5554static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) {
55 (void)urc;
5656 if (exc->exception_class != kSEHExceptionClass)
5757 _LIBUNWIND_ABORT("SEH cleanup called on non-SEH exception");
5858 free(exc);
5959}
6060
61static int _unw_init_seh(unw_cursor_t *cursor, CONTEXT *ctx);
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);
61static int __unw_init_seh(unw_cursor_t *cursor, CONTEXT *ctx);
62static DISPATCHER_CONTEXT *__unw_seh_get_disp_ctx(unw_cursor_t *cursor);
63static void __unw_seh_set_disp_ctx(unw_cursor_t *cursor,
64 DISPATCHER_CONTEXT *disp);
6465
6566/// Common implementation of SEH-style handler functions used by Itanium-
6667/// 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
6970_LIBUNWIND_EXPORT EXCEPTION_DISPOSITION
7071_GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
7172 DISPATCHER_CONTEXT *disp, __personality_routine pers) {
72 unw_context_t uc;
7373 unw_cursor_t cursor;
7474 _Unwind_Exception *exc;
7575 _Unwind_Action action;
......@@ -78,7 +78,9 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
7878 uintptr_t retval, target;
7979 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);
8284 if (ms_exc->ExceptionCode == STATUS_GCC_UNWIND) {
8385 if (IS_TARGET_UNWIND(ms_exc->ExceptionFlags)) {
8486 // 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,
112114 memset(exc->private_, 0, sizeof(exc->private_));
113115 }
114116 if (!ctx) {
115 _unw_init_seh(&cursor, disp->ContextRecord);
116 _unw_seh_set_disp_ctx(&cursor, disp);
117 unw_set_reg(&cursor, UNW_REG_IP, disp->ControlPc-1);
117 __unw_init_seh(&cursor, disp->ContextRecord);
118 __unw_seh_set_disp_ctx(&cursor, disp);
119 __unw_set_reg(&cursor, UNW_REG_IP, disp->ControlPc - 1);
118120 ctx = (struct _Unwind_Context *)&cursor;
119121
120122 if (!IS_UNWINDING(ms_exc->ExceptionFlags)) {
......@@ -130,7 +132,10 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
130132 }
131133 }
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);
134139 urc = pers(1, action, exc->exception_class, exc, ctx);
135140 _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() personality returned %d", urc);
136141 switch (urc) {
......@@ -168,18 +173,18 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
168173 _LIBUNWIND_ABORT("Personality installed context during phase 1!");
169174#ifdef __x86_64__
170175 exc->private_[2] = disp->TargetIp;
171 unw_get_reg(&cursor, UNW_X86_64_RAX, &retval);
172 unw_get_reg(&cursor, UNW_X86_64_RDX, &exc->private_[3]);
176 __unw_get_reg(&cursor, UNW_X86_64_RAX, &retval);
177 __unw_get_reg(&cursor, UNW_X86_64_RDX, &exc->private_[3]);
173178#elif defined(__arm__)
174179 exc->private_[2] = disp->TargetPc;
175 unw_get_reg(&cursor, UNW_ARM_R0, &retval);
176 unw_get_reg(&cursor, UNW_ARM_R1, &exc->private_[3]);
180 __unw_get_reg(&cursor, UNW_ARM_R0, &retval);
181 __unw_get_reg(&cursor, UNW_ARM_R1, &exc->private_[3]);
177182#elif defined(__aarch64__)
178183 exc->private_[2] = disp->TargetPc;
179 unw_get_reg(&cursor, UNW_ARM64_X0, &retval);
180 unw_get_reg(&cursor, UNW_ARM64_X1, &exc->private_[3]);
184 __unw_get_reg(&cursor, UNW_ARM64_X0, &retval);
185 __unw_get_reg(&cursor, UNW_ARM64_X1, &exc->private_[3]);
181186#endif
182 unw_get_reg(&cursor, UNW_REG_IP, &target);
187 __unw_get_reg(&cursor, UNW_REG_IP, &target);
183188 ms_exc->ExceptionCode = STATUS_GCC_UNWIND;
184189#ifdef __x86_64__
185190 ms_exc->ExceptionInformation[2] = disp->TargetIp;
......@@ -199,7 +204,7 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
199204 }
200205}
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.
203208/// This is a wrapper that calls the real SEH handler function, which in
204209/// turn (at least, for Itanium-style frames) calls the real Itanium
205210/// personality function (see \c _GCC_specific_handler()).
......@@ -207,6 +212,8 @@ extern "C" _Unwind_Reason_Code
207212__libunwind_seh_personality(int version, _Unwind_Action state,
208213 uint64_t klass, _Unwind_Exception *exc,
209214 struct _Unwind_Context *context) {
215 (void)version;
216 (void)klass;
210217 EXCEPTION_RECORD ms_exc;
211218 bool phase2 = (state & (_UA_SEARCH_PHASE|_UA_CLEANUP_PHASE)) == _UA_CLEANUP_PHASE;
212219 ms_exc.ExceptionCode = STATUS_GCC_THROW;
......@@ -215,7 +222,8 @@ __libunwind_seh_personality(int version, _Unwind_Action state,
215222 ms_exc.ExceptionInformation[0] = (ULONG_PTR)exc;
216223 ms_exc.ExceptionInformation[1] = (ULONG_PTR)context;
217224 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);
219227 EXCEPTION_DISPOSITION ms_act = disp_ctx->LanguageHandler(&ms_exc,
220228 (PVOID)disp_ctx->EstablisherFrame,
221229 disp_ctx->ContextRecord,
......@@ -234,15 +242,15 @@ unwind_phase2_forced(unw_context_t *uc,
234242 _Unwind_Exception *exception_object,
235243 _Unwind_Stop_Fn stop, void *stop_parameter) {
236244 unw_cursor_t cursor2;
237 unw_init_local(&cursor2, uc);
245 __unw_init_local(&cursor2, uc);
238246
239247 // 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
242250 // Update info about this frame.
243251 unw_proc_info_t frameInfo;
244 if (unw_get_proc_info(&cursor2, &frameInfo) != UNW_ESUCCESS) {
245 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): unw_step "
252 if (__unw_get_proc_info(&cursor2, &frameInfo) != UNW_ESUCCESS) {
253 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): __unw_step "
246254 "failed => _URC_END_OF_STACK",
247255 (void *)exception_object);
248256 return _URC_FATAL_PHASE2_ERROR;
......@@ -253,8 +261,8 @@ unwind_phase2_forced(unw_context_t *uc,
253261 char functionBuf[512];
254262 const char *functionName = functionBuf;
255263 unw_word_t offset;
256 if ((unw_get_proc_name(&cursor2, functionBuf, sizeof(functionBuf),
257 &offset) != UNW_ESUCCESS) ||
264 if ((__unw_get_proc_name(&cursor2, functionBuf, sizeof(functionBuf),
265 &offset) != UNW_ESUCCESS) ||
258266 (frameInfo.start_ip + offset > frameInfo.end_ip))
259267 functionName = ".anonymous.";
260268 _LIBUNWIND_TRACE_UNWINDING(
......@@ -304,7 +312,7 @@ unwind_phase2_forced(unw_context_t *uc,
304312 "_URC_INSTALL_CONTEXT",
305313 (void *)exception_object);
306314 // We may get control back if landing pad calls _Unwind_Resume().
307 unw_resume(&cursor2);
315 __unw_resume(&cursor2);
308316 break;
309317 default:
310318 // Personality routine returned an unknown result code.
......@@ -369,7 +377,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) {
369377 if (exception_object->private_[0] != 0) {
370378 unw_context_t uc;
371379
372 unw_getcontext(&uc);
380 __unw_getcontext(&uc);
373381 unwind_phase2_forced(&uc, exception_object,
374382 (_Unwind_Stop_Fn) exception_object->private_[0],
375383 (void *)exception_object->private_[4]);
......@@ -407,7 +415,7 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,
407415 _LIBUNWIND_TRACE_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)",
408416 (void *)exception_object, (void *)(uintptr_t)stop);
409417 unw_context_t uc;
410 unw_getcontext(&uc);
418 __unw_getcontext(&uc);
411419
412420 // Mark that this is a forced unwind, so _Unwind_Resume() can do
413421 // the right thing.
......@@ -421,7 +429,8 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,
421429/// Called by personality handler during phase 2 to get LSDA for current frame.
422430_LIBUNWIND_EXPORT uintptr_t
423431_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;
425434 _LIBUNWIND_TRACE_API(
426435 "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIxPTR,
427436 (void *)context, result);
......@@ -432,30 +441,32 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
432441/// function.
433442_LIBUNWIND_EXPORT uintptr_t
434443_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);
436445 uintptr_t result = (uintptr_t)disp->FunctionEntry->BeginAddress + disp->ImageBase;
437446 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIxPTR,
438447 (void *)context, result);
439448 return result;
440449}
441450
442static int
443_unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) {
451static int __unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) {
444452#ifdef _LIBUNWIND_TARGET_X86_64
445 new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_x86_64>(
446 context, LocalAddressSpace::sThisAddressSpace);
453 new (reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_x86_64> *>(cursor))
454 UnwindCursor<LocalAddressSpace, Registers_x86_64>(
455 context, LocalAddressSpace::sThisAddressSpace);
447456 auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor);
448457 co->setInfoBasedOnIPRegister();
449458 return UNW_ESUCCESS;
450459#elif defined(_LIBUNWIND_TARGET_ARM)
451 new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_arm>(
452 context, LocalAddressSpace::sThisAddressSpace);
460 new (reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_arm> *>(cursor))
461 UnwindCursor<LocalAddressSpace, Registers_arm>(
462 context, LocalAddressSpace::sThisAddressSpace);
453463 auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor);
454464 co->setInfoBasedOnIPRegister();
455465 return UNW_ESUCCESS;
456466#elif defined(_LIBUNWIND_TARGET_AARCH64)
457 new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_arm64>(
458 context, LocalAddressSpace::sThisAddressSpace);
467 new (reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_arm64> *>(cursor))
468 UnwindCursor<LocalAddressSpace, Registers_arm64>(
469 context, LocalAddressSpace::sThisAddressSpace);
459470 auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor);
460471 co->setInfoBasedOnIPRegister();
461472 return UNW_ESUCCESS;
......@@ -464,8 +475,7 @@ _unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) {
464475#endif
465476}
466477
467static DISPATCHER_CONTEXT *
468_unw_seh_get_disp_ctx(unw_cursor_t *cursor) {
478static DISPATCHER_CONTEXT *__unw_seh_get_disp_ctx(unw_cursor_t *cursor) {
469479#ifdef _LIBUNWIND_TARGET_X86_64
470480 return reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_x86_64> *>(cursor)->getDispatcherContext();
471481#elif defined(_LIBUNWIND_TARGET_ARM)
......@@ -477,8 +487,8 @@ _unw_seh_get_disp_ctx(unw_cursor_t *cursor) {
477487#endif
478488}
479489
480static void
481_unw_seh_set_disp_ctx(unw_cursor_t *cursor, DISPATCHER_CONTEXT *disp) {
490static void __unw_seh_set_disp_ctx(unw_cursor_t *cursor,
491 DISPATCHER_CONTEXT *disp) {
482492#ifdef _LIBUNWIND_TARGET_X86_64
483493 reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_x86_64> *>(cursor)->setDispatcherContext(disp);
484494#elif defined(_LIBUNWIND_TARGET_ARM)
lib/libunwind/src/Unwind-sjlj.c+66-54
......@@ -1,9 +1,8 @@
11//===--------------------------- Unwind-sjlj.c ----------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Implements setjump-longjump based C++ exceptions
......@@ -12,6 +11,7 @@
1211
1312#include <unwind.h>
1413
14#include <inttypes.h>
1515#include <stdint.h>
1616#include <stdbool.h>
1717#include <stdlib.h>
......@@ -52,7 +52,7 @@ struct _Unwind_FunctionContext {
5252#else
5353# if __STDC_VERSION__ >= 201112L
5454# define _LIBUNWIND_THREAD_LOCAL _Thread_local
55# elif defined(_WIN32)
55# elif defined(_MSC_VER)
5656# define _LIBUNWIND_THREAD_LOCAL __declspec(thread)
5757# elif defined(__GNUC__) || defined(__clang__)
5858# define _LIBUNWIND_THREAD_LOCAL __thread
......@@ -108,7 +108,8 @@ _Unwind_SjLj_Unregister(struct _Unwind_FunctionContext *fc) {
108108static _Unwind_Reason_Code
109109unwind_phase1(struct _Unwind_Exception *exception_object) {
110110 _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
113114 // walk each frame looking for a place to stop
114115 for (bool handlerNotFound = true; handlerNotFound; c = c->prev) {
......@@ -117,17 +118,18 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {
117118 if (c == NULL) {
118119 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): reached "
119120 "bottom => _URC_END_OF_STACK",
120 exception_object);
121 (void *)exception_object);
121122 return _URC_END_OF_STACK;
122123 }
123124
124 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: function-context=%p", c);
125 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: function-context=%p", (void *)c);
125126 // if there is a personality routine, ask it if it will want to stop at this
126127 // frame
127128 if (c->personality != NULL) {
128129 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): calling "
129 "personality function %p",
130 exception_object, c->personality);
130 "personality function %p",
131 (void *)exception_object,
132 (void *)c->personality);
131133 _Unwind_Reason_Code personalityResult = (*c->personality)(
132134 1, _UA_SEARCH_PHASE, exception_object->exception_class,
133135 exception_object, (struct _Unwind_Context *)c);
......@@ -138,12 +140,14 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {
138140 handlerNotFound = false;
139141 exception_object->private_2 = (uintptr_t) c;
140142 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): "
141 "_URC_HANDLER_FOUND", exception_object);
143 "_URC_HANDLER_FOUND",
144 (void *)exception_object);
142145 return _URC_NO_REASON;
143146
144147 case _URC_CONTINUE_UNWIND:
145148 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): "
146 "_URC_CONTINUE_UNWIND", exception_object);
149 "_URC_CONTINUE_UNWIND",
150 (void *)exception_object);
147151 // continue unwinding
148152 break;
149153
......@@ -151,7 +155,7 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {
151155 // something went wrong
152156 _LIBUNWIND_TRACE_UNWINDING(
153157 "unwind_phase1(ex_ojb=%p): _URC_FATAL_PHASE1_ERROR",
154 exception_object);
158 (void *)exception_object);
155159 return _URC_FATAL_PHASE1_ERROR;
156160 }
157161 }
......@@ -162,19 +166,21 @@ unwind_phase1(struct _Unwind_Exception *exception_object) {
162166
163167static _Unwind_Reason_Code
164168unwind_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
167172 // walk each frame until we reach where search phase said to stop
168173 _Unwind_FunctionContext_t c = __Unwind_SjLj_GetTopOfFunctionStack();
169174 while (true) {
170175 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2s(ex_ojb=%p): context=%p",
171 exception_object, c);
176 (void *)exception_object, (void *)c);
172177
173178 // check for no more frames
174179 if (c == NULL) {
175 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "
176 "bottom => _URC_END_OF_STACK",
177 exception_object);
180 _LIBUNWIND_TRACE_UNWINDING(
181 "unwind_phase2(ex_ojb=%p): __unw_step() reached "
182 "bottom => _URC_END_OF_STACK",
183 (void *)exception_object);
178184 return _URC_END_OF_STACK;
179185 }
180186
......@@ -194,7 +200,7 @@ unwind_phase2(struct _Unwind_Exception *exception_object) {
194200 // continue unwinding
195201 _LIBUNWIND_TRACE_UNWINDING(
196202 "unwind_phase2(ex_ojb=%p): _URC_CONTINUE_UNWIND",
197 exception_object);
203 (void *)exception_object);
198204 if ((uintptr_t) c == exception_object->private_2) {
199205 // phase 1 said we would stop at this frame, but we did not...
200206 _LIBUNWIND_ABORT("during phase1 personality function said it would "
......@@ -203,14 +209,14 @@ unwind_phase2(struct _Unwind_Exception *exception_object) {
203209 break;
204210 case _URC_INSTALL_CONTEXT:
205211 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): "
206 "_URC_INSTALL_CONTEXT, will resume at "
207 "landing pad %p",
208 exception_object, c->jbuf[1]);
212 "_URC_INSTALL_CONTEXT, will resume at "
213 "landing pad %p",
214 (void *)exception_object, c->jbuf[1]);
209215 // personality routine says to transfer control to landing pad
210216 // we may get control back if landing pad calls _Unwind_Resume()
211217 __Unwind_SjLj_SetTopOfFunctionStack(c);
212218 __builtin_longjmp(c->jbuf, 1);
213 // unw_resume() only returns if there was an error
219 // __unw_resume() only returns if there was an error
214220 return _URC_FATAL_PHASE2_ERROR;
215221 default:
216222 // something went wrong
......@@ -237,9 +243,10 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
237243
238244 // get next frame (skip over first which is _Unwind_RaiseException)
239245 if (c == NULL) {
240 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "
241 "bottom => _URC_END_OF_STACK",
242 exception_object);
246 _LIBUNWIND_TRACE_UNWINDING(
247 "unwind_phase2(ex_ojb=%p): __unw_step() reached "
248 "bottom => _URC_END_OF_STACK",
249 (void *)exception_object);
243250 return _URC_END_OF_STACK;
244251 }
245252
......@@ -251,11 +258,11 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
251258 (struct _Unwind_Context *)c, stop_parameter);
252259 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
253260 "stop function returned %d",
254 exception_object, stopResult);
261 (void *)exception_object, stopResult);
255262 if (stopResult != _URC_NO_REASON) {
256263 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
257264 "stopped by stop function",
258 exception_object);
265 (void *)exception_object);
259266 return _URC_FATAL_PHASE2_ERROR;
260267 }
261268
......@@ -264,7 +271,7 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
264271 __personality_routine p = (__personality_routine) c->personality;
265272 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
266273 "calling personality function %p",
267 exception_object, p);
274 (void *)exception_object, (void *)p);
268275 _Unwind_Reason_Code personalityResult =
269276 (*p)(1, action, exception_object->exception_class, exception_object,
270277 (struct _Unwind_Context *)c);
......@@ -272,13 +279,13 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
272279 case _URC_CONTINUE_UNWIND:
273280 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
274281 "personality returned _URC_CONTINUE_UNWIND",
275 exception_object);
282 (void *)exception_object);
276283 // destructors called, continue unwinding
277284 break;
278285 case _URC_INSTALL_CONTEXT:
279286 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
280287 "personality returned _URC_INSTALL_CONTEXT",
281 exception_object);
288 (void *)exception_object);
282289 // we may get control back if landing pad calls _Unwind_Resume()
283290 __Unwind_SjLj_SetTopOfFunctionStack(c);
284291 __builtin_longjmp(c->jbuf, 1);
......@@ -288,7 +295,7 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
288295 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
289296 "personality returned %d, "
290297 "_URC_FATAL_PHASE2_ERROR",
291 exception_object, personalityResult);
298 (void *)exception_object, personalityResult);
292299 return _URC_FATAL_PHASE2_ERROR;
293300 }
294301 }
......@@ -298,8 +305,8 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
298305 // call stop function one last time and tell it we've reached the end of the
299306 // stack
300307 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): calling stop "
301 "function with _UA_END_OF_STACK",
302 exception_object);
308 "function with _UA_END_OF_STACK",
309 (void *)exception_object);
303310 _Unwind_Action lastAction =
304311 (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK);
305312 (*stop)(1, lastAction, exception_object->exception_class, exception_object,
......@@ -314,7 +321,8 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object,
314321/// Called by __cxa_throw. Only returns if there is a fatal error
315322_LIBUNWIND_EXPORT _Unwind_Reason_Code
316323_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
319327 // mark that this is a non-forced unwind, so _Unwind_Resume() can do the right
320328 // thing
......@@ -344,7 +352,8 @@ _Unwind_SjLj_RaiseException(struct _Unwind_Exception *exception_object) {
344352/// __cxa_rethrow() which in turn calls _Unwind_Resume_or_Rethrow()
345353_LIBUNWIND_EXPORT void
346354_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
349358 if (exception_object->private_1 != 0)
350359 unwind_phase2_forced(exception_object,
......@@ -362,8 +371,8 @@ _Unwind_SjLj_Resume(struct _Unwind_Exception *exception_object) {
362371_LIBUNWIND_EXPORT _Unwind_Reason_Code
363372_Unwind_SjLj_Resume_or_Rethrow(struct _Unwind_Exception *exception_object) {
364373 _LIBUNWIND_TRACE_API("__Unwind_SjLj_Resume_or_Rethrow(ex_obj=%p), "
365 "private_1=%ld",
366 exception_object, exception_object->private_1);
374 "private_1=%" PRIuPTR,
375 (void *)exception_object, exception_object->private_1);
367376 // If this is non-forced and a stopping place was found, then this is a
368377 // re-throw.
369378 // Call _Unwind_RaiseException() as if this was a new exception.
......@@ -386,7 +395,8 @@ _LIBUNWIND_EXPORT uintptr_t
386395_Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
387396 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
388397 _LIBUNWIND_TRACE_API("_Unwind_GetLanguageSpecificData(context=%p) "
389 "=> 0x%0lX", context, ufc->lsda);
398 "=> 0x%" PRIuPTR,
399 (void *)context, ufc->lsda);
390400 return ufc->lsda;
391401}
392402
......@@ -394,8 +404,8 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
394404/// Called by personality handler during phase 2 to get register values.
395405_LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context,
396406 int index) {
397 _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d)",
398 context, index);
407 _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d)", (void *)context,
408 index);
399409 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
400410 return ufc->resumeParameters[index];
401411}
......@@ -404,8 +414,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context,
404414/// Called by personality handler during phase 2 to alter register values.
405415_LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
406416 uintptr_t new_value) {
407 _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%0lX)"
408 , context, index, new_value);
417 _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%" PRIuPTR
418 ")",
419 (void *)context, index, new_value);
409420 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
410421 ufc->resumeParameters[index] = new_value;
411422}
......@@ -414,8 +425,8 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
414425/// Called by personality handler during phase 2 to get instruction pointer.
415426_LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
416427 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
417 _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%lX", context,
418 ufc->resumeLocation + 1);
428 _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIu32,
429 (void *)context, ufc->resumeLocation + 1);
419430 return ufc->resumeLocation + 1;
420431}
421432
......@@ -427,8 +438,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,
427438 int *ipBefore) {
428439 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
429440 *ipBefore = 0;
430 _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%lX",
431 context, ipBefore, ufc->resumeLocation + 1);
441 _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%" PRIu32,
442 (void *)context, (void *)ipBefore,
443 ufc->resumeLocation + 1);
432444 return ufc->resumeLocation + 1;
433445}
434446
......@@ -436,8 +448,8 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,
436448/// Called by personality handler during phase 2 to alter instruction pointer.
437449_LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,
438450 uintptr_t new_value) {
439 _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%0lX)",
440 context, new_value);
451 _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%" PRIuPTR ")",
452 (void *)context, new_value);
441453 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
442454 ufc->resumeLocation = new_value - 1;
443455}
......@@ -449,7 +461,7 @@ _LIBUNWIND_EXPORT uintptr_t
449461_Unwind_GetRegionStart(struct _Unwind_Context *context) {
450462 // Not supported or needed for sjlj based unwinding
451463 (void)context;
452 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p)", context);
464 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p)", (void *)context);
453465 return 0;
454466}
455467
......@@ -459,7 +471,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {
459471_LIBUNWIND_EXPORT void
460472_Unwind_DeleteException(struct _Unwind_Exception *exception_object) {
461473 _LIBUNWIND_TRACE_API("_Unwind_DeleteException(ex_obj=%p)",
462 exception_object);
474 (void *)exception_object);
463475 if (exception_object->exception_cleanup != NULL)
464476 (*exception_object->exception_cleanup)(_URC_FOREIGN_EXCEPTION_CAUGHT,
465477 exception_object);
......@@ -473,7 +485,7 @@ _LIBUNWIND_EXPORT uintptr_t
473485_Unwind_GetDataRelBase(struct _Unwind_Context *context) {
474486 // Not supported or needed for sjlj based unwinding
475487 (void)context;
476 _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", context);
488 _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", (void *)context);
477489 _LIBUNWIND_ABORT("_Unwind_GetDataRelBase() not implemented");
478490}
479491
......@@ -484,14 +496,14 @@ _LIBUNWIND_EXPORT uintptr_t
484496_Unwind_GetTextRelBase(struct _Unwind_Context *context) {
485497 // Not supported or needed for sjlj based unwinding
486498 (void)context;
487 _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", context);
499 _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", (void *)context);
488500 _LIBUNWIND_ABORT("_Unwind_GetTextRelBase() not implemented");
489501}
490502
491503
492504/// Called by personality handler to get "Call Frame Area" for current frame.
493505_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);
495507 if (context != NULL) {
496508 _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
497509 // Setjmp/longjmp based exceptions don't have a true CFA.
lib/libunwind/src/UnwindCursor.hpp+42-11
......@@ -1,9 +1,8 @@
11//===------------------------- UnwindCursor.hpp ---------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// C++ interface to lower levels of libunwind
......@@ -12,7 +11,6 @@
1211#ifndef __UNWINDCURSOR_HPP__
1312#define __UNWINDCURSOR_HPP__
1413
15#include <algorithm>
1614#include <stdint.h>
1715#include <stdio.h>
1816#include <stdlib.h>
......@@ -106,7 +104,6 @@ private:
106104 static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide);
107105 static bool _registeredForDyldUnloads;
108106#endif
109 // Can't use std::vector<> here because this code is below libc++.
110107 static entry *_buffer;
111108 static entry *_bufferUsed;
112109 static entry *_bufferEnd;
......@@ -485,6 +482,10 @@ public:
485482 DISPATCHER_CONTEXT *getDispatcherContext() { return &_dispContext; }
486483 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
488489private:
489490
490491 pint_t getLastPC() const { return _dispContext.ControlPc; }
......@@ -789,6 +790,8 @@ bool UnwindCursor<A, R>::validFloatReg(int regNum) {
789790 if (regNum >= UNW_ARM_D0 && regNum <= UNW_ARM_D31) return true;
790791#elif defined(_LIBUNWIND_TARGET_AARCH64)
791792 if (regNum >= UNW_ARM64_D0 && regNum <= UNW_ARM64_D31) return true;
793#else
794 (void)regNum;
792795#endif
793796 return false;
794797}
......@@ -816,6 +819,7 @@ unw_fpreg_t UnwindCursor<A, R>::getFloatReg(int regNum) {
816819#elif defined(_LIBUNWIND_TARGET_AARCH64)
817820 return _msContext.V[regNum - UNW_ARM64_D0].D[0];
818821#else
822 (void)regNum;
819823 _LIBUNWIND_ABORT("float registers unimplemented");
820824#endif
821825}
......@@ -843,6 +847,8 @@ void UnwindCursor<A, R>::setFloatReg(int regNum, unw_fpreg_t value) {
843847#elif defined(_LIBUNWIND_TARGET_AARCH64)
844848 _msContext.V[regNum - UNW_ARM64_D0].D[0] = value;
845849#else
850 (void)regNum;
851 (void)value;
846852 _LIBUNWIND_ABORT("float registers unimplemented");
847853#endif
848854}
......@@ -892,6 +898,10 @@ public:
892898 virtual void saveVFPAsX();
893899#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
895905private:
896906
897907#if defined(_LIBUNWIND_ARM_EHABI)
......@@ -1221,7 +1231,6 @@ template<typename A>
12211231struct EHABISectionIterator {
12221232 typedef EHABISectionIterator _Self;
12231233
1224 typedef std::random_access_iterator_tag iterator_category;
12251234 typedef typename A::pint_t value_type;
12261235 typedef typename A::pint_t* pointer;
12271236 typedef typename A::pint_t& reference;
......@@ -1275,6 +1284,29 @@ struct EHABISectionIterator {
12751284 const UnwindInfoSections* _sects;
12761285};
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
12781310template <typename A, typename R>
12791311bool UnwindCursor<A, R>::getInfoFromEHABISection(
12801312 pint_t pc,
......@@ -1286,7 +1318,7 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection(
12861318 if (begin == end)
12871319 return false;
12881320
1289 EHABISectionIterator<A> itNextPC = std::upper_bound(begin, end, pc);
1321 EHABISectionIterator<A> itNextPC = EHABISectionUpperBound(begin, end, pc);
12901322 if (itNextPC == begin)
12911323 return false;
12921324 EHABISectionIterator<A> itThisPC = itNextPC - 1;
......@@ -1296,8 +1328,7 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection(
12961328 // in the table, we don't really know the function extent and have to choose a
12971329 // value for nextPC. Choosing max() will allow the range check during trace to
12981330 // succeed.
1299 pint_t nextPC = (itNextPC == end) ? std::numeric_limits<pint_t>::max()
1300 : itNextPC.functionAddress();
1331 pint_t nextPC = (itNextPC == end) ? UINTPTR_MAX : itNextPC.functionAddress();
13011332 pint_t indexDataAddr = itThisPC.dataAddress();
13021333
13031334 if (indexDataAddr == 0)
......@@ -1709,7 +1740,7 @@ bool UnwindCursor<A, R>::getInfoFromCompactEncodingSection(pint_t pc,
17091740 --personalityIndex; // change 1-based to zero-based index
17101741 if (personalityIndex > sectionHeader.personalityArrayCount()) {
17111742 _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",
17131744 encoding, personalityIndex,
17141745 sectionHeader.personalityArrayCount());
17151746 return false;
lib/libunwind/src/UnwindLevel1-gcc-ext.c+20-21
......@@ -1,9 +1,8 @@
11//===--------------------- UnwindLevel1-gcc-ext.c -------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Implements gcc extensions to the C++ ABI Exception Handling Level 1.
......@@ -94,10 +93,10 @@ _LIBUNWIND_EXPORT void *_Unwind_FindEnclosingFunction(void *pc) {
9493 unw_cursor_t cursor;
9594 unw_context_t uc;
9695 unw_proc_info_t info;
97 unw_getcontext(&uc);
98 unw_init_local(&cursor, &uc);
99 unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t) pc);
100 if (unw_get_proc_info(&cursor, &info) == UNW_ESUCCESS)
96 __unw_getcontext(&uc);
97 __unw_init_local(&cursor, &uc);
98 __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc);
99 if (__unw_get_proc_info(&cursor, &info) == UNW_ESUCCESS)
101100 return (void *)(intptr_t) info.start_ip;
102101 else
103102 return NULL;
......@@ -109,8 +108,8 @@ _LIBUNWIND_EXPORT _Unwind_Reason_Code
109108_Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
110109 unw_cursor_t cursor;
111110 unw_context_t uc;
112 unw_getcontext(&uc);
113 unw_init_local(&cursor, &uc);
111 __unw_getcontext(&uc);
112 __unw_init_local(&cursor, &uc);
114113
115114 _LIBUNWIND_TRACE_API("_Unwind_Backtrace(callback=%p)",
116115 (void *)(uintptr_t)callback);
......@@ -129,7 +128,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
129128#if !defined(_LIBUNWIND_ARM_EHABI)
130129 // ask libunwind to get next frame (skip over first frame which is
131130 // _Unwind_Backtrace())
132 if (unw_step(&cursor) <= 0) {
131 if (__unw_step(&cursor) <= 0) {
133132 _LIBUNWIND_TRACE_UNWINDING(" _backtrace: ended because cursor reached "
134133 "bottom of stack, returning %d",
135134 _URC_END_OF_STACK);
......@@ -138,7 +137,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
138137#else
139138 // Get the information for this frame.
140139 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) {
142141 return _URC_END_OF_STACK;
143142 }
144143
......@@ -165,8 +164,8 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
165164 char functionName[512];
166165 unw_proc_info_t frame;
167166 unw_word_t offset;
168 unw_get_proc_name(&cursor, functionName, 512, &offset);
169 unw_get_proc_info(&cursor, &frame);
167 __unw_get_proc_name(&cursor, functionName, 512, &offset);
168 __unw_get_proc_info(&cursor, &frame);
170169 _LIBUNWIND_TRACE_UNWINDING(
171170 " _backtrace: start_ip=0x%" PRIxPTR ", func=%s, lsda=0x%" PRIxPTR ", context=%p",
172171 frame.start_ip, functionName, frame.lsda,
......@@ -192,10 +191,10 @@ _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc,
192191 unw_cursor_t cursor;
193192 unw_context_t uc;
194193 unw_proc_info_t info;
195 unw_getcontext(&uc);
196 unw_init_local(&cursor, &uc);
197 unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t) pc);
198 unw_get_proc_info(&cursor, &info);
194 __unw_getcontext(&uc);
195 __unw_init_local(&cursor, &uc);
196 __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc);
197 __unw_get_proc_info(&cursor, &info);
199198 bases->tbase = (uintptr_t)info.extra;
200199 bases->dbase = 0; // dbase not used on Mac OS X
201200 bases->func = (uintptr_t)info.start_ip;
......@@ -209,7 +208,7 @@ _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc,
209208_LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) {
210209 unw_cursor_t *cursor = (unw_cursor_t *)context;
211210 unw_word_t result;
212 unw_get_reg(cursor, UNW_REG_SP, &result);
211 __unw_get_reg(cursor, UNW_REG_SP, &result);
213212 _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p) => 0x%" PRIxPTR,
214213 (void *)context, result);
215214 return (uintptr_t)result;
......@@ -234,7 +233,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,
234233/// was broken until 10.6.
235234_LIBUNWIND_EXPORT void __register_frame(const void *fde) {
236235 _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);
238237}
239238
240239
......@@ -244,7 +243,7 @@ _LIBUNWIND_EXPORT void __register_frame(const void *fde) {
244243/// was broken until 10.6.
245244_LIBUNWIND_EXPORT void __deregister_frame(const void *fde) {
246245 _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);
248247}
249248
250249
lib/libunwind/src/UnwindLevel1.c+63-57
......@@ -1,13 +1,12 @@
11//===------------------------- UnwindLevel1.c -----------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Implements C++ ABI Exception Handling Level 1 as documented at:
10// http://mentorembedded.github.io/cxx-abi/abi-eh.html
9// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
1110// using libunwind
1211//
1312//===----------------------------------------------------------------------===//
......@@ -26,9 +25,10 @@
2625#include <stdio.h>
2726#include <string.h>
2827
28#include "config.h"
2929#include "libunwind.h"
30#include "libunwind_ext.h"
3031#include "unwind.h"
31#include "config.h"
3232
3333#if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
3434
......@@ -36,33 +36,36 @@
3636
3737static _Unwind_Reason_Code
3838unwind_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
4141 // Walk each frame looking for a place to stop.
4242 bool handlerNotFound = true;
4343 while (handlerNotFound) {
4444 // Ask libunwind to get next frame (skip over first which is
4545 // _Unwind_RaiseException).
46 int stepResult = unw_step(cursor);
46 int stepResult = __unw_step(cursor);
4747 if (stepResult == 0) {
48 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step() reached "
49 "bottom => _URC_END_OF_STACK",
50 (void *)exception_object);
48 _LIBUNWIND_TRACE_UNWINDING(
49 "unwind_phase1(ex_ojb=%p): __unw_step() reached "
50 "bottom => _URC_END_OF_STACK",
51 (void *)exception_object);
5152 return _URC_END_OF_STACK;
5253 } else if (stepResult < 0) {
53 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step failed => "
54 "_URC_FATAL_PHASE1_ERROR",
55 (void *)exception_object);
54 _LIBUNWIND_TRACE_UNWINDING(
55 "unwind_phase1(ex_ojb=%p): __unw_step failed => "
56 "_URC_FATAL_PHASE1_ERROR",
57 (void *)exception_object);
5658 return _URC_FATAL_PHASE1_ERROR;
5759 }
5860
5961 // See if frame has code to run (has personality routine).
6062 unw_proc_info_t frameInfo;
6163 unw_word_t sp;
62 if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
63 _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_get_proc_info "
64 "failed => _URC_FATAL_PHASE1_ERROR",
65 (void *)exception_object);
64 if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
65 _LIBUNWIND_TRACE_UNWINDING(
66 "unwind_phase1(ex_ojb=%p): __unw_get_proc_info "
67 "failed => _URC_FATAL_PHASE1_ERROR",
68 (void *)exception_object);
6669 return _URC_FATAL_PHASE1_ERROR;
6770 }
6871
......@@ -71,12 +74,12 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
7174 char functionBuf[512];
7275 const char *functionName = functionBuf;
7376 unw_word_t offset;
74 if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
75 &offset) != UNW_ESUCCESS) ||
77 if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
78 &offset) != UNW_ESUCCESS) ||
7679 (frameInfo.start_ip + offset > frameInfo.end_ip))
7780 functionName = ".anonymous.";
7881 unw_word_t pc;
79 unw_get_reg(cursor, UNW_REG_IP, &pc);
82 __unw_get_reg(cursor, UNW_REG_IP, &pc);
8083 _LIBUNWIND_TRACE_UNWINDING(
8184 "unwind_phase1(ex_ojb=%p): pc=0x%" PRIxPTR ", start_ip=0x%" PRIxPTR
8285 ", 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
100103 // found a catch clause or locals that need destructing in this frame
101104 // stop search and remember stack pointer at the frame
102105 handlerNotFound = false;
103 unw_get_reg(cursor, UNW_REG_SP, &sp);
106 __unw_get_reg(cursor, UNW_REG_SP, &sp);
104107 exception_object->private_2 = (uintptr_t)sp;
105108 _LIBUNWIND_TRACE_UNWINDING(
106109 "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
129132
130133static _Unwind_Reason_Code
131134unwind_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
134137 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)",
135138 (void *)exception_object);
......@@ -139,27 +142,30 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
139142
140143 // Ask libunwind to get next frame (skip over first which is
141144 // _Unwind_RaiseException).
142 int stepResult = unw_step(cursor);
145 int stepResult = __unw_step(cursor);
143146 if (stepResult == 0) {
144 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "
145 "bottom => _URC_END_OF_STACK",
146 (void *)exception_object);
147 _LIBUNWIND_TRACE_UNWINDING(
148 "unwind_phase2(ex_ojb=%p): __unw_step() reached "
149 "bottom => _URC_END_OF_STACK",
150 (void *)exception_object);
147151 return _URC_END_OF_STACK;
148152 } else if (stepResult < 0) {
149 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step failed => "
150 "_URC_FATAL_PHASE1_ERROR",
151 (void *)exception_object);
153 _LIBUNWIND_TRACE_UNWINDING(
154 "unwind_phase2(ex_ojb=%p): __unw_step failed => "
155 "_URC_FATAL_PHASE1_ERROR",
156 (void *)exception_object);
152157 return _URC_FATAL_PHASE2_ERROR;
153158 }
154159
155160 // Get info about this frame.
156161 unw_word_t sp;
157162 unw_proc_info_t frameInfo;
158 unw_get_reg(cursor, UNW_REG_SP, &sp);
159 if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
160 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_get_proc_info "
161 "failed => _URC_FATAL_PHASE1_ERROR",
162 (void *)exception_object);
163 __unw_get_reg(cursor, UNW_REG_SP, &sp);
164 if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
165 _LIBUNWIND_TRACE_UNWINDING(
166 "unwind_phase2(ex_ojb=%p): __unw_get_proc_info "
167 "failed => _URC_FATAL_PHASE1_ERROR",
168 (void *)exception_object);
163169 return _URC_FATAL_PHASE2_ERROR;
164170 }
165171
......@@ -168,8 +174,8 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
168174 char functionBuf[512];
169175 const char *functionName = functionBuf;
170176 unw_word_t offset;
171 if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
172 &offset) != UNW_ESUCCESS) ||
177 if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
178 &offset) != UNW_ESUCCESS) ||
173179 (frameInfo.start_ip + offset > frameInfo.end_ip))
174180 functionName = ".anonymous.";
175181 _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
212218 // We may get control back if landing pad calls _Unwind_Resume().
213219 if (_LIBUNWIND_TRACING_UNWINDING) {
214220 unw_word_t pc;
215 unw_get_reg(cursor, UNW_REG_IP, &pc);
216 unw_get_reg(cursor, UNW_REG_SP, &sp);
221 __unw_get_reg(cursor, UNW_REG_IP, &pc);
222 __unw_get_reg(cursor, UNW_REG_SP, &sp);
217223 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering "
218224 "user code with ip=0x%" PRIxPTR
219225 ", sp=0x%" PRIxPTR,
220226 (void *)exception_object, pc, sp);
221227 }
222 unw_resume(cursor);
223 // unw_resume() only returns if there was an error.
228 __unw_resume(cursor);
229 // __unw_resume() only returns if there was an error.
224230 return _URC_FATAL_PHASE2_ERROR;
225231 default:
226232 // Personality routine returned an unknown result code.
......@@ -240,15 +246,15 @@ static _Unwind_Reason_Code
240246unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
241247 _Unwind_Exception *exception_object,
242248 _Unwind_Stop_Fn stop, void *stop_parameter) {
243 unw_init_local(cursor, uc);
249 __unw_init_local(cursor, uc);
244250
245251 // 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
248254 // Update info about this frame.
249255 unw_proc_info_t frameInfo;
250 if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
251 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): unw_step "
256 if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
257 _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): __unw_step "
252258 "failed => _URC_END_OF_STACK",
253259 (void *)exception_object);
254260 return _URC_FATAL_PHASE2_ERROR;
......@@ -259,8 +265,8 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
259265 char functionBuf[512];
260266 const char *functionName = functionBuf;
261267 unw_word_t offset;
262 if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
263 &offset) != UNW_ESUCCESS) ||
268 if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
269 &offset) != UNW_ESUCCESS) ||
264270 (frameInfo.start_ip + offset > frameInfo.end_ip))
265271 functionName = ".anonymous.";
266272 _LIBUNWIND_TRACE_UNWINDING(
......@@ -310,7 +316,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
310316 "_URC_INSTALL_CONTEXT",
311317 (void *)exception_object);
312318 // We may get control back if landing pad calls _Unwind_Resume().
313 unw_resume(cursor);
319 __unw_resume(cursor);
314320 break;
315321 default:
316322 // Personality routine returned an unknown result code.
......@@ -346,7 +352,7 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) {
346352 (void *)exception_object);
347353 unw_context_t uc;
348354 unw_cursor_t cursor;
349 unw_getcontext(&uc);
355 __unw_getcontext(&uc);
350356
351357 // Mark that this is a non-forced unwind, so _Unwind_Resume()
352358 // can do the right thing.
......@@ -380,7 +386,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) {
380386 _LIBUNWIND_TRACE_API("_Unwind_Resume(ex_obj=%p)", (void *)exception_object);
381387 unw_context_t uc;
382388 unw_cursor_t cursor;
383 unw_getcontext(&uc);
389 __unw_getcontext(&uc);
384390
385391 if (exception_object->private_1 != 0)
386392 unwind_phase2_forced(&uc, &cursor, exception_object,
......@@ -405,7 +411,7 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,
405411 (void *)exception_object, (void *)(uintptr_t)stop);
406412 unw_context_t uc;
407413 unw_cursor_t cursor;
408 unw_getcontext(&uc);
414 __unw_getcontext(&uc);
409415
410416 // Mark that this is a forced unwind, so _Unwind_Resume() can do
411417 // the right thing.
......@@ -423,7 +429,7 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) {
423429 unw_cursor_t *cursor = (unw_cursor_t *)context;
424430 unw_proc_info_t frameInfo;
425431 uintptr_t result = 0;
426 if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
432 if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
427433 result = (uintptr_t)frameInfo.lsda;
428434 _LIBUNWIND_TRACE_API(
429435 "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIxPTR,
......@@ -444,7 +450,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {
444450 unw_cursor_t *cursor = (unw_cursor_t *)context;
445451 unw_proc_info_t frameInfo;
446452 uintptr_t result = 0;
447 if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
453 if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS)
448454 result = (uintptr_t)frameInfo.start_ip;
449455 _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIxPTR,
450456 (void *)context, result);
......@@ -469,7 +475,7 @@ _LIBUNWIND_EXPORT uintptr_t
469475_Unwind_GetGR(struct _Unwind_Context *context, int index) {
470476 unw_cursor_t *cursor = (unw_cursor_t *)context;
471477 unw_word_t result;
472 unw_get_reg(cursor, index, &result);
478 __unw_get_reg(cursor, index, &result);
473479 _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d) => 0x%" PRIxPTR,
474480 (void *)context, index, result);
475481 return (uintptr_t)result;
......@@ -482,14 +488,14 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
482488 ")",
483489 (void *)context, index, value);
484490 unw_cursor_t *cursor = (unw_cursor_t *)context;
485 unw_set_reg(cursor, index, value);
491 __unw_set_reg(cursor, index, value);
486492}
487493
488494/// Called by personality handler during phase 2 to get instruction pointer.
489495_LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
490496 unw_cursor_t *cursor = (unw_cursor_t *)context;
491497 unw_word_t result;
492 unw_get_reg(cursor, UNW_REG_IP, &result);
498 __unw_get_reg(cursor, UNW_REG_IP, &result);
493499 _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIxPTR,
494500 (void *)context, result);
495501 return (uintptr_t)result;
......@@ -503,7 +509,7 @@ _LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,
503509 _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%0" PRIxPTR ")",
504510 (void *)context, value);
505511 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);
507513}
508514
509515#endif // !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
lib/libunwind/src/UnwindRegistersRestore.S+148-141
......@@ -1,9 +1,8 @@
11//===-------------------- UnwindRegistersRestore.S ------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//===----------------------------------------------------------------------===//
98
......@@ -14,7 +13,7 @@
1413#if !defined(__USING_SJLJ_EXCEPTIONS__)
1514
1615#if defined(__i386__)
17DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
16DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
1817#
1918# void libunwind::Registers_x86::jumpto()
2019#
......@@ -61,7 +60,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
6160
6261#elif defined(__x86_64__)
6362
64DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv)
63DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv)
6564#
6665# void libunwind::Registers_x86_64::jumpto()
6766#
......@@ -130,7 +129,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv)
130129
131130#elif defined(__powerpc64__)
132131
133DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv)
132DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv)
134133//
135134// void libunwind::Registers_ppc64::jumpto()
136135//
......@@ -395,120 +394,120 @@ Lnovec:
395394
396395#elif defined(__ppc__)
397396
398DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
399;
400; void libunwind::Registers_ppc::jumpto()
401;
402; On entry:
403; thread_state pointer is in r3
404;
405
406 ; restore integral registerrs
407 ; skip r0 for now
408 ; skip r1 for now
409 lwz r2, 16(r3)
410 ; skip r3 for now
411 ; skip r4 for now
412 ; skip r5 for now
413 lwz r6, 32(r3)
414 lwz r7, 36(r3)
415 lwz r8, 40(r3)
416 lwz r9, 44(r3)
417 lwz r10, 48(r3)
418 lwz r11, 52(r3)
419 lwz r12, 56(r3)
420 lwz r13, 60(r3)
421 lwz r14, 64(r3)
422 lwz r15, 68(r3)
423 lwz r16, 72(r3)
424 lwz r17, 76(r3)
425 lwz r18, 80(r3)
426 lwz r19, 84(r3)
427 lwz r20, 88(r3)
428 lwz r21, 92(r3)
429 lwz r22, 96(r3)
430 lwz r23,100(r3)
431 lwz r24,104(r3)
432 lwz r25,108(r3)
433 lwz r26,112(r3)
434 lwz r27,116(r3)
435 lwz r28,120(r3)
436 lwz r29,124(r3)
437 lwz r30,128(r3)
438 lwz r31,132(r3)
439
440 ; restore float registers
441 lfd f0, 160(r3)
442 lfd f1, 168(r3)
443 lfd f2, 176(r3)
444 lfd f3, 184(r3)
445 lfd f4, 192(r3)
446 lfd f5, 200(r3)
447 lfd f6, 208(r3)
448 lfd f7, 216(r3)
449 lfd f8, 224(r3)
450 lfd f9, 232(r3)
451 lfd f10,240(r3)
452 lfd f11,248(r3)
453 lfd f12,256(r3)
454 lfd f13,264(r3)
455 lfd f14,272(r3)
456 lfd f15,280(r3)
457 lfd f16,288(r3)
458 lfd f17,296(r3)
459 lfd f18,304(r3)
460 lfd f19,312(r3)
461 lfd f20,320(r3)
462 lfd f21,328(r3)
463 lfd f22,336(r3)
464 lfd f23,344(r3)
465 lfd f24,352(r3)
466 lfd f25,360(r3)
467 lfd f26,368(r3)
468 lfd f27,376(r3)
469 lfd f28,384(r3)
470 lfd f29,392(r3)
471 lfd f30,400(r3)
472 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
397DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
398//
399// void libunwind::Registers_ppc::jumpto()
400//
401// On entry:
402// thread_state pointer is in r3
403//
404
405 // restore integral registerrs
406 // skip r0 for now
407 // skip r1 for now
408 lwz %r2, 16(%r3)
409 // skip r3 for now
410 // skip r4 for now
411 // skip r5 for now
412 lwz %r6, 32(%r3)
413 lwz %r7, 36(%r3)
414 lwz %r8, 40(%r3)
415 lwz %r9, 44(%r3)
416 lwz %r10, 48(%r3)
417 lwz %r11, 52(%r3)
418 lwz %r12, 56(%r3)
419 lwz %r13, 60(%r3)
420 lwz %r14, 64(%r3)
421 lwz %r15, 68(%r3)
422 lwz %r16, 72(%r3)
423 lwz %r17, 76(%r3)
424 lwz %r18, 80(%r3)
425 lwz %r19, 84(%r3)
426 lwz %r20, 88(%r3)
427 lwz %r21, 92(%r3)
428 lwz %r22, 96(%r3)
429 lwz %r23,100(%r3)
430 lwz %r24,104(%r3)
431 lwz %r25,108(%r3)
432 lwz %r26,112(%r3)
433 lwz %r27,116(%r3)
434 lwz %r28,120(%r3)
435 lwz %r29,124(%r3)
436 lwz %r30,128(%r3)
437 lwz %r31,132(%r3)
438
439 // restore float registers
440 lfd %f0, 160(%r3)
441 lfd %f1, 168(%r3)
442 lfd %f2, 176(%r3)
443 lfd %f3, 184(%r3)
444 lfd %f4, 192(%r3)
445 lfd %f5, 200(%r3)
446 lfd %f6, 208(%r3)
447 lfd %f7, 216(%r3)
448 lfd %f8, 224(%r3)
449 lfd %f9, 232(%r3)
450 lfd %f10,240(%r3)
451 lfd %f11,248(%r3)
452 lfd %f12,256(%r3)
453 lfd %f13,264(%r3)
454 lfd %f14,272(%r3)
455 lfd %f15,280(%r3)
456 lfd %f16,288(%r3)
457 lfd %f17,296(%r3)
458 lfd %f18,304(%r3)
459 lfd %f19,312(%r3)
460 lfd %f20,320(%r3)
461 lfd %f21,328(%r3)
462 lfd %f22,336(%r3)
463 lfd %f23,344(%r3)
464 lfd %f24,352(%r3)
465 lfd %f25,360(%r3)
466 lfd %f26,368(%r3)
467 lfd %f27,376(%r3)
468 lfd %f28,384(%r3)
469 lfd %f29,392(%r3)
470 lfd %f30,400(%r3)
471 lfd %f31,408(%r3)
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
485484#define LOAD_VECTOR_UNALIGNEDl(_index) \
486 andis. r0,r5,(1<<(15-_index)) @\
487 beq Ldone ## _index @\
488 lwz r0, 424+_index*16(r3) @\
489 stw r0, 0(r4) @\
490 lwz r0, 424+_index*16+4(r3) @\
491 stw r0, 4(r4) @\
492 lwz r0, 424+_index*16+8(r3) @\
493 stw r0, 8(r4) @\
494 lwz r0, 424+_index*16+12(r3)@\
495 stw r0, 12(r4) @\
496 lvx v ## _index,0,r4 @\
497Ldone ## _index:
485 andis. %r0, %r5, (1<<(15-_index)) SEPARATOR \
486 beq Ldone ## _index SEPARATOR \
487 lwz %r0, 424+_index*16(%r3) SEPARATOR \
488 stw %r0, 0(%r4) SEPARATOR \
489 lwz %r0, 424+_index*16+4(%r3) SEPARATOR \
490 stw %r0, 4(%r4) SEPARATOR \
491 lwz %r0, 424+_index*16+8(%r3) SEPARATOR \
492 stw %r0, 8(%r4) SEPARATOR \
493 lwz %r0, 424+_index*16+12(%r3) SEPARATOR \
494 stw %r0, 12(%r4) SEPARATOR \
495 lvx %v ## _index, 0, %r4 SEPARATOR \
496 Ldone ## _index:
498497
499498#define LOAD_VECTOR_UNALIGNEDh(_index) \
500 andi. r0,r5,(1<<(31-_index)) @\
501 beq Ldone ## _index @\
502 lwz r0, 424+_index*16(r3) @\
503 stw r0, 0(r4) @\
504 lwz r0, 424+_index*16+4(r3) @\
505 stw r0, 4(r4) @\
506 lwz r0, 424+_index*16+8(r3) @\
507 stw r0, 8(r4) @\
508 lwz r0, 424+_index*16+12(r3)@\
509 stw r0, 12(r4) @\
510 lvx v ## _index,0,r4 @\
511 Ldone ## _index:
499 andi. %r0, %r5, (1<<(31-_index)) SEPARATOR \
500 beq Ldone ## _index SEPARATOR \
501 lwz %r0, 424+_index*16(%r3) SEPARATOR \
502 stw %r0, 0(%r4) SEPARATOR \
503 lwz %r0, 424+_index*16+4(%r3) SEPARATOR \
504 stw %r0, 4(%r4) SEPARATOR \
505 lwz %r0, 424+_index*16+8(%r3) SEPARATOR \
506 stw %r0, 8(%r4) SEPARATOR \
507 lwz %r0, 424+_index*16+12(%r3) SEPARATOR \
508 stw %r0, 12(%r4) SEPARATOR \
509 lvx %v ## _index, 0, %r4 SEPARATOR \
510 Ldone ## _index:
512511
513512
514513 LOAD_VECTOR_UNALIGNEDl(0)
......@@ -545,17 +544,17 @@ Ldone ## _index:
545544 LOAD_VECTOR_UNALIGNEDh(31)
546545
547546Lnovec:
548 lwz r0, 136(r3) ; __cr
549 mtocrf 255,r0
550 lwz r0, 148(r3) ; __ctr
551 mtctr r0
552 lwz r0, 0(r3) ; __ssr0
553 mtctr r0
554 lwz r0, 8(r3) ; do r0 now
555 lwz r5,28(r3) ; do r5 now
556 lwz r4,24(r3) ; do r4 now
557 lwz r1,12(r3) ; do sp now
558 lwz r3,20(r3) ; do r3 last
547 lwz %r0, 136(%r3) // __cr
548 mtcr %r0
549 lwz %r0, 148(%r3) // __ctr
550 mtctr %r0
551 lwz %r0, 0(%r3) // __ssr0
552 mtctr %r0
553 lwz %r0, 8(%r3) // do r0 now
554 lwz %r5, 28(%r3) // do r5 now
555 lwz %r4, 24(%r3) // do r4 now
556 lwz %r1, 12(%r3) // do sp now
557 lwz %r3, 20(%r3) // do r3 last
559558 bctr
560559
561560#elif defined(__arm64__) || defined(__aarch64__)
......@@ -567,7 +566,7 @@ Lnovec:
567566// thread_state pointer is in x0
568567//
569568 .p2align 2
570DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
569DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
571570 // skip restore of x0,x1 for now
572571 ldp x2, x3, [x0, #0x010]
573572 ldp x4, x5, [x0, #0x020]
......@@ -576,7 +575,8 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
576575 ldp x10,x11, [x0, #0x050]
577576 ldp x12,x13, [x0, #0x060]
578577 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.
580580 ldp x18,x19, [x0, #0x090]
581581 ldp x20,x21, [x0, #0x0A0]
582582 ldp x22,x23, [x0, #0x0B0]
......@@ -584,8 +584,6 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
584584 ldp x26,x27, [x0, #0x0D0]
585585 ldp x28,x29, [x0, #0x0E0]
586586 ldr x30, [x0, #0x100] // restore pc into lr
587 ldr x1, [x0, #0x0F8]
588 mov sp,x1 // restore sp
589587
590588 ldp d0, d1, [x0, #0x110]
591589 ldp d2, d3, [x0, #0x120]
......@@ -605,12 +603,21 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
605603 ldr d30, [x0, #0x200]
606604 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]
608611 ldp x0, x1, [x0, #0x000] // restore x0,x1
612 mov sp,x16 // restore sp
609613 ret x30 // jump to pc
610614
611615#elif defined(__arm__) && !defined(__APPLE__)
612616
613617#if !defined(__ARM_ARCH_ISA_ARM)
618#if (__ARM_ARCH_ISA_THUMB == 2)
619 .syntax unified
620#endif
614621 .thumb
615622#endif
616623
......@@ -621,7 +628,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
621628@ thread_state pointer is in r0
622629@
623630 .p2align 2
624DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJumpToEv)
631DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJumpToEv)
625632#if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1
626633 @ r8-r11: ldm into r1-r4, then mov to r8-r11
627634 adds r0, #0x20
......@@ -659,7 +666,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJu
659666#if defined(__ELF__)
660667 .fpu vfpv3-d16
661668#endif
662DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMDEPy)
669DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMDEPv)
663670 @ VFP and iwMMX instructions are only available when compiling with the flags
664671 @ that enable them. We do not want to do that in the library (because we do not
665672 @ want the compiler to generate instructions that access those) but this is
......@@ -680,7 +687,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFL
680687#if defined(__ELF__)
681688 .fpu vfpv3-d16
682689#endif
683DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMXEPy)
690DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMXEPv)
684691 vldmia r0, {d0-d15} @ fldmiax is deprecated in ARMv7+ and now behaves like vldmia
685692 JMP(lr)
686693
......@@ -694,7 +701,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFL
694701#if defined(__ELF__)
695702 .fpu vfpv3
696703#endif
697DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreVFPv3EPy)
704DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm12restoreVFPv3EPv)
698705 vldmia r0, {d16-d31}
699706 JMP(lr)
700707
......@@ -710,7 +717,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreVFPv3EPy)
710717#if defined(__ELF__)
711718 .arch armv5te
712719#endif
713DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPy)
720DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPv)
714721 ldcl p1, cr0, [r0], #8 @ wldrd wR0, [r0], #8
715722 ldcl p1, cr1, [r0], #8 @ wldrd wR1, [r0], #8
716723 ldcl p1, cr2, [r0], #8 @ wldrd wR2, [r0], #8
......@@ -739,7 +746,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPy)
739746#if defined(__ELF__)
740747 .arch armv5te
741748#endif
742DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXControlEPj)
749DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXControlEPj)
743750 ldc2 p1, cr8, [r0], #4 @ wldrw wCGR0, [r0], #4
744751 ldc2 p1, cr9, [r0], #4 @ wldrw wCGR1, [r0], #4
745752 ldc2 p1, cr10, [r0], #4 @ wldrw wCGR2, [r0], #4
......@@ -750,7 +757,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXCont
750757
751758#elif defined(__or1k__)
752759
753DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv)
760DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv)
754761#
755762# void libunwind::Registers_or1k::jumpto()
756763#
......@@ -809,7 +816,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv)
809816// On entry:
810817// thread state pointer is in a0 ($4)
811818//
812DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv)
819DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv)
813820 .set push
814821 .set noat
815822 .set noreorder
......@@ -918,7 +925,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv)
918925// On entry:
919926// thread state pointer is in a0 ($4)
920927//
921DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv)
928DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv)
922929 .set push
923930 .set noat
924931 .set noreorder
......@@ -1008,7 +1015,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv)
10081015// On entry:
10091016// thread_state pointer is in o0
10101017//
1011DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_sparc6jumptoEv)
1018DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_sparc6jumptoEv)
10121019 ta 3
10131020 ldd [%o0 + 64], %l0
10141021 ldd [%o0 + 72], %l2
lib/libunwind/src/UnwindRegistersSave.S+171-166
......@@ -1,9 +1,8 @@
11//===------------------------ UnwindRegistersSave.S -----------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//===----------------------------------------------------------------------===//
98
......@@ -16,7 +15,7 @@
1615#if defined(__i386__)
1716
1817#
19# extern int unw_getcontext(unw_context_t* thread_state)
18# extern int __unw_getcontext(unw_context_t* thread_state)
2019#
2120# On entry:
2221# + +
......@@ -27,7 +26,7 @@
2726# +-----------------------+ <-- SP
2827# + +
2928#
30DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
29DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
3130 push %eax
3231 movl 8(%esp), %eax
3332 movl %ebx, 4(%eax)
......@@ -57,12 +56,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
5756#elif defined(__x86_64__)
5857
5958#
60# extern int unw_getcontext(unw_context_t* thread_state)
59# extern int __unw_getcontext(unw_context_t* thread_state)
6160#
6261# On entry:
6362# thread_state pointer is in rdi
6463#
65DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
64DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
6665#if defined(_WIN64)
6766#define PTR %rcx
6867#define TMP %rdx
......@@ -119,12 +118,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
119118#elif defined(__mips__) && defined(_ABIO32) && _MIPS_SIM == _ABIO32
120119
121120#
122# extern int unw_getcontext(unw_context_t* thread_state)
121# extern int __unw_getcontext(unw_context_t* thread_state)
123122#
124123# On entry:
125124# thread_state pointer is in a0 ($4)
126125#
127DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
126DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
128127 .set push
129128 .set noat
130129 .set noreorder
......@@ -228,12 +227,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
228227#elif defined(__mips64)
229228
230229#
231# extern int unw_getcontext(unw_context_t* thread_state)
230# extern int __unw_getcontext(unw_context_t* thread_state)
232231#
233232# On entry:
234233# thread_state pointer is in a0 ($4)
235234#
236DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
235DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
237236 .set push
238237 .set noat
239238 .set noreorder
......@@ -318,21 +317,21 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
318317# elif defined(__mips__)
319318
320319#
321# extern int unw_getcontext(unw_context_t* thread_state)
320# extern int __unw_getcontext(unw_context_t* thread_state)
322321#
323322# Just trap for the time being.
324DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
323DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
325324 teq $0, $0
326325
327326#elif defined(__powerpc64__)
328327
329328//
330// extern int unw_getcontext(unw_context_t* thread_state)
329// extern int __unw_getcontext(unw_context_t* thread_state)
331330//
332331// On entry:
333332// thread_state pointer is in r3
334333//
335DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
334DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
336335
337336// store register (GPR)
338337#define PPC64_STR(n) \
......@@ -557,157 +556,157 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
557556
558557#elif defined(__ppc__)
559558
560;
561; extern int unw_getcontext(unw_context_t* thread_state)
562;
563; On entry:
564; thread_state pointer is in r3
565;
566DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
567 stw r0, 8(r3)
568 mflr r0
569 stw r0, 0(r3) ; store lr as ssr0
570 stw r1, 12(r3)
571 stw r2, 16(r3)
572 stw r3, 20(r3)
573 stw r4, 24(r3)
574 stw r5, 28(r3)
575 stw r6, 32(r3)
576 stw r7, 36(r3)
577 stw r8, 40(r3)
578 stw r9, 44(r3)
579 stw r10, 48(r3)
580 stw r11, 52(r3)
581 stw r12, 56(r3)
582 stw r13, 60(r3)
583 stw r14, 64(r3)
584 stw r15, 68(r3)
585 stw r16, 72(r3)
586 stw r17, 76(r3)
587 stw r18, 80(r3)
588 stw r19, 84(r3)
589 stw r20, 88(r3)
590 stw r21, 92(r3)
591 stw r22, 96(r3)
592 stw r23,100(r3)
593 stw r24,104(r3)
594 stw r25,108(r3)
595 stw r26,112(r3)
596 stw r27,116(r3)
597 stw r28,120(r3)
598 stw r29,124(r3)
599 stw r30,128(r3)
600 stw r31,132(r3)
601
602 ; save VRSave register
603 mfspr r0,256
604 stw r0,156(r3)
605 ; save CR registers
606 mfcr r0
607 stw r0,136(r3)
608 ; save CTR register
609 mfctr r0
610 stw r0,148(r3)
611
612 ; save float registers
613 stfd f0, 160(r3)
614 stfd f1, 168(r3)
615 stfd f2, 176(r3)
616 stfd f3, 184(r3)
617 stfd f4, 192(r3)
618 stfd f5, 200(r3)
619 stfd f6, 208(r3)
620 stfd f7, 216(r3)
621 stfd f8, 224(r3)
622 stfd f9, 232(r3)
623 stfd f10,240(r3)
624 stfd f11,248(r3)
625 stfd f12,256(r3)
626 stfd f13,264(r3)
627 stfd f14,272(r3)
628 stfd f15,280(r3)
629 stfd f16,288(r3)
630 stfd f17,296(r3)
631 stfd f18,304(r3)
632 stfd f19,312(r3)
633 stfd f20,320(r3)
634 stfd f21,328(r3)
635 stfd f22,336(r3)
636 stfd f23,344(r3)
637 stfd f24,352(r3)
638 stfd f25,360(r3)
639 stfd f26,368(r3)
640 stfd f27,376(r3)
641 stfd f28,384(r3)
642 stfd f29,392(r3)
643 stfd f30,400(r3)
644 stfd f31,408(r3)
645
646
647 ; save vector registers
648
649 subi r4,r1,16
650 rlwinm r4,r4,0,0,27 ; mask low 4-bits
651 ; r4 is now a 16-byte aligned pointer into the red zone
559//
560// extern int unw_getcontext(unw_context_t* thread_state)
561//
562// On entry:
563// thread_state pointer is in r3
564//
565DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
566 stw %r0, 8(%r3)
567 mflr %r0
568 stw %r0, 0(%r3) // store lr as ssr0
569 stw %r1, 12(%r3)
570 stw %r2, 16(%r3)
571 stw %r3, 20(%r3)
572 stw %r4, 24(%r3)
573 stw %r5, 28(%r3)
574 stw %r6, 32(%r3)
575 stw %r7, 36(%r3)
576 stw %r8, 40(%r3)
577 stw %r9, 44(%r3)
578 stw %r10, 48(%r3)
579 stw %r11, 52(%r3)
580 stw %r12, 56(%r3)
581 stw %r13, 60(%r3)
582 stw %r14, 64(%r3)
583 stw %r15, 68(%r3)
584 stw %r16, 72(%r3)
585 stw %r17, 76(%r3)
586 stw %r18, 80(%r3)
587 stw %r19, 84(%r3)
588 stw %r20, 88(%r3)
589 stw %r21, 92(%r3)
590 stw %r22, 96(%r3)
591 stw %r23,100(%r3)
592 stw %r24,104(%r3)
593 stw %r25,108(%r3)
594 stw %r26,112(%r3)
595 stw %r27,116(%r3)
596 stw %r28,120(%r3)
597 stw %r29,124(%r3)
598 stw %r30,128(%r3)
599 stw %r31,132(%r3)
600
601 // save VRSave register
602 mfspr %r0, 256
603 stw %r0, 156(%r3)
604 // save CR registers
605 mfcr %r0
606 stw %r0, 136(%r3)
607 // save CTR register
608 mfctr %r0
609 stw %r0, 148(%r3)
610
611 // save float registers
612 stfd %f0, 160(%r3)
613 stfd %f1, 168(%r3)
614 stfd %f2, 176(%r3)
615 stfd %f3, 184(%r3)
616 stfd %f4, 192(%r3)
617 stfd %f5, 200(%r3)
618 stfd %f6, 208(%r3)
619 stfd %f7, 216(%r3)
620 stfd %f8, 224(%r3)
621 stfd %f9, 232(%r3)
622 stfd %f10,240(%r3)
623 stfd %f11,248(%r3)
624 stfd %f12,256(%r3)
625 stfd %f13,264(%r3)
626 stfd %f14,272(%r3)
627 stfd %f15,280(%r3)
628 stfd %f16,288(%r3)
629 stfd %f17,296(%r3)
630 stfd %f18,304(%r3)
631 stfd %f19,312(%r3)
632 stfd %f20,320(%r3)
633 stfd %f21,328(%r3)
634 stfd %f22,336(%r3)
635 stfd %f23,344(%r3)
636 stfd %f24,352(%r3)
637 stfd %f25,360(%r3)
638 stfd %f26,368(%r3)
639 stfd %f27,376(%r3)
640 stfd %f28,384(%r3)
641 stfd %f29,392(%r3)
642 stfd %f30,400(%r3)
643 stfd %f31,408(%r3)
644
645
646 // save vector registers
647
648 subi %r4, %r1, 16
649 rlwinm %r4, %r4, 0, 0, 27 // mask low 4-bits
650 // r4 is now a 16-byte aligned pointer into the red zone
652651
653652#define SAVE_VECTOR_UNALIGNED(_vec, _offset) \
654 stvx _vec,0,r4 @\
655 lwz r5, 0(r4) @\
656 stw r5, _offset(r3) @\
657 lwz r5, 4(r4) @\
658 stw r5, _offset+4(r3) @\
659 lwz r5, 8(r4) @\
660 stw r5, _offset+8(r3) @\
661 lwz r5, 12(r4) @\
662 stw r5, _offset+12(r3)
663
664 SAVE_VECTOR_UNALIGNED( v0, 424+0x000)
665 SAVE_VECTOR_UNALIGNED( v1, 424+0x010)
666 SAVE_VECTOR_UNALIGNED( v2, 424+0x020)
667 SAVE_VECTOR_UNALIGNED( v3, 424+0x030)
668 SAVE_VECTOR_UNALIGNED( v4, 424+0x040)
669 SAVE_VECTOR_UNALIGNED( v5, 424+0x050)
670 SAVE_VECTOR_UNALIGNED( v6, 424+0x060)
671 SAVE_VECTOR_UNALIGNED( v7, 424+0x070)
672 SAVE_VECTOR_UNALIGNED( v8, 424+0x080)
673 SAVE_VECTOR_UNALIGNED( v9, 424+0x090)
674 SAVE_VECTOR_UNALIGNED(v10, 424+0x0A0)
675 SAVE_VECTOR_UNALIGNED(v11, 424+0x0B0)
676 SAVE_VECTOR_UNALIGNED(v12, 424+0x0C0)
677 SAVE_VECTOR_UNALIGNED(v13, 424+0x0D0)
678 SAVE_VECTOR_UNALIGNED(v14, 424+0x0E0)
679 SAVE_VECTOR_UNALIGNED(v15, 424+0x0F0)
680 SAVE_VECTOR_UNALIGNED(v16, 424+0x100)
681 SAVE_VECTOR_UNALIGNED(v17, 424+0x110)
682 SAVE_VECTOR_UNALIGNED(v18, 424+0x120)
683 SAVE_VECTOR_UNALIGNED(v19, 424+0x130)
684 SAVE_VECTOR_UNALIGNED(v20, 424+0x140)
685 SAVE_VECTOR_UNALIGNED(v21, 424+0x150)
686 SAVE_VECTOR_UNALIGNED(v22, 424+0x160)
687 SAVE_VECTOR_UNALIGNED(v23, 424+0x170)
688 SAVE_VECTOR_UNALIGNED(v24, 424+0x180)
689 SAVE_VECTOR_UNALIGNED(v25, 424+0x190)
690 SAVE_VECTOR_UNALIGNED(v26, 424+0x1A0)
691 SAVE_VECTOR_UNALIGNED(v27, 424+0x1B0)
692 SAVE_VECTOR_UNALIGNED(v28, 424+0x1C0)
693 SAVE_VECTOR_UNALIGNED(v29, 424+0x1D0)
694 SAVE_VECTOR_UNALIGNED(v30, 424+0x1E0)
695 SAVE_VECTOR_UNALIGNED(v31, 424+0x1F0)
696
697 li r3, 0 ; return UNW_ESUCCESS
653 stvx _vec, 0, %r4 SEPARATOR \
654 lwz %r5, 0(%r4) SEPARATOR \
655 stw %r5, _offset(%r3) SEPARATOR \
656 lwz %r5, 4(%r4) SEPARATOR \
657 stw %r5, _offset+4(%r3) SEPARATOR \
658 lwz %r5, 8(%r4) SEPARATOR \
659 stw %r5, _offset+8(%r3) SEPARATOR \
660 lwz %r5, 12(%r4) SEPARATOR \
661 stw %r5, _offset+12(%r3)
662
663 SAVE_VECTOR_UNALIGNED( %v0, 424+0x000)
664 SAVE_VECTOR_UNALIGNED( %v1, 424+0x010)
665 SAVE_VECTOR_UNALIGNED( %v2, 424+0x020)
666 SAVE_VECTOR_UNALIGNED( %v3, 424+0x030)
667 SAVE_VECTOR_UNALIGNED( %v4, 424+0x040)
668 SAVE_VECTOR_UNALIGNED( %v5, 424+0x050)
669 SAVE_VECTOR_UNALIGNED( %v6, 424+0x060)
670 SAVE_VECTOR_UNALIGNED( %v7, 424+0x070)
671 SAVE_VECTOR_UNALIGNED( %v8, 424+0x080)
672 SAVE_VECTOR_UNALIGNED( %v9, 424+0x090)
673 SAVE_VECTOR_UNALIGNED(%v10, 424+0x0A0)
674 SAVE_VECTOR_UNALIGNED(%v11, 424+0x0B0)
675 SAVE_VECTOR_UNALIGNED(%v12, 424+0x0C0)
676 SAVE_VECTOR_UNALIGNED(%v13, 424+0x0D0)
677 SAVE_VECTOR_UNALIGNED(%v14, 424+0x0E0)
678 SAVE_VECTOR_UNALIGNED(%v15, 424+0x0F0)
679 SAVE_VECTOR_UNALIGNED(%v16, 424+0x100)
680 SAVE_VECTOR_UNALIGNED(%v17, 424+0x110)
681 SAVE_VECTOR_UNALIGNED(%v18, 424+0x120)
682 SAVE_VECTOR_UNALIGNED(%v19, 424+0x130)
683 SAVE_VECTOR_UNALIGNED(%v20, 424+0x140)
684 SAVE_VECTOR_UNALIGNED(%v21, 424+0x150)
685 SAVE_VECTOR_UNALIGNED(%v22, 424+0x160)
686 SAVE_VECTOR_UNALIGNED(%v23, 424+0x170)
687 SAVE_VECTOR_UNALIGNED(%v24, 424+0x180)
688 SAVE_VECTOR_UNALIGNED(%v25, 424+0x190)
689 SAVE_VECTOR_UNALIGNED(%v26, 424+0x1A0)
690 SAVE_VECTOR_UNALIGNED(%v27, 424+0x1B0)
691 SAVE_VECTOR_UNALIGNED(%v28, 424+0x1C0)
692 SAVE_VECTOR_UNALIGNED(%v29, 424+0x1D0)
693 SAVE_VECTOR_UNALIGNED(%v30, 424+0x1E0)
694 SAVE_VECTOR_UNALIGNED(%v31, 424+0x1F0)
695
696 li %r3, 0 // return UNW_ESUCCESS
698697 blr
699698
700699
701700#elif defined(__arm64__) || defined(__aarch64__)
702701
703702//
704// extern int unw_getcontext(unw_context_t* thread_state)
703// extern int __unw_getcontext(unw_context_t* thread_state)
705704//
706705// On entry:
707706// thread_state pointer is in x0
708707//
709708 .p2align 2
710DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
709DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
711710 stp x0, x1, [x0, #0x000]
712711 stp x2, x3, [x0, #0x010]
713712 stp x4, x5, [x0, #0x020]
......@@ -751,11 +750,14 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
751750#elif defined(__arm__) && !defined(__APPLE__)
752751
753752#if !defined(__ARM_ARCH_ISA_ARM)
753#if (__ARM_ARCH_ISA_THUMB == 2)
754 .syntax unified
755#endif
754756 .thumb
755757#endif
756758
757759@
758@ extern int unw_getcontext(unw_context_t* thread_state)
760@ extern int __unw_getcontext(unw_context_t* thread_state)
759761@
760762@ On entry:
761763@ thread_state pointer is in r0
......@@ -764,10 +766,10 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
764766@ EHABI #7.4.5 notes that in general all VRS registers should be restored
765767@ however this is very hard to do for VFP registers because it is unknown
766768@ 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.
768770@
769771 .p2align 2
770DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
772DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
771773#if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1
772774 stm r0!, {r0-r7}
773775 mov r1, r8
......@@ -808,7 +810,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
808810#if defined(__ELF__)
809811 .fpu vfpv3-d16
810812#endif
811DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMDEPy)
813DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMDEPv)
812814 vstmia r0, {d0-d15}
813815 JMP(lr)
814816
......@@ -822,7 +824,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMD
822824#if defined(__ELF__)
823825 .fpu vfpv3-d16
824826#endif
825DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMXEPy)
827DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMXEPv)
826828 vstmia r0, {d0-d15} @ fstmiax is deprecated in ARMv7+ and now behaves like vstmia
827829 JMP(lr)
828830
......@@ -836,7 +838,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMX
836838#if defined(__ELF__)
837839 .fpu vfpv3
838840#endif
839DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPy)
841DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPv)
840842 @ VFP and iwMMX instructions are only available when compiling with the flags
841843 @ that enable them. We do not want to do that in the library (because we do not
842844 @ want the compiler to generate instructions that access those) but this is
......@@ -859,7 +861,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPy)
859861#if defined(__ELF__)
860862 .arch armv5te
861863#endif
862DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPy)
864DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPv)
863865 stcl p1, cr0, [r0], #8 @ wstrd wR0, [r0], #8
864866 stcl p1, cr1, [r0], #8 @ wstrd wR1, [r0], #8
865867 stcl p1, cr2, [r0], #8 @ wstrd wR2, [r0], #8
......@@ -888,7 +890,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPy)
888890#if defined(__ELF__)
889891 .arch armv5te
890892#endif
891DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj)
893DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj)
892894 stc2 p1, cr8, [r0], #4 @ wstrw wCGR0, [r0], #4
893895 stc2 p1, cr9, [r0], #4 @ wstrw wCGR1, [r0], #4
894896 stc2 p1, cr10, [r0], #4 @ wstrw wCGR2, [r0], #4
......@@ -900,12 +902,12 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControl
900902#elif defined(__or1k__)
901903
902904#
903# extern int unw_getcontext(unw_context_t* thread_state)
905# extern int __unw_getcontext(unw_context_t* thread_state)
904906#
905907# On entry:
906908# thread_state pointer is in r3
907909#
908DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
910DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
909911 l.sw 0(r3), r0
910912 l.sw 4(r3), r1
911913 l.sw 8(r3), r2
......@@ -946,12 +948,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
946948#elif defined(__sparc__)
947949
948950#
949# extern int unw_getcontext(unw_context_t* thread_state)
951# extern int __unw_getcontext(unw_context_t* thread_state)
950952#
951953# On entry:
952954# thread_state pointer is in o0
953955#
954DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
956DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
955957 ta 3
956958 add %o7, 8, %o7
957959 std %g0, [%o0 + 0]
......@@ -973,6 +975,9 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
973975 jmp %o7
974976 clr %o0 // return UNW_ESUCCESS
975977#endif
978
979 WEAK_ALIAS(__unw_getcontext, unw_getcontext)
980
976981#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */
977982
978983NO_EXEC_STACK_DIRECTIVE
lib/libunwind/src/Unwind_AppleExtras.cpp+3-4
......@@ -1,9 +1,8 @@
11//===--------------------- Unwind_AppleExtras.cpp -------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98//===----------------------------------------------------------------------===//
lib/libunwind/src/assembly.h+54-20
......@@ -1,9 +1,8 @@
11/* ===-- assembly.h - libUnwind assembler support macros -------------------===
22 *
3 * The LLVM Compiler Infrastructure
4 *
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76 *
87 * ===----------------------------------------------------------------------===
98 *
......@@ -29,14 +28,26 @@
2928#ifdef _ARCH_PWR8
3029#define PPC64_HAS_VMX
3130#endif
32#elif defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__)
33#define SEPARATOR @
3431#elif defined(__arm64__)
3532#define SEPARATOR %%
3633#else
3734#define SEPARATOR ;
3835#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
4051#define GLUE2(a, b) a ## b
4152#define GLUE(a, b) GLUE2(a, b)
4253#define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
......@@ -46,6 +57,12 @@
4657#define SYMBOL_IS_FUNC(name)
4758#define EXPORT_SYMBOL(name)
4859#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
4966#define NO_EXEC_STACK_DIRECTIVE
5067
5168#elif defined(__ELF__)
......@@ -57,6 +74,10 @@
5774#endif
5875#define EXPORT_SYMBOL(name)
5976#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
6182#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
6283 defined(__linux__)
......@@ -72,9 +93,9 @@
7293 .scl 2 SEPARATOR \
7394 .type 32 SEPARATOR \
7495 .endef
75#define EXPORT_SYMBOL2(name) \
76 .section .drectve,"yn" SEPARATOR \
77 .ascii "-export:", #name, "\0" SEPARATOR \
96#define EXPORT_SYMBOL2(name) \
97 .section .drectve,"yn" SEPARATOR \
98 .ascii "-export:", #name, "\0" SEPARATOR \
7899 .text
79100#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
80101#define EXPORT_SYMBOL(name)
......@@ -83,6 +104,23 @@
83104#endif
84105#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
86124#define NO_EXEC_STACK_DIRECTIVE
87125
88126#elif defined(__sparc__)
......@@ -93,17 +131,13 @@
93131
94132#endif
95133
96#define DEFINE_LIBUNWIND_FUNCTION(name) \
97 .globl SYMBOL_NAME(name) SEPARATOR \
98 EXPORT_SYMBOL(name) SEPARATOR \
99 SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
100 SYMBOL_NAME(name):
101
102#define DEFINE_LIBUNWIND_PRIVATE_FUNCTION(name) \
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):
134#define DEFINE_LIBUNWIND_FUNCTION(name) \
135 .globl SYMBOL_NAME(name) SEPARATOR \
136 HIDDEN_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \
137 SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
138 PPC64_OPD1 \
139 SYMBOL_NAME(name): \
140 PPC64_OPD2
107141
108142#if defined(__arm__)
109143#if !defined(__ARM_ARCH)
lib/libunwind/src/config.h+32-4
......@@ -1,9 +1,8 @@
11//===----------------------------- config.h -------------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Defines macros used within libunwind project.
......@@ -63,6 +62,35 @@
6362 #endif
6463#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
6694#if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__)
6795#define _LIBUNWIND_BUILD_SJLJ_APIS
6896#endif
lib/libunwind/src/dwarf2.h+3-4
......@@ -1,9 +1,8 @@
11//===------------------------------- dwarf2.h -----------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//===----------------------------------------------------------------------===//
98
lib/libunwind/src/libunwind.cpp+64-150
......@@ -1,9 +1,8 @@
11//===--------------------------- libunwind.cpp ----------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Implements unw_* functions from <libunwind.h>
......@@ -12,12 +11,6 @@
1211
1312#include <libunwind.h>
1413
15#ifndef NDEBUG
16#include <cstdlib> // getenv
17#endif
18#include <new>
19#include <algorithm>
20
2114#include "libunwind_ext.h"
2215#include "config.h"
2316
......@@ -36,15 +29,11 @@ LocalAddressSpace LocalAddressSpace::sThisAddressSpace;
3629_LIBUNWIND_EXPORT unw_addr_space_t unw_local_addr_space =
3730 (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
4332/// Create a cursor of a thread in this process given 'context' recorded by
44/// unw_getcontext().
45_LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cursor,
46 unw_context_t *context) {
47 _LIBUNWIND_TRACE_API("unw_init_local(cursor=%p, context=%p)",
33/// __unw_getcontext().
34_LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor,
35 unw_context_t *context) {
36 _LIBUNWIND_TRACE_API("__unw_init_local(cursor=%p, context=%p)",
4837 static_cast<void *>(cursor),
4938 static_cast<void *>(context));
5039#if defined(__i386__)
......@@ -73,101 +62,21 @@ _LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cursor,
7362# error Architecture not supported
7463#endif
7564 // Use "placement new" to allocate UnwindCursor in the cursor buffer.
76 new ((void *)cursor) UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
77 context, LocalAddressSpace::sThisAddressSpace);
65 new (reinterpret_cast<UnwindCursor<LocalAddressSpace, REGISTER_KIND> *>(cursor))
66 UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
67 context, LocalAddressSpace::sThisAddressSpace);
7868#undef REGISTER_KIND
7969 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
8070 co->setInfoBasedOnIPRegister();
8171
8272 return UNW_ESUCCESS;
8373}
84
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
74_LIBUNWIND_WEAK_ALIAS(__unw_init_local, unw_init_local)
16675
16776/// 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,
169 unw_word_t *value) {
170 _LIBUNWIND_TRACE_API("unw_get_reg(cursor=%p, regNum=%d, &value=%p)",
77_LIBUNWIND_HIDDEN int __unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
78 unw_word_t *value) {
79 _LIBUNWIND_TRACE_API("__unw_get_reg(cursor=%p, regNum=%d, &value=%p)",
17180 static_cast<void *>(cursor), regNum,
17281 static_cast<void *>(value));
17382 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
......@@ -177,12 +86,13 @@ _LIBUNWIND_EXPORT int unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
17786 }
17887 return UNW_EBADREG;
17988}
180
89_LIBUNWIND_WEAK_ALIAS(__unw_get_reg, unw_get_reg)
18190
18291/// 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,
184 unw_word_t value) {
185 _LIBUNWIND_TRACE_API("unw_set_reg(cursor=%p, regNum=%d, value=0x%" PRIxPTR ")",
92_LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
93 unw_word_t value) {
94 _LIBUNWIND_TRACE_API("__unw_set_reg(cursor=%p, regNum=%d, value=0x%" PRIxPTR
95 ")",
18696 static_cast<void *>(cursor), regNum, value);
18797 typedef LocalAddressSpace::pint_t pint_t;
18898 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
......@@ -208,12 +118,12 @@ _LIBUNWIND_EXPORT int unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
208118 }
209119 return UNW_EBADREG;
210120}
211
121_LIBUNWIND_WEAK_ALIAS(__unw_set_reg, unw_set_reg)
212122
213123/// 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,
215 unw_fpreg_t *value) {
216 _LIBUNWIND_TRACE_API("unw_get_fpreg(cursor=%p, regNum=%d, &value=%p)",
124_LIBUNWIND_HIDDEN int __unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
125 unw_fpreg_t *value) {
126 _LIBUNWIND_TRACE_API("__unw_get_fpreg(cursor=%p, regNum=%d, &value=%p)",
217127 static_cast<void *>(cursor), regNum,
218128 static_cast<void *>(value));
219129 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
......@@ -223,16 +133,16 @@ _LIBUNWIND_EXPORT int unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
223133 }
224134 return UNW_EBADREG;
225135}
226
136_LIBUNWIND_WEAK_ALIAS(__unw_get_fpreg, unw_get_fpreg)
227137
228138/// 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,
230 unw_fpreg_t value) {
139_LIBUNWIND_HIDDEN int __unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
140 unw_fpreg_t value) {
231141#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)",
233143 static_cast<void *>(cursor), regNum, value);
234144#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)",
236146 static_cast<void *>(cursor), regNum, value);
237147#endif
238148 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
......@@ -242,20 +152,20 @@ _LIBUNWIND_EXPORT int unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
242152 }
243153 return UNW_EBADREG;
244154}
245
155_LIBUNWIND_WEAK_ALIAS(__unw_set_fpreg, unw_set_fpreg)
246156
247157/// Move cursor to next frame.
248_LIBUNWIND_EXPORT int unw_step(unw_cursor_t *cursor) {
249 _LIBUNWIND_TRACE_API("unw_step(cursor=%p)", static_cast<void *>(cursor));
158_LIBUNWIND_HIDDEN int __unw_step(unw_cursor_t *cursor) {
159 _LIBUNWIND_TRACE_API("__unw_step(cursor=%p)", static_cast<void *>(cursor));
250160 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
251161 return co->step();
252162}
253
163_LIBUNWIND_WEAK_ALIAS(__unw_step, unw_step)
254164
255165/// Get unwind info at cursor position in stack frame.
256_LIBUNWIND_EXPORT int unw_get_proc_info(unw_cursor_t *cursor,
257 unw_proc_info_t *info) {
258 _LIBUNWIND_TRACE_API("unw_get_proc_info(cursor=%p, &info=%p)",
166_LIBUNWIND_HIDDEN int __unw_get_proc_info(unw_cursor_t *cursor,
167 unw_proc_info_t *info) {
168 _LIBUNWIND_TRACE_API("__unw_get_proc_info(cursor=%p, &info=%p)",
259169 static_cast<void *>(cursor), static_cast<void *>(info));
260170 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
261171 co->getInfo(info);
......@@ -264,21 +174,21 @@ _LIBUNWIND_EXPORT int unw_get_proc_info(unw_cursor_t *cursor,
264174 else
265175 return UNW_ESUCCESS;
266176}
267
177_LIBUNWIND_WEAK_ALIAS(__unw_get_proc_info, unw_get_proc_info)
268178
269179/// Resume execution at cursor position (aka longjump).
270_LIBUNWIND_EXPORT int unw_resume(unw_cursor_t *cursor) {
271 _LIBUNWIND_TRACE_API("unw_resume(cursor=%p)", static_cast<void *>(cursor));
180_LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
181 _LIBUNWIND_TRACE_API("__unw_resume(cursor=%p)", static_cast<void *>(cursor));
272182 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
273183 co->jumpto();
274184 return UNW_EUNSPEC;
275185}
276
186_LIBUNWIND_WEAK_ALIAS(__unw_resume, unw_resume)
277187
278188/// Get name of function at cursor position in stack frame.
279_LIBUNWIND_EXPORT int unw_get_proc_name(unw_cursor_t *cursor, char *buf,
280 size_t bufLen, unw_word_t *offset) {
281 _LIBUNWIND_TRACE_API("unw_get_proc_name(cursor=%p, &buf=%p, bufLen=%lu)",
189_LIBUNWIND_HIDDEN int __unw_get_proc_name(unw_cursor_t *cursor, char *buf,
190 size_t bufLen, unw_word_t *offset) {
191 _LIBUNWIND_TRACE_API("__unw_get_proc_name(cursor=%p, &buf=%p, bufLen=%lu)",
282192 static_cast<void *>(cursor), static_cast<void *>(buf),
283193 static_cast<unsigned long>(bufLen));
284194 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
......@@ -287,58 +197,62 @@ _LIBUNWIND_EXPORT int unw_get_proc_name(unw_cursor_t *cursor, char *buf,
287197 else
288198 return UNW_EUNSPEC;
289199}
290
200_LIBUNWIND_WEAK_ALIAS(__unw_get_proc_name, unw_get_proc_name)
291201
292202/// Checks if a register is a floating-point register.
293_LIBUNWIND_EXPORT int unw_is_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum) {
294 _LIBUNWIND_TRACE_API("unw_is_fpreg(cursor=%p, regNum=%d)",
203_LIBUNWIND_HIDDEN int __unw_is_fpreg(unw_cursor_t *cursor,
204 unw_regnum_t regNum) {
205 _LIBUNWIND_TRACE_API("__unw_is_fpreg(cursor=%p, regNum=%d)",
295206 static_cast<void *>(cursor), regNum);
296207 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
297208 return co->validFloatReg(regNum);
298209}
299
210_LIBUNWIND_WEAK_ALIAS(__unw_is_fpreg, unw_is_fpreg)
300211
301212/// Checks if a register is a floating-point register.
302_LIBUNWIND_EXPORT const char *unw_regname(unw_cursor_t *cursor,
303 unw_regnum_t regNum) {
304 _LIBUNWIND_TRACE_API("unw_regname(cursor=%p, regNum=%d)",
213_LIBUNWIND_HIDDEN const char *__unw_regname(unw_cursor_t *cursor,
214 unw_regnum_t regNum) {
215 _LIBUNWIND_TRACE_API("__unw_regname(cursor=%p, regNum=%d)",
305216 static_cast<void *>(cursor), regNum);
306217 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
307218 return co->getRegisterName(regNum);
308219}
309
220_LIBUNWIND_WEAK_ALIAS(__unw_regname, unw_regname)
310221
311222/// Checks if current frame is signal trampoline.
312_LIBUNWIND_EXPORT int unw_is_signal_frame(unw_cursor_t *cursor) {
313 _LIBUNWIND_TRACE_API("unw_is_signal_frame(cursor=%p)",
223_LIBUNWIND_HIDDEN int __unw_is_signal_frame(unw_cursor_t *cursor) {
224 _LIBUNWIND_TRACE_API("__unw_is_signal_frame(cursor=%p)",
314225 static_cast<void *>(cursor));
315226 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
316227 return co->isSignalFrame();
317228}
229_LIBUNWIND_WEAK_ALIAS(__unw_is_signal_frame, unw_is_signal_frame)
318230
319231#ifdef __arm__
320232// Save VFP registers d0-d15 using FSTMIADX instead of FSTMIADD
321_LIBUNWIND_EXPORT void unw_save_vfp_as_X(unw_cursor_t *cursor) {
322 _LIBUNWIND_TRACE_API("unw_fpreg_save_vfp_as_X(cursor=%p)",
233_LIBUNWIND_HIDDEN void __unw_save_vfp_as_X(unw_cursor_t *cursor) {
234 _LIBUNWIND_TRACE_API("__unw_get_fpreg_save_vfp_as_X(cursor=%p)",
323235 static_cast<void *>(cursor));
324236 AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
325237 return co->saveVFPAsX();
326238}
239_LIBUNWIND_WEAK_ALIAS(__unw_save_vfp_as_X, unw_save_vfp_as_X)
327240#endif
328241
329242
330243#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
331244/// 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)(
333246 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)",
335248 reinterpret_cast<void *>(func));
336249 DwarfFDECache<LocalAddressSpace>::iterateCacheEntries(func);
337250}
338
251_LIBUNWIND_WEAK_ALIAS(__unw_iterate_dwarf_unwind_cache,
252 unw_iterate_dwarf_unwind_cache)
339253
340254/// IPI: for __register_frame()
341void _unw_add_dynamic_fde(unw_word_t fde) {
255void __unw_add_dynamic_fde(unw_word_t fde) {
342256 CFI_Parser<LocalAddressSpace>::FDE_Info fdeInfo;
343257 CFI_Parser<LocalAddressSpace>::CIE_Info cieInfo;
344258 const char *message = CFI_Parser<LocalAddressSpace>::decodeFDE(
......@@ -352,12 +266,12 @@ void _unw_add_dynamic_fde(unw_word_t fde) {
352266 fdeInfo.pcStart, fdeInfo.pcEnd,
353267 fdeInfo.fdeStart);
354268 } 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);
356270 }
357271}
358272
359273/// IPI: for __deregister_frame()
360void _unw_remove_dynamic_fde(unw_word_t fde) {
274void __unw_remove_dynamic_fde(unw_word_t fde) {
361275 // fde is own mh_group
362276 DwarfFDECache<LocalAddressSpace>::removeAllIn((LocalAddressSpace::pint_t)fde);
363277}
lib/libunwind/src/libunwind_ext.h+28-10
......@@ -1,9 +1,8 @@
11//===------------------------ libunwind_ext.h -----------------------------===//
22//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
76//
87//
98// Extensions to libunwind API.
......@@ -23,15 +22,34 @@
2322#ifdef __cplusplus
2423extern "C" {
2524#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
2646// SPI
27extern void unw_iterate_dwarf_unwind_cache(void (*func)(unw_word_t ip_start,
28 unw_word_t ip_end,
29 unw_word_t fde,
30 unw_word_t mh));
47extern void __unw_iterate_dwarf_unwind_cache(void (*func)(
48 unw_word_t ip_start, unw_word_t ip_end, unw_word_t fde, unw_word_t mh));
3149
3250// IPI
33extern void _unw_add_dynamic_fde(unw_word_t fde);
34extern void _unw_remove_dynamic_fde(unw_word_t fde);
51extern void __unw_add_dynamic_fde(unw_word_t fde);
52extern void __unw_remove_dynamic_fde(unw_word_t fde);
3553
3654#if defined(_LIBUNWIND_ARM_EHABI)
3755extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*);