| author | |
| committer | |
| log | dab0cf6428d96af540399563f2e2d5a79c3a7d5e |
| tree | a2f005a5b62a49de15b00d78455f24663a1848c0 |
| parent | 2117fbdae35dddf368c4ce5bb39cc73fa0f78d4c |
| signature |
upstream commit 1931d3cb20a00da732c5210b123656632982fde027 files changed, 1242 insertions(+), 964 deletions(-)
lib/libunwind/LICENSE.TXT created+311| ... | ... | @@ -0,0 +1,311 @@ |
| 1 | ============================================================================== | |
| 2 | The 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 | ||
| 210 | As an exception, if, as a result of your compiling your source code, portions | |
| 211 | of this Software are embedded into an Object form of such source code, you | |
| 212 | may redistribute such embedded portions in such Object form without complying | |
| 213 | with the conditions of Sections 4(a), 4(b) and 4(d) of the License. | |
| 214 | ||
| 215 | In addition, if you combine or link compiled forms of this Software with | |
| 216 | software that is licensed under the GPLv2 ("Combined Software") and if a | |
| 217 | court of competent jurisdiction determines that the patent provision (Section | |
| 218 | 3), the indemnity provision (Section 9) or other Section of the License | |
| 219 | conflicts with the conditions of the GPLv2, you may retroactively and | |
| 220 | prospectively choose to deem waived or otherwise exclude such Section(s) of | |
| 221 | the License, but only in their entirety and only with respect to the Combined | |
| 222 | Software. | |
| 223 | ||
| 224 | ============================================================================== | |
| 225 | Software from third parties included in the LLVM Project: | |
| 226 | ============================================================================== | |
| 227 | The LLVM Project contains third party software which is under different license | |
| 228 | terms. All such code will be identified clearly using at least one of two | |
| 229 | mechanisms: | |
| 230 | 1) 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 | |
| 233 | 2) It will contain specific license and restriction terms at the top of every | |
| 234 | file. | |
| 235 | ||
| 236 | ============================================================================== | |
| 237 | Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): | |
| 238 | ============================================================================== | |
| 239 | ||
| 240 | The 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 | |
| 242 | to use it under either license. As a contributor, you agree to allow your code | |
| 243 | to be used under both. | |
| 244 | ||
| 245 | Full text of the relevant licenses is included below. | |
| 246 | ||
| 247 | ============================================================================== | |
| 248 | ||
| 249 | University of Illinois/NCSA | |
| 250 | Open Source License | |
| 251 | ||
| 252 | Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT | |
| 253 | ||
| 254 | All rights reserved. | |
| 255 | ||
| 256 | Developed by: | |
| 257 | ||
| 258 | LLVM Team | |
| 259 | ||
| 260 | University of Illinois at Urbana-Champaign | |
| 261 | ||
| 262 | http://llvm.org | |
| 263 | ||
| 264 | Permission is hereby granted, free of charge, to any person obtaining a copy of | |
| 265 | this software and associated documentation files (the "Software"), to deal with | |
| 266 | the Software without restriction, including without limitation the rights to | |
| 267 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | |
| 268 | of the Software, and to permit persons to whom the Software is furnished to do | |
| 269 | so, 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 | ||
| 283 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 284 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | |
| 285 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 286 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 287 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 288 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE | |
| 289 | SOFTWARE. | |
| 290 | ||
| 291 | ============================================================================== | |
| 292 | ||
| 293 | Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT | |
| 294 | ||
| 295 | Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 296 | of this software and associated documentation files (the "Software"), to deal | |
| 297 | in the Software without restriction, including without limitation the rights | |
| 298 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 299 | copies of the Software, and to permit persons to whom the Software is | |
| 300 | furnished to do so, subject to the following conditions: | |
| 301 | ||
| 302 | The above copyright notice and this permission notice shall be included in | |
| 303 | all copies or substantial portions of the Software. | |
| 304 | ||
| 305 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 306 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 307 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 308 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 309 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 310 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 311 | THE SOFTWARE. |
lib/libunwind/include/__libunwind_config.h+3-4| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===------------------------- __libunwind_config.h -----------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | //===----------------------------------------------------------------------===// |
| 9 | 8 |
lib/libunwind/include/libunwind.h+4-31| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===---------------------------- libunwind.h -----------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Compatible with libunwind API documented at: |
| ... | ... | @@ -76,7 +75,7 @@ typedef struct unw_addr_space *unw_addr_space_t; |
| 76 | 75 | |
| 77 | 76 | typedef int unw_regnum_t; |
| 78 | 77 | typedef uintptr_t unw_word_t; |
| 79 | #if defined(__arm__) | |
| 78 | #if defined(__arm__) && !defined(__ARM_DWARF_EH__) | |
| 80 | 79 | typedef uint64_t unw_fpreg_t; |
| 81 | 80 | #else |
| 82 | 81 | typedef double unw_fpreg_t; |
| ... | ... | @@ -125,32 +124,6 @@ extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUN |
| 125 | 124 | |
| 126 | 125 | extern unw_addr_space_t unw_local_addr_space; |
| 127 | 126 | |
| 128 | #ifdef UNW_REMOTE | |
| 129 | /* | |
| 130 | * Mac OS X "remote" API for unwinding other processes on same machine | |
| 131 | * | |
| 132 | */ | |
| 133 | extern unw_addr_space_t unw_create_addr_space_for_task(task_t); | |
| 134 | extern void unw_destroy_addr_space(unw_addr_space_t); | |
| 135 | extern int unw_init_remote_thread(unw_cursor_t *, unw_addr_space_t, thread_t *); | |
| 136 | #endif /* UNW_REMOTE */ | |
| 137 | ||
| 138 | /* | |
| 139 | * traditional libunwind "remote" API | |
| 140 | * NOT IMPLEMENTED on Mac OS X | |
| 141 | * | |
| 142 | * extern int unw_init_remote(unw_cursor_t*, unw_addr_space_t, | |
| 143 | * thread_t*); | |
| 144 | * extern unw_accessors_t unw_get_accessors(unw_addr_space_t); | |
| 145 | * extern unw_addr_space_t unw_create_addr_space(unw_accessors_t, int); | |
| 146 | * extern void unw_flush_cache(unw_addr_space_t, unw_word_t, | |
| 147 | * unw_word_t); | |
| 148 | * extern int unw_set_caching_policy(unw_addr_space_t, | |
| 149 | * unw_caching_policy_t); | |
| 150 | * extern void _U_dyn_register(unw_dyn_info_t*); | |
| 151 | * extern void _U_dyn_cancel(unw_dyn_info_t*); | |
| 152 | */ | |
| 153 | ||
| 154 | 127 | #ifdef __cplusplus |
| 155 | 128 | } |
| 156 | 129 | #endif |
lib/libunwind/include/mach-o/compact_unwind_encoding.h+3-4| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===------------------ mach-o/compact_unwind_encoding.h ------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Darwin's alternative to DWARF based unwind encodings. |
lib/libunwind/include/unwind.h+4-5| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | 1 | //===------------------------------- unwind.h -----------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // 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 | |
| 11 | 10 | // |
| 12 | 11 | //===----------------------------------------------------------------------===// |
| 13 | 12 |
lib/libunwind/src/AddressSpace.hpp+13-136| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===------------------------- AddressSpace.hpp ---------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Abstracts accessing local vs remote address spaces. |
| ... | ... | @@ -28,6 +27,9 @@ |
| 28 | 27 | |
| 29 | 28 | #if _LIBUNWIND_USE_DLADDR |
| 30 | 29 | #include <dlfcn.h> |
| 30 | #if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA) | |
| 31 | #pragma comment(lib, "dl") | |
| 32 | #endif | |
| 31 | 33 | #endif |
| 32 | 34 | |
| 33 | 35 | #ifdef __APPLE__ |
| ... | ... | @@ -457,6 +459,8 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, |
| 457 | 459 | #elif defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32) |
| 458 | 460 | // Don't even bother, since Windows has functions that do all this stuff |
| 459 | 461 | // for us. |
| 462 | (void)targetAddr; | |
| 463 | (void)info; | |
| 460 | 464 | return true; |
| 461 | 465 | #elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__) && \ |
| 462 | 466 | (__ANDROID_API__ < 21) |
| ... | ... | @@ -597,142 +601,15 @@ inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf, |
| 597 | 601 | return true; |
| 598 | 602 | } |
| 599 | 603 | } |
| 604 | #else | |
| 605 | (void)addr; | |
| 606 | (void)buf; | |
| 607 | (void)bufLen; | |
| 608 | (void)offset; | |
| 600 | 609 | #endif |
| 601 | 610 | return false; |
| 602 | 611 | } |
| 603 | 612 | |
| 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. | |
| 612 | template <typename P> | |
| 613 | class RemoteAddressSpace { | |
| 614 | public: | |
| 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); | |
| 633 | private: | |
| 634 | void *localCopy(pint_t addr); | |
| 635 | ||
| 636 | task_t fTask; | |
| 637 | }; | |
| 638 | ||
| 639 | template <typename P> uint8_t RemoteAddressSpace<P>::get8(pint_t addr) { | |
| 640 | return *((uint8_t *)localCopy(addr)); | |
| 641 | } | |
| 642 | ||
| 643 | template <typename P> uint16_t RemoteAddressSpace<P>::get16(pint_t addr) { | |
| 644 | return P::E::get16(*(uint16_t *)localCopy(addr)); | |
| 645 | } | |
| 646 | ||
| 647 | template <typename P> uint32_t RemoteAddressSpace<P>::get32(pint_t addr) { | |
| 648 | return P::E::get32(*(uint32_t *)localCopy(addr)); | |
| 649 | } | |
| 650 | ||
| 651 | template <typename P> uint64_t RemoteAddressSpace<P>::get64(pint_t addr) { | |
| 652 | return P::E::get64(*(uint64_t *)localCopy(addr)); | |
| 653 | } | |
| 654 | ||
| 655 | template <typename P> | |
| 656 | typename P::uint_t RemoteAddressSpace<P>::getP(pint_t addr) { | |
| 657 | return P::getP(*(uint64_t *)localCopy(addr)); | |
| 658 | } | |
| 659 | ||
| 660 | template <typename P> | |
| 661 | typename P::uint_t OtherAddressSpace<P>::getRegister(pint_t addr) { | |
| 662 | return P::getRegister(*(uint64_t *)localCopy(addr)); | |
| 663 | } | |
| 664 | ||
| 665 | template <typename P> | |
| 666 | uint64_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 | ||
| 675 | template <typename P> | |
| 676 | int64_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 | ||
| 685 | template <typename P> void *RemoteAddressSpace<P>::localCopy(pint_t addr) { | |
| 686 | // FIX ME | |
| 687 | } | |
| 688 | ||
| 689 | template <typename P> | |
| 690 | bool 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. | |
| 698 | struct 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. | |
| 706 | struct 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. | |
| 714 | struct 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. | |
| 722 | struct 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. | |
| 729 | struct unw_addr_space_ppc64 : public unw_addr_space { | |
| 730 | unw_addr_space_ppc64(task_t task) : oas(task) {} | |
| 731 | RemoteAddressSpace<Pointer64<LittleEndian>> oas; | |
| 732 | }; | |
| 733 | ||
| 734 | #endif // UNW_REMOTE | |
| 735 | ||
| 736 | 613 | } // namespace libunwind |
| 737 | 614 | |
| 738 | 615 | #endif // __ADDRESSSPACE_HPP__ |
lib/libunwind/src/CompactUnwinder.hpp+3-4| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===-------------------------- CompactUnwinder.hpp -----------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Does runtime stack unwinding using compact unwind encodings. |
lib/libunwind/src/DwarfInstructions.hpp+31-8| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===-------------------------- DwarfInstructions.hpp ---------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Processor specific interpretation of DWARF unwind info. |
| ... | ... | @@ -82,12 +81,11 @@ typename A::pint_t DwarfInstructions<A, R>::getSavedRegister( |
| 82 | 81 | const RegisterLocation &savedReg) { |
| 83 | 82 | switch (savedReg.location) { |
| 84 | 83 | case CFI_Parser<A>::kRegisterInCFA: |
| 85 | return addressSpace.getRegister(cfa + (pint_t)savedReg.value); | |
| 84 | return (pint_t)addressSpace.getRegister(cfa + (pint_t)savedReg.value); | |
| 86 | 85 | |
| 87 | 86 | 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)); | |
| 91 | 89 | |
| 92 | 90 | case CFI_Parser<A>::kRegisterIsExpression: |
| 93 | 91 | return evaluateExpression((pint_t)savedReg.value, addressSpace, |
| ... | ... | @@ -234,6 +232,31 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc, |
| 234 | 232 | } |
| 235 | 233 | #endif |
| 236 | 234 | |
| 235 | #if defined(_LIBUNWIND_TARGET_PPC64) | |
| 236 | #define PPC64_ELFV1_R2_LOAD_INST_ENCODING 0xe8410028u // ld r2,40(r1) | |
| 237 | #define PPC64_ELFV1_R2_OFFSET 40 | |
| 238 | #define PPC64_ELFV2_R2_LOAD_INST_ENCODING 0xe8410018u // ld r2,24(r1) | |
| 239 | #define PPC64_ELFV2_R2_OFFSET 24 | |
| 240 | // If the instruction at return address is a TOC (r2) restore, | |
| 241 | // then r2 was saved and needs to be restored. | |
| 242 | // ELFv2 ABI specifies that the TOC Pointer must be saved at SP + 24, | |
| 243 | // while in ELFv1 ABI it is saved at SP + 40. | |
| 244 | if (R::getArch() == REGISTERS_PPC64 && returnAddress != 0) { | |
| 245 | pint_t sp = newRegisters.getRegister(UNW_REG_SP); | |
| 246 | pint_t r2 = 0; | |
| 247 | switch (addressSpace.get32(returnAddress)) { | |
| 248 | case PPC64_ELFV1_R2_LOAD_INST_ENCODING: | |
| 249 | r2 = addressSpace.get64(sp + PPC64_ELFV1_R2_OFFSET); | |
| 250 | break; | |
| 251 | case PPC64_ELFV2_R2_LOAD_INST_ENCODING: | |
| 252 | r2 = addressSpace.get64(sp + PPC64_ELFV2_R2_OFFSET); | |
| 253 | break; | |
| 254 | } | |
| 255 | if (r2) | |
| 256 | newRegisters.setRegister(UNW_PPC64_R2, r2); | |
| 257 | } | |
| 258 | #endif | |
| 259 | ||
| 237 | 260 | // Return address is address after call site instruction, so setting IP to |
| 238 | 261 | // that does simualates a return. |
| 239 | 262 | newRegisters.setIP(returnAddress); |
lib/libunwind/src/DwarfParser.hpp+3-4| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===--------------------------- DwarfParser.hpp --------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Parses DWARF CFIs (FDEs and CIEs). |
lib/libunwind/src/EHHeaderParser.hpp+3-4| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===------------------------- EHHeaderParser.hpp -------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Parses ELF .eh_frame_hdr sections. |
lib/libunwind/src/RWMutex.hpp+43-6| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===----------------------------- Registers.hpp --------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Abstract interface to shared reader/writer log, hiding platform and |
| ... | ... | @@ -18,6 +17,9 @@ |
| 18 | 17 | #include <windows.h> |
| 19 | 18 | #elif !defined(_LIBUNWIND_HAS_NO_THREADS) |
| 20 | 19 | #include <pthread.h> |
| 20 | #if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA) | |
| 21 | #pragma comment(lib, "pthread") | |
| 22 | #endif | |
| 21 | 23 | #endif |
| 22 | 24 | |
| 23 | 25 | namespace libunwind { |
| ... | ... | @@ -57,11 +59,11 @@ private: |
| 57 | 59 | SRWLOCK _lock = SRWLOCK_INIT; |
| 58 | 60 | }; |
| 59 | 61 | |
| 60 | #else | |
| 62 | #elif !defined(LIBUNWIND_USE_WEAK_PTHREAD) | |
| 61 | 63 | |
| 62 | 64 | class _LIBUNWIND_HIDDEN RWMutex { |
| 63 | 65 | public: |
| 64 | bool lock_shared() { return pthread_rwlock_rdlock(&_lock) == 0; } | |
| 66 | bool lock_shared() { return pthread_rwlock_rdlock(&_lock) == 0; } | |
| 65 | 67 | bool unlock_shared() { return pthread_rwlock_unlock(&_lock) == 0; } |
| 66 | 68 | bool lock() { return pthread_rwlock_wrlock(&_lock) == 0; } |
| 67 | 69 | bool unlock() { return pthread_rwlock_unlock(&_lock) == 0; } |
| ... | ... | @@ -70,6 +72,41 @@ private: |
| 70 | 72 | pthread_rwlock_t _lock = PTHREAD_RWLOCK_INITIALIZER; |
| 71 | 73 | }; |
| 72 | 74 | |
| 75 | #else | |
| 76 | ||
| 77 | extern "C" int __attribute__((weak)) | |
| 78 | pthread_create(pthread_t *thread, const pthread_attr_t *attr, | |
| 79 | void *(*start_routine)(void *), void *arg); | |
| 80 | extern "C" int __attribute__((weak)) | |
| 81 | pthread_rwlock_rdlock(pthread_rwlock_t *lock); | |
| 82 | extern "C" int __attribute__((weak)) | |
| 83 | pthread_rwlock_wrlock(pthread_rwlock_t *lock); | |
| 84 | extern "C" int __attribute__((weak)) | |
| 85 | pthread_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 | ||
| 91 | class _LIBUNWIND_HIDDEN RWMutex { | |
| 92 | public: | |
| 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 | ||
| 106 | private: | |
| 107 | pthread_rwlock_t _lock = PTHREAD_RWLOCK_INITIALIZER; | |
| 108 | }; | |
| 109 | ||
| 73 | 110 | #endif |
| 74 | 111 | |
| 75 | 112 | } // namespace libunwind |
lib/libunwind/src/Registers.hpp+13-14| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===----------------------------- Registers.hpp --------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Models register sets for supported processors. |
| ... | ... | @@ -2104,16 +2103,16 @@ private: |
| 2104 | 2103 | uint32_t __pc; // Program counter r15 |
| 2105 | 2104 | }; |
| 2106 | 2105 | |
| 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*); | |
| 2113 | 2112 | #if defined(__ARM_WMMX) |
| 2114 | static void saveiWMMX(unw_fpreg_t*); | |
| 2113 | static void saveiWMMX(void*); | |
| 2115 | 2114 | static void saveiWMMXControl(uint32_t*); |
| 2116 | static void restoreiWMMX(unw_fpreg_t*); | |
| 2115 | static void restoreiWMMX(void*); | |
| 2117 | 2116 | static void restoreiWMMXControl(uint32_t*); |
| 2118 | 2117 | #endif |
| 2119 | 2118 | void restoreCoreAndJumpTo(); |
| ... | ... | @@ -2155,7 +2154,7 @@ inline Registers_arm::Registers_arm(const void *registers) |
| 2155 | 2154 | _saved_vfp_d16_d31(false) { |
| 2156 | 2155 | static_assert((check_fit<Registers_arm, unw_context_t>::does_fit), |
| 2157 | 2156 | "arm registers do not fit into unw_context_t"); |
| 2158 | // See unw_getcontext() note about data. | |
| 2157 | // See __unw_getcontext() note about data. | |
| 2159 | 2158 | memcpy(&_registers, registers, sizeof(_registers)); |
| 2160 | 2159 | memset(&_vfp_d0_d15_pad, 0, sizeof(_vfp_d0_d15_pad)); |
| 2161 | 2160 | memset(&_vfp_d16_d31, 0, sizeof(_vfp_d16_d31)); |
| ... | ... | @@ -2434,7 +2433,7 @@ inline const char *Registers_arm::getRegisterName(int regNum) { |
| 2434 | 2433 | |
| 2435 | 2434 | inline bool Registers_arm::validFloatRegister(int regNum) const { |
| 2436 | 2435 | // NOTE: Consider the intel MMX registers floating points so the |
| 2437 | // unw_get_fpreg can be used to transmit the 64-bit data back. | |
| 2436 | // __unw_get_fpreg can be used to transmit the 64-bit data back. | |
| 2438 | 2437 | return ((regNum >= UNW_ARM_D0) && (regNum <= UNW_ARM_D31)) |
| 2439 | 2438 | #if defined(__ARM_WMMX) |
| 2440 | 2439 | || ((regNum >= UNW_ARM_WR0) && (regNum <= UNW_ARM_WR15)) |
lib/libunwind/src/Unwind-EHABI.cpp+56-53| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===--------------------------- Unwind-EHABI.cpp -------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Implements ARM zero-cost C++ exceptions |
| ... | ... | @@ -21,8 +20,6 @@ |
| 21 | 20 | #include <stdlib.h> |
| 22 | 21 | #include <string.h> |
| 23 | 22 | |
| 24 | #include <type_traits> | |
| 25 | ||
| 26 | 23 | #include "config.h" |
| 27 | 24 | #include "libunwind.h" |
| 28 | 25 | #include "libunwind_ext.h" |
| ... | ... | @@ -34,7 +31,11 @@ namespace { |
| 34 | 31 | // signinficant byte. |
| 35 | 32 | uint8_t getByte(const uint32_t* data, size_t offset) { |
| 36 | 33 | const uint8_t* byteData = reinterpret_cast<const uint8_t*>(data); |
| 34 | #ifdef __LITTLE_ENDIAN__ | |
| 37 | 35 | return byteData[(offset & ~(size_t)0x03) + (3 - (offset & (size_t)0x03))]; |
| 36 | #else | |
| 37 | return byteData[offset]; | |
| 38 | #endif | |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | 41 | const char* getNextWord(const char* data, uint32_t* out) { |
| ... | ... | @@ -182,7 +183,7 @@ static _Unwind_Reason_Code unwindOneFrame(_Unwind_State state, |
| 182 | 183 | if (result != _URC_CONTINUE_UNWIND) |
| 183 | 184 | return result; |
| 184 | 185 | |
| 185 | if (unw_step(reinterpret_cast<unw_cursor_t*>(context)) != UNW_STEP_SUCCESS) | |
| 186 | if (__unw_step(reinterpret_cast<unw_cursor_t *>(context)) != UNW_STEP_SUCCESS) | |
| 186 | 187 | return _URC_FAILURE; |
| 187 | 188 | return _URC_CONTINUE_UNWIND; |
| 188 | 189 | } |
| ... | ... | @@ -443,17 +444,18 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 443 | 444 | // In this implementation, the phases don't share the VRS backing store. |
| 444 | 445 | // Instead, they are passed the original |uc| and they create a new VRS |
| 445 | 446 | // from scratch thus achieving the same effect. |
| 446 | unw_init_local(cursor, uc); | |
| 447 | __unw_init_local(cursor, uc); | |
| 447 | 448 | |
| 448 | 449 | // Walk each frame looking for a place to stop. |
| 449 | 450 | for (bool handlerNotFound = true; handlerNotFound;) { |
| 450 | 451 | |
| 451 | 452 | // See if frame has code to run (has personality routine). |
| 452 | 453 | 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)); | |
| 457 | 459 | return _URC_FATAL_PHASE1_ERROR; |
| 458 | 460 | } |
| 459 | 461 | |
| ... | ... | @@ -462,12 +464,12 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 462 | 464 | char functionBuf[512]; |
| 463 | 465 | const char *functionName = functionBuf; |
| 464 | 466 | 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) || | |
| 467 | 469 | (frameInfo.start_ip + offset > frameInfo.end_ip)) |
| 468 | 470 | functionName = ".anonymous."; |
| 469 | 471 | unw_word_t pc; |
| 470 | unw_get_reg(cursor, UNW_REG_IP, &pc); | |
| 472 | __unw_get_reg(cursor, UNW_REG_IP, &pc); | |
| 471 | 473 | _LIBUNWIND_TRACE_UNWINDING( |
| 472 | 474 | "unwind_phase1(ex_ojb=%p): pc=0x%" PRIxPTR ", start_ip=0x%" PRIxPTR ", func=%s, " |
| 473 | 475 | "lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR, |
| ... | ... | @@ -537,7 +539,7 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor |
| 537 | 539 | _Unwind_Exception *exception_object, |
| 538 | 540 | bool resume) { |
| 539 | 541 | // See comment at the start of unwind_phase1 regarding VRS integrity. |
| 540 | unw_init_local(cursor, uc); | |
| 542 | __unw_init_local(cursor, uc); | |
| 541 | 543 | |
| 542 | 544 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)", |
| 543 | 545 | static_cast<void *>(exception_object)); |
| ... | ... | @@ -559,19 +561,20 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor |
| 559 | 561 | // for. After this, continue unwinding as if normal. |
| 560 | 562 | // |
| 561 | 563 | // 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); | |
| 564 | 566 | resume = false; |
| 565 | 567 | } |
| 566 | 568 | |
| 567 | 569 | // Get info about this frame. |
| 568 | 570 | unw_word_t sp; |
| 569 | 571 | 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)); | |
| 575 | 578 | return _URC_FATAL_PHASE2_ERROR; |
| 576 | 579 | } |
| 577 | 580 | |
| ... | ... | @@ -580,8 +583,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor |
| 580 | 583 | char functionBuf[512]; |
| 581 | 584 | const char *functionName = functionBuf; |
| 582 | 585 | 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) || | |
| 585 | 588 | (frameInfo.start_ip + offset > frameInfo.end_ip)) |
| 586 | 589 | functionName = ".anonymous."; |
| 587 | 590 | _LIBUNWIND_TRACE_UNWINDING( |
| ... | ... | @@ -625,8 +628,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor |
| 625 | 628 | // We may get control back if landing pad calls _Unwind_Resume(). |
| 626 | 629 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 627 | 630 | 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); | |
| 630 | 633 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering " |
| 631 | 634 | "user code with ip=0x%" PRIxPTR ", sp=0x%" PRIxPTR, |
| 632 | 635 | static_cast<void *>(exception_object), |
| ... | ... | @@ -637,11 +640,11 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor |
| 637 | 640 | // EHABI #7.4.1 says we need to preserve pc for when _Unwind_Resume |
| 638 | 641 | // is called back, to find this same frame. |
| 639 | 642 | unw_word_t pc; |
| 640 | unw_get_reg(cursor, UNW_REG_IP, &pc); | |
| 643 | __unw_get_reg(cursor, UNW_REG_IP, &pc); | |
| 641 | 644 | exception_object->unwinder_cache.reserved2 = (uint32_t)pc; |
| 642 | 645 | } |
| 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. | |
| 645 | 648 | return _URC_FATAL_PHASE2_ERROR; |
| 646 | 649 | |
| 647 | 650 | // # EHABI #7.4.3 |
| ... | ... | @@ -670,7 +673,7 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) { |
| 670 | 673 | static_cast<void *>(exception_object)); |
| 671 | 674 | unw_context_t uc; |
| 672 | 675 | unw_cursor_t cursor; |
| 673 | unw_getcontext(&uc); | |
| 676 | __unw_getcontext(&uc); | |
| 674 | 677 | |
| 675 | 678 | // This field for is for compatibility with GCC to say this isn't a forced |
| 676 | 679 | // unwind. EHABI #7.2 |
| ... | ... | @@ -708,7 +711,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) { |
| 708 | 711 | static_cast<void *>(exception_object)); |
| 709 | 712 | unw_context_t uc; |
| 710 | 713 | unw_cursor_t cursor; |
| 711 | unw_getcontext(&uc); | |
| 714 | __unw_getcontext(&uc); | |
| 712 | 715 | |
| 713 | 716 | // _Unwind_RaiseException on EHABI will always set the reserved1 field to 0, |
| 714 | 717 | // which is in the same position as private_1 below. |
| ... | ... | @@ -725,7 +728,7 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) { |
| 725 | 728 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 726 | 729 | unw_proc_info_t frameInfo; |
| 727 | 730 | uintptr_t result = 0; |
| 728 | if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) | |
| 731 | if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) | |
| 729 | 732 | result = (uintptr_t)frameInfo.lsda; |
| 730 | 733 | _LIBUNWIND_TRACE_API( |
| 731 | 734 | "_Unwind_GetLanguageSpecificData(context=%p) => 0x%llx", |
| ... | ... | @@ -765,8 +768,8 @@ _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, |
| 765 | 768 | case _UVRSC_CORE: |
| 766 | 769 | if (representation != _UVRSD_UINT32 || regno > 15) |
| 767 | 770 | 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 | |
| 770 | 773 | ? _UVRSR_OK |
| 771 | 774 | : _UVRSR_FAILED; |
| 772 | 775 | case _UVRSC_VFP: |
| ... | ... | @@ -776,28 +779,28 @@ _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, |
| 776 | 779 | // Can only touch d0-15 with FSTMFDX. |
| 777 | 780 | if (regno > 15) |
| 778 | 781 | return _UVRSR_FAILED; |
| 779 | unw_save_vfp_as_X(cursor); | |
| 782 | __unw_save_vfp_as_X(cursor); | |
| 780 | 783 | } else { |
| 781 | 784 | if (regno > 31) |
| 782 | 785 | return _UVRSR_FAILED; |
| 783 | 786 | } |
| 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 | |
| 786 | 789 | ? _UVRSR_OK |
| 787 | 790 | : _UVRSR_FAILED; |
| 788 | 791 | #if defined(__ARM_WMMX) |
| 789 | 792 | case _UVRSC_WMMXC: |
| 790 | 793 | if (representation != _UVRSD_UINT32 || regno > 3) |
| 791 | 794 | 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 | |
| 794 | 797 | ? _UVRSR_OK |
| 795 | 798 | : _UVRSR_FAILED; |
| 796 | 799 | case _UVRSC_WMMXD: |
| 797 | 800 | if (representation != _UVRSD_DOUBLE || regno > 31) |
| 798 | 801 | 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 | |
| 801 | 804 | ? _UVRSR_OK |
| 802 | 805 | : _UVRSR_FAILED; |
| 803 | 806 | #else |
| ... | ... | @@ -819,8 +822,8 @@ _Unwind_VRS_Get_Internal(_Unwind_Context *context, |
| 819 | 822 | case _UVRSC_CORE: |
| 820 | 823 | if (representation != _UVRSD_UINT32 || regno > 15) |
| 821 | 824 | 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 | |
| 824 | 827 | ? _UVRSR_OK |
| 825 | 828 | : _UVRSR_FAILED; |
| 826 | 829 | case _UVRSC_VFP: |
| ... | ... | @@ -830,28 +833,28 @@ _Unwind_VRS_Get_Internal(_Unwind_Context *context, |
| 830 | 833 | // Can only touch d0-15 with FSTMFDX. |
| 831 | 834 | if (regno > 15) |
| 832 | 835 | return _UVRSR_FAILED; |
| 833 | unw_save_vfp_as_X(cursor); | |
| 836 | __unw_save_vfp_as_X(cursor); | |
| 834 | 837 | } else { |
| 835 | 838 | if (regno > 31) |
| 836 | 839 | return _UVRSR_FAILED; |
| 837 | 840 | } |
| 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 | |
| 840 | 843 | ? _UVRSR_OK |
| 841 | 844 | : _UVRSR_FAILED; |
| 842 | 845 | #if defined(__ARM_WMMX) |
| 843 | 846 | case _UVRSC_WMMXC: |
| 844 | 847 | if (representation != _UVRSD_UINT32 || regno > 3) |
| 845 | 848 | 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 | |
| 848 | 851 | ? _UVRSR_OK |
| 849 | 852 | : _UVRSR_FAILED; |
| 850 | 853 | case _UVRSC_WMMXD: |
| 851 | 854 | if (representation != _UVRSD_DOUBLE || regno > 31) |
| 852 | 855 | 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 | |
| 855 | 858 | ? _UVRSR_OK |
| 856 | 859 | : _UVRSR_FAILED; |
| 857 | 860 | #else |
| ... | ... | @@ -960,7 +963,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) { |
| 960 | 963 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 961 | 964 | unw_proc_info_t frameInfo; |
| 962 | 965 | uintptr_t result = 0; |
| 963 | if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) | |
| 966 | if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) | |
| 964 | 967 | result = (uintptr_t)frameInfo.start_ip; |
| 965 | 968 | _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%llX", |
| 966 | 969 | static_cast<void *>(context), (long long)result); |
| ... | ... | @@ -983,7 +986,7 @@ extern "C" _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 983 | 986 | __gnu_unwind_frame(_Unwind_Exception *exception_object, |
| 984 | 987 | struct _Unwind_Context *context) { |
| 985 | 988 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 986 | if (unw_step(cursor) != UNW_STEP_SUCCESS) | |
| 989 | if (__unw_step(cursor) != UNW_STEP_SUCCESS) | |
| 987 | 990 | return _URC_FAILURE; |
| 988 | 991 | return _URC_OK; |
| 989 | 992 | } |
lib/libunwind/src/Unwind-EHABI.h+3-4| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===------------------------- Unwind-EHABI.hpp ---------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | //===----------------------------------------------------------------------===// |
lib/libunwind/src/Unwind-seh.cpp+55-45| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===--------------------------- Unwind-seh.cpp ---------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | //===----------------------------------------------------------------------===// |
| 9 | 8 | // |
| ... | ... | @@ -53,14 +52,16 @@ static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0 |
| 53 | 52 | /// Exception cleanup routine used by \c _GCC_specific_handler to |
| 54 | 53 | /// free foreign exceptions. |
| 55 | 54 | static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) { |
| 55 | (void)urc; | |
| 56 | 56 | if (exc->exception_class != kSEHExceptionClass) |
| 57 | 57 | _LIBUNWIND_ABORT("SEH cleanup called on non-SEH exception"); |
| 58 | 58 | free(exc); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | static int _unw_init_seh(unw_cursor_t *cursor, CONTEXT *ctx); | |
| 62 | static DISPATCHER_CONTEXT *_unw_seh_get_disp_ctx(unw_cursor_t *cursor); | |
| 63 | static void _unw_seh_set_disp_ctx(unw_cursor_t *cursor, DISPATCHER_CONTEXT *disp); | |
| 61 | static int __unw_init_seh(unw_cursor_t *cursor, CONTEXT *ctx); | |
| 62 | static DISPATCHER_CONTEXT *__unw_seh_get_disp_ctx(unw_cursor_t *cursor); | |
| 63 | static void __unw_seh_set_disp_ctx(unw_cursor_t *cursor, | |
| 64 | DISPATCHER_CONTEXT *disp); | |
| 64 | 65 | |
| 65 | 66 | /// Common implementation of SEH-style handler functions used by Itanium- |
| 66 | 67 | /// style frames. Depending on how and why it was called, it may do one of: |
| ... | ... | @@ -69,7 +70,6 @@ static void _unw_seh_set_disp_ctx(unw_cursor_t *cursor, DISPATCHER_CONTEXT *disp |
| 69 | 70 | _LIBUNWIND_EXPORT EXCEPTION_DISPOSITION |
| 70 | 71 | _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx, |
| 71 | 72 | DISPATCHER_CONTEXT *disp, __personality_routine pers) { |
| 72 | unw_context_t uc; | |
| 73 | 73 | unw_cursor_t cursor; |
| 74 | 74 | _Unwind_Exception *exc; |
| 75 | 75 | _Unwind_Action action; |
| ... | ... | @@ -78,7 +78,9 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx, |
| 78 | 78 | uintptr_t retval, target; |
| 79 | 79 | bool ours = false; |
| 80 | 80 | |
| 81 | _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler(%#010x(%x), %p)", ms_exc->ExceptionCode, ms_exc->ExceptionFlags, frame); | |
| 81 | _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler(%#010lx(%lx), %p)", | |
| 82 | ms_exc->ExceptionCode, ms_exc->ExceptionFlags, | |
| 83 | (void *)frame); | |
| 82 | 84 | if (ms_exc->ExceptionCode == STATUS_GCC_UNWIND) { |
| 83 | 85 | if (IS_TARGET_UNWIND(ms_exc->ExceptionFlags)) { |
| 84 | 86 | // Set up the upper return value (the lower one and the target PC |
| ... | ... | @@ -112,9 +114,9 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx, |
| 112 | 114 | memset(exc->private_, 0, sizeof(exc->private_)); |
| 113 | 115 | } |
| 114 | 116 | 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); | |
| 118 | 120 | ctx = (struct _Unwind_Context *)&cursor; |
| 119 | 121 | |
| 120 | 122 | if (!IS_UNWINDING(ms_exc->ExceptionFlags)) { |
| ... | ... | @@ -130,7 +132,10 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx, |
| 130 | 132 | } |
| 131 | 133 | } |
| 132 | 134 | |
| 133 | _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() calling personality function %p(1, %d, %llx, %p, %p)", pers, action, exc->exception_class, exc, ctx); | |
| 135 | _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() calling personality " | |
| 136 | "function %p(1, %d, %llx, %p, %p)", | |
| 137 | (void *)pers, action, exc->exception_class, | |
| 138 | (void *)exc, (void *)ctx); | |
| 134 | 139 | urc = pers(1, action, exc->exception_class, exc, ctx); |
| 135 | 140 | _LIBUNWIND_TRACE_UNWINDING("_GCC_specific_handler() personality returned %d", urc); |
| 136 | 141 | switch (urc) { |
| ... | ... | @@ -168,18 +173,18 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx, |
| 168 | 173 | _LIBUNWIND_ABORT("Personality installed context during phase 1!"); |
| 169 | 174 | #ifdef __x86_64__ |
| 170 | 175 | 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]); | |
| 173 | 178 | #elif defined(__arm__) |
| 174 | 179 | 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]); | |
| 177 | 182 | #elif defined(__aarch64__) |
| 178 | 183 | 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]); | |
| 181 | 186 | #endif |
| 182 | unw_get_reg(&cursor, UNW_REG_IP, &target); | |
| 187 | __unw_get_reg(&cursor, UNW_REG_IP, &target); | |
| 183 | 188 | ms_exc->ExceptionCode = STATUS_GCC_UNWIND; |
| 184 | 189 | #ifdef __x86_64__ |
| 185 | 190 | ms_exc->ExceptionInformation[2] = disp->TargetIp; |
| ... | ... | @@ -199,7 +204,7 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx, |
| 199 | 204 | } |
| 200 | 205 | } |
| 201 | 206 | |
| 202 | /// Personality function returned by \c unw_get_proc_info() in SEH contexts. | |
| 207 | /// Personality function returned by \c __unw_get_proc_info() in SEH contexts. | |
| 203 | 208 | /// This is a wrapper that calls the real SEH handler function, which in |
| 204 | 209 | /// turn (at least, for Itanium-style frames) calls the real Itanium |
| 205 | 210 | /// personality function (see \c _GCC_specific_handler()). |
| ... | ... | @@ -207,6 +212,8 @@ extern "C" _Unwind_Reason_Code |
| 207 | 212 | __libunwind_seh_personality(int version, _Unwind_Action state, |
| 208 | 213 | uint64_t klass, _Unwind_Exception *exc, |
| 209 | 214 | struct _Unwind_Context *context) { |
| 215 | (void)version; | |
| 216 | (void)klass; | |
| 210 | 217 | EXCEPTION_RECORD ms_exc; |
| 211 | 218 | bool phase2 = (state & (_UA_SEARCH_PHASE|_UA_CLEANUP_PHASE)) == _UA_CLEANUP_PHASE; |
| 212 | 219 | ms_exc.ExceptionCode = STATUS_GCC_THROW; |
| ... | ... | @@ -215,7 +222,8 @@ __libunwind_seh_personality(int version, _Unwind_Action state, |
| 215 | 222 | ms_exc.ExceptionInformation[0] = (ULONG_PTR)exc; |
| 216 | 223 | ms_exc.ExceptionInformation[1] = (ULONG_PTR)context; |
| 217 | 224 | ms_exc.ExceptionInformation[2] = state; |
| 218 | DISPATCHER_CONTEXT *disp_ctx = _unw_seh_get_disp_ctx((unw_cursor_t *)context); | |
| 225 | DISPATCHER_CONTEXT *disp_ctx = | |
| 226 | __unw_seh_get_disp_ctx((unw_cursor_t *)context); | |
| 219 | 227 | EXCEPTION_DISPOSITION ms_act = disp_ctx->LanguageHandler(&ms_exc, |
| 220 | 228 | (PVOID)disp_ctx->EstablisherFrame, |
| 221 | 229 | disp_ctx->ContextRecord, |
| ... | ... | @@ -234,15 +242,15 @@ unwind_phase2_forced(unw_context_t *uc, |
| 234 | 242 | _Unwind_Exception *exception_object, |
| 235 | 243 | _Unwind_Stop_Fn stop, void *stop_parameter) { |
| 236 | 244 | unw_cursor_t cursor2; |
| 237 | unw_init_local(&cursor2, uc); | |
| 245 | __unw_init_local(&cursor2, uc); | |
| 238 | 246 | |
| 239 | 247 | // Walk each frame until we reach where search phase said to stop |
| 240 | while (unw_step(&cursor2) > 0) { | |
| 248 | while (__unw_step(&cursor2) > 0) { | |
| 241 | 249 | |
| 242 | 250 | // Update info about this frame. |
| 243 | 251 | 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 " | |
| 246 | 254 | "failed => _URC_END_OF_STACK", |
| 247 | 255 | (void *)exception_object); |
| 248 | 256 | return _URC_FATAL_PHASE2_ERROR; |
| ... | ... | @@ -253,8 +261,8 @@ unwind_phase2_forced(unw_context_t *uc, |
| 253 | 261 | char functionBuf[512]; |
| 254 | 262 | const char *functionName = functionBuf; |
| 255 | 263 | 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) || | |
| 258 | 266 | (frameInfo.start_ip + offset > frameInfo.end_ip)) |
| 259 | 267 | functionName = ".anonymous."; |
| 260 | 268 | _LIBUNWIND_TRACE_UNWINDING( |
| ... | ... | @@ -304,7 +312,7 @@ unwind_phase2_forced(unw_context_t *uc, |
| 304 | 312 | "_URC_INSTALL_CONTEXT", |
| 305 | 313 | (void *)exception_object); |
| 306 | 314 | // We may get control back if landing pad calls _Unwind_Resume(). |
| 307 | unw_resume(&cursor2); | |
| 315 | __unw_resume(&cursor2); | |
| 308 | 316 | break; |
| 309 | 317 | default: |
| 310 | 318 | // Personality routine returned an unknown result code. |
| ... | ... | @@ -369,7 +377,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) { |
| 369 | 377 | if (exception_object->private_[0] != 0) { |
| 370 | 378 | unw_context_t uc; |
| 371 | 379 | |
| 372 | unw_getcontext(&uc); | |
| 380 | __unw_getcontext(&uc); | |
| 373 | 381 | unwind_phase2_forced(&uc, exception_object, |
| 374 | 382 | (_Unwind_Stop_Fn) exception_object->private_[0], |
| 375 | 383 | (void *)exception_object->private_[4]); |
| ... | ... | @@ -407,7 +415,7 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object, |
| 407 | 415 | _LIBUNWIND_TRACE_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)", |
| 408 | 416 | (void *)exception_object, (void *)(uintptr_t)stop); |
| 409 | 417 | unw_context_t uc; |
| 410 | unw_getcontext(&uc); | |
| 418 | __unw_getcontext(&uc); | |
| 411 | 419 | |
| 412 | 420 | // Mark that this is a forced unwind, so _Unwind_Resume() can do |
| 413 | 421 | // the right thing. |
| ... | ... | @@ -421,7 +429,8 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object, |
| 421 | 429 | /// Called by personality handler during phase 2 to get LSDA for current frame. |
| 422 | 430 | _LIBUNWIND_EXPORT uintptr_t |
| 423 | 431 | _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) { |
| 424 | uintptr_t result = (uintptr_t)_unw_seh_get_disp_ctx((unw_cursor_t *)context)->HandlerData; | |
| 432 | uintptr_t result = | |
| 433 | (uintptr_t)__unw_seh_get_disp_ctx((unw_cursor_t *)context)->HandlerData; | |
| 425 | 434 | _LIBUNWIND_TRACE_API( |
| 426 | 435 | "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIxPTR, |
| 427 | 436 | (void *)context, result); |
| ... | ... | @@ -432,30 +441,32 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) { |
| 432 | 441 | /// function. |
| 433 | 442 | _LIBUNWIND_EXPORT uintptr_t |
| 434 | 443 | _Unwind_GetRegionStart(struct _Unwind_Context *context) { |
| 435 | DISPATCHER_CONTEXT *disp = _unw_seh_get_disp_ctx((unw_cursor_t *)context); | |
| 444 | DISPATCHER_CONTEXT *disp = __unw_seh_get_disp_ctx((unw_cursor_t *)context); | |
| 436 | 445 | uintptr_t result = (uintptr_t)disp->FunctionEntry->BeginAddress + disp->ImageBase; |
| 437 | 446 | _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIxPTR, |
| 438 | 447 | (void *)context, result); |
| 439 | 448 | return result; |
| 440 | 449 | } |
| 441 | 450 | |
| 442 | static int | |
| 443 | _unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) { | |
| 451 | static int __unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) { | |
| 444 | 452 | #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); | |
| 447 | 456 | auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor); |
| 448 | 457 | co->setInfoBasedOnIPRegister(); |
| 449 | 458 | return UNW_ESUCCESS; |
| 450 | 459 | #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); | |
| 453 | 463 | auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor); |
| 454 | 464 | co->setInfoBasedOnIPRegister(); |
| 455 | 465 | return UNW_ESUCCESS; |
| 456 | 466 | #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); | |
| 459 | 470 | auto *co = reinterpret_cast<AbstractUnwindCursor *>(cursor); |
| 460 | 471 | co->setInfoBasedOnIPRegister(); |
| 461 | 472 | return UNW_ESUCCESS; |
| ... | ... | @@ -464,8 +475,7 @@ _unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) { |
| 464 | 475 | #endif |
| 465 | 476 | } |
| 466 | 477 | |
| 467 | static DISPATCHER_CONTEXT * | |
| 468 | _unw_seh_get_disp_ctx(unw_cursor_t *cursor) { | |
| 478 | static DISPATCHER_CONTEXT *__unw_seh_get_disp_ctx(unw_cursor_t *cursor) { | |
| 469 | 479 | #ifdef _LIBUNWIND_TARGET_X86_64 |
| 470 | 480 | return reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_x86_64> *>(cursor)->getDispatcherContext(); |
| 471 | 481 | #elif defined(_LIBUNWIND_TARGET_ARM) |
| ... | ... | @@ -477,8 +487,8 @@ _unw_seh_get_disp_ctx(unw_cursor_t *cursor) { |
| 477 | 487 | #endif |
| 478 | 488 | } |
| 479 | 489 | |
| 480 | static void | |
| 481 | _unw_seh_set_disp_ctx(unw_cursor_t *cursor, DISPATCHER_CONTEXT *disp) { | |
| 490 | static void __unw_seh_set_disp_ctx(unw_cursor_t *cursor, | |
| 491 | DISPATCHER_CONTEXT *disp) { | |
| 482 | 492 | #ifdef _LIBUNWIND_TARGET_X86_64 |
| 483 | 493 | reinterpret_cast<UnwindCursor<LocalAddressSpace, Registers_x86_64> *>(cursor)->setDispatcherContext(disp); |
| 484 | 494 | #elif defined(_LIBUNWIND_TARGET_ARM) |
lib/libunwind/src/Unwind-sjlj.c+66-54| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===--------------------------- Unwind-sjlj.c ----------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Implements setjump-longjump based C++ exceptions |
| ... | ... | @@ -12,6 +11,7 @@ |
| 12 | 11 | |
| 13 | 12 | #include <unwind.h> |
| 14 | 13 | |
| 14 | #include <inttypes.h> | |
| 15 | 15 | #include <stdint.h> |
| 16 | 16 | #include <stdbool.h> |
| 17 | 17 | #include <stdlib.h> |
| ... | ... | @@ -52,7 +52,7 @@ struct _Unwind_FunctionContext { |
| 52 | 52 | #else |
| 53 | 53 | # if __STDC_VERSION__ >= 201112L |
| 54 | 54 | # define _LIBUNWIND_THREAD_LOCAL _Thread_local |
| 55 | # elif defined(_WIN32) | |
| 55 | # elif defined(_MSC_VER) | |
| 56 | 56 | # define _LIBUNWIND_THREAD_LOCAL __declspec(thread) |
| 57 | 57 | # elif defined(__GNUC__) || defined(__clang__) |
| 58 | 58 | # define _LIBUNWIND_THREAD_LOCAL __thread |
| ... | ... | @@ -108,7 +108,8 @@ _Unwind_SjLj_Unregister(struct _Unwind_FunctionContext *fc) { |
| 108 | 108 | static _Unwind_Reason_Code |
| 109 | 109 | unwind_phase1(struct _Unwind_Exception *exception_object) { |
| 110 | 110 | _Unwind_FunctionContext_t c = __Unwind_SjLj_GetTopOfFunctionStack(); |
| 111 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: initial function-context=%p", c); | |
| 111 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: initial function-context=%p", | |
| 112 | (void *)c); | |
| 112 | 113 | |
| 113 | 114 | // walk each frame looking for a place to stop |
| 114 | 115 | for (bool handlerNotFound = true; handlerNotFound; c = c->prev) { |
| ... | ... | @@ -117,17 +118,18 @@ unwind_phase1(struct _Unwind_Exception *exception_object) { |
| 117 | 118 | if (c == NULL) { |
| 118 | 119 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): reached " |
| 119 | 120 | "bottom => _URC_END_OF_STACK", |
| 120 | exception_object); | |
| 121 | (void *)exception_object); | |
| 121 | 122 | return _URC_END_OF_STACK; |
| 122 | 123 | } |
| 123 | 124 | |
| 124 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: function-context=%p", c); | |
| 125 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase1: function-context=%p", (void *)c); | |
| 125 | 126 | // if there is a personality routine, ask it if it will want to stop at this |
| 126 | 127 | // frame |
| 127 | 128 | if (c->personality != NULL) { |
| 128 | 129 | _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); | |
| 131 | 133 | _Unwind_Reason_Code personalityResult = (*c->personality)( |
| 132 | 134 | 1, _UA_SEARCH_PHASE, exception_object->exception_class, |
| 133 | 135 | exception_object, (struct _Unwind_Context *)c); |
| ... | ... | @@ -138,12 +140,14 @@ unwind_phase1(struct _Unwind_Exception *exception_object) { |
| 138 | 140 | handlerNotFound = false; |
| 139 | 141 | exception_object->private_2 = (uintptr_t) c; |
| 140 | 142 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): " |
| 141 | "_URC_HANDLER_FOUND", exception_object); | |
| 143 | "_URC_HANDLER_FOUND", | |
| 144 | (void *)exception_object); | |
| 142 | 145 | return _URC_NO_REASON; |
| 143 | 146 | |
| 144 | 147 | case _URC_CONTINUE_UNWIND: |
| 145 | 148 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): " |
| 146 | "_URC_CONTINUE_UNWIND", exception_object); | |
| 149 | "_URC_CONTINUE_UNWIND", | |
| 150 | (void *)exception_object); | |
| 147 | 151 | // continue unwinding |
| 148 | 152 | break; |
| 149 | 153 | |
| ... | ... | @@ -151,7 +155,7 @@ unwind_phase1(struct _Unwind_Exception *exception_object) { |
| 151 | 155 | // something went wrong |
| 152 | 156 | _LIBUNWIND_TRACE_UNWINDING( |
| 153 | 157 | "unwind_phase1(ex_ojb=%p): _URC_FATAL_PHASE1_ERROR", |
| 154 | exception_object); | |
| 158 | (void *)exception_object); | |
| 155 | 159 | return _URC_FATAL_PHASE1_ERROR; |
| 156 | 160 | } |
| 157 | 161 | } |
| ... | ... | @@ -162,19 +166,21 @@ unwind_phase1(struct _Unwind_Exception *exception_object) { |
| 162 | 166 | |
| 163 | 167 | static _Unwind_Reason_Code |
| 164 | 168 | unwind_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); | |
| 166 | 171 | |
| 167 | 172 | // walk each frame until we reach where search phase said to stop |
| 168 | 173 | _Unwind_FunctionContext_t c = __Unwind_SjLj_GetTopOfFunctionStack(); |
| 169 | 174 | while (true) { |
| 170 | 175 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2s(ex_ojb=%p): context=%p", |
| 171 | exception_object, c); | |
| 176 | (void *)exception_object, (void *)c); | |
| 172 | 177 | |
| 173 | 178 | // check for no more frames |
| 174 | 179 | 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); | |
| 178 | 184 | return _URC_END_OF_STACK; |
| 179 | 185 | } |
| 180 | 186 | |
| ... | ... | @@ -194,7 +200,7 @@ unwind_phase2(struct _Unwind_Exception *exception_object) { |
| 194 | 200 | // continue unwinding |
| 195 | 201 | _LIBUNWIND_TRACE_UNWINDING( |
| 196 | 202 | "unwind_phase2(ex_ojb=%p): _URC_CONTINUE_UNWIND", |
| 197 | exception_object); | |
| 203 | (void *)exception_object); | |
| 198 | 204 | if ((uintptr_t) c == exception_object->private_2) { |
| 199 | 205 | // phase 1 said we would stop at this frame, but we did not... |
| 200 | 206 | _LIBUNWIND_ABORT("during phase1 personality function said it would " |
| ... | ... | @@ -203,14 +209,14 @@ unwind_phase2(struct _Unwind_Exception *exception_object) { |
| 203 | 209 | break; |
| 204 | 210 | case _URC_INSTALL_CONTEXT: |
| 205 | 211 | _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]); | |
| 209 | 215 | // personality routine says to transfer control to landing pad |
| 210 | 216 | // we may get control back if landing pad calls _Unwind_Resume() |
| 211 | 217 | __Unwind_SjLj_SetTopOfFunctionStack(c); |
| 212 | 218 | __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 | |
| 214 | 220 | return _URC_FATAL_PHASE2_ERROR; |
| 215 | 221 | default: |
| 216 | 222 | // something went wrong |
| ... | ... | @@ -237,9 +243,10 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object, |
| 237 | 243 | |
| 238 | 244 | // get next frame (skip over first which is _Unwind_RaiseException) |
| 239 | 245 | 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); | |
| 243 | 250 | return _URC_END_OF_STACK; |
| 244 | 251 | } |
| 245 | 252 | |
| ... | ... | @@ -251,11 +258,11 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object, |
| 251 | 258 | (struct _Unwind_Context *)c, stop_parameter); |
| 252 | 259 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " |
| 253 | 260 | "stop function returned %d", |
| 254 | exception_object, stopResult); | |
| 261 | (void *)exception_object, stopResult); | |
| 255 | 262 | if (stopResult != _URC_NO_REASON) { |
| 256 | 263 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " |
| 257 | 264 | "stopped by stop function", |
| 258 | exception_object); | |
| 265 | (void *)exception_object); | |
| 259 | 266 | return _URC_FATAL_PHASE2_ERROR; |
| 260 | 267 | } |
| 261 | 268 | |
| ... | ... | @@ -264,7 +271,7 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object, |
| 264 | 271 | __personality_routine p = (__personality_routine) c->personality; |
| 265 | 272 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " |
| 266 | 273 | "calling personality function %p", |
| 267 | exception_object, p); | |
| 274 | (void *)exception_object, (void *)p); | |
| 268 | 275 | _Unwind_Reason_Code personalityResult = |
| 269 | 276 | (*p)(1, action, exception_object->exception_class, exception_object, |
| 270 | 277 | (struct _Unwind_Context *)c); |
| ... | ... | @@ -272,13 +279,13 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object, |
| 272 | 279 | case _URC_CONTINUE_UNWIND: |
| 273 | 280 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " |
| 274 | 281 | "personality returned _URC_CONTINUE_UNWIND", |
| 275 | exception_object); | |
| 282 | (void *)exception_object); | |
| 276 | 283 | // destructors called, continue unwinding |
| 277 | 284 | break; |
| 278 | 285 | case _URC_INSTALL_CONTEXT: |
| 279 | 286 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " |
| 280 | 287 | "personality returned _URC_INSTALL_CONTEXT", |
| 281 | exception_object); | |
| 288 | (void *)exception_object); | |
| 282 | 289 | // we may get control back if landing pad calls _Unwind_Resume() |
| 283 | 290 | __Unwind_SjLj_SetTopOfFunctionStack(c); |
| 284 | 291 | __builtin_longjmp(c->jbuf, 1); |
| ... | ... | @@ -288,7 +295,7 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object, |
| 288 | 295 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " |
| 289 | 296 | "personality returned %d, " |
| 290 | 297 | "_URC_FATAL_PHASE2_ERROR", |
| 291 | exception_object, personalityResult); | |
| 298 | (void *)exception_object, personalityResult); | |
| 292 | 299 | return _URC_FATAL_PHASE2_ERROR; |
| 293 | 300 | } |
| 294 | 301 | } |
| ... | ... | @@ -298,8 +305,8 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object, |
| 298 | 305 | // call stop function one last time and tell it we've reached the end of the |
| 299 | 306 | // stack |
| 300 | 307 | _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); | |
| 303 | 310 | _Unwind_Action lastAction = |
| 304 | 311 | (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK); |
| 305 | 312 | (*stop)(1, lastAction, exception_object->exception_class, exception_object, |
| ... | ... | @@ -314,7 +321,8 @@ unwind_phase2_forced(struct _Unwind_Exception *exception_object, |
| 314 | 321 | /// Called by __cxa_throw. Only returns if there is a fatal error |
| 315 | 322 | _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 316 | 323 | _Unwind_SjLj_RaiseException(struct _Unwind_Exception *exception_object) { |
| 317 | _LIBUNWIND_TRACE_API("_Unwind_SjLj_RaiseException(ex_obj=%p)", exception_object); | |
| 324 | _LIBUNWIND_TRACE_API("_Unwind_SjLj_RaiseException(ex_obj=%p)", | |
| 325 | (void *)exception_object); | |
| 318 | 326 | |
| 319 | 327 | // mark that this is a non-forced unwind, so _Unwind_Resume() can do the right |
| 320 | 328 | // thing |
| ... | ... | @@ -344,7 +352,8 @@ _Unwind_SjLj_RaiseException(struct _Unwind_Exception *exception_object) { |
| 344 | 352 | /// __cxa_rethrow() which in turn calls _Unwind_Resume_or_Rethrow() |
| 345 | 353 | _LIBUNWIND_EXPORT void |
| 346 | 354 | _Unwind_SjLj_Resume(struct _Unwind_Exception *exception_object) { |
| 347 | _LIBUNWIND_TRACE_API("_Unwind_SjLj_Resume(ex_obj=%p)", exception_object); | |
| 355 | _LIBUNWIND_TRACE_API("_Unwind_SjLj_Resume(ex_obj=%p)", | |
| 356 | (void *)exception_object); | |
| 348 | 357 | |
| 349 | 358 | if (exception_object->private_1 != 0) |
| 350 | 359 | unwind_phase2_forced(exception_object, |
| ... | ... | @@ -362,8 +371,8 @@ _Unwind_SjLj_Resume(struct _Unwind_Exception *exception_object) { |
| 362 | 371 | _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 363 | 372 | _Unwind_SjLj_Resume_or_Rethrow(struct _Unwind_Exception *exception_object) { |
| 364 | 373 | _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); | |
| 367 | 376 | // If this is non-forced and a stopping place was found, then this is a |
| 368 | 377 | // re-throw. |
| 369 | 378 | // Call _Unwind_RaiseException() as if this was a new exception. |
| ... | ... | @@ -386,7 +395,8 @@ _LIBUNWIND_EXPORT uintptr_t |
| 386 | 395 | _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) { |
| 387 | 396 | _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context; |
| 388 | 397 | _LIBUNWIND_TRACE_API("_Unwind_GetLanguageSpecificData(context=%p) " |
| 389 | "=> 0x%0lX", context, ufc->lsda); | |
| 398 | "=> 0x%" PRIuPTR, | |
| 399 | (void *)context, ufc->lsda); | |
| 390 | 400 | return ufc->lsda; |
| 391 | 401 | } |
| 392 | 402 | |
| ... | ... | @@ -394,8 +404,8 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) { |
| 394 | 404 | /// Called by personality handler during phase 2 to get register values. |
| 395 | 405 | _LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, |
| 396 | 406 | 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); | |
| 399 | 409 | _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context; |
| 400 | 410 | return ufc->resumeParameters[index]; |
| 401 | 411 | } |
| ... | ... | @@ -404,8 +414,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, |
| 404 | 414 | /// Called by personality handler during phase 2 to alter register values. |
| 405 | 415 | _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index, |
| 406 | 416 | 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); | |
| 409 | 420 | _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context; |
| 410 | 421 | ufc->resumeParameters[index] = new_value; |
| 411 | 422 | } |
| ... | ... | @@ -414,8 +425,8 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index, |
| 414 | 425 | /// Called by personality handler during phase 2 to get instruction pointer. |
| 415 | 426 | _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) { |
| 416 | 427 | _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); | |
| 419 | 430 | return ufc->resumeLocation + 1; |
| 420 | 431 | } |
| 421 | 432 | |
| ... | ... | @@ -427,8 +438,9 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context, |
| 427 | 438 | int *ipBefore) { |
| 428 | 439 | _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context; |
| 429 | 440 | *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); | |
| 432 | 444 | return ufc->resumeLocation + 1; |
| 433 | 445 | } |
| 434 | 446 | |
| ... | ... | @@ -436,8 +448,8 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context, |
| 436 | 448 | /// Called by personality handler during phase 2 to alter instruction pointer. |
| 437 | 449 | _LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context, |
| 438 | 450 | 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); | |
| 441 | 453 | _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context; |
| 442 | 454 | ufc->resumeLocation = new_value - 1; |
| 443 | 455 | } |
| ... | ... | @@ -449,7 +461,7 @@ _LIBUNWIND_EXPORT uintptr_t |
| 449 | 461 | _Unwind_GetRegionStart(struct _Unwind_Context *context) { |
| 450 | 462 | // Not supported or needed for sjlj based unwinding |
| 451 | 463 | (void)context; |
| 452 | _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p)", context); | |
| 464 | _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p)", (void *)context); | |
| 453 | 465 | return 0; |
| 454 | 466 | } |
| 455 | 467 | |
| ... | ... | @@ -459,7 +471,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) { |
| 459 | 471 | _LIBUNWIND_EXPORT void |
| 460 | 472 | _Unwind_DeleteException(struct _Unwind_Exception *exception_object) { |
| 461 | 473 | _LIBUNWIND_TRACE_API("_Unwind_DeleteException(ex_obj=%p)", |
| 462 | exception_object); | |
| 474 | (void *)exception_object); | |
| 463 | 475 | if (exception_object->exception_cleanup != NULL) |
| 464 | 476 | (*exception_object->exception_cleanup)(_URC_FOREIGN_EXCEPTION_CAUGHT, |
| 465 | 477 | exception_object); |
| ... | ... | @@ -473,7 +485,7 @@ _LIBUNWIND_EXPORT uintptr_t |
| 473 | 485 | _Unwind_GetDataRelBase(struct _Unwind_Context *context) { |
| 474 | 486 | // Not supported or needed for sjlj based unwinding |
| 475 | 487 | (void)context; |
| 476 | _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", context); | |
| 488 | _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", (void *)context); | |
| 477 | 489 | _LIBUNWIND_ABORT("_Unwind_GetDataRelBase() not implemented"); |
| 478 | 490 | } |
| 479 | 491 | |
| ... | ... | @@ -484,14 +496,14 @@ _LIBUNWIND_EXPORT uintptr_t |
| 484 | 496 | _Unwind_GetTextRelBase(struct _Unwind_Context *context) { |
| 485 | 497 | // Not supported or needed for sjlj based unwinding |
| 486 | 498 | (void)context; |
| 487 | _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", context); | |
| 499 | _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", (void *)context); | |
| 488 | 500 | _LIBUNWIND_ABORT("_Unwind_GetTextRelBase() not implemented"); |
| 489 | 501 | } |
| 490 | 502 | |
| 491 | 503 | |
| 492 | 504 | /// Called by personality handler to get "Call Frame Area" for current frame. |
| 493 | 505 | _LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) { |
| 494 | _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p)", context); | |
| 506 | _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p)", (void *)context); | |
| 495 | 507 | if (context != NULL) { |
| 496 | 508 | _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context; |
| 497 | 509 | // Setjmp/longjmp based exceptions don't have a true CFA. |
lib/libunwind/src/UnwindCursor.hpp+42-11| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===------------------------- UnwindCursor.hpp ---------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // C++ interface to lower levels of libunwind |
| ... | ... | @@ -12,7 +11,6 @@ |
| 12 | 11 | #ifndef __UNWINDCURSOR_HPP__ |
| 13 | 12 | #define __UNWINDCURSOR_HPP__ |
| 14 | 13 | |
| 15 | #include <algorithm> | |
| 16 | 14 | #include <stdint.h> |
| 17 | 15 | #include <stdio.h> |
| 18 | 16 | #include <stdlib.h> |
| ... | ... | @@ -106,7 +104,6 @@ private: |
| 106 | 104 | static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide); |
| 107 | 105 | static bool _registeredForDyldUnloads; |
| 108 | 106 | #endif |
| 109 | // Can't use std::vector<> here because this code is below libc++. | |
| 110 | 107 | static entry *_buffer; |
| 111 | 108 | static entry *_bufferUsed; |
| 112 | 109 | static entry *_bufferEnd; |
| ... | ... | @@ -485,6 +482,10 @@ public: |
| 485 | 482 | DISPATCHER_CONTEXT *getDispatcherContext() { return &_dispContext; } |
| 486 | 483 | void setDispatcherContext(DISPATCHER_CONTEXT *disp) { _dispContext = *disp; } |
| 487 | 484 | |
| 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 | ||
| 488 | 489 | private: |
| 489 | 490 | |
| 490 | 491 | pint_t getLastPC() const { return _dispContext.ControlPc; } |
| ... | ... | @@ -789,6 +790,8 @@ bool UnwindCursor<A, R>::validFloatReg(int regNum) { |
| 789 | 790 | if (regNum >= UNW_ARM_D0 && regNum <= UNW_ARM_D31) return true; |
| 790 | 791 | #elif defined(_LIBUNWIND_TARGET_AARCH64) |
| 791 | 792 | if (regNum >= UNW_ARM64_D0 && regNum <= UNW_ARM64_D31) return true; |
| 793 | #else | |
| 794 | (void)regNum; | |
| 792 | 795 | #endif |
| 793 | 796 | return false; |
| 794 | 797 | } |
| ... | ... | @@ -816,6 +819,7 @@ unw_fpreg_t UnwindCursor<A, R>::getFloatReg(int regNum) { |
| 816 | 819 | #elif defined(_LIBUNWIND_TARGET_AARCH64) |
| 817 | 820 | return _msContext.V[regNum - UNW_ARM64_D0].D[0]; |
| 818 | 821 | #else |
| 822 | (void)regNum; | |
| 819 | 823 | _LIBUNWIND_ABORT("float registers unimplemented"); |
| 820 | 824 | #endif |
| 821 | 825 | } |
| ... | ... | @@ -843,6 +847,8 @@ void UnwindCursor<A, R>::setFloatReg(int regNum, unw_fpreg_t value) { |
| 843 | 847 | #elif defined(_LIBUNWIND_TARGET_AARCH64) |
| 844 | 848 | _msContext.V[regNum - UNW_ARM64_D0].D[0] = value; |
| 845 | 849 | #else |
| 850 | (void)regNum; | |
| 851 | (void)value; | |
| 846 | 852 | _LIBUNWIND_ABORT("float registers unimplemented"); |
| 847 | 853 | #endif |
| 848 | 854 | } |
| ... | ... | @@ -892,6 +898,10 @@ public: |
| 892 | 898 | virtual void saveVFPAsX(); |
| 893 | 899 | #endif |
| 894 | 900 | |
| 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 | ||
| 895 | 905 | private: |
| 896 | 906 | |
| 897 | 907 | #if defined(_LIBUNWIND_ARM_EHABI) |
| ... | ... | @@ -1221,7 +1231,6 @@ template<typename A> |
| 1221 | 1231 | struct EHABISectionIterator { |
| 1222 | 1232 | typedef EHABISectionIterator _Self; |
| 1223 | 1233 | |
| 1224 | typedef std::random_access_iterator_tag iterator_category; | |
| 1225 | 1234 | typedef typename A::pint_t value_type; |
| 1226 | 1235 | typedef typename A::pint_t* pointer; |
| 1227 | 1236 | typedef typename A::pint_t& reference; |
| ... | ... | @@ -1275,6 +1284,29 @@ struct EHABISectionIterator { |
| 1275 | 1284 | const UnwindInfoSections* _sects; |
| 1276 | 1285 | }; |
| 1277 | 1286 | |
| 1287 | namespace { | |
| 1288 | ||
| 1289 | template <typename A> | |
| 1290 | EHABISectionIterator<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 | ||
| 1278 | 1310 | template <typename A, typename R> |
| 1279 | 1311 | bool UnwindCursor<A, R>::getInfoFromEHABISection( |
| 1280 | 1312 | pint_t pc, |
| ... | ... | @@ -1286,7 +1318,7 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection( |
| 1286 | 1318 | if (begin == end) |
| 1287 | 1319 | return false; |
| 1288 | 1320 | |
| 1289 | EHABISectionIterator<A> itNextPC = std::upper_bound(begin, end, pc); | |
| 1321 | EHABISectionIterator<A> itNextPC = EHABISectionUpperBound(begin, end, pc); | |
| 1290 | 1322 | if (itNextPC == begin) |
| 1291 | 1323 | return false; |
| 1292 | 1324 | EHABISectionIterator<A> itThisPC = itNextPC - 1; |
| ... | ... | @@ -1296,8 +1328,7 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection( |
| 1296 | 1328 | // in the table, we don't really know the function extent and have to choose a |
| 1297 | 1329 | // value for nextPC. Choosing max() will allow the range check during trace to |
| 1298 | 1330 | // 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(); | |
| 1301 | 1332 | pint_t indexDataAddr = itThisPC.dataAddress(); |
| 1302 | 1333 | |
| 1303 | 1334 | if (indexDataAddr == 0) |
| ... | ... | @@ -1709,7 +1740,7 @@ bool UnwindCursor<A, R>::getInfoFromCompactEncodingSection(pint_t pc, |
| 1709 | 1740 | --personalityIndex; // change 1-based to zero-based index |
| 1710 | 1741 | if (personalityIndex > sectionHeader.personalityArrayCount()) { |
| 1711 | 1742 | _LIBUNWIND_DEBUG_LOG("found encoding 0x%08X with personality index %d, " |
| 1712 | "but personality table has only %d entires", | |
| 1743 | "but personality table has only %d entries", | |
| 1713 | 1744 | encoding, personalityIndex, |
| 1714 | 1745 | sectionHeader.personalityArrayCount()); |
| 1715 | 1746 | return false; |
lib/libunwind/src/UnwindLevel1-gcc-ext.c+20-21| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===--------------------- UnwindLevel1-gcc-ext.c -------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Implements gcc extensions to the C++ ABI Exception Handling Level 1. |
| ... | ... | @@ -94,10 +93,10 @@ _LIBUNWIND_EXPORT void *_Unwind_FindEnclosingFunction(void *pc) { |
| 94 | 93 | unw_cursor_t cursor; |
| 95 | 94 | unw_context_t uc; |
| 96 | 95 | 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) | |
| 101 | 100 | return (void *)(intptr_t) info.start_ip; |
| 102 | 101 | else |
| 103 | 102 | return NULL; |
| ... | ... | @@ -109,8 +108,8 @@ _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 109 | 108 | _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { |
| 110 | 109 | unw_cursor_t cursor; |
| 111 | 110 | unw_context_t uc; |
| 112 | unw_getcontext(&uc); | |
| 113 | unw_init_local(&cursor, &uc); | |
| 111 | __unw_getcontext(&uc); | |
| 112 | __unw_init_local(&cursor, &uc); | |
| 114 | 113 | |
| 115 | 114 | _LIBUNWIND_TRACE_API("_Unwind_Backtrace(callback=%p)", |
| 116 | 115 | (void *)(uintptr_t)callback); |
| ... | ... | @@ -129,7 +128,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { |
| 129 | 128 | #if !defined(_LIBUNWIND_ARM_EHABI) |
| 130 | 129 | // ask libunwind to get next frame (skip over first frame which is |
| 131 | 130 | // _Unwind_Backtrace()) |
| 132 | if (unw_step(&cursor) <= 0) { | |
| 131 | if (__unw_step(&cursor) <= 0) { | |
| 133 | 132 | _LIBUNWIND_TRACE_UNWINDING(" _backtrace: ended because cursor reached " |
| 134 | 133 | "bottom of stack, returning %d", |
| 135 | 134 | _URC_END_OF_STACK); |
| ... | ... | @@ -138,7 +137,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { |
| 138 | 137 | #else |
| 139 | 138 | // Get the information for this frame. |
| 140 | 139 | unw_proc_info_t frameInfo; |
| 141 | if (unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) { | |
| 140 | if (__unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) { | |
| 142 | 141 | return _URC_END_OF_STACK; |
| 143 | 142 | } |
| 144 | 143 | |
| ... | ... | @@ -165,8 +164,8 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { |
| 165 | 164 | char functionName[512]; |
| 166 | 165 | unw_proc_info_t frame; |
| 167 | 166 | 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); | |
| 170 | 169 | _LIBUNWIND_TRACE_UNWINDING( |
| 171 | 170 | " _backtrace: start_ip=0x%" PRIxPTR ", func=%s, lsda=0x%" PRIxPTR ", context=%p", |
| 172 | 171 | frame.start_ip, functionName, frame.lsda, |
| ... | ... | @@ -192,10 +191,10 @@ _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc, |
| 192 | 191 | unw_cursor_t cursor; |
| 193 | 192 | unw_context_t uc; |
| 194 | 193 | 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); | |
| 199 | 198 | bases->tbase = (uintptr_t)info.extra; |
| 200 | 199 | bases->dbase = 0; // dbase not used on Mac OS X |
| 201 | 200 | bases->func = (uintptr_t)info.start_ip; |
| ... | ... | @@ -209,7 +208,7 @@ _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc, |
| 209 | 208 | _LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) { |
| 210 | 209 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 211 | 210 | unw_word_t result; |
| 212 | unw_get_reg(cursor, UNW_REG_SP, &result); | |
| 211 | __unw_get_reg(cursor, UNW_REG_SP, &result); | |
| 213 | 212 | _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p) => 0x%" PRIxPTR, |
| 214 | 213 | (void *)context, result); |
| 215 | 214 | return (uintptr_t)result; |
| ... | ... | @@ -234,7 +233,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context, |
| 234 | 233 | /// was broken until 10.6. |
| 235 | 234 | _LIBUNWIND_EXPORT void __register_frame(const void *fde) { |
| 236 | 235 | _LIBUNWIND_TRACE_API("__register_frame(%p)", fde); |
| 237 | _unw_add_dynamic_fde((unw_word_t)(uintptr_t) fde); | |
| 236 | __unw_add_dynamic_fde((unw_word_t)(uintptr_t)fde); | |
| 238 | 237 | } |
| 239 | 238 | |
| 240 | 239 | |
| ... | ... | @@ -244,7 +243,7 @@ _LIBUNWIND_EXPORT void __register_frame(const void *fde) { |
| 244 | 243 | /// was broken until 10.6. |
| 245 | 244 | _LIBUNWIND_EXPORT void __deregister_frame(const void *fde) { |
| 246 | 245 | _LIBUNWIND_TRACE_API("__deregister_frame(%p)", fde); |
| 247 | _unw_remove_dynamic_fde((unw_word_t)(uintptr_t) fde); | |
| 246 | __unw_remove_dynamic_fde((unw_word_t)(uintptr_t)fde); | |
| 248 | 247 | } |
| 249 | 248 | |
| 250 | 249 |
lib/libunwind/src/UnwindLevel1.c+63-57| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | 1 | //===------------------------- UnwindLevel1.c -----------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // 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 | |
| 11 | 10 | // using libunwind |
| 12 | 11 | // |
| 13 | 12 | //===----------------------------------------------------------------------===// |
| ... | ... | @@ -26,9 +25,10 @@ |
| 26 | 25 | #include <stdio.h> |
| 27 | 26 | #include <string.h> |
| 28 | 27 | |
| 28 | #include "config.h" | |
| 29 | 29 | #include "libunwind.h" |
| 30 | #include "libunwind_ext.h" | |
| 30 | 31 | #include "unwind.h" |
| 31 | #include "config.h" | |
| 32 | 32 | |
| 33 | 33 | #if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__) |
| 34 | 34 | |
| ... | ... | @@ -36,33 +36,36 @@ |
| 36 | 36 | |
| 37 | 37 | static _Unwind_Reason_Code |
| 38 | 38 | unwind_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); | |
| 40 | 40 | |
| 41 | 41 | // Walk each frame looking for a place to stop. |
| 42 | 42 | bool handlerNotFound = true; |
| 43 | 43 | while (handlerNotFound) { |
| 44 | 44 | // Ask libunwind to get next frame (skip over first which is |
| 45 | 45 | // _Unwind_RaiseException). |
| 46 | int stepResult = unw_step(cursor); | |
| 46 | int stepResult = __unw_step(cursor); | |
| 47 | 47 | 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); | |
| 51 | 52 | return _URC_END_OF_STACK; |
| 52 | 53 | } 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); | |
| 56 | 58 | return _URC_FATAL_PHASE1_ERROR; |
| 57 | 59 | } |
| 58 | 60 | |
| 59 | 61 | // See if frame has code to run (has personality routine). |
| 60 | 62 | unw_proc_info_t frameInfo; |
| 61 | 63 | 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); | |
| 66 | 69 | return _URC_FATAL_PHASE1_ERROR; |
| 67 | 70 | } |
| 68 | 71 | |
| ... | ... | @@ -71,12 +74,12 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 71 | 74 | char functionBuf[512]; |
| 72 | 75 | const char *functionName = functionBuf; |
| 73 | 76 | 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) || | |
| 76 | 79 | (frameInfo.start_ip + offset > frameInfo.end_ip)) |
| 77 | 80 | functionName = ".anonymous."; |
| 78 | 81 | unw_word_t pc; |
| 79 | unw_get_reg(cursor, UNW_REG_IP, &pc); | |
| 82 | __unw_get_reg(cursor, UNW_REG_IP, &pc); | |
| 80 | 83 | _LIBUNWIND_TRACE_UNWINDING( |
| 81 | 84 | "unwind_phase1(ex_ojb=%p): pc=0x%" PRIxPTR ", start_ip=0x%" PRIxPTR |
| 82 | 85 | ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR "", |
| ... | ... | @@ -100,7 +103,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 100 | 103 | // found a catch clause or locals that need destructing in this frame |
| 101 | 104 | // stop search and remember stack pointer at the frame |
| 102 | 105 | handlerNotFound = false; |
| 103 | unw_get_reg(cursor, UNW_REG_SP, &sp); | |
| 106 | __unw_get_reg(cursor, UNW_REG_SP, &sp); | |
| 104 | 107 | exception_object->private_2 = (uintptr_t)sp; |
| 105 | 108 | _LIBUNWIND_TRACE_UNWINDING( |
| 106 | 109 | "unwind_phase1(ex_ojb=%p): _URC_HANDLER_FOUND", |
| ... | ... | @@ -129,7 +132,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 129 | 132 | |
| 130 | 133 | static _Unwind_Reason_Code |
| 131 | 134 | unwind_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); | |
| 133 | 136 | |
| 134 | 137 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)", |
| 135 | 138 | (void *)exception_object); |
| ... | ... | @@ -139,27 +142,30 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 139 | 142 | |
| 140 | 143 | // Ask libunwind to get next frame (skip over first which is |
| 141 | 144 | // _Unwind_RaiseException). |
| 142 | int stepResult = unw_step(cursor); | |
| 145 | int stepResult = __unw_step(cursor); | |
| 143 | 146 | 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); | |
| 147 | 151 | return _URC_END_OF_STACK; |
| 148 | 152 | } 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); | |
| 152 | 157 | return _URC_FATAL_PHASE2_ERROR; |
| 153 | 158 | } |
| 154 | 159 | |
| 155 | 160 | // Get info about this frame. |
| 156 | 161 | unw_word_t sp; |
| 157 | 162 | 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); | |
| 163 | 169 | return _URC_FATAL_PHASE2_ERROR; |
| 164 | 170 | } |
| 165 | 171 | |
| ... | ... | @@ -168,8 +174,8 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 168 | 174 | char functionBuf[512]; |
| 169 | 175 | const char *functionName = functionBuf; |
| 170 | 176 | 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) || | |
| 173 | 179 | (frameInfo.start_ip + offset > frameInfo.end_ip)) |
| 174 | 180 | functionName = ".anonymous."; |
| 175 | 181 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): start_ip=0x%" PRIxPTR |
| ... | ... | @@ -212,15 +218,15 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except |
| 212 | 218 | // We may get control back if landing pad calls _Unwind_Resume(). |
| 213 | 219 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 214 | 220 | 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); | |
| 217 | 223 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering " |
| 218 | 224 | "user code with ip=0x%" PRIxPTR |
| 219 | 225 | ", sp=0x%" PRIxPTR, |
| 220 | 226 | (void *)exception_object, pc, sp); |
| 221 | 227 | } |
| 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. | |
| 224 | 230 | return _URC_FATAL_PHASE2_ERROR; |
| 225 | 231 | default: |
| 226 | 232 | // Personality routine returned an unknown result code. |
| ... | ... | @@ -240,15 +246,15 @@ static _Unwind_Reason_Code |
| 240 | 246 | unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, |
| 241 | 247 | _Unwind_Exception *exception_object, |
| 242 | 248 | _Unwind_Stop_Fn stop, void *stop_parameter) { |
| 243 | unw_init_local(cursor, uc); | |
| 249 | __unw_init_local(cursor, uc); | |
| 244 | 250 | |
| 245 | 251 | // Walk each frame until we reach where search phase said to stop |
| 246 | while (unw_step(cursor) > 0) { | |
| 252 | while (__unw_step(cursor) > 0) { | |
| 247 | 253 | |
| 248 | 254 | // Update info about this frame. |
| 249 | 255 | 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 " | |
| 252 | 258 | "failed => _URC_END_OF_STACK", |
| 253 | 259 | (void *)exception_object); |
| 254 | 260 | return _URC_FATAL_PHASE2_ERROR; |
| ... | ... | @@ -259,8 +265,8 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, |
| 259 | 265 | char functionBuf[512]; |
| 260 | 266 | const char *functionName = functionBuf; |
| 261 | 267 | 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) || | |
| 264 | 270 | (frameInfo.start_ip + offset > frameInfo.end_ip)) |
| 265 | 271 | functionName = ".anonymous."; |
| 266 | 272 | _LIBUNWIND_TRACE_UNWINDING( |
| ... | ... | @@ -310,7 +316,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, |
| 310 | 316 | "_URC_INSTALL_CONTEXT", |
| 311 | 317 | (void *)exception_object); |
| 312 | 318 | // We may get control back if landing pad calls _Unwind_Resume(). |
| 313 | unw_resume(cursor); | |
| 319 | __unw_resume(cursor); | |
| 314 | 320 | break; |
| 315 | 321 | default: |
| 316 | 322 | // Personality routine returned an unknown result code. |
| ... | ... | @@ -346,7 +352,7 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) { |
| 346 | 352 | (void *)exception_object); |
| 347 | 353 | unw_context_t uc; |
| 348 | 354 | unw_cursor_t cursor; |
| 349 | unw_getcontext(&uc); | |
| 355 | __unw_getcontext(&uc); | |
| 350 | 356 | |
| 351 | 357 | // Mark that this is a non-forced unwind, so _Unwind_Resume() |
| 352 | 358 | // can do the right thing. |
| ... | ... | @@ -380,7 +386,7 @@ _Unwind_Resume(_Unwind_Exception *exception_object) { |
| 380 | 386 | _LIBUNWIND_TRACE_API("_Unwind_Resume(ex_obj=%p)", (void *)exception_object); |
| 381 | 387 | unw_context_t uc; |
| 382 | 388 | unw_cursor_t cursor; |
| 383 | unw_getcontext(&uc); | |
| 389 | __unw_getcontext(&uc); | |
| 384 | 390 | |
| 385 | 391 | if (exception_object->private_1 != 0) |
| 386 | 392 | unwind_phase2_forced(&uc, &cursor, exception_object, |
| ... | ... | @@ -405,7 +411,7 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object, |
| 405 | 411 | (void *)exception_object, (void *)(uintptr_t)stop); |
| 406 | 412 | unw_context_t uc; |
| 407 | 413 | unw_cursor_t cursor; |
| 408 | unw_getcontext(&uc); | |
| 414 | __unw_getcontext(&uc); | |
| 409 | 415 | |
| 410 | 416 | // Mark that this is a forced unwind, so _Unwind_Resume() can do |
| 411 | 417 | // the right thing. |
| ... | ... | @@ -423,7 +429,7 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) { |
| 423 | 429 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 424 | 430 | unw_proc_info_t frameInfo; |
| 425 | 431 | uintptr_t result = 0; |
| 426 | if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) | |
| 432 | if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) | |
| 427 | 433 | result = (uintptr_t)frameInfo.lsda; |
| 428 | 434 | _LIBUNWIND_TRACE_API( |
| 429 | 435 | "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIxPTR, |
| ... | ... | @@ -444,7 +450,7 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) { |
| 444 | 450 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 445 | 451 | unw_proc_info_t frameInfo; |
| 446 | 452 | uintptr_t result = 0; |
| 447 | if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) | |
| 453 | if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) | |
| 448 | 454 | result = (uintptr_t)frameInfo.start_ip; |
| 449 | 455 | _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIxPTR, |
| 450 | 456 | (void *)context, result); |
| ... | ... | @@ -469,7 +475,7 @@ _LIBUNWIND_EXPORT uintptr_t |
| 469 | 475 | _Unwind_GetGR(struct _Unwind_Context *context, int index) { |
| 470 | 476 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 471 | 477 | unw_word_t result; |
| 472 | unw_get_reg(cursor, index, &result); | |
| 478 | __unw_get_reg(cursor, index, &result); | |
| 473 | 479 | _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d) => 0x%" PRIxPTR, |
| 474 | 480 | (void *)context, index, result); |
| 475 | 481 | return (uintptr_t)result; |
| ... | ... | @@ -482,14 +488,14 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index, |
| 482 | 488 | ")", |
| 483 | 489 | (void *)context, index, value); |
| 484 | 490 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 485 | unw_set_reg(cursor, index, value); | |
| 491 | __unw_set_reg(cursor, index, value); | |
| 486 | 492 | } |
| 487 | 493 | |
| 488 | 494 | /// Called by personality handler during phase 2 to get instruction pointer. |
| 489 | 495 | _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) { |
| 490 | 496 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 491 | 497 | unw_word_t result; |
| 492 | unw_get_reg(cursor, UNW_REG_IP, &result); | |
| 498 | __unw_get_reg(cursor, UNW_REG_IP, &result); | |
| 493 | 499 | _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIxPTR, |
| 494 | 500 | (void *)context, result); |
| 495 | 501 | return (uintptr_t)result; |
| ... | ... | @@ -503,7 +509,7 @@ _LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context, |
| 503 | 509 | _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%0" PRIxPTR ")", |
| 504 | 510 | (void *)context, value); |
| 505 | 511 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 506 | unw_set_reg(cursor, UNW_REG_IP, value); | |
| 512 | __unw_set_reg(cursor, UNW_REG_IP, value); | |
| 507 | 513 | } |
| 508 | 514 | |
| 509 | 515 | #endif // !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__) |
lib/libunwind/src/UnwindRegistersRestore.S+148-141| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===-------------------- UnwindRegistersRestore.S ------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | //===----------------------------------------------------------------------===// |
| 9 | 8 | |
| ... | ... | @@ -14,7 +13,7 @@ |
| 14 | 13 | #if !defined(__USING_SJLJ_EXCEPTIONS__) |
| 15 | 14 | |
| 16 | 15 | #if defined(__i386__) |
| 17 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv) | |
| 16 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv) | |
| 18 | 17 | # |
| 19 | 18 | # void libunwind::Registers_x86::jumpto() |
| 20 | 19 | # |
| ... | ... | @@ -61,7 +60,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv) |
| 61 | 60 | |
| 62 | 61 | #elif defined(__x86_64__) |
| 63 | 62 | |
| 64 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv) | |
| 63 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv) | |
| 65 | 64 | # |
| 66 | 65 | # void libunwind::Registers_x86_64::jumpto() |
| 67 | 66 | # |
| ... | ... | @@ -130,7 +129,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv) |
| 130 | 129 | |
| 131 | 130 | #elif defined(__powerpc64__) |
| 132 | 131 | |
| 133 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv) | |
| 132 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv) | |
| 134 | 133 | // |
| 135 | 134 | // void libunwind::Registers_ppc64::jumpto() |
| 136 | 135 | // |
| ... | ... | @@ -395,120 +394,120 @@ Lnovec: |
| 395 | 394 | |
| 396 | 395 | #elif defined(__ppc__) |
| 397 | 396 | |
| 398 | DEFINE_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 | |
| 397 | DEFINE_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) | |
| 483 | 472 | |
| 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 | ||
| 484 | 483 | |
| 485 | 484 | #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 @\ | |
| 497 | Ldone ## _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: | |
| 498 | 497 | |
| 499 | 498 | #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: | |
| 512 | 511 | |
| 513 | 512 | |
| 514 | 513 | LOAD_VECTOR_UNALIGNEDl(0) |
| ... | ... | @@ -545,17 +544,17 @@ Ldone ## _index: |
| 545 | 544 | LOAD_VECTOR_UNALIGNEDh(31) |
| 546 | 545 | |
| 547 | 546 | Lnovec: |
| 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 | |
| 559 | 558 | bctr |
| 560 | 559 | |
| 561 | 560 | #elif defined(__arm64__) || defined(__aarch64__) |
| ... | ... | @@ -567,7 +566,7 @@ Lnovec: |
| 567 | 566 | // thread_state pointer is in x0 |
| 568 | 567 | // |
| 569 | 568 | .p2align 2 |
| 570 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv) | |
| 569 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv) | |
| 571 | 570 | // skip restore of x0,x1 for now |
| 572 | 571 | ldp x2, x3, [x0, #0x010] |
| 573 | 572 | ldp x4, x5, [x0, #0x020] |
| ... | ... | @@ -576,7 +575,8 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv) |
| 576 | 575 | ldp x10,x11, [x0, #0x050] |
| 577 | 576 | ldp x12,x13, [x0, #0x060] |
| 578 | 577 | ldp x14,x15, [x0, #0x070] |
| 579 | ldp x16,x17, [x0, #0x080] | |
| 578 | // x16 and x17 were clobbered by the call into the unwinder, so no point in | |
| 579 | // restoring them. | |
| 580 | 580 | ldp x18,x19, [x0, #0x090] |
| 581 | 581 | ldp x20,x21, [x0, #0x0A0] |
| 582 | 582 | ldp x22,x23, [x0, #0x0B0] |
| ... | ... | @@ -584,8 +584,6 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv) |
| 584 | 584 | ldp x26,x27, [x0, #0x0D0] |
| 585 | 585 | ldp x28,x29, [x0, #0x0E0] |
| 586 | 586 | ldr x30, [x0, #0x100] // restore pc into lr |
| 587 | ldr x1, [x0, #0x0F8] | |
| 588 | mov sp,x1 // restore sp | |
| 589 | 587 | |
| 590 | 588 | ldp d0, d1, [x0, #0x110] |
| 591 | 589 | ldp d2, d3, [x0, #0x120] |
| ... | ... | @@ -605,12 +603,21 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv) |
| 605 | 603 | ldr d30, [x0, #0x200] |
| 606 | 604 | ldr d31, [x0, #0x208] |
| 607 | 605 | |
| 606 | // Finally, restore sp. This must be done after the the last read from the | |
| 607 | // context struct, because it is allocated on the stack, and an exception | |
| 608 | // could clobber the de-allocated portion of the stack after sp has been | |
| 609 | // restored. | |
| 610 | ldr x16, [x0, #0x0F8] | |
| 608 | 611 | ldp x0, x1, [x0, #0x000] // restore x0,x1 |
| 612 | mov sp,x16 // restore sp | |
| 609 | 613 | ret x30 // jump to pc |
| 610 | 614 | |
| 611 | 615 | #elif defined(__arm__) && !defined(__APPLE__) |
| 612 | 616 | |
| 613 | 617 | #if !defined(__ARM_ARCH_ISA_ARM) |
| 618 | #if (__ARM_ARCH_ISA_THUMB == 2) | |
| 619 | .syntax unified | |
| 620 | #endif | |
| 614 | 621 | .thumb |
| 615 | 622 | #endif |
| 616 | 623 | |
| ... | ... | @@ -621,7 +628,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv) |
| 621 | 628 | @ thread_state pointer is in r0 |
| 622 | 629 | @ |
| 623 | 630 | .p2align 2 |
| 624 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJumpToEv) | |
| 631 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJumpToEv) | |
| 625 | 632 | #if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1 |
| 626 | 633 | @ r8-r11: ldm into r1-r4, then mov to r8-r11 |
| 627 | 634 | adds r0, #0x20 |
| ... | ... | @@ -659,7 +666,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJu |
| 659 | 666 | #if defined(__ELF__) |
| 660 | 667 | .fpu vfpv3-d16 |
| 661 | 668 | #endif |
| 662 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMDEPy) | |
| 669 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMDEPv) | |
| 663 | 670 | @ VFP and iwMMX instructions are only available when compiling with the flags |
| 664 | 671 | @ that enable them. We do not want to do that in the library (because we do not |
| 665 | 672 | @ want the compiler to generate instructions that access those) but this is |
| ... | ... | @@ -680,7 +687,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFL |
| 680 | 687 | #if defined(__ELF__) |
| 681 | 688 | .fpu vfpv3-d16 |
| 682 | 689 | #endif |
| 683 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMXEPy) | |
| 690 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMXEPv) | |
| 684 | 691 | vldmia r0, {d0-d15} @ fldmiax is deprecated in ARMv7+ and now behaves like vldmia |
| 685 | 692 | JMP(lr) |
| 686 | 693 | |
| ... | ... | @@ -694,7 +701,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFL |
| 694 | 701 | #if defined(__ELF__) |
| 695 | 702 | .fpu vfpv3 |
| 696 | 703 | #endif |
| 697 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreVFPv3EPy) | |
| 704 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm12restoreVFPv3EPv) | |
| 698 | 705 | vldmia r0, {d16-d31} |
| 699 | 706 | JMP(lr) |
| 700 | 707 | |
| ... | ... | @@ -710,7 +717,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreVFPv3EPy) |
| 710 | 717 | #if defined(__ELF__) |
| 711 | 718 | .arch armv5te |
| 712 | 719 | #endif |
| 713 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPy) | |
| 720 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPv) | |
| 714 | 721 | ldcl p1, cr0, [r0], #8 @ wldrd wR0, [r0], #8 |
| 715 | 722 | ldcl p1, cr1, [r0], #8 @ wldrd wR1, [r0], #8 |
| 716 | 723 | ldcl p1, cr2, [r0], #8 @ wldrd wR2, [r0], #8 |
| ... | ... | @@ -739,7 +746,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPy) |
| 739 | 746 | #if defined(__ELF__) |
| 740 | 747 | .arch armv5te |
| 741 | 748 | #endif |
| 742 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXControlEPj) | |
| 749 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXControlEPj) | |
| 743 | 750 | ldc2 p1, cr8, [r0], #4 @ wldrw wCGR0, [r0], #4 |
| 744 | 751 | ldc2 p1, cr9, [r0], #4 @ wldrw wCGR1, [r0], #4 |
| 745 | 752 | ldc2 p1, cr10, [r0], #4 @ wldrw wCGR2, [r0], #4 |
| ... | ... | @@ -750,7 +757,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXCont |
| 750 | 757 | |
| 751 | 758 | #elif defined(__or1k__) |
| 752 | 759 | |
| 753 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv) | |
| 760 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv) | |
| 754 | 761 | # |
| 755 | 762 | # void libunwind::Registers_or1k::jumpto() |
| 756 | 763 | # |
| ... | ... | @@ -809,7 +816,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv) |
| 809 | 816 | // On entry: |
| 810 | 817 | // thread state pointer is in a0 ($4) |
| 811 | 818 | // |
| 812 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv) | |
| 819 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv) | |
| 813 | 820 | .set push |
| 814 | 821 | .set noat |
| 815 | 822 | .set noreorder |
| ... | ... | @@ -918,7 +925,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_o326jumptoEv) |
| 918 | 925 | // On entry: |
| 919 | 926 | // thread state pointer is in a0 ($4) |
| 920 | 927 | // |
| 921 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv) | |
| 928 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv) | |
| 922 | 929 | .set push |
| 923 | 930 | .set noat |
| 924 | 931 | .set noreorder |
| ... | ... | @@ -1008,7 +1015,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv) |
| 1008 | 1015 | // On entry: |
| 1009 | 1016 | // thread_state pointer is in o0 |
| 1010 | 1017 | // |
| 1011 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_sparc6jumptoEv) | |
| 1018 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_sparc6jumptoEv) | |
| 1012 | 1019 | ta 3 |
| 1013 | 1020 | ldd [%o0 + 64], %l0 |
| 1014 | 1021 | ldd [%o0 + 72], %l2 |
lib/libunwind/src/UnwindRegistersSave.S+171-166| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===------------------------ UnwindRegistersSave.S -----------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | //===----------------------------------------------------------------------===// |
| 9 | 8 | |
| ... | ... | @@ -16,7 +15,7 @@ |
| 16 | 15 | #if defined(__i386__) |
| 17 | 16 | |
| 18 | 17 | # |
| 19 | # extern int unw_getcontext(unw_context_t* thread_state) | |
| 18 | # extern int __unw_getcontext(unw_context_t* thread_state) | |
| 20 | 19 | # |
| 21 | 20 | # On entry: |
| 22 | 21 | # + + |
| ... | ... | @@ -27,7 +26,7 @@ |
| 27 | 26 | # +-----------------------+ <-- SP |
| 28 | 27 | # + + |
| 29 | 28 | # |
| 30 | DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) | |
| 29 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) | |
| 31 | 30 | push %eax |
| 32 | 31 | movl 8(%esp), %eax |
| 33 | 32 | movl %ebx, 4(%eax) |
| ... | ... | @@ -57,12 +56,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) |
| 57 | 56 | #elif defined(__x86_64__) |
| 58 | 57 | |
| 59 | 58 | # |
| 60 | # extern int unw_getcontext(unw_context_t* thread_state) | |
| 59 | # extern int __unw_getcontext(unw_context_t* thread_state) | |
| 61 | 60 | # |
| 62 | 61 | # On entry: |
| 63 | 62 | # thread_state pointer is in rdi |
| 64 | 63 | # |
| 65 | DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) | |
| 64 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) | |
| 66 | 65 | #if defined(_WIN64) |
| 67 | 66 | #define PTR %rcx |
| 68 | 67 | #define TMP %rdx |
| ... | ... | @@ -119,12 +118,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) |
| 119 | 118 | #elif defined(__mips__) && defined(_ABIO32) && _MIPS_SIM == _ABIO32 |
| 120 | 119 | |
| 121 | 120 | # |
| 122 | # extern int unw_getcontext(unw_context_t* thread_state) | |
| 121 | # extern int __unw_getcontext(unw_context_t* thread_state) | |
| 123 | 122 | # |
| 124 | 123 | # On entry: |
| 125 | 124 | # thread_state pointer is in a0 ($4) |
| 126 | 125 | # |
| 127 | DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) | |
| 126 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) | |
| 128 | 127 | .set push |
| 129 | 128 | .set noat |
| 130 | 129 | .set noreorder |
| ... | ... | @@ -228,12 +227,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) |
| 228 | 227 | #elif defined(__mips64) |
| 229 | 228 | |
| 230 | 229 | # |
| 231 | # extern int unw_getcontext(unw_context_t* thread_state) | |
| 230 | # extern int __unw_getcontext(unw_context_t* thread_state) | |
| 232 | 231 | # |
| 233 | 232 | # On entry: |
| 234 | 233 | # thread_state pointer is in a0 ($4) |
| 235 | 234 | # |
| 236 | DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) | |
| 235 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) | |
| 237 | 236 | .set push |
| 238 | 237 | .set noat |
| 239 | 238 | .set noreorder |
| ... | ... | @@ -318,21 +317,21 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) |
| 318 | 317 | # elif defined(__mips__) |
| 319 | 318 | |
| 320 | 319 | # |
| 321 | # extern int unw_getcontext(unw_context_t* thread_state) | |
| 320 | # extern int __unw_getcontext(unw_context_t* thread_state) | |
| 322 | 321 | # |
| 323 | 322 | # Just trap for the time being. |
| 324 | DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) | |
| 323 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) | |
| 325 | 324 | teq $0, $0 |
| 326 | 325 | |
| 327 | 326 | #elif defined(__powerpc64__) |
| 328 | 327 | |
| 329 | 328 | // |
| 330 | // extern int unw_getcontext(unw_context_t* thread_state) | |
| 329 | // extern int __unw_getcontext(unw_context_t* thread_state) | |
| 331 | 330 | // |
| 332 | 331 | // On entry: |
| 333 | 332 | // thread_state pointer is in r3 |
| 334 | 333 | // |
| 335 | DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) | |
| 334 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) | |
| 336 | 335 | |
| 337 | 336 | // store register (GPR) |
| 338 | 337 | #define PPC64_STR(n) \ |
| ... | ... | @@ -557,157 +556,157 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) |
| 557 | 556 | |
| 558 | 557 | #elif defined(__ppc__) |
| 559 | 558 | |
| 560 | ; | |
| 561 | ; extern int unw_getcontext(unw_context_t* thread_state) | |
| 562 | ; | |
| 563 | ; On entry: | |
| 564 | ; thread_state pointer is in r3 | |
| 565 | ; | |
| 566 | DEFINE_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 | // | |
| 565 | DEFINE_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 | |
| 652 | 651 | |
| 653 | 652 | #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 | |
| 698 | 697 | blr |
| 699 | 698 | |
| 700 | 699 | |
| 701 | 700 | #elif defined(__arm64__) || defined(__aarch64__) |
| 702 | 701 | |
| 703 | 702 | // |
| 704 | // extern int unw_getcontext(unw_context_t* thread_state) | |
| 703 | // extern int __unw_getcontext(unw_context_t* thread_state) | |
| 705 | 704 | // |
| 706 | 705 | // On entry: |
| 707 | 706 | // thread_state pointer is in x0 |
| 708 | 707 | // |
| 709 | 708 | .p2align 2 |
| 710 | DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) | |
| 709 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) | |
| 711 | 710 | stp x0, x1, [x0, #0x000] |
| 712 | 711 | stp x2, x3, [x0, #0x010] |
| 713 | 712 | stp x4, x5, [x0, #0x020] |
| ... | ... | @@ -751,11 +750,14 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) |
| 751 | 750 | #elif defined(__arm__) && !defined(__APPLE__) |
| 752 | 751 | |
| 753 | 752 | #if !defined(__ARM_ARCH_ISA_ARM) |
| 753 | #if (__ARM_ARCH_ISA_THUMB == 2) | |
| 754 | .syntax unified | |
| 755 | #endif | |
| 754 | 756 | .thumb |
| 755 | 757 | #endif |
| 756 | 758 | |
| 757 | 759 | @ |
| 758 | @ extern int unw_getcontext(unw_context_t* thread_state) | |
| 760 | @ extern int __unw_getcontext(unw_context_t* thread_state) | |
| 759 | 761 | @ |
| 760 | 762 | @ On entry: |
| 761 | 763 | @ thread_state pointer is in r0 |
| ... | ... | @@ -764,10 +766,10 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) |
| 764 | 766 | @ EHABI #7.4.5 notes that in general all VRS registers should be restored |
| 765 | 767 | @ however this is very hard to do for VFP registers because it is unknown |
| 766 | 768 | @ to the library how many registers are implemented by the architecture. |
| 767 | @ Instead, VFP registers are demand saved by logic external to unw_getcontext. | |
| 769 | @ Instead, VFP registers are demand saved by logic external to __unw_getcontext. | |
| 768 | 770 | @ |
| 769 | 771 | .p2align 2 |
| 770 | DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) | |
| 772 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) | |
| 771 | 773 | #if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1 |
| 772 | 774 | stm r0!, {r0-r7} |
| 773 | 775 | mov r1, r8 |
| ... | ... | @@ -808,7 +810,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) |
| 808 | 810 | #if defined(__ELF__) |
| 809 | 811 | .fpu vfpv3-d16 |
| 810 | 812 | #endif |
| 811 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMDEPy) | |
| 813 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMDEPv) | |
| 812 | 814 | vstmia r0, {d0-d15} |
| 813 | 815 | JMP(lr) |
| 814 | 816 | |
| ... | ... | @@ -822,7 +824,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMD |
| 822 | 824 | #if defined(__ELF__) |
| 823 | 825 | .fpu vfpv3-d16 |
| 824 | 826 | #endif |
| 825 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMXEPy) | |
| 827 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMXEPv) | |
| 826 | 828 | vstmia r0, {d0-d15} @ fstmiax is deprecated in ARMv7+ and now behaves like vstmia |
| 827 | 829 | JMP(lr) |
| 828 | 830 | |
| ... | ... | @@ -836,7 +838,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMX |
| 836 | 838 | #if defined(__ELF__) |
| 837 | 839 | .fpu vfpv3 |
| 838 | 840 | #endif |
| 839 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPy) | |
| 841 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPv) | |
| 840 | 842 | @ VFP and iwMMX instructions are only available when compiling with the flags |
| 841 | 843 | @ that enable them. We do not want to do that in the library (because we do not |
| 842 | 844 | @ want the compiler to generate instructions that access those) but this is |
| ... | ... | @@ -859,7 +861,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPy) |
| 859 | 861 | #if defined(__ELF__) |
| 860 | 862 | .arch armv5te |
| 861 | 863 | #endif |
| 862 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPy) | |
| 864 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPv) | |
| 863 | 865 | stcl p1, cr0, [r0], #8 @ wstrd wR0, [r0], #8 |
| 864 | 866 | stcl p1, cr1, [r0], #8 @ wstrd wR1, [r0], #8 |
| 865 | 867 | stcl p1, cr2, [r0], #8 @ wstrd wR2, [r0], #8 |
| ... | ... | @@ -888,7 +890,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPy) |
| 888 | 890 | #if defined(__ELF__) |
| 889 | 891 | .arch armv5te |
| 890 | 892 | #endif |
| 891 | DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj) | |
| 893 | DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj) | |
| 892 | 894 | stc2 p1, cr8, [r0], #4 @ wstrw wCGR0, [r0], #4 |
| 893 | 895 | stc2 p1, cr9, [r0], #4 @ wstrw wCGR1, [r0], #4 |
| 894 | 896 | stc2 p1, cr10, [r0], #4 @ wstrw wCGR2, [r0], #4 |
| ... | ... | @@ -900,12 +902,12 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControl |
| 900 | 902 | #elif defined(__or1k__) |
| 901 | 903 | |
| 902 | 904 | # |
| 903 | # extern int unw_getcontext(unw_context_t* thread_state) | |
| 905 | # extern int __unw_getcontext(unw_context_t* thread_state) | |
| 904 | 906 | # |
| 905 | 907 | # On entry: |
| 906 | 908 | # thread_state pointer is in r3 |
| 907 | 909 | # |
| 908 | DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) | |
| 910 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) | |
| 909 | 911 | l.sw 0(r3), r0 |
| 910 | 912 | l.sw 4(r3), r1 |
| 911 | 913 | l.sw 8(r3), r2 |
| ... | ... | @@ -946,12 +948,12 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) |
| 946 | 948 | #elif defined(__sparc__) |
| 947 | 949 | |
| 948 | 950 | # |
| 949 | # extern int unw_getcontext(unw_context_t* thread_state) | |
| 951 | # extern int __unw_getcontext(unw_context_t* thread_state) | |
| 950 | 952 | # |
| 951 | 953 | # On entry: |
| 952 | 954 | # thread_state pointer is in o0 |
| 953 | 955 | # |
| 954 | DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) | |
| 956 | DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) | |
| 955 | 957 | ta 3 |
| 956 | 958 | add %o7, 8, %o7 |
| 957 | 959 | std %g0, [%o0 + 0] |
| ... | ... | @@ -973,6 +975,9 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) |
| 973 | 975 | jmp %o7 |
| 974 | 976 | clr %o0 // return UNW_ESUCCESS |
| 975 | 977 | #endif |
| 978 | ||
| 979 | WEAK_ALIAS(__unw_getcontext, unw_getcontext) | |
| 980 | ||
| 976 | 981 | #endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */ |
| 977 | 982 | |
| 978 | 983 | NO_EXEC_STACK_DIRECTIVE |
lib/libunwind/src/Unwind_AppleExtras.cpp+3-4| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===--------------------- Unwind_AppleExtras.cpp -------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | //===----------------------------------------------------------------------===// |
lib/libunwind/src/assembly.h+54-20| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | /* ===-- assembly.h - libUnwind assembler support macros -------------------=== |
| 2 | 2 | * |
| 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 | |
| 7 | 6 | * |
| 8 | 7 | * ===----------------------------------------------------------------------=== |
| 9 | 8 | * |
| ... | ... | @@ -29,14 +28,26 @@ |
| 29 | 28 | #ifdef _ARCH_PWR8 |
| 30 | 29 | #define PPC64_HAS_VMX |
| 31 | 30 | #endif |
| 32 | #elif defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__) | |
| 33 | #define SEPARATOR @ | |
| 34 | 31 | #elif defined(__arm64__) |
| 35 | 32 | #define SEPARATOR %% |
| 36 | 33 | #else |
| 37 | 34 | #define SEPARATOR ; |
| 38 | 35 | #endif |
| 39 | 36 | |
| 37 | #if defined(__powerpc64__) && (!defined(_CALL_ELF) || _CALL_ELF == 1) | |
| 38 | #define PPC64_OPD1 .section .opd,"aw",@progbits SEPARATOR | |
| 39 | #define PPC64_OPD2 SEPARATOR \ | |
| 40 | .p2align 3 SEPARATOR \ | |
| 41 | .quad .Lfunc_begin0 SEPARATOR \ | |
| 42 | .quad .TOC.@tocbase SEPARATOR \ | |
| 43 | .quad 0 SEPARATOR \ | |
| 44 | .text SEPARATOR \ | |
| 45 | .Lfunc_begin0: | |
| 46 | #else | |
| 47 | #define PPC64_OPD1 | |
| 48 | #define PPC64_OPD2 | |
| 49 | #endif | |
| 50 | ||
| 40 | 51 | #define GLUE2(a, b) a ## b |
| 41 | 52 | #define GLUE(a, b) GLUE2(a, b) |
| 42 | 53 | #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name) |
| ... | ... | @@ -46,6 +57,12 @@ |
| 46 | 57 | #define SYMBOL_IS_FUNC(name) |
| 47 | 58 | #define EXPORT_SYMBOL(name) |
| 48 | 59 | #define HIDDEN_SYMBOL(name) .private_extern name |
| 60 | #define WEAK_SYMBOL(name) .weak_reference name | |
| 61 | #define WEAK_ALIAS(name, aliasname) \ | |
| 62 | .globl SYMBOL_NAME(aliasname) SEPARATOR \ | |
| 63 | WEAK_SYMBOL(aliasname) SEPARATOR \ | |
| 64 | SYMBOL_NAME(aliasname) = SYMBOL_NAME(name) | |
| 65 | ||
| 49 | 66 | #define NO_EXEC_STACK_DIRECTIVE |
| 50 | 67 | |
| 51 | 68 | #elif defined(__ELF__) |
| ... | ... | @@ -57,6 +74,10 @@ |
| 57 | 74 | #endif |
| 58 | 75 | #define EXPORT_SYMBOL(name) |
| 59 | 76 | #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) | |
| 60 | 81 | |
| 61 | 82 | #if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \ |
| 62 | 83 | defined(__linux__) |
| ... | ... | @@ -72,9 +93,9 @@ |
| 72 | 93 | .scl 2 SEPARATOR \ |
| 73 | 94 | .type 32 SEPARATOR \ |
| 74 | 95 | .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 \ | |
| 78 | 99 | .text |
| 79 | 100 | #if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS) |
| 80 | 101 | #define EXPORT_SYMBOL(name) |
| ... | ... | @@ -83,6 +104,23 @@ |
| 83 | 104 | #endif |
| 84 | 105 | #define HIDDEN_SYMBOL(name) |
| 85 | 106 | |
| 107 | #if defined(__MINGW32__) | |
| 108 | #define WEAK_ALIAS(name, aliasname) \ | |
| 109 | .globl SYMBOL_NAME(aliasname) SEPARATOR \ | |
| 110 | EXPORT_SYMBOL(aliasname) SEPARATOR \ | |
| 111 | SYMBOL_NAME(aliasname) = SYMBOL_NAME(name) | |
| 112 | #else | |
| 113 | #define WEAK_ALIAS3(name, aliasname) \ | |
| 114 | .section .drectve,"yn" SEPARATOR \ | |
| 115 | .ascii "-alternatename:", #aliasname, "=", #name, "\0" SEPARATOR \ | |
| 116 | .text | |
| 117 | #define WEAK_ALIAS2(name, aliasname) \ | |
| 118 | WEAK_ALIAS3(name, aliasname) | |
| 119 | #define WEAK_ALIAS(name, aliasname) \ | |
| 120 | EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR \ | |
| 121 | WEAK_ALIAS2(SYMBOL_NAME(name), SYMBOL_NAME(aliasname)) | |
| 122 | #endif | |
| 123 | ||
| 86 | 124 | #define NO_EXEC_STACK_DIRECTIVE |
| 87 | 125 | |
| 88 | 126 | #elif defined(__sparc__) |
| ... | ... | @@ -93,17 +131,13 @@ |
| 93 | 131 | |
| 94 | 132 | #endif |
| 95 | 133 | |
| 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 | |
| 107 | 141 | |
| 108 | 142 | #if defined(__arm__) |
| 109 | 143 | #if !defined(__ARM_ARCH) |
lib/libunwind/src/config.h+32-4| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===----------------------------- config.h -------------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Defines macros used within libunwind project. |
| ... | ... | @@ -63,6 +62,35 @@ |
| 63 | 62 | #endif |
| 64 | 63 | #endif |
| 65 | 64 | |
| 65 | #define STR(a) #a | |
| 66 | #define XSTR(a) STR(a) | |
| 67 | #define SYMBOL_NAME(name) XSTR(__USER_LABEL_PREFIX__) #name | |
| 68 | ||
| 69 | #if defined(__APPLE__) | |
| 70 | #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \ | |
| 71 | __asm__(".globl " SYMBOL_NAME(aliasname)); \ | |
| 72 | __asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name)); \ | |
| 73 | extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname \ | |
| 74 | __attribute__((weak_import)); | |
| 75 | #elif defined(__ELF__) | |
| 76 | #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \ | |
| 77 | extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname \ | |
| 78 | __attribute__((weak, alias(#name))); | |
| 79 | #elif defined(_WIN32) | |
| 80 | #if defined(__MINGW32__) | |
| 81 | #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \ | |
| 82 | extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname \ | |
| 83 | __attribute__((alias(#name))); | |
| 84 | #else | |
| 85 | #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \ | |
| 86 | __pragma(comment(linker, "/alternatename:" SYMBOL_NAME(aliasname) "=" \ | |
| 87 | SYMBOL_NAME(name))) \ | |
| 88 | extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname; | |
| 89 | #endif | |
| 90 | #else | |
| 91 | #error Unsupported target | |
| 92 | #endif | |
| 93 | ||
| 66 | 94 | #if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__) |
| 67 | 95 | #define _LIBUNWIND_BUILD_SJLJ_APIS |
| 68 | 96 | #endif |
lib/libunwind/src/dwarf2.h+3-4| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===------------------------------- dwarf2.h -----------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | //===----------------------------------------------------------------------===// |
| 9 | 8 |
lib/libunwind/src/libunwind.cpp+64-150| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===--------------------------- libunwind.cpp ----------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Implements unw_* functions from <libunwind.h> |
| ... | ... | @@ -12,12 +11,6 @@ |
| 12 | 11 | |
| 13 | 12 | #include <libunwind.h> |
| 14 | 13 | |
| 15 | #ifndef NDEBUG | |
| 16 | #include <cstdlib> // getenv | |
| 17 | #endif | |
| 18 | #include <new> | |
| 19 | #include <algorithm> | |
| 20 | ||
| 21 | 14 | #include "libunwind_ext.h" |
| 22 | 15 | #include "config.h" |
| 23 | 16 | |
| ... | ... | @@ -36,15 +29,11 @@ LocalAddressSpace LocalAddressSpace::sThisAddressSpace; |
| 36 | 29 | _LIBUNWIND_EXPORT unw_addr_space_t unw_local_addr_space = |
| 37 | 30 | (unw_addr_space_t)&LocalAddressSpace::sThisAddressSpace; |
| 38 | 31 | |
| 39 | /// record the registers and stack position of the caller | |
| 40 | extern int unw_getcontext(unw_context_t *); | |
| 41 | // note: unw_getcontext() implemented in assembly | |
| 42 | ||
| 43 | 32 | /// 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)", | |
| 48 | 37 | static_cast<void *>(cursor), |
| 49 | 38 | static_cast<void *>(context)); |
| 50 | 39 | #if defined(__i386__) |
| ... | ... | @@ -73,101 +62,21 @@ _LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cursor, |
| 73 | 62 | # error Architecture not supported |
| 74 | 63 | #endif |
| 75 | 64 | // 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); | |
| 78 | 68 | #undef REGISTER_KIND |
| 79 | 69 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| 80 | 70 | co->setInfoBasedOnIPRegister(); |
| 81 | 71 | |
| 82 | 72 | return UNW_ESUCCESS; |
| 83 | 73 | } |
| 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 | ||
| 118 | static 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) | |
| 166 | 75 | |
| 167 | 76 | /// Get value of specified register at cursor position in stack frame. |
| 168 | _LIBUNWIND_EXPORT int unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum, | |
| 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)", | |
| 171 | 80 | static_cast<void *>(cursor), regNum, |
| 172 | 81 | static_cast<void *>(value)); |
| 173 | 82 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| ... | ... | @@ -177,12 +86,13 @@ _LIBUNWIND_EXPORT int unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum, |
| 177 | 86 | } |
| 178 | 87 | return UNW_EBADREG; |
| 179 | 88 | } |
| 180 | ||
| 89 | _LIBUNWIND_WEAK_ALIAS(__unw_get_reg, unw_get_reg) | |
| 181 | 90 | |
| 182 | 91 | /// Set value of specified register at cursor position in stack frame. |
| 183 | _LIBUNWIND_EXPORT int unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum, | |
| 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 | ")", | |
| 186 | 96 | static_cast<void *>(cursor), regNum, value); |
| 187 | 97 | typedef LocalAddressSpace::pint_t pint_t; |
| 188 | 98 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| ... | ... | @@ -208,12 +118,12 @@ _LIBUNWIND_EXPORT int unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum, |
| 208 | 118 | } |
| 209 | 119 | return UNW_EBADREG; |
| 210 | 120 | } |
| 211 | ||
| 121 | _LIBUNWIND_WEAK_ALIAS(__unw_set_reg, unw_set_reg) | |
| 212 | 122 | |
| 213 | 123 | /// Get value of specified float register at cursor position in stack frame. |
| 214 | _LIBUNWIND_EXPORT int unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum, | |
| 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)", | |
| 217 | 127 | static_cast<void *>(cursor), regNum, |
| 218 | 128 | static_cast<void *>(value)); |
| 219 | 129 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| ... | ... | @@ -223,16 +133,16 @@ _LIBUNWIND_EXPORT int unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum, |
| 223 | 133 | } |
| 224 | 134 | return UNW_EBADREG; |
| 225 | 135 | } |
| 226 | ||
| 136 | _LIBUNWIND_WEAK_ALIAS(__unw_get_fpreg, unw_get_fpreg) | |
| 227 | 137 | |
| 228 | 138 | /// Set value of specified float register at cursor position in stack frame. |
| 229 | _LIBUNWIND_EXPORT int unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum, | |
| 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) { | |
| 231 | 141 | #if defined(_LIBUNWIND_ARM_EHABI) |
| 232 | _LIBUNWIND_TRACE_API("unw_set_fpreg(cursor=%p, regNum=%d, value=%llX)", | |
| 142 | _LIBUNWIND_TRACE_API("__unw_set_fpreg(cursor=%p, regNum=%d, value=%llX)", | |
| 233 | 143 | static_cast<void *>(cursor), regNum, value); |
| 234 | 144 | #else |
| 235 | _LIBUNWIND_TRACE_API("unw_set_fpreg(cursor=%p, regNum=%d, value=%g)", | |
| 145 | _LIBUNWIND_TRACE_API("__unw_set_fpreg(cursor=%p, regNum=%d, value=%g)", | |
| 236 | 146 | static_cast<void *>(cursor), regNum, value); |
| 237 | 147 | #endif |
| 238 | 148 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| ... | ... | @@ -242,20 +152,20 @@ _LIBUNWIND_EXPORT int unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum, |
| 242 | 152 | } |
| 243 | 153 | return UNW_EBADREG; |
| 244 | 154 | } |
| 245 | ||
| 155 | _LIBUNWIND_WEAK_ALIAS(__unw_set_fpreg, unw_set_fpreg) | |
| 246 | 156 | |
| 247 | 157 | /// 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)); | |
| 250 | 160 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| 251 | 161 | return co->step(); |
| 252 | 162 | } |
| 253 | ||
| 163 | _LIBUNWIND_WEAK_ALIAS(__unw_step, unw_step) | |
| 254 | 164 | |
| 255 | 165 | /// 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)", | |
| 259 | 169 | static_cast<void *>(cursor), static_cast<void *>(info)); |
| 260 | 170 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| 261 | 171 | co->getInfo(info); |
| ... | ... | @@ -264,21 +174,21 @@ _LIBUNWIND_EXPORT int unw_get_proc_info(unw_cursor_t *cursor, |
| 264 | 174 | else |
| 265 | 175 | return UNW_ESUCCESS; |
| 266 | 176 | } |
| 267 | ||
| 177 | _LIBUNWIND_WEAK_ALIAS(__unw_get_proc_info, unw_get_proc_info) | |
| 268 | 178 | |
| 269 | 179 | /// 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)); | |
| 272 | 182 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| 273 | 183 | co->jumpto(); |
| 274 | 184 | return UNW_EUNSPEC; |
| 275 | 185 | } |
| 276 | ||
| 186 | _LIBUNWIND_WEAK_ALIAS(__unw_resume, unw_resume) | |
| 277 | 187 | |
| 278 | 188 | /// Get name of function at cursor position in stack frame. |
| 279 | _LIBUNWIND_EXPORT int unw_get_proc_name(unw_cursor_t *cursor, char *buf, | |
| 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)", | |
| 282 | 192 | static_cast<void *>(cursor), static_cast<void *>(buf), |
| 283 | 193 | static_cast<unsigned long>(bufLen)); |
| 284 | 194 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| ... | ... | @@ -287,58 +197,62 @@ _LIBUNWIND_EXPORT int unw_get_proc_name(unw_cursor_t *cursor, char *buf, |
| 287 | 197 | else |
| 288 | 198 | return UNW_EUNSPEC; |
| 289 | 199 | } |
| 290 | ||
| 200 | _LIBUNWIND_WEAK_ALIAS(__unw_get_proc_name, unw_get_proc_name) | |
| 291 | 201 | |
| 292 | 202 | /// Checks if a register is a floating-point register. |
| 293 | _LIBUNWIND_EXPORT int unw_is_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum) { | |
| 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)", | |
| 295 | 206 | static_cast<void *>(cursor), regNum); |
| 296 | 207 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| 297 | 208 | return co->validFloatReg(regNum); |
| 298 | 209 | } |
| 299 | ||
| 210 | _LIBUNWIND_WEAK_ALIAS(__unw_is_fpreg, unw_is_fpreg) | |
| 300 | 211 | |
| 301 | 212 | /// 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)", | |
| 305 | 216 | static_cast<void *>(cursor), regNum); |
| 306 | 217 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| 307 | 218 | return co->getRegisterName(regNum); |
| 308 | 219 | } |
| 309 | ||
| 220 | _LIBUNWIND_WEAK_ALIAS(__unw_regname, unw_regname) | |
| 310 | 221 | |
| 311 | 222 | /// 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)", | |
| 314 | 225 | static_cast<void *>(cursor)); |
| 315 | 226 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| 316 | 227 | return co->isSignalFrame(); |
| 317 | 228 | } |
| 229 | _LIBUNWIND_WEAK_ALIAS(__unw_is_signal_frame, unw_is_signal_frame) | |
| 318 | 230 | |
| 319 | 231 | #ifdef __arm__ |
| 320 | 232 | // 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)", | |
| 323 | 235 | static_cast<void *>(cursor)); |
| 324 | 236 | AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; |
| 325 | 237 | return co->saveVFPAsX(); |
| 326 | 238 | } |
| 239 | _LIBUNWIND_WEAK_ALIAS(__unw_save_vfp_as_X, unw_save_vfp_as_X) | |
| 327 | 240 | #endif |
| 328 | 241 | |
| 329 | 242 | |
| 330 | 243 | #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) |
| 331 | 244 | /// SPI: walks cached DWARF entries |
| 332 | _LIBUNWIND_EXPORT void unw_iterate_dwarf_unwind_cache(void (*func)( | |
| 245 | _LIBUNWIND_HIDDEN void __unw_iterate_dwarf_unwind_cache(void (*func)( | |
| 333 | 246 | unw_word_t ip_start, unw_word_t ip_end, unw_word_t fde, unw_word_t mh)) { |
| 334 | _LIBUNWIND_TRACE_API("unw_iterate_dwarf_unwind_cache(func=%p)", | |
| 247 | _LIBUNWIND_TRACE_API("__unw_iterate_dwarf_unwind_cache(func=%p)", | |
| 335 | 248 | reinterpret_cast<void *>(func)); |
| 336 | 249 | DwarfFDECache<LocalAddressSpace>::iterateCacheEntries(func); |
| 337 | 250 | } |
| 338 | ||
| 251 | _LIBUNWIND_WEAK_ALIAS(__unw_iterate_dwarf_unwind_cache, | |
| 252 | unw_iterate_dwarf_unwind_cache) | |
| 339 | 253 | |
| 340 | 254 | /// IPI: for __register_frame() |
| 341 | void _unw_add_dynamic_fde(unw_word_t fde) { | |
| 255 | void __unw_add_dynamic_fde(unw_word_t fde) { | |
| 342 | 256 | CFI_Parser<LocalAddressSpace>::FDE_Info fdeInfo; |
| 343 | 257 | CFI_Parser<LocalAddressSpace>::CIE_Info cieInfo; |
| 344 | 258 | const char *message = CFI_Parser<LocalAddressSpace>::decodeFDE( |
| ... | ... | @@ -352,12 +266,12 @@ void _unw_add_dynamic_fde(unw_word_t fde) { |
| 352 | 266 | fdeInfo.pcStart, fdeInfo.pcEnd, |
| 353 | 267 | fdeInfo.fdeStart); |
| 354 | 268 | } else { |
| 355 | _LIBUNWIND_DEBUG_LOG("_unw_add_dynamic_fde: bad fde: %s", message); | |
| 269 | _LIBUNWIND_DEBUG_LOG("__unw_add_dynamic_fde: bad fde: %s", message); | |
| 356 | 270 | } |
| 357 | 271 | } |
| 358 | 272 | |
| 359 | 273 | /// IPI: for __deregister_frame() |
| 360 | void _unw_remove_dynamic_fde(unw_word_t fde) { | |
| 274 | void __unw_remove_dynamic_fde(unw_word_t fde) { | |
| 361 | 275 | // fde is own mh_group |
| 362 | 276 | DwarfFDECache<LocalAddressSpace>::removeAllIn((LocalAddressSpace::pint_t)fde); |
| 363 | 277 | } |
lib/libunwind/src/libunwind_ext.h+28-10| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //===------------------------ libunwind_ext.h -----------------------------===// |
| 2 | 2 | // |
| 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 | |
| 7 | 6 | // |
| 8 | 7 | // |
| 9 | 8 | // Extensions to libunwind API. |
| ... | ... | @@ -23,15 +22,34 @@ |
| 23 | 22 | #ifdef __cplusplus |
| 24 | 23 | extern "C" { |
| 25 | 24 | #endif |
| 25 | ||
| 26 | extern int __unw_getcontext(unw_context_t *); | |
| 27 | extern int __unw_init_local(unw_cursor_t *, unw_context_t *); | |
| 28 | extern int __unw_step(unw_cursor_t *); | |
| 29 | extern int __unw_get_reg(unw_cursor_t *, unw_regnum_t, unw_word_t *); | |
| 30 | extern int __unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *); | |
| 31 | extern int __unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t); | |
| 32 | extern int __unw_set_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t); | |
| 33 | extern int __unw_resume(unw_cursor_t *); | |
| 34 | ||
| 35 | #ifdef __arm__ | |
| 36 | /* Save VFP registers in FSTMX format (instead of FSTMD). */ | |
| 37 | extern void __unw_save_vfp_as_X(unw_cursor_t *); | |
| 38 | #endif | |
| 39 | ||
| 40 | extern const char *__unw_regname(unw_cursor_t *, unw_regnum_t); | |
| 41 | extern int __unw_get_proc_info(unw_cursor_t *, unw_proc_info_t *); | |
| 42 | extern int __unw_is_fpreg(unw_cursor_t *, unw_regnum_t); | |
| 43 | extern int __unw_is_signal_frame(unw_cursor_t *); | |
| 44 | extern int __unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *); | |
| 45 | ||
| 26 | 46 | // SPI |
| 27 | extern 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)); | |
| 47 | extern 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)); | |
| 31 | 49 | |
| 32 | 50 | // IPI |
| 33 | extern void _unw_add_dynamic_fde(unw_word_t fde); | |
| 34 | extern void _unw_remove_dynamic_fde(unw_word_t fde); | |
| 51 | extern void __unw_add_dynamic_fde(unw_word_t fde); | |
| 52 | extern void __unw_remove_dynamic_fde(unw_word_t fde); | |
| 35 | 53 | |
| 36 | 54 | #if defined(_LIBUNWIND_ARM_EHABI) |
| 37 | 55 | extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*); |