diff --git a/app/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java b/app/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java index 081b0c89e..c33990cdc 100644 --- a/app/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java +++ b/app/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java @@ -128,6 +128,7 @@ public class PojavLoginActivity extends BaseActivity if (revokeCount >= 3) { Toast.makeText(PojavLoginActivity.this, R.string.toast_permission_denied, Toast.LENGTH_LONG).show(); finish(); + return 0; } requestStoragePermission(); diff --git a/app/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlButton.java b/app/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlButton.java index 108dffca0..e19f57f32 100644 --- a/app/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlButton.java +++ b/app/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlButton.java @@ -156,7 +156,12 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc if (getParent() != null) { ((ControlLayout) getParent()).hideAllHandleViews(); } - mHandleView.show(); + + try { + mHandleView.show(); + } catch (Throwable th) { + th.printStackTrace(); + } } } diff --git a/app/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java b/app/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java index 2e563d6dd..345e5cbc1 100644 --- a/app/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java +++ b/app/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java @@ -39,6 +39,7 @@ public class ControlLayout extends FrameLayout public void loadLayout(CustomControls controlLayout) { if (mModifiable) { + hideAllHandleViews(); removeAllViews(); } diff --git a/app/src/main/jni/awt_xawt/awt_GraphicsEnv.c b/app/src/main/jni/awt_xawt/awt_GraphicsEnv.c index cfc888f8c..8c5229676 100644 --- a/app/src/main/jni/awt_xawt/awt_GraphicsEnv.c +++ b/app/src/main/jni/awt_xawt/awt_GraphicsEnv.c @@ -78,7 +78,6 @@ JNIEXPORT jint JNICALL Java_sun_awt_X11GraphicsEnvironment_getNumScreens(JNIEnv * 0 otherwise */ JNIEXPORT jint JNICALL Java_sun_awt_X11GraphicsEnvironment_checkShmExt(JNIEnv *env, jclass cls, jboolean verbose) { - // This could be return 0 once MITShm implementation added return (jint) -1; } diff --git a/app/src/main/jni/crash_dump/debuggerd/.clang-format b/app/src/main/jni/crash_dump/debuggerd/.clang-format deleted file mode 100644 index 9b7478c07..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/.clang-format +++ /dev/null @@ -1,15 +0,0 @@ -BasedOnStyle: Google -AllowShortBlocksOnASingleLine: false -AllowShortFunctionsOnASingleLine: false - -ColumnLimit: 100 -CommentPragmas: NOLINT:.* -DerivePointerAlignment: false -IndentWidth: 2 -ContinuationIndentWidth: 2 -PointerAlignment: Left -TabWidth: 2 -UseTab: Never -PenaltyExcessCharacter: 32 - -Cpp11BracedListStyle: false diff --git a/app/src/main/jni/crash_dump/debuggerd/Android.mk b/app/src/main/jni/crash_dump/debuggerd/Android.mk deleted file mode 100644 index bb5544b2f..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/Android.mk +++ /dev/null @@ -1,79 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -common_cppflags := \ - -std=gnu++11 \ - -W \ - -Wall \ - -Wextra \ - -Wunused \ - -Werror \ - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - backtrace.cpp \ - debuggerd.cpp \ - elf_utils.cpp \ - getevent.cpp \ - signal_sender.cpp \ - tombstone.cpp \ - utility.cpp \ - selinux_fake.cpp - -LOCAL_SRC_FILES_arm := arm/machine.cpp -LOCAL_SRC_FILES_arm64 := arm64/machine.cpp -LOCAL_SRC_FILES_x86 := x86/machine.cpp -LOCAL_SRC_FILES_x86_64 := x86_64/machine.cpp - -LOCAL_CPPFLAGS := $(common_cppflags) \ - -I$(HERE_PATH)/crash_dump/libbase/include - -LOCAL_INIT_RC_32 := debuggerd.rc -LOCAL_INIT_RC_64 := debuggerd64.rc - -ifeq ($(TARGET_IS_64_BIT),true) -LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT -endif - -LOCAL_LDLIBS := -llog -LOCAL_SHARED_LIBRARIES := \ - libbacktrace \ - libcrashdumpbase - -LOCAL_CLANG := true - -LOCAL_MODULE := crashdump -LOCAL_MULTILIB := both - -include $(BUILD_SHARED_LIBRARY) - - - -include $(CLEAR_VARS) -LOCAL_SRC_FILES := crasher.c -LOCAL_SRC_FILES_arm := arm/crashglue.S -LOCAL_SRC_FILES_arm64 := arm64/crashglue.S -LOCAL_SRC_FILES_mips := mips/crashglue.S -LOCAL_SRC_FILES_mips64 := mips64/crashglue.S -LOCAL_SRC_FILES_x86 := x86/crashglue.S -LOCAL_SRC_FILES_x86_64 := x86_64/crashglue.S -LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) -LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS += -fstack-protector-all -Werror -Wno-free-nonheap-object -Wno-date-time \ - -I$(HERE_PATH)/crash_dump/libbase/include - -#LOCAL_FORCE_STATIC_EXECUTABLE := true -LOCAL_SHARED_LIBRARIES := libcutils liblog libc - -# The arm emulator has VFP but not VFPv3-D32. -ifeq ($(ARCH_ARM_HAVE_VFP_D32),true) -LOCAL_ASFLAGS_arm += -DHAS_VFP_D32 -endif - -LOCAL_MODULE := crasher -LOCAL_MODULE_STEM_32 := crasher -LOCAL_MODULE_STEM_64 := crasher64 -LOCAL_MULTILIB := both - -# include $(BUILD_EXECUTABLE) - diff --git a/app/src/main/jni/crash_dump/debuggerd/MODULE_LICENSE_APACHE2 b/app/src/main/jni/crash_dump/debuggerd/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/src/main/jni/crash_dump/debuggerd/NOTICE b/app/src/main/jni/crash_dump/debuggerd/NOTICE deleted file mode 100644 index c5b1efa7a..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/NOTICE +++ /dev/null @@ -1,190 +0,0 @@ - - Copyright (c) 2005-2008, The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - diff --git a/app/src/main/jni/crash_dump/debuggerd/arm/crashglue.S b/app/src/main/jni/crash_dump/debuggerd/arm/crashglue.S deleted file mode 100644 index 4fbfd6e45..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/arm/crashglue.S +++ /dev/null @@ -1,64 +0,0 @@ -.globl crash1 -.type crash1, %function -crash1: - ldr r0, =0xa5a50000 - ldr r1, =0xa5a50001 - ldr r2, =0xa5a50002 - ldr r3, =0xa5a50003 - ldr r4, =0xa5a50004 - ldr r5, =0xa5a50005 - ldr r6, =0xa5a50006 - ldr r7, =0xa5a50007 - ldr r8, =0xa5a50008 - ldr r9, =0xa5a50009 - ldr r10, =0xa5a50010 - ldr r11, =0xa5a50011 - ldr r12, =0xa5a50012 - - - fconstd d0, #0 - fconstd d1, #1 - fconstd d2, #2 - fconstd d3, #3 - fconstd d4, #4 - fconstd d5, #5 - fconstd d6, #6 - fconstd d7, #7 - fconstd d8, #8 - fconstd d9, #9 - fconstd d10, #10 - fconstd d11, #11 - fconstd d12, #12 - fconstd d13, #13 - fconstd d14, #14 - fconstd d15, #15 -#if defined(HAS_VFP_D32) - fconstd d16, #16 - fconstd d17, #17 - fconstd d18, #18 - fconstd d19, #19 - fconstd d20, #20 - fconstd d21, #21 - fconstd d22, #22 - fconstd d23, #23 - fconstd d24, #24 - fconstd d25, #25 - fconstd d26, #26 - fconstd d27, #27 - fconstd d28, #28 - fconstd d29, #29 - fconstd d30, #30 - fconstd d31, #31 -#endif - - mov lr, #0 - ldr lr, [lr] - b . - -.globl crashnostack -.type crashnostack, %function -crashnostack: - mov sp, #0 - mov r0, #0 - ldr r0, [r0] - b . diff --git a/app/src/main/jni/crash_dump/debuggerd/arm/machine.cpp b/app/src/main/jni/crash_dump/debuggerd/arm/machine.cpp deleted file mode 100644 index 78c230615..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/arm/machine.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Copyright 2006, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "DEBUG" - -#include -#include -#include -#include - -#include -#include - -#include "machine.h" -#include "utility.h" - -void dump_memory_and_code(log_t* log, Backtrace* backtrace) { - pt_regs regs; - if (ptrace(PTRACE_GETREGS, backtrace->Tid(), 0, ®s)) { - ALOGE("cannot get registers: %s\n", strerror(errno)); - return; - } - - static const char reg_names[] = "r0r1r2r3r4r5r6r7r8r9slfpipsp"; - - for (int reg = 0; reg < 14; reg++) { - dump_memory(log, backtrace, regs.uregs[reg], "memory near %.2s:", ®_names[reg * 2]); - } - - dump_memory(log, backtrace, static_cast(regs.ARM_pc), "code around pc:"); - - if (regs.ARM_pc != regs.ARM_lr) { - dump_memory(log, backtrace, static_cast(regs.ARM_lr), "code around lr:"); - } -} - -void dump_registers(log_t* log, pid_t tid) { - pt_regs r; - if (ptrace(PTRACE_GETREGS, tid, 0, &r)) { - ALOGE("cannot get registers: %s\n", strerror(errno)); - return; - } - - _LOG(log, logtype::REGISTERS, " r0 %08x r1 %08x r2 %08x r3 %08x\n", - static_cast(r.ARM_r0), static_cast(r.ARM_r1), - static_cast(r.ARM_r2), static_cast(r.ARM_r3)); - _LOG(log, logtype::REGISTERS, " r4 %08x r5 %08x r6 %08x r7 %08x\n", - static_cast(r.ARM_r4), static_cast(r.ARM_r5), - static_cast(r.ARM_r6), static_cast(r.ARM_r7)); - _LOG(log, logtype::REGISTERS, " r8 %08x r9 %08x sl %08x fp %08x\n", - static_cast(r.ARM_r8), static_cast(r.ARM_r9), - static_cast(r.ARM_r10), static_cast(r.ARM_fp)); - _LOG(log, logtype::REGISTERS, " ip %08x sp %08x lr %08x pc %08x cpsr %08x\n", - static_cast(r.ARM_ip), static_cast(r.ARM_sp), - static_cast(r.ARM_lr), static_cast(r.ARM_pc), - static_cast(r.ARM_cpsr)); - - user_vfp vfp_regs; - if (ptrace(PTRACE_GETVFPREGS, tid, 0, &vfp_regs)) { - ALOGE("cannot get FP registers: %s\n", strerror(errno)); - return; - } - - for (size_t i = 0; i < 32; i += 2) { - _LOG(log, logtype::FP_REGISTERS, " d%-2d %016llx d%-2d %016llx\n", - i, vfp_regs.fpregs[i], i+1, vfp_regs.fpregs[i+1]); - } - _LOG(log, logtype::FP_REGISTERS, " scr %08lx\n", vfp_regs.fpscr); -} diff --git a/app/src/main/jni/crash_dump/debuggerd/arm64/crashglue.S b/app/src/main/jni/crash_dump/debuggerd/arm64/crashglue.S deleted file mode 100644 index e58b54246..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/arm64/crashglue.S +++ /dev/null @@ -1,79 +0,0 @@ -.globl crash1 -.type crash1, %function -crash1: - ldr x0, =0xa5a50000 - ldr x1, =0xa5a50001 - ldr x2, =0xa5a50002 - ldr x3, =0xa5a50003 - ldr x4, =0xa5a50004 - ldr x5, =0xa5a50005 - ldr x6, =0xa5a50006 - ldr x7, =0xa5a50007 - ldr x8, =0xa5a50008 - ldr x9, =0xa5a50009 - ldr x10, =0xa5a50010 - ldr x11, =0xa5a50011 - ldr x12, =0xa5a50012 - ldr x13, =0xa5a50013 - ldr x14, =0xa5a50014 - ldr x15, =0xa5a50015 - ldr x16, =0xa5a50016 - ldr x17, =0xa5a50017 - ldr x18, =0xa5a50018 - ldr x19, =0xa5a50019 - ldr x20, =0xa5a50020 - ldr x21, =0xa5a50021 - ldr x22, =0xa5a50022 - ldr x23, =0xa5a50023 - ldr x24, =0xa5a50024 - ldr x25, =0xa5a50025 - ldr x26, =0xa5a50026 - ldr x27, =0xa5a50027 - ldr x28, =0xa5a50028 - ldr x29, =0xa5a50029 - - fmov d0, -1.0 // -1 is more convincing than 0. - fmov d1, 1.0 - fmov d2, 2.0 - fmov d3, 3.0 - fmov d4, 4.0 - fmov d5, 5.0 - fmov d6, 6.0 - fmov d7, 7.0 - fmov d8, 8.0 - fmov d9, 9.0 - fmov d10, 10.0 - fmov d11, 11.0 - fmov d12, 12.0 - fmov d13, 13.0 - fmov d14, 14.0 - fmov d15, 15.0 - fmov d16, 16.0 - fmov d17, 17.0 - fmov d18, 18.0 - fmov d19, 19.0 - fmov d20, 20.0 - fmov d21, 21.0 - fmov d22, 22.0 - fmov d23, 23.0 - fmov d24, 24.0 - fmov d25, 25.0 - fmov d26, 26.0 - fmov d27, 27.0 - fmov d28, 28.0 - fmov d29, 29.0 - fmov d30, 30.0 - fmov d31, 31.0 - - mov x30, xzr - ldr x30, [x30] - b . - - -.globl crashnostack -.type crashnostack, %function -crashnostack: - mov x0, xzr - add sp, x0, xzr - ldr x0, [x0] - b . diff --git a/app/src/main/jni/crash_dump/debuggerd/arm64/machine.cpp b/app/src/main/jni/crash_dump/debuggerd/arm64/machine.cpp deleted file mode 100644 index e7bf79a8f..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/arm64/machine.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * - * Copyright 2014, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "DEBUG" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "machine.h" -#include "utility.h" - -void dump_memory_and_code(log_t* log, Backtrace* backtrace) { - struct user_pt_regs regs; - struct iovec io; - io.iov_base = ®s; - io.iov_len = sizeof(regs); - - if (ptrace(PTRACE_GETREGSET, backtrace->Tid(), reinterpret_cast(NT_PRSTATUS), &io) == -1) { - ALOGE("ptrace failed to get registers: %s", strerror(errno)); - return; - } - - for (int reg = 0; reg < 31; reg++) { - dump_memory(log, backtrace, regs.regs[reg], "memory near x%d:", reg); - } - - dump_memory(log, backtrace, static_cast(regs.pc), "code around pc:"); - - if (regs.pc != regs.sp) { - dump_memory(log, backtrace, static_cast(regs.sp), "code around sp:"); - } -} - -void dump_registers(log_t* log, pid_t tid) { - struct user_pt_regs r; - struct iovec io; - io.iov_base = &r; - io.iov_len = sizeof(r); - - if (ptrace(PTRACE_GETREGSET, tid, (void*) NT_PRSTATUS, (void*) &io) == -1) { - ALOGE("ptrace error: %s\n", strerror(errno)); - return; - } - - for (int i = 0; i < 28; i += 4) { - _LOG(log, logtype::REGISTERS, - " x%-2d %016llx x%-2d %016llx x%-2d %016llx x%-2d %016llx\n", - i, r.regs[i], - i+1, r.regs[i+1], - i+2, r.regs[i+2], - i+3, r.regs[i+3]); - } - - _LOG(log, logtype::REGISTERS, " x28 %016llx x29 %016llx x30 %016llx\n", - r.regs[28], r.regs[29], r.regs[30]); - - _LOG(log, logtype::REGISTERS, " sp %016llx pc %016llx pstate %016llx\n", - r.sp, r.pc, r.pstate); - - struct user_fpsimd_state f; - io.iov_base = &f; - io.iov_len = sizeof(f); - - if (ptrace(PTRACE_GETREGSET, tid, (void*) NT_PRFPREG, (void*) &io) == -1) { - ALOGE("ptrace error: %s\n", strerror(errno)); - return; - } - - for (int i = 0; i < 32; i += 2) { - _LOG(log, logtype::FP_REGISTERS, - " v%-2d %016" PRIx64 "%016" PRIx64 " v%-2d %016" PRIx64 "%016" PRIx64 "\n", - i, - static_cast(f.vregs[i] >> 64), - static_cast(f.vregs[i]), - i+1, - static_cast(f.vregs[i+1] >> 64), - static_cast(f.vregs[i+1])); - } - _LOG(log, logtype::FP_REGISTERS, " fpsr %08x fpcr %08x\n", f.fpsr, f.fpcr); -} diff --git a/app/src/main/jni/crash_dump/debuggerd/backtrace.cpp b/app/src/main/jni/crash_dump/debuggerd/backtrace.cpp deleted file mode 100644 index 8f4a53f57..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/backtrace.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "DEBUG" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include "backtrace.h" - -#include "utility.h" - -static void dump_process_header(log_t* log, pid_t pid) { - char path[PATH_MAX]; - char procnamebuf[1024]; - char* procname = NULL; - FILE* fp; - - snprintf(path, sizeof(path), "/proc/%d/cmdline", pid); - if ((fp = fopen(path, "r"))) { - procname = fgets(procnamebuf, sizeof(procnamebuf), fp); - fclose(fp); - } - - time_t t = time(NULL); - struct tm tm; - localtime_r(&t, &tm); - char timestr[64]; - strftime(timestr, sizeof(timestr), "%F %T", &tm); - _LOG(log, logtype::BACKTRACE, "\n\n----- pid %d at %s -----\n", pid, timestr); - - if (procname) { - _LOG(log, logtype::BACKTRACE, "Cmd line: %s\n", procname); - } - _LOG(log, logtype::BACKTRACE, "ABI: '%s'\n", ABI_STRING); -} - -static void dump_process_footer(log_t* log, pid_t pid) { - _LOG(log, logtype::BACKTRACE, "\n----- end %d -----\n", pid); -} - -static void dump_thread(log_t* log, BacktraceMap* map, pid_t pid, pid_t tid) { - char path[PATH_MAX]; - char threadnamebuf[1024]; - char* threadname = NULL; - FILE* fp; - - snprintf(path, sizeof(path), "/proc/%d/comm", tid); - if ((fp = fopen(path, "r"))) { - threadname = fgets(threadnamebuf, sizeof(threadnamebuf), fp); - fclose(fp); - if (threadname) { - size_t len = strlen(threadname); - if (len && threadname[len - 1] == '\n') { - threadname[len - 1] = '\0'; - } - } - } - - _LOG(log, logtype::BACKTRACE, "\n\"%s\" sysTid=%d\n", threadname ? threadname : "", tid); - - std::unique_ptr backtrace(Backtrace::Create(pid, tid, map)); - if (backtrace->Unwind(0)) { - dump_backtrace_to_log(backtrace.get(), log, " "); - } else { - ALOGE("Unwind failed: tid = %d: %s", tid, - backtrace->GetErrorString(backtrace->GetError()).c_str()); - } -} - -void dump_backtrace(int fd, BacktraceMap* map, pid_t pid, pid_t tid, - const std::set& siblings, std::string* amfd_data) { - log_t log; - log.tfd = fd; - log.amfd_data = amfd_data; - - dump_process_header(&log, pid); - dump_thread(&log, map, pid, tid); - - for (pid_t sibling : siblings) { - dump_thread(&log, map, pid, sibling); - } - - dump_process_footer(&log, pid); -} - -void dump_backtrace_to_log(Backtrace* backtrace, log_t* log, const char* prefix) { - for (size_t i = 0; i < backtrace->NumFrames(); i++) { - _LOG(log, logtype::BACKTRACE, "%s%s\n", prefix, backtrace->FormatFrameData(i).c_str()); - } -} diff --git a/app/src/main/jni/crash_dump/debuggerd/backtrace.h b/app/src/main/jni/crash_dump/debuggerd/backtrace.h deleted file mode 100644 index acd5eaac6..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/backtrace.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DEBUGGERD_BACKTRACE_H -#define _DEBUGGERD_BACKTRACE_H - -#include - -#include -#include - -#include "utility.h" - -class Backtrace; -class BacktraceMap; - -// Dumps a backtrace using a format similar to what Dalvik uses so that the result -// can be intermixed in a bug report. -void dump_backtrace(int fd, BacktraceMap* map, pid_t pid, pid_t tid, - const std::set& siblings, std::string* amfd_data); - -/* Dumps the backtrace in the backtrace data structure to the log. */ -void dump_backtrace_to_log(Backtrace* backtrace, log_t* log, const char* prefix); - -#endif // _DEBUGGERD_BACKTRACE_H diff --git a/app/src/main/jni/crash_dump/debuggerd/crasher.c b/app/src/main/jni/crash_dump/debuggerd/crasher.c deleted file mode 100644 index 75f070b58..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/crasher.c +++ /dev/null @@ -1,215 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifndef __unused -#define __unused __attribute__((__unused__)) -#endif - -extern const char* __progname; - -void crash1(void); -void crashnostack(void); -static int do_action(const char* arg); - -static void maybe_abort() { - if (time(0) != 42) { - abort(); - } -} - -static char* smash_stack_dummy_buf; -__attribute__ ((noinline)) static void smash_stack_dummy_function(volatile int* plen) { - smash_stack_dummy_buf[*plen] = 0; -} - -// This must be marked with "__attribute__ ((noinline))", to ensure the -// compiler generates the proper stack guards around this function. -// Assign local array address to global variable to force stack guards. -// Use another noinline function to corrupt the stack. -__attribute__ ((noinline)) static int smash_stack(volatile int* plen) { - printf("crasher: deliberately corrupting stack...\n"); - - char buf[128]; - smash_stack_dummy_buf = buf; - // This should corrupt stack guards and make process abort. - smash_stack_dummy_function(plen); - return 0; -} - -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Winfinite-recursion" -#endif - -static void* global = 0; // So GCC doesn't optimize the tail recursion out of overflow_stack. - -__attribute__((noinline)) static void overflow_stack(void* p) { - void* buf[1]; - buf[0] = p; - global = buf; - overflow_stack(&buf); -} - -#if defined(__clang__) -#pragma clang diagnostic pop -#endif - -static void *noisy(void *x) -{ - char c = (uintptr_t) x; - for(;;) { - usleep(250*1000); - write(2, &c, 1); - if(c == 'C') *((volatile unsigned*) 0) = 42; - } - return NULL; -} - -static int ctest() -{ - pthread_t thr; - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - pthread_create(&thr, &attr, noisy, (void*) 'A'); - pthread_create(&thr, &attr, noisy, (void*) 'B'); - pthread_create(&thr, &attr, noisy, (void*) 'C'); - for(;;) ; - return 0; -} - -static void* thread_callback(void* raw_arg) -{ - return (void*) (uintptr_t) do_action((const char*) raw_arg); -} - -static int do_action_on_thread(const char* arg) -{ - pthread_t t; - pthread_create(&t, NULL, thread_callback, (void*) arg); - void* result = NULL; - pthread_join(t, &result); - return (int) (uintptr_t) result; -} - -__attribute__((noinline)) static int crash3(int a) { - *((int*) 0xdead) = a; - return a*4; -} - -__attribute__((noinline)) static int crash2(int a) { - a = crash3(a) + 2; - return a*3; -} - -__attribute__((noinline)) static int crash(int a) { - a = crash2(a) + 1; - return a*2; -} - -static void abuse_heap() { - char buf[16]; - free((void*) buf); // GCC is smart enough to warn about this, but we're doing it deliberately. -} - -static void sigsegv_non_null() { - int* a = (int *)(&do_action); - *a = 42; -} - -static int do_action(const char* arg) -{ - fprintf(stderr,"crasher: init pid=%d tid=%d\n", getpid(), gettid()); - - if (!strncmp(arg, "thread-", strlen("thread-"))) { - return do_action_on_thread(arg + strlen("thread-")); - } else if (!strcmp(arg, "SIGSEGV-non-null")) { - sigsegv_non_null(); - } else if (!strcmp(arg, "smash-stack")) { - volatile int len = 128; - return smash_stack(&len); - } else if (!strcmp(arg, "stack-overflow")) { - overflow_stack(NULL); - } else if (!strcmp(arg, "nostack")) { - crashnostack(); - } else if (!strcmp(arg, "ctest")) { - return ctest(); - } else if (!strcmp(arg, "exit")) { - exit(1); - } else if (!strcmp(arg, "crash") || !strcmp(arg, "SIGSEGV")) { - return crash(42); - } else if (!strcmp(arg, "abort")) { - maybe_abort(); - } else if (!strcmp(arg, "assert")) { - __assert("some_file.c", 123, "false"); - } else if (!strcmp(arg, "assert2")) { - __assert2("some_file.c", 123, "some_function", "false"); - } else if (!strcmp(arg, "LOG_ALWAYS_FATAL")) { - LOG_ALWAYS_FATAL("hello %s", "world"); - } else if (!strcmp(arg, "LOG_ALWAYS_FATAL_IF")) { - LOG_ALWAYS_FATAL_IF(true, "hello %s", "world"); - } else if (!strcmp(arg, "SIGFPE")) { - raise(SIGFPE); - return EXIT_SUCCESS; - } else if (!strcmp(arg, "SIGTRAP")) { - raise(SIGTRAP); - return EXIT_SUCCESS; - } else if (!strcmp(arg, "heap-usage")) { - abuse_heap(); - } else if (!strcmp(arg, "SIGSEGV-unmapped")) { - char* map = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); - munmap(map, sizeof(int)); - map[0] = '8'; - } - - fprintf(stderr, "%s OP\n", __progname); - fprintf(stderr, "where OP is:\n"); - fprintf(stderr, " smash-stack overwrite a stack-guard canary\n"); - fprintf(stderr, " stack-overflow recurse until the stack overflows\n"); - fprintf(stderr, " heap-corruption cause a libc abort by corrupting the heap\n"); - fprintf(stderr, " heap-usage cause a libc abort by abusing a heap function\n"); - fprintf(stderr, " nostack crash with a NULL stack pointer\n"); - fprintf(stderr, " ctest (obsoleted by thread-crash?)\n"); - fprintf(stderr, " exit call exit(1)\n"); - fprintf(stderr, " abort call abort()\n"); - fprintf(stderr, " assert call assert() without a function\n"); - fprintf(stderr, " assert2 call assert() with a function\n"); - fprintf(stderr, " LOG_ALWAYS_FATAL call LOG_ALWAYS_FATAL\n"); - fprintf(stderr, " LOG_ALWAYS_FATAL_IF call LOG_ALWAYS_FATAL\n"); - fprintf(stderr, " SIGFPE cause a SIGFPE\n"); - fprintf(stderr, " SIGSEGV cause a SIGSEGV at address 0x0 (synonym: crash)\n"); - fprintf(stderr, " SIGSEGV-non-null cause a SIGSEGV at a non-zero address\n"); - fprintf(stderr, " SIGSEGV-unmapped mmap/munmap a region of memory and then attempt to access it\n"); - fprintf(stderr, " SIGTRAP cause a SIGTRAP\n"); - fprintf(stderr, "prefix any of the above with 'thread-' to not run\n"); - fprintf(stderr, "on the process' main thread.\n"); - return EXIT_SUCCESS; -} - -int main(int argc, char **argv) -{ - fprintf(stderr,"crasher: built at " __TIME__ "!@\n"); - - if(argc > 1) { - return do_action(argv[1]); - } else { - crash1(); - } - - return 0; -} diff --git a/app/src/main/jni/crash_dump/debuggerd/debuggerd.cpp b/app/src/main/jni/crash_dump/debuggerd/debuggerd.cpp deleted file mode 100644 index 0248de394..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/debuggerd.cpp +++ /dev/null @@ -1,950 +0,0 @@ -/* - * Copyright 2006, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include "backtrace.h" -#include "getevent.h" -#include "signal_sender.h" -#include "tombstone.h" -#include "utility.h" - -// If the 32 bit executable is compiled on a 64 bit system, -// use the 32 bit socket name. -#if defined(TARGET_IS_64_BIT) && !defined(__LP64__) -#define SOCKET_NAME DEBUGGER32_SOCKET_NAME -#else -#define SOCKET_NAME DEBUGGER_SOCKET_NAME -#endif - -struct debugger_request_t { - debugger_action_t action; - pid_t pid, tid; - uid_t uid, gid; - uintptr_t abort_msg_address; - int32_t original_si_code; -}; - -static void wait_for_user_action(const debugger_request_t& request) { - // Explain how to attach the debugger. - ALOGI("***********************************************************\n" - "* Process %d has been suspended while crashing.\n" - "* To attach gdbserver and start gdb, run this on the host:\n" - "*\n" - "* gdbclient.py -p %d\n" - "*\n" - "* Wait for gdb to start, then press the VOLUME DOWN key\n" - "* to let the process continue crashing.\n" - "***********************************************************", - request.pid, request.tid); - - // Wait for VOLUME DOWN. - while (true) { - input_event e; - if (get_event(&e, -1) == 0) { - if (e.type == EV_KEY && e.code == KEY_VOLUMEDOWN && e.value == 0) { - break; - } - } - } - - ALOGI("debuggerd resuming process %d", request.pid); -} - -static int get_process_info(pid_t tid, pid_t* out_pid, uid_t* out_uid, uid_t* out_gid) { - char path[64]; - snprintf(path, sizeof(path), "/proc/%d/status", tid); - - FILE* fp = fopen(path, "r"); - if (!fp) { - return -1; - } - - int fields = 0; - char line[1024]; - while (fgets(line, sizeof(line), fp)) { - size_t len = strlen(line); - if (len > 6 && !memcmp(line, "Tgid:\t", 6)) { - *out_pid = atoi(line + 6); - fields |= 1; - } else if (len > 5 && !memcmp(line, "Uid:\t", 5)) { - *out_uid = atoi(line + 5); - fields |= 2; - } else if (len > 5 && !memcmp(line, "Gid:\t", 5)) { - *out_gid = atoi(line + 5); - fields |= 4; - } - } - fclose(fp); - return fields == 7 ? 0 : -1; -} - -/* - * Corresponds with debugger_action_t enum type in - * include/cutils/debugger.h. - */ -static const char *debuggerd_perms[] = { - NULL, /* crash is only used on self, no check applied */ - "dump_tombstone", - "dump_backtrace" -}; - -static int audit_callback(void* data, security_class_t /* cls */, char* buf, size_t len) -{ - struct debugger_request_t* req = reinterpret_cast(data); - - if (!req) { - ALOGE("No debuggerd request audit data"); - return 0; - } - - snprintf(buf, len, "pid=%d uid=%d gid=%d", req->pid, req->uid, req->gid); - return 0; -} - -static bool selinux_action_allowed(int s, debugger_request_t* request) -{ - char *scon = NULL, *tcon = NULL; - const char *tclass = "debuggerd"; - const char *perm; - bool allowed = false; - - if (request->action <= 0 || request->action >= (sizeof(debuggerd_perms)/sizeof(debuggerd_perms[0]))) { - ALOGE("SELinux: No permission defined for debugger action %d", request->action); - return false; - } - - perm = debuggerd_perms[request->action]; - - if (getpeercon(s, &scon) < 0) { - ALOGE("Cannot get peer context from socket\n"); - goto out; - } - - if (getpidcon(request->tid, &tcon) < 0) { - ALOGE("Cannot get context for tid %d\n", request->tid); - goto out; - } - - allowed = true; // (selinux_check_access(scon, tcon, tclass, perm, reinterpret_cast(request)) == 0); - -out: - freecon(scon); - freecon(tcon); - return allowed; -} - -static bool pid_contains_tid(pid_t pid, pid_t tid) { - char task_path[PATH_MAX]; - if (snprintf(task_path, PATH_MAX, "/proc/%d/task/%d", pid, tid) >= PATH_MAX) { - ALOGE("debuggerd: task path overflow (pid = %d, tid = %d)\n", pid, tid); - exit(1); - } - - return access(task_path, F_OK) == 0; -} - -static int read_request(int fd, debugger_request_t* out_request) { - ucred cr; - socklen_t len = sizeof(cr); - int status = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &len); - if (status != 0) { - ALOGE("cannot get credentials"); - return -1; - } - - ALOGV("reading tid"); - fcntl(fd, F_SETFL, O_NONBLOCK); - - pollfd pollfds[1]; - pollfds[0].fd = fd; - pollfds[0].events = POLLIN; - pollfds[0].revents = 0; - status = TEMP_FAILURE_RETRY(poll(pollfds, 1, 3000)); - if (status != 1) { - ALOGE("timed out reading tid (from pid=%d uid=%d)\n", cr.pid, cr.uid); - return -1; - } - - debugger_msg_t msg; - memset(&msg, 0, sizeof(msg)); - status = TEMP_FAILURE_RETRY(read(fd, &msg, sizeof(msg))); - if (status < 0) { - ALOGE("read failure? %s (pid=%d uid=%d)\n", strerror(errno), cr.pid, cr.uid); - return -1; - } - if (status != sizeof(debugger_msg_t)) { - ALOGE("invalid crash request of size %d (from pid=%d uid=%d)\n", status, cr.pid, cr.uid); - return -1; - } - - out_request->action = static_cast(msg.action); - out_request->tid = msg.tid; - out_request->pid = cr.pid; - out_request->uid = cr.uid; - out_request->gid = cr.gid; - out_request->abort_msg_address = msg.abort_msg_address; - out_request->original_si_code = msg.original_si_code; - - if (msg.action == DEBUGGER_ACTION_CRASH) { - // Ensure that the tid reported by the crashing process is valid. - // This check needs to happen again after ptracing the requested thread to prevent a race. - if (!pid_contains_tid(out_request->pid, out_request->tid)) { - ALOGE("tid %d does not exist in pid %d. ignoring debug request\n", out_request->tid, - out_request->pid); - return -1; - } - } else if (cr.uid == 0 || (cr.uid == AID_SYSTEM && msg.action == DEBUGGER_ACTION_DUMP_BACKTRACE)) { - // Only root or system can ask us to attach to any process and dump it explicitly. - // However, system is only allowed to collect backtraces but cannot dump tombstones. - status = get_process_info(out_request->tid, &out_request->pid, - &out_request->uid, &out_request->gid); - if (status < 0) { - ALOGE("tid %d does not exist. ignoring explicit dump request\n", out_request->tid); - return -1; - } - - if (!selinux_action_allowed(fd, out_request)) - return -1; - } else { - // No one else is allowed to dump arbitrary processes. - return -1; - } - return 0; -} - -static int activity_manager_connect() { - android::base::unique_fd amfd(socket(PF_UNIX, SOCK_STREAM, 0)); - if (amfd.get() < -1) { - ALOGE("debuggerd: Unable to connect to activity manager (socket failed: %s)", strerror(errno)); - return -1; - } - - struct sockaddr_un address; - memset(&address, 0, sizeof(address)); - address.sun_family = AF_UNIX; - // The path used here must match the value defined in NativeCrashListener.java. - strncpy(address.sun_path, "/data/system/ndebugsocket", sizeof(address.sun_path)); - if (TEMP_FAILURE_RETRY(connect(amfd.get(), reinterpret_cast(&address), - sizeof(address))) == -1) { - ALOGE("debuggerd: Unable to connect to activity manager (connect failed: %s)", strerror(errno)); - return -1; - } - - struct timeval tv; - memset(&tv, 0, sizeof(tv)); - tv.tv_sec = 1; // tight leash - if (setsockopt(amfd.get(), SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) { - ALOGE("debuggerd: Unable to connect to activity manager (setsockopt SO_SNDTIMEO failed: %s)", - strerror(errno)); - return -1; - } - - tv.tv_sec = 3; // 3 seconds on handshake read - if (setsockopt(amfd.get(), SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) { - ALOGE("debuggerd: Unable to connect to activity manager (setsockopt SO_RCVTIMEO failed: %s)", - strerror(errno)); - return -1; - } - - return amfd.release(); -} - -static void activity_manager_write(int pid, int signal, int amfd, const std::string& amfd_data) { - if (amfd == -1) { - return; - } - - // Activity Manager protocol: binary 32-bit network-byte-order ints for the - // pid and signal number, followed by the raw text of the dump, culminating - // in a zero byte that marks end-of-data. - uint32_t datum = htonl(pid); - if (!android::base::WriteFully(amfd, &datum, 4)) { - ALOGE("AM pid write failed: %s\n", strerror(errno)); - return; - } - datum = htonl(signal); - if (!android::base::WriteFully(amfd, &datum, 4)) { - ALOGE("AM signal write failed: %s\n", strerror(errno)); - return; - } - - if (!android::base::WriteFully(amfd, amfd_data.c_str(), amfd_data.size())) { - ALOGE("AM data write failed: %s\n", strerror(errno)); - return; - } - - // Send EOD to the Activity Manager, then wait for its ack to avoid racing - // ahead and killing the target out from under it. - uint8_t eodMarker = 0; - if (!android::base::WriteFully(amfd, &eodMarker, 1)) { - ALOGE("AM eod write failed: %s\n", strerror(errno)); - return; - } - // 3 sec timeout reading the ack; we're fine if the read fails. - android::base::ReadFully(amfd, &eodMarker, 1); -} - -static bool should_attach_gdb(const debugger_request_t& request) { - if (request.action == DEBUGGER_ACTION_CRASH) { - return property_get_bool("debug.debuggerd.wait_for_gdb", false); - } - return false; -} - -#if defined(__LP64__) -static bool is32bit(pid_t tid) { - char* exeline; - if (asprintf(&exeline, "/proc/%d/exe", tid) == -1) { - return false; - } - int fd = TEMP_FAILURE_RETRY(open(exeline, O_RDONLY | O_CLOEXEC)); - int saved_errno = errno; - free(exeline); - if (fd == -1) { - ALOGW("Failed to open /proc/%d/exe %s", tid, strerror(saved_errno)); - return false; - } - - char ehdr[EI_NIDENT]; - ssize_t bytes = TEMP_FAILURE_RETRY(read(fd, &ehdr, sizeof(ehdr))); - close(fd); - if (bytes != (ssize_t) sizeof(ehdr) || memcmp(ELFMAG, ehdr, SELFMAG) != 0) { - return false; - } - if (ehdr[EI_CLASS] == ELFCLASS32) { - return true; - } - return false; -} - -static void redirect_to_32(int fd, debugger_request_t* request) { - debugger_msg_t msg; - memset(&msg, 0, sizeof(msg)); - msg.tid = request->tid; - msg.action = request->action; - - int sock_fd = socket_local_client(DEBUGGER32_SOCKET_NAME, ANDROID_SOCKET_NAMESPACE_ABSTRACT, - SOCK_STREAM | SOCK_CLOEXEC); - if (sock_fd < 0) { - ALOGE("Failed to connect to debuggerd32: %s", strerror(errno)); - return; - } - - if (TEMP_FAILURE_RETRY(write(sock_fd, &msg, sizeof(msg))) != (ssize_t) sizeof(msg)) { - ALOGE("Failed to write request to debuggerd32 socket: %s", strerror(errno)); - close(sock_fd); - return; - } - - char ack; - if (TEMP_FAILURE_RETRY(read(sock_fd, &ack, 1)) == -1) { - ALOGE("Failed to read ack from debuggerd32 socket: %s", strerror(errno)); - close(sock_fd); - return; - } - - char buffer[1024]; - ssize_t bytes_read; - while ((bytes_read = TEMP_FAILURE_RETRY(read(sock_fd, buffer, sizeof(buffer)))) > 0) { - ssize_t bytes_to_send = bytes_read; - ssize_t bytes_written; - do { - bytes_written = TEMP_FAILURE_RETRY(write(fd, buffer + bytes_read - bytes_to_send, - bytes_to_send)); - if (bytes_written == -1) { - if (errno == EAGAIN) { - // Retry the write. - continue; - } - ALOGE("Error while writing data to fd: %s", strerror(errno)); - break; - } - bytes_to_send -= bytes_written; - } while (bytes_written != 0 && bytes_to_send > 0); - if (bytes_to_send != 0) { - ALOGE("Failed to write all data to fd: read %zd, sent %zd", bytes_read, bytes_to_send); - break; - } - } - close(sock_fd); -} -#endif - -// Attach to a thread, and verify that it's still a member of the given process -static bool ptrace_attach_thread(pid_t pid, pid_t tid) { - if (ptrace(PTRACE_ATTACH, tid, 0, 0) != 0) { - return false; - } - - // Make sure that the task we attached to is actually part of the pid we're dumping. - if (!pid_contains_tid(pid, tid)) { - if (ptrace(PTRACE_DETACH, tid, 0, 0) != 0) { - ALOGE("debuggerd: failed to detach from thread '%d'", tid); - exit(1); - } - return false; - } - - return true; -} - -static void ptrace_siblings(pid_t pid, pid_t main_tid, std::set& tids) { - char task_path[PATH_MAX]; - - if (snprintf(task_path, PATH_MAX, "/proc/%d/task", pid) >= PATH_MAX) { - ALOGE("debuggerd: task path overflow (pid = %d)\n", pid); - abort(); - } - - std::unique_ptr d(opendir(task_path), closedir); - - // Bail early if the task directory cannot be opened. - if (!d) { - ALOGE("debuggerd: failed to open /proc/%d/task: %s", pid, strerror(errno)); - return; - } - - struct dirent* de; - while ((de = readdir(d.get())) != NULL) { - // Ignore "." and "..". - if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) { - continue; - } - - char* end; - pid_t tid = strtoul(de->d_name, &end, 10); - if (*end) { - continue; - } - - if (tid == main_tid) { - continue; - } - - if (!ptrace_attach_thread(pid, tid)) { - ALOGE("debuggerd: ptrace attach to %d failed: %s", tid, strerror(errno)); - continue; - } - - tids.insert(tid); - } -} - -static bool perform_dump(const debugger_request_t& request, int fd, int tombstone_fd, - BacktraceMap* backtrace_map, const std::set& siblings, - int* crash_signal, std::string* amfd_data) { - if (TEMP_FAILURE_RETRY(write(fd, "\0", 1)) != 1) { - ALOGE("debuggerd: failed to respond to client: %s\n", strerror(errno)); - return false; - } - - int total_sleep_time_usec = 0; - while (true) { - int signal = wait_for_signal(request.tid, &total_sleep_time_usec); - switch (signal) { - case -1: - ALOGE("debuggerd: timed out waiting for signal"); - return false; - - case SIGSTOP: - if (request.action == DEBUGGER_ACTION_DUMP_TOMBSTONE) { - ALOGV("debuggerd: stopped -- dumping to tombstone"); - engrave_tombstone(tombstone_fd, backtrace_map, request.pid, request.tid, siblings, signal, - request.original_si_code, request.abort_msg_address, amfd_data); - } else if (request.action == DEBUGGER_ACTION_DUMP_BACKTRACE) { - ALOGV("debuggerd: stopped -- dumping to fd"); - dump_backtrace(fd, backtrace_map, request.pid, request.tid, siblings, nullptr); - } else { - ALOGV("debuggerd: stopped -- continuing"); - if (ptrace(PTRACE_CONT, request.tid, 0, 0) != 0) { - ALOGE("debuggerd: ptrace continue failed: %s", strerror(errno)); - return false; - } - continue; // loop again - } - break; - - case SIGABRT: - case SIGBUS: - case SIGFPE: - case SIGILL: - case SIGSEGV: -#ifdef SIGSTKFLT - case SIGSTKFLT: -#endif - case SIGSYS: - case SIGTRAP: - ALOGV("stopped -- fatal signal\n"); - *crash_signal = signal; - engrave_tombstone(tombstone_fd, backtrace_map, request.pid, request.tid, siblings, signal, - request.original_si_code, request.abort_msg_address, amfd_data); - break; - - default: - ALOGE("debuggerd: process stopped due to unexpected signal %d\n", signal); - break; - } - break; - } - - return true; -} - -static bool drop_privileges() { - // AID_LOG: for reading the logs data associated with the crashing process. - // AID_READPROC: for reading /proc//{comm,cmdline}. - gid_t groups[] = { AID_DEBUGGERD, AID_LOG, AID_READPROC }; - if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { - ALOGE("debuggerd: failed to setgroups: %s", strerror(errno)); - return false; - } - - if (setresgid(AID_DEBUGGERD, AID_DEBUGGERD, AID_DEBUGGERD) != 0) { - ALOGE("debuggerd: failed to setresgid: %s", strerror(errno)); - return false; - } - - if (setresuid(AID_DEBUGGERD, AID_DEBUGGERD, AID_DEBUGGERD) != 0) { - ALOGE("debuggerd: failed to setresuid: %s", strerror(errno)); - return false; - } - - return true; -} - -static void worker_process(int fd, debugger_request_t& request) { - // Open the tombstone file if we need it. - std::string tombstone_path; - int tombstone_fd = -1; - switch (request.action) { - case DEBUGGER_ACTION_DUMP_TOMBSTONE: - case DEBUGGER_ACTION_CRASH: - tombstone_fd = open_tombstone(&tombstone_path); - if (tombstone_fd == -1) { - ALOGE("debuggerd: failed to open tombstone file: %s\n", strerror(errno)); - exit(1); - } - break; - - case DEBUGGER_ACTION_DUMP_BACKTRACE: - break; - - default: - ALOGE("debuggerd: unexpected request action: %d", request.action); - exit(1); - } - - // At this point, the thread that made the request is blocked in - // a read() call. If the thread has crashed, then this gives us - // time to PTRACE_ATTACH to it before it has a chance to really fault. - // - // The PTRACE_ATTACH sends a SIGSTOP to the target process, but it - // won't necessarily have stopped by the time ptrace() returns. (We - // currently assume it does.) We write to the file descriptor to - // ensure that it can run as soon as we call PTRACE_CONT below. - // See details in bionic/libc/linker/debugger.c, in function - // debugger_signal_handler(). - - // Attach to the target process. - if (!ptrace_attach_thread(request.pid, request.tid)) { - ALOGE("debuggerd: ptrace attach failed: %s", strerror(errno)); - exit(1); - } - - // DEBUGGER_ACTION_CRASH requests can come from arbitrary processes and the tid field in the - // request is sent from the other side. If an attacker can cause a process to be spawned with the - // pid of their process, they could trick debuggerd into dumping that process by exiting after - // sending the request. Validate the trusted request.uid/gid to defend against this. - if (request.action == DEBUGGER_ACTION_CRASH) { - pid_t pid; - uid_t uid; - gid_t gid; - if (get_process_info(request.tid, &pid, &uid, &gid) != 0) { - ALOGE("debuggerd: failed to get process info for tid '%d'", request.tid); - exit(1); - } - - if (pid != request.pid || uid != request.uid || gid != request.gid) { - ALOGE( - "debuggerd: attached task %d does not match request: " - "expected pid=%d,uid=%d,gid=%d, actual pid=%d,uid=%d,gid=%d", - request.tid, request.pid, request.uid, request.gid, pid, uid, gid); - exit(1); - } - } - - // Don't attach to the sibling threads if we want to attach gdb. - // Supposedly, it makes the process less reliable. - bool attach_gdb = should_attach_gdb(request); - if (attach_gdb) { - // Open all of the input devices we need to listen for VOLUMEDOWN before dropping privileges. - if (init_getevent() != 0) { - ALOGE("debuggerd: failed to initialize input device, not waiting for gdb"); - attach_gdb = false; - } - - } - - std::set siblings; - if (!attach_gdb) { - ptrace_siblings(request.pid, request.tid, siblings); - } - - // Generate the backtrace map before dropping privileges. - std::unique_ptr backtrace_map(BacktraceMap::Create(request.pid)); - - int amfd = -1; - std::unique_ptr amfd_data; - if (request.action == DEBUGGER_ACTION_CRASH) { - // Connect to the activity manager before dropping privileges. - amfd = activity_manager_connect(); - amfd_data.reset(new std::string); - } - - bool succeeded = false; - - // Now that we've done everything that requires privileges, we can drop them. - if (!drop_privileges()) { - ALOGE("debuggerd: failed to drop privileges, exiting"); - _exit(1); - } - - int crash_signal = SIGKILL; - succeeded = perform_dump(request, fd, tombstone_fd, backtrace_map.get(), siblings, - &crash_signal, amfd_data.get()); - if (succeeded) { - if (request.action == DEBUGGER_ACTION_DUMP_TOMBSTONE) { - if (!tombstone_path.empty()) { - android::base::WriteFully(fd, tombstone_path.c_str(), tombstone_path.length()); - } - } - } - - if (attach_gdb) { - // Tell the signal process to send SIGSTOP to the target. - if (!send_signal(request.pid, 0, SIGSTOP)) { - ALOGE("debuggerd: failed to stop process for gdb attach: %s", strerror(errno)); - attach_gdb = false; - } - } - - if (!attach_gdb) { - // Tell the Activity Manager about the crashing process. If we are - // waiting for gdb to attach, do not send this or Activity Manager - // might kill the process before anyone can attach. - activity_manager_write(request.pid, crash_signal, amfd, *amfd_data.get()); - } - - if (ptrace(PTRACE_DETACH, request.tid, 0, 0) != 0) { - ALOGE("debuggerd: ptrace detach from %d failed: %s", request.tid, strerror(errno)); - } - - for (pid_t sibling : siblings) { - ptrace(PTRACE_DETACH, sibling, 0, 0); - } - - // Send the signal back to the process if it crashed and we're not waiting for gdb. - if (!attach_gdb && request.action == DEBUGGER_ACTION_CRASH) { - if (!send_signal(request.pid, request.tid, crash_signal)) { - ALOGE("debuggerd: failed to kill process %d: %s", request.pid, strerror(errno)); - } - } - - // Wait for gdb, if requested. - if (attach_gdb) { - wait_for_user_action(request); - - // Now tell the activity manager about this process. - activity_manager_write(request.pid, crash_signal, amfd, *amfd_data.get()); - - // Tell the signal process to send SIGCONT to the target. - if (!send_signal(request.pid, 0, SIGCONT)) { - ALOGE("debuggerd: failed to resume process %d: %s", request.pid, strerror(errno)); - } - - uninit_getevent(); - } - - close(amfd); - - exit(!succeeded); -} - -static void monitor_worker_process(int child_pid, const debugger_request_t& request) { - struct timespec timeout = {.tv_sec = 10, .tv_nsec = 0 }; - if (should_attach_gdb(request)) { - // If wait_for_gdb is enabled, set the timeout to something large. - timeout.tv_sec = INT_MAX; - } - - sigset_t signal_set; - sigemptyset(&signal_set); - sigaddset(&signal_set, SIGCHLD); - - bool kill_worker = false; - bool kill_target = false; - bool kill_self = false; - - int status; - siginfo_t siginfo; - int signal = TEMP_FAILURE_RETRY(sigtimedwait(&signal_set, &siginfo, &timeout)); - if (signal == SIGCHLD) { - pid_t rc = waitpid(-1, &status, WNOHANG | WUNTRACED); - if (rc != child_pid) { - ALOGE("debuggerd: waitpid returned unexpected pid (%d), committing murder-suicide", rc); - - if (WIFEXITED(status)) { - ALOGW("debuggerd: pid %d exited with status %d", rc, WEXITSTATUS(status)); - } else if (WIFSIGNALED(status)) { - ALOGW("debuggerd: pid %d received signal %d", rc, WTERMSIG(status)); - } else if (WIFSTOPPED(status)) { - ALOGW("debuggerd: pid %d stopped by signal %d", rc, WSTOPSIG(status)); - } else if (WIFCONTINUED(status)) { - ALOGW("debuggerd: pid %d continued", rc); - } - - kill_worker = true; - kill_target = true; - kill_self = true; - } else if (WIFSIGNALED(status)) { - ALOGE("debuggerd: worker process %d terminated due to signal %d", child_pid, WTERMSIG(status)); - kill_worker = false; - kill_target = true; - } else if (WIFSTOPPED(status)) { - ALOGE("debuggerd: worker process %d stopped due to signal %d", child_pid, WSTOPSIG(status)); - kill_worker = true; - kill_target = true; - } - } else { - ALOGE("debuggerd: worker process %d timed out", child_pid); - kill_worker = true; - kill_target = true; - } - - if (kill_worker) { - // Something bad happened, kill the worker. - if (kill(child_pid, SIGKILL) != 0) { - ALOGE("debuggerd: failed to kill worker process %d: %s", child_pid, strerror(errno)); - } else { - waitpid(child_pid, &status, 0); - } - } - - int exit_signal = SIGCONT; - if (kill_target && request.action == DEBUGGER_ACTION_CRASH) { - ALOGE("debuggerd: killing target %d", request.pid); - exit_signal = SIGKILL; - } else { - ALOGW("debuggerd: resuming target %d", request.pid); - } - - if (kill(request.pid, exit_signal) != 0) { - ALOGE("debuggerd: failed to send signal %d to target: %s", exit_signal, strerror(errno)); - } - - if (kill_self) { - stop_signal_sender(); - _exit(1); - } -} - -static void handle_request(int fd) { - ALOGV("handle_request(%d)\n", fd); - - ScopedFd closer(fd); - debugger_request_t request; - memset(&request, 0, sizeof(request)); - int status = read_request(fd, &request); - if (status != 0) { - return; - } - - ALOGW("debuggerd: handling request: pid=%d uid=%d gid=%d tid=%d\n", request.pid, request.uid, - request.gid, request.tid); - -#if defined(__LP64__) - // On 64 bit systems, requests to dump 32 bit and 64 bit tids come - // to the 64 bit debuggerd. If the process is a 32 bit executable, - // redirect the request to the 32 bit debuggerd. - if (is32bit(request.tid)) { - // Only dump backtrace and dump tombstone requests can be redirected. - if (request.action == DEBUGGER_ACTION_DUMP_BACKTRACE || - request.action == DEBUGGER_ACTION_DUMP_TOMBSTONE) { - redirect_to_32(fd, &request); - } else { - ALOGE("debuggerd: Not allowed to redirect action %d to 32 bit debuggerd\n", request.action); - } - return; - } -#endif - - // Fork a child to handle the rest of the request. - pid_t fork_pid = fork(); - if (fork_pid == -1) { - ALOGE("debuggerd: failed to fork: %s\n", strerror(errno)); - } else if (fork_pid == 0) { - worker_process(fd, request); - } else { - monitor_worker_process(fork_pid, request); - } -} - -static int do_server() { - // debuggerd crashes can't be reported to debuggerd. - // Reset all of the crash handlers. - signal(SIGABRT, SIG_DFL); - signal(SIGBUS, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGILL, SIG_DFL); - signal(SIGSEGV, SIG_DFL); -#ifdef SIGSTKFLT - signal(SIGSTKFLT, SIG_DFL); -#endif - signal(SIGTRAP, SIG_DFL); - - // Ignore failed writes to closed sockets - signal(SIGPIPE, SIG_IGN); - - // Block SIGCHLD so we can sigtimedwait for it. - sigset_t sigchld; - sigemptyset(&sigchld); - sigaddset(&sigchld, SIGCHLD); - sigprocmask(SIG_SETMASK, &sigchld, nullptr); - - int s = socket_local_server(SOCKET_NAME, ANDROID_SOCKET_NAMESPACE_ABSTRACT, - SOCK_STREAM | SOCK_CLOEXEC); - if (s == -1) return 1; - - // Fork a process that stays root, and listens on a pipe to pause and resume the target. - if (!start_signal_sender()) { - ALOGE("debuggerd: failed to fork signal sender"); - return 1; - } - - ALOGI("debuggerd: starting\n"); - - for (;;) { - sockaddr_storage ss; - sockaddr* addrp = reinterpret_cast(&ss); - socklen_t alen = sizeof(ss); - - ALOGV("waiting for connection\n"); - int fd = accept4(s, addrp, &alen, SOCK_CLOEXEC); - if (fd == -1) { - ALOGE("accept failed: %s\n", strerror(errno)); - continue; - } - - handle_request(fd); - } - return 0; -} - -static int do_explicit_dump(pid_t tid, bool dump_backtrace) { - fprintf(stdout, "Sending request to dump task %d.\n", tid); - - if (dump_backtrace) { - fflush(stdout); - if (dump_backtrace_to_file(tid, fileno(stdout)) < 0) { - fputs("Error dumping backtrace.\n", stderr); - return 1; - } - } else { - char tombstone_path[PATH_MAX]; - if (dump_tombstone(tid, tombstone_path, sizeof(tombstone_path)) < 0) { - fputs("Error dumping tombstone.\n", stderr); - return 1; - } - fprintf(stderr, "Tombstone written to: %s\n", tombstone_path); - } - return 0; -} - -static void usage() { - fputs("Usage: -b []\n" - " -b dump backtrace to console, otherwise dump full tombstone file\n" - "\n" - "If tid specified, sends a request to debuggerd to dump that task.\n" - "Otherwise, starts the debuggerd server.\n", stderr); -} - -int main(int argc, char** argv) { - union selinux_callback cb; - if (argc == 1) { - cb.func_audit = audit_callback; - selinux_set_callback(SELINUX_CB_AUDIT, cb); - cb.func_log = selinux_log_callback; - selinux_set_callback(SELINUX_CB_LOG, cb); - return do_server(); - } - - bool dump_backtrace = false; - bool have_tid = false; - pid_t tid = 0; - for (int i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-b")) { - dump_backtrace = true; - } else if (!have_tid) { - tid = atoi(argv[i]); - have_tid = true; - } else { - usage(); - return 1; - } - } - if (!have_tid) { - usage(); - return 1; - } - return do_explicit_dump(tid, dump_backtrace); -} diff --git a/app/src/main/jni/crash_dump/debuggerd/debuggerd.rc b/app/src/main/jni/crash_dump/debuggerd/debuggerd.rc deleted file mode 100644 index 1c6b9ff94..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/debuggerd.rc +++ /dev/null @@ -1,3 +0,0 @@ -service debuggerd /system/bin/debuggerd - group root readproc - writepid /dev/cpuset/system-background/tasks diff --git a/app/src/main/jni/crash_dump/debuggerd/debuggerd64.rc b/app/src/main/jni/crash_dump/debuggerd/debuggerd64.rc deleted file mode 100644 index 3e8847a5a..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/debuggerd64.rc +++ /dev/null @@ -1,3 +0,0 @@ -service debuggerd64 /system/bin/debuggerd64 - group root readproc - writepid /dev/cpuset/system-background/tasks diff --git a/app/src/main/jni/crash_dump/debuggerd/elf_utils.cpp b/app/src/main/jni/crash_dump/debuggerd/elf_utils.cpp deleted file mode 100644 index 9959f2e1f..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/elf_utils.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "DEBUG" - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "elf_utils.h" - -#define NOTE_ALIGN(size) ((size + 3) & ~3) - -template -static bool get_build_id( - Backtrace* backtrace, uintptr_t base_addr, uint8_t* e_ident, std::string* build_id) { - HdrType hdr; - - memcpy(&hdr.e_ident[0], e_ident, EI_NIDENT); - - // First read the rest of the header. - if (backtrace->Read(base_addr + EI_NIDENT, reinterpret_cast(&hdr) + EI_NIDENT, - sizeof(HdrType) - EI_NIDENT) != sizeof(HdrType) - EI_NIDENT) { - return false; - } - - for (size_t i = 0; i < hdr.e_phnum; i++) { - PhdrType phdr; - if (backtrace->Read(base_addr + hdr.e_phoff + i * hdr.e_phentsize, - reinterpret_cast(&phdr), sizeof(phdr)) != sizeof(phdr)) { - return false; - } - // Looking for the .note.gnu.build-id note. - if (phdr.p_type == PT_NOTE) { - size_t hdr_size = phdr.p_filesz; - uintptr_t addr = base_addr + phdr.p_offset; - while (hdr_size >= sizeof(NhdrType)) { - NhdrType nhdr; - if (backtrace->Read(addr, reinterpret_cast(&nhdr), sizeof(nhdr)) != sizeof(nhdr)) { - return false; - } - addr += sizeof(nhdr); - if (nhdr.n_type == NT_GNU_BUILD_ID) { - // Skip the name (which is the owner and should be "GNU"). - addr += NOTE_ALIGN(nhdr.n_namesz); - uint8_t build_id_data[160]; - if (nhdr.n_descsz > sizeof(build_id_data)) { - ALOGE("Possible corrupted note, desc size value is too large: %u", - nhdr.n_descsz); - return false; - } - if (backtrace->Read(addr, build_id_data, nhdr.n_descsz) != nhdr.n_descsz) { - return false; - } - - build_id->clear(); - for (size_t bytes = 0; bytes < nhdr.n_descsz; bytes++) { - *build_id += android::base::StringPrintf("%02x", build_id_data[bytes]); - } - - return true; - } else { - // Move past the extra note data. - hdr_size -= sizeof(nhdr); - size_t skip_bytes = NOTE_ALIGN(nhdr.n_namesz) + NOTE_ALIGN(nhdr.n_descsz); - addr += skip_bytes; - if (hdr_size < skip_bytes) { - break; - } - hdr_size -= skip_bytes; - } - } - } - } - return false; -} - -bool elf_get_build_id(Backtrace* backtrace, uintptr_t addr, std::string* build_id) { - // Read and verify the elf magic number first. - uint8_t e_ident[EI_NIDENT]; - if (backtrace->Read(addr, e_ident, SELFMAG) != SELFMAG) { - return false; - } - - if (memcmp(e_ident, ELFMAG, SELFMAG) != 0) { - return false; - } - - // Read the rest of EI_NIDENT. - if (backtrace->Read(addr + SELFMAG, e_ident + SELFMAG, EI_NIDENT - SELFMAG) != EI_NIDENT - SELFMAG) { - return false; - } - - if (e_ident[EI_CLASS] == ELFCLASS32) { - return get_build_id(backtrace, addr, e_ident, build_id); - } else if (e_ident[EI_CLASS] == ELFCLASS64) { - return get_build_id(backtrace, addr, e_ident, build_id); - } - - return false; -} diff --git a/app/src/main/jni/crash_dump/debuggerd/elf_utils.h b/app/src/main/jni/crash_dump/debuggerd/elf_utils.h deleted file mode 100644 index 11d0a4348..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/elf_utils.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DEBUGGERD_ELF_UTILS_H -#define _DEBUGGERD_ELF_UTILS_H - -#include -#include - -class Backtrace; - -bool elf_get_build_id(Backtrace*, uintptr_t, std::string*); - -#endif // _DEBUGGERD_ELF_UTILS_H diff --git a/app/src/main/jni/crash_dump/debuggerd/getevent.cpp b/app/src/main/jni/crash_dump/debuggerd/getevent.cpp deleted file mode 100644 index 751c4fb61..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/getevent.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static struct pollfd* ufds; -static char** device_names; -static int nfds; - -static int open_device(const char* device) { - int version; - int fd; - struct pollfd* new_ufds; - char** new_device_names; - char name[80]; - char location[80]; - char idstr[80]; - struct input_id id; - - fd = open(device, O_RDWR); - if (fd < 0) { - return -1; - } - - if (ioctl(fd, EVIOCGVERSION, &version)) { - return -1; - } - if (ioctl(fd, EVIOCGID, &id)) { - return -1; - } - name[sizeof(name) - 1] = '\0'; - location[sizeof(location) - 1] = '\0'; - idstr[sizeof(idstr) - 1] = '\0'; - if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) { - name[0] = '\0'; - } - if (ioctl(fd, EVIOCGPHYS(sizeof(location) - 1), &location) < 1) { - location[0] = '\0'; - } - if (ioctl(fd, EVIOCGUNIQ(sizeof(idstr) - 1), &idstr) < 1) { - idstr[0] = '\0'; - } - - new_ufds = reinterpret_cast(realloc(ufds, sizeof(ufds[0]) * (nfds + 1))); - if (new_ufds == NULL) { - fprintf(stderr, "out of memory\n"); - return -1; - } - ufds = new_ufds; - new_device_names = reinterpret_cast(realloc( - device_names, sizeof(device_names[0]) * (nfds + 1))); - if (new_device_names == NULL) { - fprintf(stderr, "out of memory\n"); - return -1; - } - device_names = new_device_names; - ufds[nfds].fd = fd; - ufds[nfds].events = POLLIN; - device_names[nfds] = strdup(device); - nfds++; - - return 0; -} - -int close_device(const char* device) { - int i; - for (i = 1; i < nfds; i++) { - if (strcmp(device_names[i], device) == 0) { - int count = nfds - i - 1; - free(device_names[i]); - memmove(device_names + i, device_names + i + 1, sizeof(device_names[0]) * count); - memmove(ufds + i, ufds + i + 1, sizeof(ufds[0]) * count); - nfds--; - return 0; - } - } - return -1; -} - -static int read_notify(const char* dirname, int nfd) { - int res; - char devname[PATH_MAX]; - char* filename; - char event_buf[512]; - int event_size; - int event_pos = 0; - struct inotify_event *event; - - res = read(nfd, event_buf, sizeof(event_buf)); - if (res < (int)sizeof(*event)) { - if (errno == EINTR) - return 0; - fprintf(stderr, "could not get event, %s\n", strerror(errno)); - return 1; - } - - strcpy(devname, dirname); - filename = devname + strlen(devname); - *filename++ = '/'; - - while (res >= (int)sizeof(*event)) { - event = reinterpret_cast(event_buf + event_pos); - if (event->len) { - strcpy(filename, event->name); - if (event->mask & IN_CREATE) { - open_device(devname); - } else { - close_device(devname); - } - } - event_size = sizeof(*event) + event->len; - res -= event_size; - event_pos += event_size; - } - return 0; -} - -static int scan_dir(const char* dirname) { - char devname[PATH_MAX]; - char* filename; - DIR* dir; - struct dirent* de; - dir = opendir(dirname); - if (dir == NULL) - return -1; - strcpy(devname, dirname); - filename = devname + strlen(devname); - *filename++ = '/'; - while ((de = readdir(dir))) { - if ((de->d_name[0] == '.' && de->d_name[1] == '\0') || - (de->d_name[1] == '.' && de->d_name[2] == '\0')) - continue; - strcpy(filename, de->d_name); - open_device(devname); - } - closedir(dir); - return 0; -} - -int init_getevent() { - int res; - const char* device_path = "/dev/input"; - - nfds = 1; - ufds = reinterpret_cast(calloc(1, sizeof(ufds[0]))); - ufds[0].fd = inotify_init(); - ufds[0].events = POLLIN; - - res = inotify_add_watch(ufds[0].fd, device_path, IN_DELETE | IN_CREATE); - if (res < 0) { - return 1; - } - res = scan_dir(device_path); - if (res < 0) { - return 1; - } - return 0; -} - -void uninit_getevent() { - int i; - for (i = 0; i < nfds; i++) { - close(ufds[i].fd); - } - free(ufds); - ufds = 0; - nfds = 0; -} - -int get_event(struct input_event* event, int timeout) { - int res; - int i; - int pollres; - const char* device_path = "/dev/input"; - while (1) { - pollres = poll(ufds, nfds, timeout); - if (pollres == 0) { - return 1; - } - if (ufds[0].revents & POLLIN) { - read_notify(device_path, ufds[0].fd); - } - for (i = 1; i < nfds; i++) { - if (ufds[i].revents) { - if (ufds[i].revents & POLLIN) { - res = read(ufds[i].fd, event, sizeof(*event)); - if (res < static_cast(sizeof(event))) { - fprintf(stderr, "could not get event\n"); - return -1; - } - return 0; - } - } - } - } - return 0; -} diff --git a/app/src/main/jni/crash_dump/debuggerd/getevent.h b/app/src/main/jni/crash_dump/debuggerd/getevent.h deleted file mode 100644 index 426139d33..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/getevent.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DEBUGGERD_GETEVENT_H -#define _DEBUGGERD_GETEVENT_H - -int init_getevent(); -void uninit_getevent(); -int get_event(struct input_event* event, int timeout); - -#endif // _DEBUGGERD_GETEVENT_H diff --git a/app/src/main/jni/crash_dump/debuggerd/machine.h b/app/src/main/jni/crash_dump/debuggerd/machine.h deleted file mode 100644 index e65b147f6..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/machine.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DEBUGGERD_MACHINE_H -#define _DEBUGGERD_MACHINE_H - -#include - -#include - -#include "utility.h" - -void dump_memory_and_code(log_t* log, Backtrace* backtrace); -void dump_registers(log_t* log, pid_t tid); - -#endif // _DEBUGGERD_MACHINE_H diff --git a/app/src/main/jni/crash_dump/debuggerd/property_fake.cpp b/app/src/main/jni/crash_dump/debuggerd/property_fake.cpp deleted file mode 100644 index af942df2d..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/property_fake.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include -#include - -#include "sys/system_properties.h" - -std::unordered_map g_properties; - -extern "C" int property_set(const char* name, const char* value) { - if (g_properties.count(name) != 0) { - g_properties.erase(name); - } - g_properties[name] = value; - return 0; -} - -extern "C" int property_get(const char* key, char* value, const char* default_value) { - if (g_properties.count(key) == 0) { - if (default_value == nullptr) { - return 0; - } - strncpy(value, default_value, PROP_VALUE_MAX-1); - } else { - strncpy(value, g_properties[key].c_str(), PROP_VALUE_MAX-1); - } - value[PROP_VALUE_MAX-1] = '\0'; - return strlen(value); -} diff --git a/app/src/main/jni/crash_dump/debuggerd/selinux/android.h b/app/src/main/jni/crash_dump/debuggerd/selinux/android.h deleted file mode 100644 index abed0870c..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/selinux/android.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -extern "C" int selinux_android_restorecon(const char*, unsigned int); diff --git a/app/src/main/jni/crash_dump/debuggerd/selinux_fake.cpp b/app/src/main/jni/crash_dump/debuggerd/selinux_fake.cpp deleted file mode 100644 index acdd0a97c..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/selinux_fake.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -extern "C" int selinux_android_restorecon(const char*, unsigned int) { - return 0; -} diff --git a/app/src/main/jni/crash_dump/debuggerd/signal_sender.cpp b/app/src/main/jni/crash_dump/debuggerd/signal_sender.cpp deleted file mode 100644 index 4be7e6e2b..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/signal_sender.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "signal_sender.h" - -static int signal_fd = -1; -static pid_t signal_pid; -struct signal_message { - pid_t pid; - pid_t tid; - int signal; -}; - -static void set_signal_sender_process_name() { -#if defined(__LP64__) - static constexpr char long_process_name[] = "debuggerd64:signaller"; - static constexpr char short_process_name[] = "debuggerd64:sig"; - static_assert(sizeof(long_process_name) <= sizeof("/system/bin/debuggerd64"), ""); -#else - static constexpr char long_process_name[] = "debuggerd:signaller"; - static constexpr char short_process_name[] = "debuggerd:sig"; - static_assert(sizeof(long_process_name) <= sizeof("/system/bin/debuggerd"), ""); -#endif - - // pthread_setname_np has a maximum length of 16 chars, including null terminator. - static_assert(sizeof(short_process_name) <= 16, ""); - pthread_setname_np(pthread_self(), short_process_name); - - char* progname = const_cast(getprogname()); - if (strlen(progname) <= strlen(long_process_name)) { - ALOGE("debuggerd: unexpected progname %s", progname); - return; - } - - memset(progname, 0, strlen(progname)); - strcpy(progname, long_process_name); -} - -// Fork a process to send signals for the worker processes to use after they've dropped privileges. -bool start_signal_sender() { - if (signal_pid != 0) { - ALOGE("debuggerd: attempted to start signal sender multiple times"); - return false; - } - - int sfd[2]; - if (socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sfd) != 0) { - ALOGE("debuggerd: failed to create socketpair for signal sender: %s", strerror(errno)); - return false; - } - - pid_t parent = getpid(); - pid_t fork_pid = fork(); - if (fork_pid == -1) { - ALOGE("debuggerd: failed to initialize signal sender: fork failed: %s", strerror(errno)); - return false; - } else if (fork_pid == 0) { - close(sfd[1]); - - set_signal_sender_process_name(); - - while (true) { - signal_message msg; - int rc = TEMP_FAILURE_RETRY(read(sfd[0], &msg, sizeof(msg))); - if (rc < 0) { - ALOGE("debuggerd: signal sender failed to read from socket"); - break; - } else if (rc != sizeof(msg)) { - ALOGE("debuggerd: signal sender read unexpected number of bytes: %d", rc); - break; - } - - // Report success after sending a signal - int err = 0; - if (msg.tid > 0) { - if (syscall(SYS_tgkill, msg.pid, msg.tid, msg.signal) != 0) { - err = errno; - } - } else { - if (kill(msg.pid, msg.signal) != 0) { - err = errno; - } - } - - if (TEMP_FAILURE_RETRY(write(sfd[0], &err, sizeof(err))) < 0) { - ALOGE("debuggerd: signal sender failed to write: %s", strerror(errno)); - } - } - - // Our parent proably died, but if not, kill them. - if (getppid() == parent) { - kill(parent, SIGKILL); - } - _exit(1); - } else { - close(sfd[0]); - signal_fd = sfd[1]; - signal_pid = fork_pid; - return true; - } -} - -bool stop_signal_sender() { - if (signal_pid <= 0) { - return false; - } - - if (kill(signal_pid, SIGKILL) != 0) { - ALOGE("debuggerd: failed to kill signal sender: %s", strerror(errno)); - return false; - } - - close(signal_fd); - signal_fd = -1; - - int status; - waitpid(signal_pid, &status, 0); - signal_pid = 0; - - return true; -} - -bool send_signal(pid_t pid, pid_t tid, int signal) { - if (signal_fd == -1) { - ALOGE("debuggerd: attempted to send signal before signal sender was started"); - errno = EHOSTUNREACH; - return false; - } - - signal_message msg = {.pid = pid, .tid = tid, .signal = signal }; - if (TEMP_FAILURE_RETRY(write(signal_fd, &msg, sizeof(msg))) < 0) { - ALOGE("debuggerd: failed to send message to signal sender: %s", strerror(errno)); - errno = EHOSTUNREACH; - return false; - } - - int response; - ssize_t rc = TEMP_FAILURE_RETRY(read(signal_fd, &response, sizeof(response))); - if (rc == 0) { - ALOGE("debuggerd: received EOF from signal sender"); - errno = EHOSTUNREACH; - return false; - } else if (rc < 0) { - ALOGE("debuggerd: failed to receive response from signal sender: %s", strerror(errno)); - errno = EHOSTUNREACH; - return false; - } - - if (response == 0) { - return true; - } - - errno = response; - return false; -} diff --git a/app/src/main/jni/crash_dump/debuggerd/signal_sender.h b/app/src/main/jni/crash_dump/debuggerd/signal_sender.h deleted file mode 100644 index 0443272e6..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/signal_sender.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DEBUGGERD_SIGNAL_SENDER_H -#define _DEBUGGERD_SIGNAL_SENDER_H - -#include - -bool start_signal_sender(); -bool stop_signal_sender(); - -// Sends a signal to a target process or thread. -// If tid is greater than zero, this performs tgkill(pid, tid, signal). -// Otherwise, it performs kill(pid, signal). -bool send_signal(pid_t pid, pid_t tid, int signal); - -#endif diff --git a/app/src/main/jni/crash_dump/debuggerd/sys/system_properties.h b/app/src/main/jni/crash_dump/debuggerd/sys/system_properties.h deleted file mode 100644 index 9d4434530..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/sys/system_properties.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _DEBUGGERD_TEST_SYS_SYSTEM_PROPERTIES_H -#define _DEBUGGERD_TEST_SYS_SYSTEM_PROPERTIES_H - -// This is just enough to get the property code to compile on -// the host. - -#define PROP_NAME_MAX 32 -#define PROP_VALUE_MAX 92 - -#endif // _DEBUGGERD_TEST_SYS_SYSTEM_PROPERTIES_H diff --git a/app/src/main/jni/crash_dump/debuggerd/tombstone.cpp b/app/src/main/jni/crash_dump/debuggerd/tombstone.cpp deleted file mode 100644 index fa983fa1f..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/tombstone.cpp +++ /dev/null @@ -1,702 +0,0 @@ -/* - * Copyright (C) 2012-2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "DEBUG" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "backtrace.h" -#include "elf_utils.h" -#include "machine.h" -#include "tombstone.h" - -#define STACK_WORDS 16 - -#define MAX_TOMBSTONES 10 -#define TOMBSTONE_DIR "/data/tombstones" -#define TOMBSTONE_TEMPLATE (TOMBSTONE_DIR"/tombstone_%02d") - -static bool signal_has_si_addr(int sig) { - switch (sig) { - case SIGBUS: - case SIGFPE: - case SIGILL: - case SIGSEGV: - case SIGTRAP: - return true; - default: - return false; - } -} - -static const char* get_signame(int sig) { - switch(sig) { - case SIGABRT: return "SIGABRT"; - case SIGBUS: return "SIGBUS"; - case SIGFPE: return "SIGFPE"; - case SIGILL: return "SIGILL"; - case SIGSEGV: return "SIGSEGV"; -#if defined(SIGSTKFLT) - case SIGSTKFLT: return "SIGSTKFLT"; -#endif - case SIGSTOP: return "SIGSTOP"; - case SIGTRAP: return "SIGTRAP"; - default: return "?"; - } -} - -static const char* get_sigcode(int signo, int code) { - // Try the signal-specific codes... - switch (signo) { - case SIGILL: - switch (code) { - case ILL_ILLOPC: return "ILL_ILLOPC"; - case ILL_ILLOPN: return "ILL_ILLOPN"; - case ILL_ILLADR: return "ILL_ILLADR"; - case ILL_ILLTRP: return "ILL_ILLTRP"; - case ILL_PRVOPC: return "ILL_PRVOPC"; - case ILL_PRVREG: return "ILL_PRVREG"; - case ILL_COPROC: return "ILL_COPROC"; - case ILL_BADSTK: return "ILL_BADSTK"; - } - static_assert(NSIGILL == ILL_BADSTK, "missing ILL_* si_code"); - break; - case SIGBUS: - switch (code) { - case BUS_ADRALN: return "BUS_ADRALN"; - case BUS_ADRERR: return "BUS_ADRERR"; - case BUS_OBJERR: return "BUS_OBJERR"; - case BUS_MCEERR_AR: return "BUS_MCEERR_AR"; - case BUS_MCEERR_AO: return "BUS_MCEERR_AO"; - } - static_assert(NSIGBUS == BUS_MCEERR_AO, "missing BUS_* si_code"); - break; - case SIGFPE: - switch (code) { - case FPE_INTDIV: return "FPE_INTDIV"; - case FPE_INTOVF: return "FPE_INTOVF"; - case FPE_FLTDIV: return "FPE_FLTDIV"; - case FPE_FLTOVF: return "FPE_FLTOVF"; - case FPE_FLTUND: return "FPE_FLTUND"; - case FPE_FLTRES: return "FPE_FLTRES"; - case FPE_FLTINV: return "FPE_FLTINV"; - case FPE_FLTSUB: return "FPE_FLTSUB"; - } - static_assert(NSIGFPE == FPE_FLTSUB, "missing FPE_* si_code"); - break; - case SIGSEGV: - switch (code) { - case SEGV_MAPERR: return "SEGV_MAPERR"; - case SEGV_ACCERR: return "SEGV_ACCERR"; -#if defined(SEGV_BNDERR) - case SEGV_BNDERR: return "SEGV_BNDERR"; -#endif - } -#if defined(SEGV_BNDERR) - static_assert(NSIGSEGV == SEGV_BNDERR, "missing SEGV_* si_code"); -#else - static_assert(NSIGSEGV == SEGV_ACCERR, "missing SEGV_* si_code"); -#endif - break; - case SIGTRAP: - switch (code) { - case TRAP_BRKPT: return "TRAP_BRKPT"; - case TRAP_TRACE: return "TRAP_TRACE"; - case TRAP_BRANCH: return "TRAP_BRANCH"; - case TRAP_HWBKPT: return "TRAP_HWBKPT"; - } - static_assert(NSIGTRAP == TRAP_HWBKPT, "missing TRAP_* si_code"); - break; - } - // Then the other codes... - switch (code) { - case SI_USER: return "SI_USER"; - case SI_KERNEL: return "SI_KERNEL"; - case SI_QUEUE: return "SI_QUEUE"; - case SI_TIMER: return "SI_TIMER"; - case SI_MESGQ: return "SI_MESGQ"; - case SI_ASYNCIO: return "SI_ASYNCIO"; - case SI_SIGIO: return "SI_SIGIO"; - case SI_TKILL: return "SI_TKILL"; - case SI_DETHREAD: return "SI_DETHREAD"; - } - // Then give up... - return "?"; -} - -static void dump_header_info(log_t* log) { - char fingerprint[PROPERTY_VALUE_MAX]; - char revision[PROPERTY_VALUE_MAX]; - - property_get("ro.build.fingerprint", fingerprint, "unknown"); - property_get("ro.revision", revision, "unknown"); - - _LOG(log, logtype::HEADER, "Build fingerprint: '%s'\n", fingerprint); - _LOG(log, logtype::HEADER, "Revision: '%s'\n", revision); - _LOG(log, logtype::HEADER, "ABI: '%s'\n", ABI_STRING); -} - -static void dump_signal_info(log_t* log, pid_t tid, int signal, int si_code) { - siginfo_t si; - memset(&si, 0, sizeof(si)); - if (ptrace(PTRACE_GETSIGINFO, tid, 0, &si) == -1) { - ALOGE("cannot get siginfo: %s\n", strerror(errno)); - return; - } - - // bionic has to re-raise some signals, which overwrites the si_code with SI_TKILL. - si.si_code = si_code; - - char addr_desc[32]; // ", fault addr 0x1234" - if (signal_has_si_addr(signal)) { - snprintf(addr_desc, sizeof(addr_desc), "%p", si.si_addr); - } else { - snprintf(addr_desc, sizeof(addr_desc), "--------"); - } - - _LOG(log, logtype::HEADER, "signal %d (%s), code %d (%s), fault addr %s\n", - signal, get_signame(signal), si.si_code, get_sigcode(signal, si.si_code), addr_desc); -} - -static void dump_thread_info(log_t* log, pid_t pid, pid_t tid) { - char path[64]; - char threadnamebuf[1024]; - char* threadname = nullptr; - FILE *fp; - - snprintf(path, sizeof(path), "/proc/%d/comm", tid); - if ((fp = fopen(path, "r"))) { - threadname = fgets(threadnamebuf, sizeof(threadnamebuf), fp); - fclose(fp); - if (threadname) { - size_t len = strlen(threadname); - if (len && threadname[len - 1] == '\n') { - threadname[len - 1] = '\0'; - } - } - } - // Blacklist logd, logd.reader, logd.writer, logd.auditd, logd.control ... - static const char logd[] = "logd"; - if (threadname != nullptr && !strncmp(threadname, logd, sizeof(logd) - 1) - && (!threadname[sizeof(logd) - 1] || (threadname[sizeof(logd) - 1] == '.'))) { - log->should_retrieve_logcat = false; - } - - char procnamebuf[1024]; - char* procname = nullptr; - - snprintf(path, sizeof(path), "/proc/%d/cmdline", pid); - if ((fp = fopen(path, "r"))) { - procname = fgets(procnamebuf, sizeof(procnamebuf), fp); - fclose(fp); - } - - _LOG(log, logtype::HEADER, "pid: %d, tid: %d, name: %s >>> %s <<<\n", pid, tid, - threadname ? threadname : "UNKNOWN", procname ? procname : "UNKNOWN"); -} - -static void dump_stack_segment( - Backtrace* backtrace, log_t* log, uintptr_t* sp, size_t words, int label) { - // Read the data all at once. - word_t stack_data[words]; - size_t bytes_read = backtrace->Read(*sp, reinterpret_cast(&stack_data[0]), sizeof(word_t) * words); - words = bytes_read / sizeof(word_t); - std::string line; - for (size_t i = 0; i < words; i++) { - line = " "; - if (i == 0 && label >= 0) { - // Print the label once. - line += android::base::StringPrintf("#%02d ", label); - } else { - line += " "; - } - line += android::base::StringPrintf("%" PRIPTR " %" PRIPTR, *sp, stack_data[i]); - - backtrace_map_t map; - backtrace->FillInMap(stack_data[i], &map); - if (BacktraceMap::IsValid(map) && !map.name.empty()) { - line += " " + map.name; - uintptr_t offset = 0; - std::string func_name(backtrace->GetFunctionName(stack_data[i], &offset)); - if (!func_name.empty()) { - line += " (" + func_name; - if (offset) { - line += android::base::StringPrintf("+%" PRIuPTR, offset); - } - line += ')'; - } - } - _LOG(log, logtype::STACK, "%s\n", line.c_str()); - - *sp += sizeof(word_t); - } -} - -static void dump_stack(Backtrace* backtrace, log_t* log) { - size_t first = 0, last; - for (size_t i = 0; i < backtrace->NumFrames(); i++) { - const backtrace_frame_data_t* frame = backtrace->GetFrame(i); - if (frame->sp) { - if (!first) { - first = i+1; - } - last = i; - } - } - if (!first) { - return; - } - first--; - - // Dump a few words before the first frame. - word_t sp = backtrace->GetFrame(first)->sp - STACK_WORDS * sizeof(word_t); - dump_stack_segment(backtrace, log, &sp, STACK_WORDS, -1); - - // Dump a few words from all successive frames. - // Only log the first 3 frames, put the rest in the tombstone. - for (size_t i = first; i <= last; i++) { - const backtrace_frame_data_t* frame = backtrace->GetFrame(i); - if (sp != frame->sp) { - _LOG(log, logtype::STACK, " ........ ........\n"); - sp = frame->sp; - } - if (i == last) { - dump_stack_segment(backtrace, log, &sp, STACK_WORDS, i); - if (sp < frame->sp + frame->stack_size) { - _LOG(log, logtype::STACK, " ........ ........\n"); - } - } else { - size_t words = frame->stack_size / sizeof(word_t); - if (words == 0) { - words = 1; - } else if (words > STACK_WORDS) { - words = STACK_WORDS; - } - dump_stack_segment(backtrace, log, &sp, words, i); - } - } -} - -static std::string get_addr_string(uintptr_t addr) { - std::string addr_str; -#if defined(__LP64__) - addr_str = android::base::StringPrintf("%08x'%08x", - static_cast(addr >> 32), - static_cast(addr & 0xffffffff)); -#else - addr_str = android::base::StringPrintf("%08x", addr); -#endif - return addr_str; -} - -static void dump_abort_message(Backtrace* backtrace, log_t* log, uintptr_t address) { - if (address == 0) { - return; - } - - address += sizeof(size_t); // Skip the buffer length. - - char msg[512]; - memset(msg, 0, sizeof(msg)); - char* p = &msg[0]; - while (p < &msg[sizeof(msg)]) { - word_t data; - size_t len = sizeof(word_t); - if (!backtrace->ReadWord(address, &data)) { - break; - } - address += sizeof(word_t); - - while (len > 0 && (*p++ = (data >> (sizeof(word_t) - len) * 8) & 0xff) != 0) { - len--; - } - } - msg[sizeof(msg) - 1] = '\0'; - - _LOG(log, logtype::HEADER, "Abort message: '%s'\n", msg); -} - -static void dump_all_maps(Backtrace* backtrace, BacktraceMap* map, log_t* log, pid_t tid) { - bool print_fault_address_marker = false; - uintptr_t addr = 0; - siginfo_t si; - memset(&si, 0, sizeof(si)); - if (ptrace(PTRACE_GETSIGINFO, tid, 0, &si) != -1) { - print_fault_address_marker = signal_has_si_addr(si.si_signo); - addr = reinterpret_cast(si.si_addr); - } else { - ALOGE("Cannot get siginfo for %d: %s\n", tid, strerror(errno)); - } - - _LOG(log, logtype::MAPS, "\n"); - if (!print_fault_address_marker) { - _LOG(log, logtype::MAPS, "memory map:\n"); - } else { - _LOG(log, logtype::MAPS, "memory map: (fault address prefixed with --->)\n"); - if (map->begin() != map->end() && addr < map->begin()->start) { - _LOG(log, logtype::MAPS, "--->Fault address falls at %s before any mapped regions\n", - get_addr_string(addr).c_str()); - print_fault_address_marker = false; - } - } - - std::string line; - for (BacktraceMap::const_iterator it = map->begin(); it != map->end(); ++it) { - line = " "; - if (print_fault_address_marker) { - if (addr < it->start) { - _LOG(log, logtype::MAPS, "--->Fault address falls at %s between mapped regions\n", - get_addr_string(addr).c_str()); - print_fault_address_marker = false; - } else if (addr >= it->start && addr < it->end) { - line = "--->"; - print_fault_address_marker = false; - } - } - line += get_addr_string(it->start) + '-' + get_addr_string(it->end - 1) + ' '; - if (it->flags & PROT_READ) { - line += 'r'; - } else { - line += '-'; - } - if (it->flags & PROT_WRITE) { - line += 'w'; - } else { - line += '-'; - } - if (it->flags & PROT_EXEC) { - line += 'x'; - } else { - line += '-'; - } - line += android::base::StringPrintf(" %8" PRIxPTR " %8" PRIxPTR, - it->offset, it->end - it->start); - bool space_needed = true; - if (it->name.length() > 0) { - space_needed = false; - line += " " + it->name; - std::string build_id; - if ((it->flags & PROT_READ) && elf_get_build_id(backtrace, it->start, &build_id)) { - line += " (BuildId: " + build_id + ")"; - } - } - if (it->load_base != 0) { - if (space_needed) { - line += ' '; - } - line += android::base::StringPrintf(" (load base 0x%" PRIxPTR ")", it->load_base); - } - _LOG(log, logtype::MAPS, "%s\n", line.c_str()); - } - if (print_fault_address_marker) { - _LOG(log, logtype::MAPS, "--->Fault address falls at %s after any mapped regions\n", - get_addr_string(addr).c_str()); - } -} - -static void dump_backtrace_and_stack(Backtrace* backtrace, log_t* log) { - if (backtrace->NumFrames()) { - _LOG(log, logtype::BACKTRACE, "\nbacktrace:\n"); - dump_backtrace_to_log(backtrace, log, " "); - - _LOG(log, logtype::STACK, "\nstack:\n"); - dump_stack(backtrace, log); - } -} - -static void dump_thread(log_t* log, pid_t pid, pid_t tid, BacktraceMap* map, int signal, - int si_code, uintptr_t abort_msg_address, bool primary_thread) { - log->current_tid = tid; - if (!primary_thread) { - _LOG(log, logtype::THREAD, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n"); - } - dump_thread_info(log, pid, tid); - - if (signal) { - dump_signal_info(log, tid, signal, si_code); - } - - std::unique_ptr backtrace(Backtrace::Create(pid, tid, map)); - if (primary_thread) { - dump_abort_message(backtrace.get(), log, abort_msg_address); - } - dump_registers(log, tid); - if (backtrace->Unwind(0)) { - dump_backtrace_and_stack(backtrace.get(), log); - } else { - ALOGE("Unwind failed: pid = %d, tid = %d", pid, tid); - } - - if (primary_thread) { - dump_memory_and_code(log, backtrace.get()); - if (map) { - dump_all_maps(backtrace.get(), map, log, tid); - } - } - - log->current_tid = log->crashed_tid; -} - -// Reads the contents of the specified log device, filters out the entries -// that don't match the specified pid, and writes them to the tombstone file. -// -// If "tail" is non-zero, log the last "tail" number of lines. -static EventTagMap* g_eventTagMap = NULL; - -static void dump_log_file( - log_t* log, pid_t pid, const char* filename, unsigned int tail) { - bool first = true; - struct logger_list* logger_list; - - if (!log->should_retrieve_logcat) { - return; - } - - logger_list = android_logger_list_open( - android_name_to_log_id(filename), ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, tail, pid); - - if (!logger_list) { - ALOGE("Unable to open %s: %s\n", filename, strerror(errno)); - return; - } - - struct log_msg log_entry; - - while (true) { - ssize_t actual = android_logger_list_read(logger_list, &log_entry); - struct logger_entry* entry; - - if (actual < 0) { - if (actual == -EINTR) { - // interrupted by signal, retry - continue; - } else if (actual == -EAGAIN) { - // non-blocking EOF; we're done - break; - } else { - ALOGE("Error while reading log: %s\n", strerror(-actual)); - break; - } - } else if (actual == 0) { - ALOGE("Got zero bytes while reading log: %s\n", strerror(errno)); - break; - } - - // NOTE: if you ALOGV something here, this will spin forever, - // because you will be writing as fast as you're reading. Any - // high-frequency debug diagnostics should just be written to - // the tombstone file. - - entry = &log_entry.entry_v1; - - if (first) { - _LOG(log, logtype::LOGS, "--------- %slog %s\n", - tail ? "tail end of " : "", filename); - first = false; - } - - // Msg format is: \0\0 - // - // We want to display it in the same format as "logcat -v threadtime" - // (although in this case the pid is redundant). - static const char* kPrioChars = "!.VDIWEFS"; - unsigned hdr_size = log_entry.entry.hdr_size; - if (!hdr_size) { - hdr_size = sizeof(log_entry.entry_v1); - } - char* msg = reinterpret_cast(log_entry.buf) + hdr_size; - - char timeBuf[32]; - time_t sec = static_cast(entry->sec); - struct tm tmBuf; - struct tm* ptm; - ptm = localtime_r(&sec, &tmBuf); - strftime(timeBuf, sizeof(timeBuf), "%m-%d %H:%M:%S", ptm); - - if (log_entry.id() == LOG_ID_EVENTS) { - if (!g_eventTagMap) { - g_eventTagMap = android_openEventTagMap(EVENT_TAG_MAP_FILE); - } - AndroidLogEntry e; - char buf[512]; - android_log_processBinaryLogBuffer(entry, &e, g_eventTagMap, buf, sizeof(buf)); - _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8s: %s\n", - timeBuf, entry->nsec / 1000000, entry->pid, entry->tid, - 'I', e.tag, e.message); - continue; - } - - unsigned char prio = msg[0]; - char* tag = msg + 1; - msg = tag + strlen(tag) + 1; - - // consume any trailing newlines - char* nl = msg + strlen(msg) - 1; - while (nl >= msg && *nl == '\n') { - *nl-- = '\0'; - } - - char prioChar = (prio < strlen(kPrioChars) ? kPrioChars[prio] : '?'); - - // Look for line breaks ('\n') and display each text line - // on a separate line, prefixed with the header, like logcat does. - do { - nl = strchr(msg, '\n'); - if (nl) { - *nl = '\0'; - ++nl; - } - - _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8s: %s\n", - timeBuf, entry->nsec / 1000000, entry->pid, entry->tid, - prioChar, tag, msg); - } while ((msg = nl)); - } - - android_logger_list_free(logger_list); -} - -// Dumps the logs generated by the specified pid to the tombstone, from both -// "system" and "main" log devices. Ideally we'd interleave the output. -static void dump_logs(log_t* log, pid_t pid, unsigned int tail) { - dump_log_file(log, pid, "system", tail); - dump_log_file(log, pid, "main", tail); -} - -// Dumps all information about the specified pid to the tombstone. -static void dump_crash(log_t* log, BacktraceMap* map, pid_t pid, pid_t tid, - const std::set& siblings, int signal, int si_code, - uintptr_t abort_msg_address) { - // don't copy log messages to tombstone unless this is a dev device - char value[PROPERTY_VALUE_MAX]; - property_get("ro.debuggable", value, "0"); - bool want_logs = (value[0] == '1'); - - _LOG(log, logtype::HEADER, - "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n"); - dump_header_info(log); - dump_thread(log, pid, tid, map, signal, si_code, abort_msg_address, true); - if (want_logs) { - dump_logs(log, pid, 5); - } - - if (!siblings.empty()) { - for (pid_t sibling : siblings) { - dump_thread(log, pid, sibling, map, 0, 0, 0, false); - } - } - - if (want_logs) { - dump_logs(log, pid, 0); - } -} - -// open_tombstone - find an available tombstone slot, if any, of the -// form tombstone_XX where XX is 00 to MAX_TOMBSTONES-1, inclusive. If no -// file is available, we reuse the least-recently-modified file. -int open_tombstone(std::string* out_path) { - // In a single pass, find an available slot and, in case none - // exist, find and record the least-recently-modified file. - char path[128]; - int fd = -1; - int oldest = -1; - struct stat oldest_sb; - for (int i = 0; i < MAX_TOMBSTONES; i++) { - snprintf(path, sizeof(path), TOMBSTONE_TEMPLATE, i); - - struct stat sb; - if (stat(path, &sb) == 0) { - if (oldest < 0 || sb.st_mtime < oldest_sb.st_mtime) { - oldest = i; - oldest_sb.st_mtime = sb.st_mtime; - } - continue; - } - if (errno != ENOENT) continue; - - fd = open(path, O_CREAT | O_EXCL | O_WRONLY | O_NOFOLLOW | O_CLOEXEC, 0600); - if (fd < 0) continue; // raced ? - - if (out_path) { - *out_path = path; - } - fchown(fd, AID_SYSTEM, AID_SYSTEM); - return fd; - } - - if (oldest < 0) { - ALOGE("debuggerd: failed to find a valid tombstone, default to using tombstone 0.\n"); - oldest = 0; - } - - // we didn't find an available file, so we clobber the oldest one - snprintf(path, sizeof(path), TOMBSTONE_TEMPLATE, oldest); - fd = open(path, O_CREAT | O_TRUNC | O_WRONLY | O_NOFOLLOW | O_CLOEXEC, 0600); - if (fd < 0) { - ALOGE("debuggerd: failed to open tombstone file '%s': %s\n", path, strerror(errno)); - return -1; - } - - if (out_path) { - *out_path = path; - } - fchown(fd, AID_SYSTEM, AID_SYSTEM); - return fd; -} - -void engrave_tombstone(int tombstone_fd, BacktraceMap* map, pid_t pid, pid_t tid, - const std::set& siblings, int signal, int original_si_code, - uintptr_t abort_msg_address, std::string* amfd_data) { - log_t log; - log.current_tid = tid; - log.crashed_tid = tid; - - if (tombstone_fd < 0) { - ALOGE("debuggerd: skipping tombstone write, nothing to do.\n"); - return; - } - - log.tfd = tombstone_fd; - log.amfd_data = amfd_data; - dump_crash(&log, map, pid, tid, siblings, signal, original_si_code, abort_msg_address); -} diff --git a/app/src/main/jni/crash_dump/debuggerd/tombstone.h b/app/src/main/jni/crash_dump/debuggerd/tombstone.h deleted file mode 100644 index 487d95058..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/tombstone.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _DEBUGGERD_TOMBSTONE_H -#define _DEBUGGERD_TOMBSTONE_H - -#include -#include -#include -#include -#include - -class BacktraceMap; - -/* Create and open a tombstone file for writing. - * Returns a writable file descriptor, or -1 with errno set appropriately. - * If out_path is non-null, *out_path is set to the path of the tombstone file. - */ -int open_tombstone(std::string* path); - -/* Creates a tombstone file and writes the crash dump to it. */ -void engrave_tombstone(int tombstone_fd, BacktraceMap* map, pid_t pid, pid_t tid, - const std::set& siblings, int signal, int original_si_code, - uintptr_t abort_msg_address, std::string* amfd_data); - -#endif // _DEBUGGERD_TOMBSTONE_H diff --git a/app/src/main/jni/crash_dump/debuggerd/utility.cpp b/app/src/main/jni/crash_dump/debuggerd/utility.cpp deleted file mode 100644 index bd060954e..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/utility.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "DEBUG" - -#include "utility.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -constexpr int SLEEP_TIME_USEC = 50000; // 0.05 seconds -constexpr int MAX_TOTAL_SLEEP_USEC = 10000000; // 10 seconds - -// Whitelist output desired in the logcat output. -bool is_allowed_in_logcat(enum logtype ltype) { - if ((ltype == HEADER) - || (ltype == REGISTERS) - || (ltype == BACKTRACE)) { - return true; - } - return false; -} - -void _LOG(log_t* log, enum logtype ltype, const char* fmt, ...) { - bool write_to_tombstone = (log->tfd != -1); - bool write_to_logcat = is_allowed_in_logcat(ltype) - && log->crashed_tid != -1 - && log->current_tid != -1 - && (log->crashed_tid == log->current_tid); - - char buf[512]; - va_list ap; - va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - - size_t len = strlen(buf); - if (len <= 0) { - return; - } - - if (write_to_tombstone) { - TEMP_FAILURE_RETRY(write(log->tfd, buf, len)); - } - - if (write_to_logcat) { - __android_log_buf_write(LOG_ID_CRASH, ANDROID_LOG_FATAL, LOG_TAG, buf); - if (log->amfd_data != nullptr) { - *log->amfd_data += buf; - } - } -} - -int wait_for_signal(pid_t tid, int* total_sleep_time_usec) { - while (true) { - int status; - pid_t n = TEMP_FAILURE_RETRY(waitpid(tid, &status, __WALL | WNOHANG)); - if (n == -1) { - ALOGE("waitpid failed: tid %d, %s", tid, strerror(errno)); - return -1; - } else if (n == tid) { - if (WIFSTOPPED(status)) { - return WSTOPSIG(status); - } else { - ALOGE("unexpected waitpid response: n=%d, status=%08x\n", n, status); - // This is the only circumstance under which we can allow a detach - // to fail with ESRCH, which indicates the tid has exited. - return -1; - } - } - - if (*total_sleep_time_usec > MAX_TOTAL_SLEEP_USEC) { - ALOGE("timed out waiting for stop signal: tid=%d", tid); - return -1; - } - - usleep(SLEEP_TIME_USEC); - *total_sleep_time_usec += SLEEP_TIME_USEC; - } -} - -#define MEMORY_BYTES_TO_DUMP 256 -#define MEMORY_BYTES_PER_LINE 16 - -void dump_memory(log_t* log, Backtrace* backtrace, uintptr_t addr, const char* fmt, ...) { - std::string log_msg; - va_list ap; - va_start(ap, fmt); - android::base::StringAppendV(&log_msg, fmt, ap); - va_end(ap); - - // Align the address to sizeof(long) and start 32 bytes before the address. - addr &= ~(sizeof(long) - 1); - if (addr >= 4128) { - addr -= 32; - } - - // Don't bother if the address looks too low, or looks too high. - if (addr < 4096 || -#if defined(__LP64__) - addr > 0x4000000000000000UL - MEMORY_BYTES_TO_DUMP) { -#else - addr > 0xffff0000 - MEMORY_BYTES_TO_DUMP) { -#endif - return; - } - - _LOG(log, logtype::MEMORY, "\n%s\n", log_msg.c_str()); - - // Dump 256 bytes - uintptr_t data[MEMORY_BYTES_TO_DUMP/sizeof(uintptr_t)]; - memset(data, 0, MEMORY_BYTES_TO_DUMP); - size_t bytes = backtrace->Read(addr, reinterpret_cast(data), sizeof(data)); - if (bytes % sizeof(uintptr_t) != 0) { - // This should never happen, but just in case. - ALOGE("Bytes read %zu, is not a multiple of %zu", bytes, sizeof(uintptr_t)); - bytes &= ~(sizeof(uintptr_t) - 1); - } - - uintptr_t start = 0; - bool skip_2nd_read = false; - if (bytes == 0) { - // In this case, we might want to try another read at the beginning of - // the next page only if it's within the amount of memory we would have - // read. - size_t page_size = sysconf(_SC_PAGE_SIZE); - start = ((addr + (page_size - 1)) & ~(page_size - 1)) - addr; - if (start == 0 || start >= MEMORY_BYTES_TO_DUMP) { - skip_2nd_read = true; - } - } - - if (bytes < MEMORY_BYTES_TO_DUMP && !skip_2nd_read) { - // Try to do one more read. This could happen if a read crosses a map, - // but the maps do not have any break between them. Or it could happen - // if reading from an unreadable map, but the read would cross back - // into a readable map. Only requires one extra read because a map has - // to contain at least one page, and the total number of bytes to dump - // is smaller than a page. - size_t bytes2 = backtrace->Read(addr + start + bytes, reinterpret_cast(data) + bytes, - sizeof(data) - bytes - start); - bytes += bytes2; - if (bytes2 > 0 && bytes % sizeof(uintptr_t) != 0) { - // This should never happen, but we'll try and continue any way. - ALOGE("Bytes after second read %zu, is not a multiple of %zu", bytes, sizeof(uintptr_t)); - bytes &= ~(sizeof(uintptr_t) - 1); - } - } - - // Dump the code around memory as: - // addr contents ascii - // 0000000000008d34 ef000000e8bd0090 e1b00000512fff1e ............../Q - // 0000000000008d44 ea00b1f9e92d0090 e3a070fcef000000 ......-..p...... - // On 32-bit machines, there are still 16 bytes per line but addresses and - // words are of course presented differently. - uintptr_t* data_ptr = data; - size_t current = 0; - size_t total_bytes = start + bytes; - for (size_t line = 0; line < MEMORY_BYTES_TO_DUMP / MEMORY_BYTES_PER_LINE; line++) { - std::string logline; - android::base::StringAppendF(&logline, " %" PRIPTR, addr); - - addr += MEMORY_BYTES_PER_LINE; - std::string ascii; - for (size_t i = 0; i < MEMORY_BYTES_PER_LINE / sizeof(uintptr_t); i++) { - if (current >= start && current + sizeof(uintptr_t) <= total_bytes) { - android::base::StringAppendF(&logline, " %" PRIPTR, *data_ptr); - - // Fill out the ascii string from the data. - uint8_t* ptr = reinterpret_cast(data_ptr); - for (size_t val = 0; val < sizeof(uintptr_t); val++, ptr++) { - if (*ptr >= 0x20 && *ptr < 0x7f) { - ascii += *ptr; - } else { - ascii += '.'; - } - } - data_ptr++; - } else { - logline += ' ' + std::string(sizeof(uintptr_t) * 2, '-'); - ascii += std::string(sizeof(uintptr_t), '.'); - } - current += sizeof(uintptr_t); - } - _LOG(log, logtype::MEMORY, "%s %s\n", logline.c_str(), ascii.c_str()); - } -} diff --git a/app/src/main/jni/crash_dump/debuggerd/utility.h b/app/src/main/jni/crash_dump/debuggerd/utility.h deleted file mode 100644 index cd01188c3..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/utility.h +++ /dev/null @@ -1,84 +0,0 @@ -/* system/debuggerd/utility.h -** -** Copyright 2008, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -#ifndef _DEBUGGERD_UTILITY_H -#define _DEBUGGERD_UTILITY_H - -#include -#include - -#include - -#include - -// Figure out the abi based on defined macros. -#if defined(__arm__) -#define ABI_STRING "arm" -#elif defined(__aarch64__) -#define ABI_STRING "arm64" -#elif defined(__mips__) && !defined(__LP64__) -#define ABI_STRING "mips" -#elif defined(__mips__) && defined(__LP64__) -#define ABI_STRING "mips64" -#elif defined(__i386__) -#define ABI_STRING "x86" -#elif defined(__x86_64__) -#define ABI_STRING "x86_64" -#else -#error "Unsupported ABI" -#endif - - -struct log_t{ - // Tombstone file descriptor. - int tfd; - // Data to be sent to the Activity Manager. - std::string* amfd_data; - // The tid of the thread that crashed. - pid_t crashed_tid; - // The tid of the thread we are currently working with. - pid_t current_tid; - // logd daemon crash, can block asking for logcat data, allow suppression. - bool should_retrieve_logcat; - - log_t() - : tfd(-1), amfd_data(nullptr), crashed_tid(-1), current_tid(-1), - should_retrieve_logcat(true) {} -}; - -// List of types of logs to simplify the logging decision in _LOG -enum logtype { - HEADER, - THREAD, - REGISTERS, - FP_REGISTERS, - BACKTRACE, - MAPS, - MEMORY, - STACK, - LOGS -}; - -// Log information onto the tombstone. -void _LOG(log_t* log, logtype ltype, const char *fmt, ...) - __attribute__ ((format(printf, 3, 4))); - -int wait_for_signal(pid_t tid, int* total_sleep_time_usec); - -void dump_memory(log_t* log, Backtrace* backtrace, uintptr_t addr, const char* fmt, ...); - -#endif // _DEBUGGERD_UTILITY_H diff --git a/app/src/main/jni/crash_dump/debuggerd/x86/crashglue.S b/app/src/main/jni/crash_dump/debuggerd/x86/crashglue.S deleted file mode 100644 index 59df43250..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/x86/crashglue.S +++ /dev/null @@ -1,15 +0,0 @@ -.globl crash1 -.globl crashnostack - -crash1: - movl $0xa5a50000, %eax - movl $0xa5a50001, %ebx - movl $0xa5a50002, %ecx - - movl $0, %edx - jmp *%edx - - -crashnostack: - movl $0, %ebp - jmp *%ebp diff --git a/app/src/main/jni/crash_dump/debuggerd/x86/machine.cpp b/app/src/main/jni/crash_dump/debuggerd/x86/machine.cpp deleted file mode 100644 index af10817a4..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/x86/machine.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2006, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "DEBUG" - -#include -#include -#include -#include - -#include -#include - -#include "machine.h" -#include "utility.h" - -void dump_memory_and_code(log_t* log, Backtrace* backtrace) { - struct pt_regs r; - if (ptrace(PTRACE_GETREGS, backtrace->Tid(), 0, &r) == -1) { - ALOGE("cannot get registers: %s\n", strerror(errno)); - return; - } - - dump_memory(log, backtrace, static_cast(r.eax), "memory near eax:"); - dump_memory(log, backtrace, static_cast(r.ebx), "memory near ebx:"); - dump_memory(log, backtrace, static_cast(r.ecx), "memory near ecx:"); - dump_memory(log, backtrace, static_cast(r.edx), "memory near edx:"); - dump_memory(log, backtrace, static_cast(r.esi), "memory near esi:"); - dump_memory(log, backtrace, static_cast(r.edi), "memory near edi:"); - - dump_memory(log, backtrace, static_cast(r.eip), "code around eip:"); -} - -void dump_registers(log_t* log, pid_t tid) { - struct pt_regs r; - if (ptrace(PTRACE_GETREGS, tid, 0, &r) == -1) { - ALOGE("cannot get registers: %s\n", strerror(errno)); - return; - } - - _LOG(log, logtype::REGISTERS, " eax %08lx ebx %08lx ecx %08lx edx %08lx\n", - r.eax, r.ebx, r.ecx, r.edx); - _LOG(log, logtype::REGISTERS, " esi %08lx edi %08lx\n", - r.esi, r.edi); - _LOG(log, logtype::REGISTERS, " xcs %08x xds %08x xes %08x xfs %08x xss %08x\n", - r.xcs, r.xds, r.xes, r.xfs, r.xss); - _LOG(log, logtype::REGISTERS, " eip %08lx ebp %08lx esp %08lx flags %08lx\n", - r.eip, r.ebp, r.esp, r.eflags); -} diff --git a/app/src/main/jni/crash_dump/debuggerd/x86_64/crashglue.S b/app/src/main/jni/crash_dump/debuggerd/x86_64/crashglue.S deleted file mode 100644 index 4d2a5c023..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/x86_64/crashglue.S +++ /dev/null @@ -1,15 +0,0 @@ -.globl crash1 -.globl crashnostack - -crash1: - movl $0xa5a50000, %eax - movl $0xa5a50001, %ebx - movl $0xa5a50002, %ecx - - movl $0, %edx - jmp *%rdx - - -crashnostack: - movl $0, %ebp - jmp *%rbp diff --git a/app/src/main/jni/crash_dump/debuggerd/x86_64/machine.cpp b/app/src/main/jni/crash_dump/debuggerd/x86_64/machine.cpp deleted file mode 100644 index fc86bc2b9..000000000 --- a/app/src/main/jni/crash_dump/debuggerd/x86_64/machine.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* -** Copyright 2013, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -#define LOG_TAG "DEBUG" - -#include -#include -#include -#include -#include - -#include -#include - -#include "machine.h" -#include "utility.h" - -void dump_memory_and_code(log_t* log, Backtrace* backtrace) { - struct user_regs_struct r; - if (ptrace(PTRACE_GETREGS, backtrace->Tid(), 0, &r) == -1) { - ALOGE("cannot get registers: %s\n", strerror(errno)); - return; - } - - dump_memory(log, backtrace, static_cast(r.rax), "memory near rax:"); - dump_memory(log, backtrace, static_cast(r.rbx), "memory near rbx:"); - dump_memory(log, backtrace, static_cast(r.rcx), "memory near rcx:"); - dump_memory(log, backtrace, static_cast(r.rdx), "memory near rdx:"); - dump_memory(log, backtrace, static_cast(r.rsi), "memory near rsi:"); - dump_memory(log, backtrace, static_cast(r.rdi), "memory near rdi:"); - - dump_memory(log, backtrace, static_cast(r.rip), "code around rip:"); -} - -void dump_registers(log_t* log, pid_t tid) { - struct user_regs_struct r; - if (ptrace(PTRACE_GETREGS, tid, 0, &r) == -1) { - ALOGE("cannot get registers: %s\n", strerror(errno)); - return; - } - - _LOG(log, logtype::REGISTERS, " rax %016lx rbx %016lx rcx %016lx rdx %016lx\n", - r.rax, r.rbx, r.rcx, r.rdx); - _LOG(log, logtype::REGISTERS, " rsi %016lx rdi %016lx\n", - r.rsi, r.rdi); - _LOG(log, logtype::REGISTERS, " r8 %016lx r9 %016lx r10 %016lx r11 %016lx\n", - r.r8, r.r9, r.r10, r.r11); - _LOG(log, logtype::REGISTERS, " r12 %016lx r13 %016lx r14 %016lx r15 %016lx\n", - r.r12, r.r13, r.r14, r.r15); - _LOG(log, logtype::REGISTERS, " cs %016lx ss %016lx\n", - r.cs, r.ss); - _LOG(log, logtype::REGISTERS, " rip %016lx rbp %016lx rsp %016lx eflags %016lx\n", - r.rip, r.rbp, r.rsp, r.eflags); -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/Android.build.mk b/app/src/main/jni/crash_dump/libbacktrace/Android.build.mk deleted file mode 100644 index fad14ed7c..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/Android.build.mk +++ /dev/null @@ -1,95 +0,0 @@ -# -# Copyright (C) 2014 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -include $(CLEAR_VARS) - -LOCAL_MODULE := $(module) -LOCAL_MODULE_TAGS := $(module_tag) -LOCAL_MULTILIB := $($(module)_multilib) -ifeq ($(LOCAL_MULTILIB),both) -ifneq ($(build_target),$(filter $(build_target),SHARED_LIBRARY STATIC_LIBRARY)) - LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32 - LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 -endif -endif - -# ifeq ($(build_type),target) -# include $(LLVM_DEVICE_BUILD_MK) -# else -# include $(LLVM_HOST_BUILD_MK) -# endif - -LOCAL_ADDITIONAL_DEPENDENCIES += \ - $(LOCAL_PATH)/Android.mk \ - $(LOCAL_PATH)/Android.build.mk \ - -LOCAL_CFLAGS += \ - $(libbacktrace_common_cflags) \ - $($(module)_cflags) \ - $($(module)_cflags_$(build_type)) \ - -LOCAL_CLANG_CFLAGS += \ - $(libbacktrace_common_clang_cflags) \ - -LOCAL_CONLYFLAGS += \ - $(libbacktrace_common_conlyflags) \ - $($(module)_conlyflags) \ - $($(module)_conlyflags_$(build_type)) \ - -LOCAL_CPPFLAGS += \ - $(libbacktrace_common_cppflags) \ - $($(module)_cppflags) \ - $($(module)_cppflags_$(build_type)) \ - -LOCAL_C_INCLUDES += \ - $(libbacktrace_common_c_includes) \ - $($(module)_c_includes) \ - $($(module)_c_includes_$(build_type)) \ - -LOCAL_SRC_FILES := \ - $($(module)_src_files) \ - $($(module)_src_files_$(build_type)) \ - -LOCAL_STATIC_LIBRARIES += \ - $($(module)_static_libraries) \ - $($(module)_static_libraries_$(build_type)) \ - -LOCAL_SHARED_LIBRARIES += \ - $($(module)_shared_libraries) \ - $($(module)_shared_libraries_$(build_type)) \ - -LOCAL_LDLIBS += \ - $($(module)_ldlibs) \ - $($(module)_ldlibs_$(build_type)) \ - -LOCAL_STRIP_MODULE := $($(module)_strip_module) - -ifeq ($(build_type),target) - include $(BUILD_$(build_target)) -endif - -ifeq ($(build_type),host) - # Only build if host builds are supported. - ifeq ($(build_host),true) - # -fno-omit-frame-pointer should be set for host build. Because currently - # libunwind can't recognize .debug_frame using dwarf version 4, and it relies - # on stack frame pointer to do unwinding on x86. - # $(LLVM_HOST_BUILD_MK) overwrites -fno-omit-frame-pointer. so the below line - # must be after the include. - LOCAL_CFLAGS += -Wno-extern-c-compat -fno-omit-frame-pointer - include $(BUILD_HOST_$(build_target)) - endif -endif diff --git a/app/src/main/jni/crash_dump/libbacktrace/Android.mk b/app/src/main/jni/crash_dump/libbacktrace/Android.mk deleted file mode 100644 index 383d12211..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/Android.mk +++ /dev/null @@ -1,124 +0,0 @@ -# -# Copyright (C) 2014 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -LOCAL_PATH:= $(call my-dir) - -libbacktrace_common_cflags := \ - -Wall \ - -Werror - -libbacktrace_common_conlyflags := \ - -std=gnu99 \ - -libbacktrace_common_cppflags := \ - -std=gnu++11 \ - -I$(HERE_PATH)/crash_dump/libbase/include \ - -I$(HERE_PATH)/crash_dump/libunwind/include/tdep - -# The latest clang (r230699) does not allow SP/PC to be declared in inline asm lists. -libbacktrace_common_clang_cflags += \ - -Wno-inline-asm - -build_host := false -ifeq ($(HOST_OS),linux) -ifeq ($(HOST_ARCH),$(filter $(HOST_ARCH),x86 x86_64)) -build_host := true -endif -endif - -# LLVM_ROOT_PATH := external/llvm -# include $(LLVM_ROOT_PATH)/llvm.mk - -#------------------------------------------------------------------------- -# The libbacktrace library. -#------------------------------------------------------------------------- -libbacktrace_src_files := \ - Backtrace.cpp \ - BacktraceCurrent.cpp \ - BacktraceMap.cpp \ - BacktracePtrace.cpp \ - thread_utils.c \ - ThreadEntry.cpp \ - UnwindCurrent.cpp \ - UnwindMap.cpp \ - UnwindPtrace.cpp \ - -libbacktrace_shared_ldlibs := -llog -libbacktrace_shared_libraries := libunwind libcrashdumpbase - -module := libbacktrace -module_tag := optional -build_type := target -build_target := SHARED_LIBRARY -include $(LOCAL_PATH)/Android.build.mk -build_type := host -libbacktrace_multilib := both -include $(LOCAL_PATH)/Android.build.mk -libbacktrace_static_ldlibs := -llog -lunwind -# -lbase - -# libbacktrace_static_libraries := libunwind - - -build_target := STATIC_LIBRARY -include $(LOCAL_PATH)/Android.build.mk -libbacktrace_static_libraries := - -#------------------------------------------------------------------------- -# The libbacktrace_offline shared library. -#------------------------------------------------------------------------- -libbacktrace_offline_src_files := \ - BacktraceOffline.cpp \ - -# Use shared llvm library on device to save space. -libbacktrace_offline_shared_libraries_target := \ - libbacktrace \ - libbase \ - liblog \ - libunwind \ - libutils \ - libLLVM \ - -libbacktrace_offline_static_libraries_target := \ - libziparchive \ - libz \ - -# Use static llvm libraries on host to remove dependency on 32-bit llvm shared library -# which is not included in the prebuilt. -libbacktrace_offline_static_libraries_host := \ - libbacktrace \ - libunwind \ - libziparchive-host \ - libz \ - libbase \ - liblog \ - libutils \ - libLLVMObject \ - libLLVMBitReader \ - libLLVMMC \ - libLLVMMCParser \ - libLLVMCore \ - libLLVMSupport \ - -module := libbacktrace_offline -build_type := target -build_target := STATIC_LIBRARY -libbacktrace_offline_multilib := both -# i don't know if this lib is required or not -# include $(LOCAL_PATH)/Android.build.mk -build_type := host -# include $(LOCAL_PATH)/Android.build.mk - diff --git a/app/src/main/jni/crash_dump/libbacktrace/Backtrace.cpp b/app/src/main/jni/crash_dump/libbacktrace/Backtrace.cpp deleted file mode 100644 index 0d2e11bdf..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/Backtrace.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#include "BacktraceLog.h" -#include "thread_utils.h" -#include "UnwindCurrent.h" -#include "UnwindPtrace.h" - -using android::base::StringPrintf; - -//------------------------------------------------------------------------- -// Backtrace functions. -//------------------------------------------------------------------------- -Backtrace::Backtrace(pid_t pid, pid_t tid, BacktraceMap* map) - : pid_(pid), tid_(tid), map_(map), map_shared_(true) { - if (map_ == nullptr) { - map_ = BacktraceMap::Create(pid); - map_shared_ = false; - } -} - -Backtrace::~Backtrace() { - if (map_ && !map_shared_) { - delete map_; - map_ = nullptr; - } -} - -std::string Backtrace::GetFunctionName(uintptr_t pc, uintptr_t* offset) { - std::string func_name = GetFunctionNameRaw(pc, offset); - return func_name; -} - -bool Backtrace::VerifyReadWordArgs(uintptr_t ptr, word_t* out_value) { - if (ptr & (sizeof(word_t)-1)) { - BACK_LOGW("invalid pointer %p", reinterpret_cast(ptr)); - *out_value = static_cast(-1); - return false; - } - return true; -} - -std::string Backtrace::FormatFrameData(size_t frame_num) { - if (frame_num >= frames_.size()) { - return ""; - } - return FormatFrameData(&frames_[frame_num]); -} - -std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) { - uintptr_t relative_pc; - std::string map_name; - if (BacktraceMap::IsValid(frame->map)) { - relative_pc = BacktraceMap::GetRelativePc(frame->map, frame->pc); - if (!frame->map.name.empty()) { - map_name = frame->map.name.c_str(); - if (map_name[0] == '[' && map_name[map_name.size() - 1] == ']') { - map_name.resize(map_name.size() - 1); - map_name += StringPrintf(":%" PRIPTR "]", frame->map.start); - } - } else { - map_name = StringPrintf("", frame->map.start); - } - } else { - map_name = ""; - relative_pc = frame->pc; - } - - std::string line(StringPrintf("#%02zu pc %" PRIPTR " ", frame->num, relative_pc)); - line += map_name; - // Special handling for non-zero offset maps, we need to print that - // information. - if (frame->map.offset != 0) { - line += " (offset " + StringPrintf("0x%" PRIxPTR, frame->map.offset) + ")"; - } - if (!frame->func_name.empty()) { - line += " (" + frame->func_name; - if (frame->func_offset) { - line += StringPrintf("+%" PRIuPTR, frame->func_offset); - } - line += ')'; - } - - return line; -} - -void Backtrace::FillInMap(uintptr_t pc, backtrace_map_t* map) { - if (map_ != nullptr) { - map_->FillIn(pc, map); - } -} - -Backtrace* Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map) { - if (pid == BACKTRACE_CURRENT_PROCESS) { - pid = getpid(); - if (tid == BACKTRACE_CURRENT_THREAD) { - tid = gettid(); - } - } else if (tid == BACKTRACE_CURRENT_THREAD) { - tid = pid; - } - - if (pid == getpid()) { - return new UnwindCurrent(pid, tid, map); - } else { - return new UnwindPtrace(pid, tid, map); - } -} - -std::string Backtrace::GetErrorString(BacktraceUnwindError error) { - switch (error) { - case BACKTRACE_UNWIND_NO_ERROR: - return "No error"; - case BACKTRACE_UNWIND_ERROR_SETUP_FAILED: - return "Setup failed"; - case BACKTRACE_UNWIND_ERROR_MAP_MISSING: - return "No map found"; - case BACKTRACE_UNWIND_ERROR_INTERNAL: - return "Internal libbacktrace error, please submit a bugreport"; - case BACKTRACE_UNWIND_ERROR_THREAD_DOESNT_EXIST: - return "Thread doesn't exist"; - case BACKTRACE_UNWIND_ERROR_THREAD_TIMEOUT: - return "Thread has not repsonded to signal in time"; - case BACKTRACE_UNWIND_ERROR_UNSUPPORTED_OPERATION: - return "Attempt to use an unsupported feature"; - case BACKTRACE_UNWIND_ERROR_NO_CONTEXT: - return "Attempt to do an offline unwind without a context"; - } -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/BacktraceCurrent.cpp b/app/src/main/jni/crash_dump/libbacktrace/BacktraceCurrent.cpp deleted file mode 100644 index 5173e2cc9..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/BacktraceCurrent.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define _GNU_SOURCE 1 -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#include "BacktraceCurrent.h" -#include "BacktraceLog.h" -#include "ThreadEntry.h" -#include "thread_utils.h" - -bool BacktraceCurrent::ReadWord(uintptr_t ptr, word_t* out_value) { - if (!VerifyReadWordArgs(ptr, out_value)) { - return false; - } - - backtrace_map_t map; - FillInMap(ptr, &map); - if (BacktraceMap::IsValid(map) && map.flags & PROT_READ) { - *out_value = *reinterpret_cast(ptr); - return true; - } else { - BACK_LOGW("pointer %p not in a readable map", reinterpret_cast(ptr)); - *out_value = static_cast(-1); - return false; - } -} - -size_t BacktraceCurrent::Read(uintptr_t addr, uint8_t* buffer, size_t bytes) { - backtrace_map_t map; - FillInMap(addr, &map); - if (!BacktraceMap::IsValid(map) || !(map.flags & PROT_READ)) { - return 0; - } - bytes = MIN(map.end - addr, bytes); - memcpy(buffer, reinterpret_cast(addr), bytes); - return bytes; -} - -bool BacktraceCurrent::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { - if (GetMap() == nullptr) { - // Without a map object, we can't do anything. - error_ = BACKTRACE_UNWIND_ERROR_MAP_MISSING; - return false; - } - - error_ = BACKTRACE_UNWIND_NO_ERROR; - if (ucontext) { - return UnwindFromContext(num_ignore_frames, ucontext); - } - - if (Tid() != gettid()) { - return UnwindThread(num_ignore_frames); - } - - return UnwindFromContext(num_ignore_frames, nullptr); -} - -bool BacktraceCurrent::DiscardFrame(const backtrace_frame_data_t& frame) { - if (BacktraceMap::IsValid(frame.map)) { - const std::string library = basename(frame.map.name.c_str()); - if (library == "libunwind.so" || library == "libbacktrace.so") { - return true; - } - } - return false; -} - -static pthread_mutex_t g_sigaction_mutex = PTHREAD_MUTEX_INITIALIZER; - -static void SignalLogOnly(int, siginfo_t*, void*) { - BACK_LOGE("pid %d, tid %d: Received a spurious signal %d\n", getpid(), gettid(), THREAD_SIGNAL); -} - -static void SignalHandler(int, siginfo_t*, void* sigcontext) { - ThreadEntry* entry = ThreadEntry::Get(getpid(), gettid(), false); - if (!entry) { - BACK_LOGE("pid %d, tid %d entry not found", getpid(), gettid()); - return; - } - - entry->CopyUcontextFromSigcontext(sigcontext); - - // Indicate the ucontext is now valid. - entry->Wake(); - - // Pause the thread until the unwind is complete. This avoids having - // the thread run ahead causing problems. - // The number indicates that we are waiting for the second Wake() call - // overall which is made by the thread requesting an unwind. - if (entry->Wait(2)) { - // Do not remove the entry here because that can result in a deadlock - // if the code cannot properly send a signal to the thread under test. - entry->Wake(); - } else { - // At this point, it is possible that entry has been freed, so just exit. - BACK_LOGE("Timed out waiting for unwind thread to indicate it completed."); - } -} - -bool BacktraceCurrent::UnwindThread(size_t num_ignore_frames) { - // Prevent multiple threads trying to set the trigger action on different - // threads at the same time. - pthread_mutex_lock(&g_sigaction_mutex); - - ThreadEntry* entry = ThreadEntry::Get(Pid(), Tid()); - entry->Lock(); - - struct sigaction act, oldact; - memset(&act, 0, sizeof(act)); - act.sa_sigaction = SignalHandler; - act.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK; - sigemptyset(&act.sa_mask); - if (sigaction(THREAD_SIGNAL, &act, &oldact) != 0) { - BACK_LOGE("sigaction failed: %s", strerror(errno)); - ThreadEntry::Remove(entry); - pthread_mutex_unlock(&g_sigaction_mutex); - error_ = BACKTRACE_UNWIND_ERROR_INTERNAL; - return false; - } - - if (tgkill(Pid(), Tid(), THREAD_SIGNAL) != 0) { - // Do not emit an error message, this might be expected. Set the - // error and let the caller decide. - if (errno == ESRCH) { - error_ = BACKTRACE_UNWIND_ERROR_THREAD_DOESNT_EXIST; - } else { - error_ = BACKTRACE_UNWIND_ERROR_INTERNAL; - } - - sigaction(THREAD_SIGNAL, &oldact, nullptr); - ThreadEntry::Remove(entry); - pthread_mutex_unlock(&g_sigaction_mutex); - return false; - } - - // Wait for the thread to get the ucontext. The number indicates - // that we are waiting for the first Wake() call made by the thread. - bool wait_completed = entry->Wait(1); - - if (!wait_completed && oldact.sa_sigaction == nullptr) { - // If the wait failed, it could be that the signal could not be delivered - // within the timeout. Add a signal handler that's simply going to log - // something so that we don't crash if the signal eventually gets - // delivered. Only do this if there isn't already an action set up. - memset(&act, 0, sizeof(act)); - act.sa_sigaction = SignalLogOnly; - act.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK; - sigemptyset(&act.sa_mask); - sigaction(THREAD_SIGNAL, &act, nullptr); - } else { - sigaction(THREAD_SIGNAL, &oldact, nullptr); - } - // After the thread has received the signal, allow other unwinders to - // continue. - pthread_mutex_unlock(&g_sigaction_mutex); - - bool unwind_done = false; - if (wait_completed) { - unwind_done = UnwindFromContext(num_ignore_frames, entry->GetUcontext()); - - // Tell the signal handler to exit and release the entry. - entry->Wake(); - - // Wait for the thread to indicate it is done with the ThreadEntry. - if (!entry->Wait(3)) { - // Send a warning, but do not mark as a failure to unwind. - BACK_LOGW("Timed out waiting for signal handler to indicate it finished."); - } - } else { - // Check to see if the thread has disappeared. - if (tgkill(Pid(), Tid(), 0) == -1 && errno == ESRCH) { - error_ = BACKTRACE_UNWIND_ERROR_THREAD_DOESNT_EXIST; - } else { - error_ = BACKTRACE_UNWIND_ERROR_THREAD_TIMEOUT; - BACK_LOGE("Timed out waiting for signal handler to get ucontext data."); - } - } - - ThreadEntry::Remove(entry); - - return unwind_done; -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/BacktraceCurrent.h b/app/src/main/jni/crash_dump/libbacktrace/BacktraceCurrent.h deleted file mode 100644 index 8aad36d00..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/BacktraceCurrent.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LIBBACKTRACE_BACKTRACE_CURRENT_H -#define _LIBBACKTRACE_BACKTRACE_CURRENT_H - -#include -#include -#include - -#include - -// The signal used to cause a thread to dump the stack. -#if defined(__GLIBC__) -// In order to run the backtrace_tests on the host, we can't use -// the internal real time signals used by GLIBC. To avoid this, -// use SIGRTMIN for the signal to dump the stack. -#define THREAD_SIGNAL SIGRTMIN -#else -#define THREAD_SIGNAL (__SIGRTMIN+1) -#endif - -class BacktraceMap; - -class BacktraceCurrent : public Backtrace { -public: - BacktraceCurrent(pid_t pid, pid_t tid, BacktraceMap* map) : Backtrace(pid, tid, map) {} - virtual ~BacktraceCurrent() {} - - size_t Read(uintptr_t addr, uint8_t* buffer, size_t bytes) override; - - bool ReadWord(uintptr_t ptr, word_t* out_value) override; - - bool Unwind(size_t num_ignore_frames, ucontext_t* ucontext) override; - -protected: - bool DiscardFrame(const backtrace_frame_data_t& frame); - -private: - bool UnwindThread(size_t num_ignore_frames); - - virtual bool UnwindFromContext(size_t num_ignore_frames, ucontext_t* ucontext) = 0; -}; - -#endif // _LIBBACKTRACE_BACKTRACE_CURRENT_H diff --git a/app/src/main/jni/crash_dump/libbacktrace/BacktraceLog.h b/app/src/main/jni/crash_dump/libbacktrace/BacktraceLog.h deleted file mode 100644 index 5c39f1c04..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/BacktraceLog.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LIBBACKTRACE_BACKTRACE_LOG_H -#define _LIBBACKTRACE_BACKTRACE_LOG_H - -#define LOG_TAG "libbacktrace" - -#include - -// Macro to log the function name along with the warning message. -#define BACK_LOGW(format, ...) \ - ALOGW("%s: " format, __PRETTY_FUNCTION__, ##__VA_ARGS__) - -#define BACK_LOGE(format, ...) \ - ALOGE("%s: " format, __PRETTY_FUNCTION__, ##__VA_ARGS__) - -#endif // _LIBBACKTRACE_BACKTRACE_LOG_H diff --git a/app/src/main/jni/crash_dump/libbacktrace/BacktraceMap.cpp b/app/src/main/jni/crash_dump/libbacktrace/BacktraceMap.cpp deleted file mode 100644 index ba866328c..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/BacktraceMap.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include "thread_utils.h" - -BacktraceMap::BacktraceMap(pid_t pid) : pid_(pid) { - if (pid_ < 0) { - pid_ = getpid(); - } -} - -BacktraceMap::~BacktraceMap() { -} - -void BacktraceMap::FillIn(uintptr_t addr, backtrace_map_t* map) { - for (BacktraceMap::const_iterator it = begin(); - it != end(); ++it) { - if (addr >= it->start && addr < it->end) { - *map = *it; - return; - } - } - *map = {}; -} - -bool BacktraceMap::ParseLine(const char* line, backtrace_map_t* map) { - unsigned long int start; - unsigned long int end; - char permissions[5]; - int name_pos; - -#if defined(__APPLE__) -// Mac OS vmmap(1) output: -// __TEXT 0009f000-000a1000 [ 8K 8K] r-x/rwx SM=COW /Volumes/android/dalvik-dev/out/host/darwin-x86/bin/libcorkscrew_test\n -// 012345678901234567890123456789012345678901234567890123456789 -// 0 1 2 3 4 5 - if (sscanf(line, "%*21c %lx-%lx [%*13c] %3c/%*3c SM=%*3c %n", - &start, &end, permissions, &name_pos) != 3) { -#else -// Linux /proc//maps lines: -// 6f000000-6f01e000 rwxp 00000000 00:0c 16389419 /system/lib/libcomposer.so\n -// 012345678901234567890123456789012345678901234567890123456789 -// 0 1 2 3 4 5 - if (sscanf(line, "%lx-%lx %4s %*x %*x:%*x %*d %n", - &start, &end, permissions, &name_pos) != 3) { -#endif - return false; - } - - map->start = start; - map->end = end; - map->flags = PROT_NONE; - if (permissions[0] == 'r') { - map->flags |= PROT_READ; - } - if (permissions[1] == 'w') { - map->flags |= PROT_WRITE; - } - if (permissions[2] == 'x') { - map->flags |= PROT_EXEC; - } - - map->name = line+name_pos; - if (!map->name.empty() && map->name[map->name.length()-1] == '\n') { - map->name.erase(map->name.length()-1); - } - - ALOGV("Parsed map: start=%p, end=%p, flags=%x, name=%s", - reinterpret_cast(map->start), reinterpret_cast(map->end), - map->flags, map->name.c_str()); - return true; -} - -bool BacktraceMap::Build() { -#if defined(__APPLE__) - char cmd[sizeof(pid_t)*3 + sizeof("vmmap -w -resident -submap -allSplitLibs -interleaved ") + 1]; -#else - char path[sizeof(pid_t)*3 + sizeof("/proc//maps") + 1]; -#endif - char line[1024]; - -#if defined(__APPLE__) - // cmd is guaranteed to always be big enough to hold this string. - snprintf(cmd, sizeof(cmd), "vmmap -w -resident -submap -allSplitLibs -interleaved %d", pid_); - FILE* fp = popen(cmd, "r"); -#else - // path is guaranteed to always be big enough to hold this string. - snprintf(path, sizeof(path), "/proc/%d/maps", pid_); - FILE* fp = fopen(path, "r"); -#endif - if (fp == nullptr) { - return false; - } - - while(fgets(line, sizeof(line), fp)) { - backtrace_map_t map; - if (ParseLine(line, &map)) { - maps_.push_back(map); - } - } -#if defined(__APPLE__) - pclose(fp); -#else - fclose(fp); -#endif - - return true; -} - -#if defined(__APPLE__) -// Corkscrew and libunwind don't compile on the mac, so create a generic -// map object. -BacktraceMap* BacktraceMap::Create(pid_t pid, bool /*uncached*/) { - BacktraceMap* map = new BacktraceMap(pid); - if (!map->Build()) { - delete map; - return nullptr; - } - return map; -} -#endif - -BacktraceMap* BacktraceMap::Create(pid_t pid, const std::vector& maps) { - BacktraceMap* backtrace_map = new BacktraceMap(pid); - backtrace_map->maps_.insert(backtrace_map->maps_.begin(), maps.begin(), maps.end()); - std::sort(backtrace_map->maps_.begin(), backtrace_map->maps_.end(), - [](const backtrace_map_t& map1, const backtrace_map_t& map2) { - return map1.start < map2.start; - }); - return backtrace_map; -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/BacktraceOffline.cpp b/app/src/main/jni/crash_dump/libbacktrace/BacktraceOffline.cpp deleted file mode 100644 index 9a4f62224..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/BacktraceOffline.cpp +++ /dev/null @@ -1,760 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "BacktraceOffline.h" - -extern "C" { -#define UNW_REMOTE_ONLY -#include -} - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-parameter" - -#include -#include -#include -#include - -#pragma clang diagnostic pop - -#include "BacktraceLog.h" - -void Space::Clear() { - start = 0; - end = 0; - data = nullptr; -} - -size_t Space::Read(uint64_t addr, uint8_t* buffer, size_t size) { - if (addr >= start && addr < end) { - size_t read_size = std::min(size, static_cast(end - addr)); - memcpy(buffer, data + (addr - start), read_size); - return read_size; - } - return 0; -} - -static int FindProcInfo(unw_addr_space_t addr_space, unw_word_t ip, unw_proc_info* proc_info, - int need_unwind_info, void* arg) { - BacktraceOffline* backtrace = reinterpret_cast(arg); - bool result = backtrace->FindProcInfo(addr_space, ip, proc_info, need_unwind_info); - return result ? 0 : -UNW_EINVAL; -} - -static void PutUnwindInfo(unw_addr_space_t, unw_proc_info_t*, void*) { -} - -static int GetDynInfoListAddr(unw_addr_space_t, unw_word_t*, void*) { - return -UNW_ENOINFO; -} - -static int AccessMem(unw_addr_space_t, unw_word_t addr, unw_word_t* value, int write, void* arg) { - if (write == 1) { - return -UNW_EINVAL; - } - BacktraceOffline* backtrace = reinterpret_cast(arg); - *value = 0; - size_t read_size = backtrace->Read(addr, reinterpret_cast(value), sizeof(unw_word_t)); - // Strictly we should check if read_size matches sizeof(unw_word_t), but it is possible in - // .eh_frame_hdr that the section can end at a position not aligned in sizeof(unw_word_t), and - // we should permit the read at the end of the section. - return (read_size > 0u ? 0 : -UNW_EINVAL); -} - -static int AccessReg(unw_addr_space_t, unw_regnum_t unwind_reg, unw_word_t* value, int write, - void* arg) { - if (write == 1) { - return -UNW_EINVAL; - } - BacktraceOffline* backtrace = reinterpret_cast(arg); - uint64_t reg_value; - bool result = backtrace->ReadReg(unwind_reg, ®_value); - if (result) { - *value = static_cast(reg_value); - } - return result ? 0 : -UNW_EINVAL; -} - -static int AccessFpReg(unw_addr_space_t, unw_regnum_t, unw_fpreg_t*, int, void*) { - return -UNW_EINVAL; -} - -static int Resume(unw_addr_space_t, unw_cursor_t*, void*) { - return -UNW_EINVAL; -} - -static int GetProcName(unw_addr_space_t, unw_word_t, char*, size_t, unw_word_t*, void*) { - return -UNW_EINVAL; -} - -static unw_accessors_t accessors = { - .find_proc_info = FindProcInfo, - .put_unwind_info = PutUnwindInfo, - .get_dyn_info_list_addr = GetDynInfoListAddr, - .access_mem = AccessMem, - .access_reg = AccessReg, - .access_fpreg = AccessFpReg, - .resume = Resume, - .get_proc_name = GetProcName, -}; - -bool BacktraceOffline::Unwind(size_t num_ignore_frames, ucontext_t* context) { - if (context == nullptr) { - BACK_LOGW("The context is needed for offline backtracing."); - error_ = BACKTRACE_UNWIND_ERROR_NO_CONTEXT; - return false; - } - context_ = context; - error_ = BACKTRACE_UNWIND_NO_ERROR; - - unw_addr_space_t addr_space = unw_create_addr_space(&accessors, 0); - unw_cursor_t cursor; - int ret = unw_init_remote(&cursor, addr_space, this); - if (ret != 0) { - BACK_LOGW("unw_init_remote failed %d", ret); - unw_destroy_addr_space(addr_space); - error_ = BACKTRACE_UNWIND_ERROR_SETUP_FAILED; - return false; - } - size_t num_frames = 0; - do { - unw_word_t pc; - ret = unw_get_reg(&cursor, UNW_REG_IP, &pc); - if (ret < 0) { - BACK_LOGW("Failed to read IP %d", ret); - break; - } - unw_word_t sp; - ret = unw_get_reg(&cursor, UNW_REG_SP, &sp); - if (ret < 0) { - BACK_LOGW("Failed to read SP %d", ret); - break; - } - - if (num_ignore_frames == 0) { - frames_.resize(num_frames + 1); - backtrace_frame_data_t* frame = &frames_[num_frames]; - frame->num = num_frames; - frame->pc = static_cast(pc); - frame->sp = static_cast(sp); - frame->stack_size = 0; - - if (num_frames > 0) { - backtrace_frame_data_t* prev = &frames_[num_frames - 1]; - prev->stack_size = frame->sp - prev->sp; - } - frame->func_name = GetFunctionName(frame->pc, &frame->func_offset); - FillInMap(frame->pc, &frame->map); - num_frames++; - } else { - num_ignore_frames--; - } - ret = unw_step(&cursor); - } while (ret > 0 && num_frames < MAX_BACKTRACE_FRAMES); - - unw_destroy_addr_space(addr_space); - context_ = nullptr; - return true; -} - -bool BacktraceOffline::ReadWord(uintptr_t ptr, word_t* out_value) { - size_t bytes_read = Read(ptr, reinterpret_cast(out_value), sizeof(word_t)); - return bytes_read == sizeof(word_t); -} - -size_t BacktraceOffline::Read(uintptr_t addr, uint8_t* buffer, size_t bytes) { - // Normally, libunwind needs stack information and call frame information to do remote unwinding. - // If call frame information is stored in .debug_frame, libunwind can read it from file - // by itself. If call frame information is stored in .eh_frame, we need to provide data in - // .eh_frame/.eh_frame_hdr sections. - // The order of readings below doesn't matter, as the spaces don't overlap with each other. - size_t read_size = eh_frame_hdr_space_.Read(addr, buffer, bytes); - if (read_size != 0) { - return read_size; - } - read_size = eh_frame_space_.Read(addr, buffer, bytes); - if (read_size != 0) { - return read_size; - } - read_size = stack_space_.Read(addr, buffer, bytes); - return read_size; -} - -static bool FileOffsetToVaddr( - const std::vector& program_headers, - uint64_t file_offset, uint64_t* vaddr) { - for (auto& header : program_headers) { - if (file_offset >= header.file_offset && file_offset < header.file_offset + header.file_size) { - // TODO: Consider load_bias? - *vaddr = file_offset - header.file_offset + header.vaddr; - return true; - } - } - return false; -} - -bool BacktraceOffline::FindProcInfo(unw_addr_space_t addr_space, uint64_t ip, - unw_proc_info_t* proc_info, int need_unwind_info) { - backtrace_map_t map; - FillInMap(ip, &map); - if (!BacktraceMap::IsValid(map)) { - return false; - } - const std::string& filename = map.name; - DebugFrameInfo* debug_frame = GetDebugFrameInFile(filename); - if (debug_frame == nullptr) { - return false; - } - if (debug_frame->is_eh_frame) { - uint64_t ip_offset = ip - map.start + map.offset; - uint64_t ip_vaddr; // vaddr in the elf file. - bool result = FileOffsetToVaddr(debug_frame->eh_frame.program_headers, ip_offset, &ip_vaddr); - if (!result) { - return false; - } - // Calculate the addresses where .eh_frame_hdr and .eh_frame stay when the process was running. - eh_frame_hdr_space_.start = (ip - ip_vaddr) + debug_frame->eh_frame.eh_frame_hdr_vaddr; - eh_frame_hdr_space_.end = - eh_frame_hdr_space_.start + debug_frame->eh_frame.eh_frame_hdr_data.size(); - eh_frame_hdr_space_.data = debug_frame->eh_frame.eh_frame_hdr_data.data(); - - eh_frame_space_.start = (ip - ip_vaddr) + debug_frame->eh_frame.eh_frame_vaddr; - eh_frame_space_.end = eh_frame_space_.start + debug_frame->eh_frame.eh_frame_data.size(); - eh_frame_space_.data = debug_frame->eh_frame.eh_frame_data.data(); - - unw_dyn_info di; - memset(&di, '\0', sizeof(di)); - di.start_ip = map.start; - di.end_ip = map.end; - di.format = UNW_INFO_FORMAT_REMOTE_TABLE; - di.u.rti.name_ptr = 0; - di.u.rti.segbase = eh_frame_hdr_space_.start; - di.u.rti.table_data = - eh_frame_hdr_space_.start + debug_frame->eh_frame.fde_table_offset_in_eh_frame_hdr; - di.u.rti.table_len = (eh_frame_hdr_space_.end - di.u.rti.table_data) / sizeof(unw_word_t); - int ret = dwarf_search_unwind_table(addr_space, ip, &di, proc_info, need_unwind_info, this); - return ret == 0; - } - - eh_frame_hdr_space_.Clear(); - eh_frame_space_.Clear(); - unw_dyn_info_t di; - unw_word_t segbase = map.start - map.offset; - int found = dwarf_find_debug_frame(0, &di, ip, segbase, filename.c_str(), map.start, map.end); - if (found == 1) { - int ret = dwarf_search_unwind_table(addr_space, ip, &di, proc_info, need_unwind_info, this); - return ret == 0; - } - return false; -} - -bool BacktraceOffline::ReadReg(size_t reg, uint64_t* value) { - bool result = true; -#if defined(__arm__) - switch (reg) { - case UNW_ARM_R0: - *value = context_->uc_mcontext.arm_r0; - break; - case UNW_ARM_R1: - *value = context_->uc_mcontext.arm_r1; - break; - case UNW_ARM_R2: - *value = context_->uc_mcontext.arm_r2; - break; - case UNW_ARM_R3: - *value = context_->uc_mcontext.arm_r3; - break; - case UNW_ARM_R4: - *value = context_->uc_mcontext.arm_r4; - break; - case UNW_ARM_R5: - *value = context_->uc_mcontext.arm_r5; - break; - case UNW_ARM_R6: - *value = context_->uc_mcontext.arm_r6; - break; - case UNW_ARM_R7: - *value = context_->uc_mcontext.arm_r7; - break; - case UNW_ARM_R8: - *value = context_->uc_mcontext.arm_r8; - break; - case UNW_ARM_R9: - *value = context_->uc_mcontext.arm_r9; - break; - case UNW_ARM_R10: - *value = context_->uc_mcontext.arm_r10; - break; - case UNW_ARM_R11: - *value = context_->uc_mcontext.arm_fp; - break; - case UNW_ARM_R12: - *value = context_->uc_mcontext.arm_ip; - break; - case UNW_ARM_R13: - *value = context_->uc_mcontext.arm_sp; - break; - case UNW_ARM_R14: - *value = context_->uc_mcontext.arm_lr; - break; - case UNW_ARM_R15: - *value = context_->uc_mcontext.arm_pc; - break; - default: - result = false; - } -#elif defined(__aarch64__) - if (reg <= UNW_AARCH64_PC) { - *value = context_->uc_mcontext.regs[reg]; - } else { - result = false; - } -#elif defined(__x86_64__) - switch (reg) { - case UNW_X86_64_R8: - *value = context_->uc_mcontext.gregs[REG_R8]; - break; - case UNW_X86_64_R9: - *value = context_->uc_mcontext.gregs[REG_R9]; - break; - case UNW_X86_64_R10: - *value = context_->uc_mcontext.gregs[REG_R10]; - break; - case UNW_X86_64_R11: - *value = context_->uc_mcontext.gregs[REG_R11]; - break; - case UNW_X86_64_R12: - *value = context_->uc_mcontext.gregs[REG_R12]; - break; - case UNW_X86_64_R13: - *value = context_->uc_mcontext.gregs[REG_R13]; - break; - case UNW_X86_64_R14: - *value = context_->uc_mcontext.gregs[REG_R14]; - break; - case UNW_X86_64_R15: - *value = context_->uc_mcontext.gregs[REG_R15]; - break; - case UNW_X86_64_RDI: - *value = context_->uc_mcontext.gregs[REG_RDI]; - break; - case UNW_X86_64_RSI: - *value = context_->uc_mcontext.gregs[REG_RSI]; - break; - case UNW_X86_64_RBP: - *value = context_->uc_mcontext.gregs[REG_RBP]; - break; - case UNW_X86_64_RBX: - *value = context_->uc_mcontext.gregs[REG_RBX]; - break; - case UNW_X86_64_RDX: - *value = context_->uc_mcontext.gregs[REG_RDX]; - break; - case UNW_X86_64_RAX: - *value = context_->uc_mcontext.gregs[REG_RAX]; - break; - case UNW_X86_64_RCX: - *value = context_->uc_mcontext.gregs[REG_RCX]; - break; - case UNW_X86_64_RSP: - *value = context_->uc_mcontext.gregs[REG_RSP]; - break; - case UNW_X86_64_RIP: - *value = context_->uc_mcontext.gregs[REG_RIP]; - break; - default: - result = false; - } -#elif defined(__i386__) - switch (reg) { - case UNW_X86_GS: - *value = context_->uc_mcontext.gregs[REG_GS]; - break; - case UNW_X86_FS: - *value = context_->uc_mcontext.gregs[REG_FS]; - break; - case UNW_X86_ES: - *value = context_->uc_mcontext.gregs[REG_ES]; - break; - case UNW_X86_DS: - *value = context_->uc_mcontext.gregs[REG_DS]; - break; - case UNW_X86_EAX: - *value = context_->uc_mcontext.gregs[REG_EAX]; - break; - case UNW_X86_EBX: - *value = context_->uc_mcontext.gregs[REG_EBX]; - break; - case UNW_X86_ECX: - *value = context_->uc_mcontext.gregs[REG_ECX]; - break; - case UNW_X86_EDX: - *value = context_->uc_mcontext.gregs[REG_EDX]; - break; - case UNW_X86_ESI: - *value = context_->uc_mcontext.gregs[REG_ESI]; - break; - case UNW_X86_EDI: - *value = context_->uc_mcontext.gregs[REG_EDI]; - break; - case UNW_X86_EBP: - *value = context_->uc_mcontext.gregs[REG_EBP]; - break; - case UNW_X86_EIP: - *value = context_->uc_mcontext.gregs[REG_EIP]; - break; - case UNW_X86_ESP: - *value = context_->uc_mcontext.gregs[REG_ESP]; - break; - case UNW_X86_TRAPNO: - *value = context_->uc_mcontext.gregs[REG_TRAPNO]; - break; - case UNW_X86_CS: - *value = context_->uc_mcontext.gregs[REG_CS]; - break; - case UNW_X86_EFLAGS: - *value = context_->uc_mcontext.gregs[REG_EFL]; - break; - case UNW_X86_SS: - *value = context_->uc_mcontext.gregs[REG_SS]; - break; - default: - result = false; - } -#endif - return result; -} - -std::string BacktraceOffline::GetFunctionNameRaw(uintptr_t, uintptr_t* offset) { - // We don't have enough information to support this. And it is expensive. - *offset = 0; - return ""; -} - -std::unordered_map> BacktraceOffline::debug_frames_; -std::unordered_set BacktraceOffline::debug_frame_missing_files_; - -static DebugFrameInfo* ReadDebugFrameFromFile(const std::string& filename); - -DebugFrameInfo* BacktraceOffline::GetDebugFrameInFile(const std::string& filename) { - if (cache_file_) { - auto it = debug_frames_.find(filename); - if (it != debug_frames_.end()) { - return it->second.get(); - } - if (debug_frame_missing_files_.find(filename) != debug_frame_missing_files_.end()) { - return nullptr; - } - } - DebugFrameInfo* debug_frame = ReadDebugFrameFromFile(filename); - if (cache_file_) { - if (debug_frame != nullptr) { - debug_frames_.emplace(filename, std::unique_ptr(debug_frame)); - } else { - debug_frame_missing_files_.insert(filename); - } - } else { - if (last_debug_frame_ != nullptr) { - delete last_debug_frame_; - } - last_debug_frame_ = debug_frame; - } - return debug_frame; -} - -static bool OmitEncodedValue(uint8_t encode, const uint8_t*& p) { - if (encode == DW_EH_PE_omit) { - return 0; - } - uint8_t format = encode & 0x0f; - switch (format) { - case DW_EH_PE_ptr: - p += sizeof(unw_word_t); - break; - case DW_EH_PE_uleb128: - case DW_EH_PE_sleb128: - while ((*p & 0x80) != 0) { - ++p; - } - ++p; - break; - case DW_EH_PE_udata2: - case DW_EH_PE_sdata2: - p += 2; - break; - case DW_EH_PE_udata4: - case DW_EH_PE_sdata4: - p += 4; - break; - case DW_EH_PE_udata8: - case DW_EH_PE_sdata8: - p += 8; - break; - default: - return false; - } - return true; -} - -static bool GetFdeTableOffsetInEhFrameHdr(const std::vector& data, - uint64_t* table_offset_in_eh_frame_hdr) { - const uint8_t* p = data.data(); - const uint8_t* end = p + data.size(); - if (p + 4 > end) { - return false; - } - uint8_t version = *p++; - if (version != 1) { - return false; - } - uint8_t eh_frame_ptr_encode = *p++; - uint8_t fde_count_encode = *p++; - uint8_t fde_table_encode = *p++; - - if (fde_table_encode != (DW_EH_PE_datarel | DW_EH_PE_sdata4)) { - return false; - } - - if (!OmitEncodedValue(eh_frame_ptr_encode, p) || !OmitEncodedValue(fde_count_encode, p)) { - return false; - } - if (p >= end) { - return false; - } - *table_offset_in_eh_frame_hdr = p - data.data(); - return true; -} - -using ProgramHeader = DebugFrameInfo::EhFrame::ProgramHeader; - -template -DebugFrameInfo* ReadDebugFrameFromELFFile(const llvm::object::ELFFile* elf) { - bool has_eh_frame_hdr = false; - uint64_t eh_frame_hdr_vaddr = 0; - std::vector eh_frame_hdr_data; - bool has_eh_frame = false; - uint64_t eh_frame_vaddr = 0; - std::vector eh_frame_data; - - for (auto it = elf->section_begin(); it != elf->section_end(); ++it) { - llvm::ErrorOr name = elf->getSectionName(&*it); - if (name) { - if (name.get() == ".debug_frame") { - DebugFrameInfo* debug_frame = new DebugFrameInfo; - debug_frame->is_eh_frame = false; - return debug_frame; - } - if (name.get() == ".eh_frame_hdr") { - has_eh_frame_hdr = true; - eh_frame_hdr_vaddr = it->sh_addr; - llvm::ErrorOr> data = elf->getSectionContents(&*it); - if (data) { - eh_frame_hdr_data.insert(eh_frame_hdr_data.begin(), data->data(), - data->data() + data->size()); - } else { - return nullptr; - } - } else if (name.get() == ".eh_frame") { - has_eh_frame = true; - eh_frame_vaddr = it->sh_addr; - llvm::ErrorOr> data = elf->getSectionContents(&*it); - if (data) { - eh_frame_data.insert(eh_frame_data.begin(), data->data(), data->data() + data->size()); - } else { - return nullptr; - } - } - } - } - if (!(has_eh_frame_hdr && has_eh_frame)) { - return nullptr; - } - uint64_t fde_table_offset; - if (!GetFdeTableOffsetInEhFrameHdr(eh_frame_hdr_data, &fde_table_offset)) { - return nullptr; - } - - std::vector program_headers; - for (auto it = elf->program_header_begin(); it != elf->program_header_end(); ++it) { - ProgramHeader header; - header.vaddr = it->p_vaddr; - header.file_offset = it->p_offset; - header.file_size = it->p_filesz; - program_headers.push_back(header); - } - DebugFrameInfo* debug_frame = new DebugFrameInfo; - debug_frame->is_eh_frame = true; - debug_frame->eh_frame.eh_frame_hdr_vaddr = eh_frame_hdr_vaddr; - debug_frame->eh_frame.eh_frame_vaddr = eh_frame_vaddr; - debug_frame->eh_frame.fde_table_offset_in_eh_frame_hdr = fde_table_offset; - debug_frame->eh_frame.eh_frame_hdr_data = std::move(eh_frame_hdr_data); - debug_frame->eh_frame.eh_frame_data = std::move(eh_frame_data); - debug_frame->eh_frame.program_headers = program_headers; - return debug_frame; -} - -static bool IsValidElfPath(const std::string& filename) { - static const char elf_magic[] = {0x7f, 'E', 'L', 'F'}; - - struct stat st; - if (stat(filename.c_str(), &st) != 0 || !S_ISREG(st.st_mode)) { - return false; - } - FILE* fp = fopen(filename.c_str(), "reb"); - if (fp == nullptr) { - return false; - } - char buf[4]; - if (fread(buf, 4, 1, fp) != 1) { - fclose(fp); - return false; - } - fclose(fp); - return memcmp(buf, elf_magic, 4) == 0; -} - -static bool IsValidApkPath(const std::string& apk_path) { - static const char zip_preamble[] = {0x50, 0x4b, 0x03, 0x04}; - struct stat st; - if (stat(apk_path.c_str(), &st) != 0 || !S_ISREG(st.st_mode)) { - return false; - } - FILE* fp = fopen(apk_path.c_str(), "reb"); - if (fp == nullptr) { - return false; - } - char buf[4]; - if (fread(buf, 4, 1, fp) != 1) { - fclose(fp); - return false; - } - fclose(fp); - return memcmp(buf, zip_preamble, 4) == 0; -} - -class ScopedZiparchiveHandle { - public: - ScopedZiparchiveHandle(ZipArchiveHandle handle) : handle_(handle) { - } - - ~ScopedZiparchiveHandle() { - CloseArchive(handle_); - } - - private: - ZipArchiveHandle handle_; -}; - -llvm::object::OwningBinary OpenEmbeddedElfFile(const std::string& filename) { - llvm::object::OwningBinary nothing; - size_t pos = filename.find("!/"); - if (pos == std::string::npos) { - return nothing; - } - std::string apk_file = filename.substr(0, pos); - std::string elf_file = filename.substr(pos + 2); - if (!IsValidApkPath(apk_file)) { - BACK_LOGW("%s is not a valid apk file", apk_file.c_str()); - return nothing; - } - ZipArchiveHandle handle; - int32_t ret_code = OpenArchive(apk_file.c_str(), &handle); - if (ret_code != 0) { - CloseArchive(handle); - BACK_LOGW("failed to open archive %s: %s", apk_file.c_str(), ErrorCodeString(ret_code)); - return nothing; - } - ScopedZiparchiveHandle scoped_handle(handle); - ZipEntry zentry; - ret_code = FindEntry(handle, ZipString(elf_file.c_str()), &zentry); - if (ret_code != 0) { - BACK_LOGW("failed to find %s in %s: %s", elf_file.c_str(), apk_file.c_str(), - ErrorCodeString(ret_code)); - return nothing; - } - if (zentry.method != kCompressStored || zentry.compressed_length != zentry.uncompressed_length) { - BACK_LOGW("%s is compressed in %s, which doesn't support running directly", elf_file.c_str(), - apk_file.c_str()); - return nothing; - } - auto buffer_or_err = llvm::MemoryBuffer::getOpenFileSlice(GetFileDescriptor(handle), apk_file, - zentry.uncompressed_length, - zentry.offset); - if (!buffer_or_err) { - BACK_LOGW("failed to read %s in %s: %s", elf_file.c_str(), apk_file.c_str(), - buffer_or_err.getError().message().c_str()); - return nothing; - } - auto binary_or_err = llvm::object::createBinary(buffer_or_err.get()->getMemBufferRef()); - if (!binary_or_err) { - BACK_LOGW("failed to create binary for %s in %s: %s", elf_file.c_str(), apk_file.c_str(), - binary_or_err.getError().message().c_str()); - return nothing; - } - return llvm::object::OwningBinary(std::move(binary_or_err.get()), - std::move(buffer_or_err.get())); -} - -static DebugFrameInfo* ReadDebugFrameFromFile(const std::string& filename) { - llvm::object::OwningBinary owning_binary; - if (filename.find("!/") != std::string::npos) { - owning_binary = OpenEmbeddedElfFile(filename); - } else { - if (!IsValidElfPath(filename)) { - return nullptr; - } - auto binary_or_err = llvm::object::createBinary(llvm::StringRef(filename)); - if (!binary_or_err) { - return nullptr; - } - owning_binary = std::move(binary_or_err.get()); - } - llvm::object::Binary* binary = owning_binary.getBinary(); - auto obj = llvm::dyn_cast(binary); - if (obj == nullptr) { - return nullptr; - } - if (auto elf = llvm::dyn_cast(obj)) { - return ReadDebugFrameFromELFFile(elf->getELFFile()); - } - if (auto elf = llvm::dyn_cast(obj)) { - return ReadDebugFrameFromELFFile(elf->getELFFile()); - } - return nullptr; -} - -Backtrace* Backtrace::CreateOffline(pid_t pid, pid_t tid, BacktraceMap* map, - const backtrace_stackinfo_t& stack, bool cache_file) { - return new BacktraceOffline(pid, tid, map, stack, cache_file); -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/BacktraceOffline.h b/app/src/main/jni/crash_dump/libbacktrace/BacktraceOffline.h deleted file mode 100644 index 42f826da9..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/BacktraceOffline.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LIBBACKTRACE_UNWIND_OFFLINE_H -#define _LIBBACKTRACE_UNWIND_OFFLINE_H - -#include -#include -#include -#include - -#include -#include - -#include - -struct Space { - uint64_t start; - uint64_t end; - const uint8_t* data; - - Space() { - Clear(); - } - - void Clear(); - size_t Read(uint64_t addr, uint8_t* buffer, size_t size); -}; - -struct DebugFrameInfo { - bool is_eh_frame; - struct EhFrame { - uint64_t eh_frame_hdr_vaddr; - uint64_t eh_frame_vaddr; - uint64_t fde_table_offset_in_eh_frame_hdr; - std::vector eh_frame_hdr_data; - std::vector eh_frame_data; - struct ProgramHeader { - uint64_t vaddr; - uint64_t file_offset; - uint64_t file_size; - }; - std::vector program_headers; - } eh_frame; -}; - -class BacktraceOffline : public Backtrace { - public: - BacktraceOffline(pid_t pid, pid_t tid, BacktraceMap* map, const backtrace_stackinfo_t& stack, - bool cache_file) - : Backtrace(pid, tid, map), - cache_file_(cache_file), - context_(nullptr), - last_debug_frame_(nullptr) { - stack_space_.start = stack.start; - stack_space_.end = stack.end; - stack_space_.data = stack.data; - } - - virtual ~BacktraceOffline() { - if (last_debug_frame_ != nullptr) { - delete last_debug_frame_; - } - } - - bool Unwind(size_t num_ignore_frames, ucontext_t* context) override; - - bool ReadWord(uintptr_t ptr, word_t* out_value) override; - - size_t Read(uintptr_t addr, uint8_t* buffer, size_t bytes) override; - - bool FindProcInfo(unw_addr_space_t addr_space, uint64_t ip, unw_proc_info_t* proc_info, - int need_unwind_info); - - bool ReadReg(size_t reg_index, uint64_t* value); - - protected: - std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) override; - DebugFrameInfo* GetDebugFrameInFile(const std::string& filename); - - static std::unordered_map> debug_frames_; - static std::unordered_set debug_frame_missing_files_; - - bool cache_file_; - ucontext_t* context_; - Space eh_frame_hdr_space_; - Space eh_frame_space_; - Space stack_space_; - DebugFrameInfo* last_debug_frame_; -}; - -#endif // _LIBBACKTRACE_BACKTRACE_OFFLINE_H diff --git a/app/src/main/jni/crash_dump/libbacktrace/BacktracePtrace.cpp b/app/src/main/jni/crash_dump/libbacktrace/BacktracePtrace.cpp deleted file mode 100644 index fd8b7134f..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/BacktracePtrace.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "BacktraceLog.h" -#include "BacktracePtrace.h" -#include "thread_utils.h" - -#if !defined(__APPLE__) -static bool PtraceRead(pid_t tid, uintptr_t addr, word_t* out_value) { - // ptrace() returns -1 and sets errno when the operation fails. - // To disambiguate -1 from a valid result, we clear errno beforehand. - errno = 0; - *out_value = ptrace(PTRACE_PEEKTEXT, tid, reinterpret_cast(addr), nullptr); - if (*out_value == static_cast(-1) && errno) { - return false; - } - return true; -} -#endif - -bool BacktracePtrace::ReadWord(uintptr_t ptr, word_t* out_value) { -#if defined(__APPLE__) - BACK_LOGW("MacOS does not support reading from another pid."); - return false; -#else - if (!VerifyReadWordArgs(ptr, out_value)) { - return false; - } - - backtrace_map_t map; - FillInMap(ptr, &map); - if (!BacktraceMap::IsValid(map) || !(map.flags & PROT_READ)) { - return false; - } - - return PtraceRead(Tid(), ptr, out_value); -#endif -} - -size_t BacktracePtrace::Read(uintptr_t addr, uint8_t* buffer, size_t bytes) { -#if defined(__APPLE__) - BACK_LOGW("MacOS does not support reading from another pid."); - return 0; -#else - backtrace_map_t map; - FillInMap(addr, &map); - if (!BacktraceMap::IsValid(map) || !(map.flags & PROT_READ)) { - return 0; - } - - bytes = MIN(map.end - addr, bytes); - size_t bytes_read = 0; - word_t data_word; - size_t align_bytes = addr & (sizeof(word_t) - 1); - if (align_bytes != 0) { - if (!PtraceRead(Tid(), addr & ~(sizeof(word_t) - 1), &data_word)) { - return 0; - } - size_t copy_bytes = MIN(sizeof(word_t) - align_bytes, bytes); - memcpy(buffer, reinterpret_cast(&data_word) + align_bytes, copy_bytes); - addr += copy_bytes; - buffer += copy_bytes; - bytes -= copy_bytes; - bytes_read += copy_bytes; - } - - size_t num_words = bytes / sizeof(word_t); - for (size_t i = 0; i < num_words; i++) { - if (!PtraceRead(Tid(), addr, &data_word)) { - return bytes_read; - } - memcpy(buffer, &data_word, sizeof(word_t)); - buffer += sizeof(word_t); - addr += sizeof(word_t); - bytes_read += sizeof(word_t); - } - - size_t left_over = bytes & (sizeof(word_t) - 1); - if (left_over) { - if (!PtraceRead(Tid(), addr, &data_word)) { - return bytes_read; - } - memcpy(buffer, &data_word, left_over); - bytes_read += left_over; - } - return bytes_read; -#endif -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/BacktracePtrace.h b/app/src/main/jni/crash_dump/libbacktrace/BacktracePtrace.h deleted file mode 100644 index 1d498115e..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/BacktracePtrace.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LIBBACKTRACE_BACKTRACE_PTRACE_H -#define _LIBBACKTRACE_BACKTRACE_PTRACE_H - -#include -#include - -#include - -class BacktraceMap; - -class BacktracePtrace : public Backtrace { -public: - BacktracePtrace(pid_t pid, pid_t tid, BacktraceMap* map) : Backtrace(pid, tid, map) {} - virtual ~BacktracePtrace() {} - - size_t Read(uintptr_t addr, uint8_t* buffer, size_t bytes); - - bool ReadWord(uintptr_t ptr, word_t* out_value); -}; - -#endif // _LIBBACKTRACE_BACKTRACE_PTRACE_H diff --git a/app/src/main/jni/crash_dump/libbacktrace/GetPss.cpp b/app/src/main/jni/crash_dump/libbacktrace/GetPss.cpp deleted file mode 100644 index 09a721dee..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/GetPss.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include - -// This is an extremely simplified version of libpagemap. - -#define _BITS(x, offset, bits) (((x) >> offset) & ((1LL << (bits)) - 1)) - -#define PAGEMAP_PRESENT(x) (_BITS(x, 63, 1)) -#define PAGEMAP_SWAPPED(x) (_BITS(x, 62, 1)) -#define PAGEMAP_SHIFT(x) (_BITS(x, 55, 6)) -#define PAGEMAP_PFN(x) (_BITS(x, 0, 55)) -#define PAGEMAP_SWAP_OFFSET(x) (_BITS(x, 5, 50)) -#define PAGEMAP_SWAP_TYPE(x) (_BITS(x, 0, 5)) - -static bool ReadData(int fd, unsigned long place, uint64_t *data) { - if (lseek(fd, place * sizeof(uint64_t), SEEK_SET) < 0) { - return false; - } - if (read(fd, (void*)data, sizeof(uint64_t)) != (ssize_t)sizeof(uint64_t)) { - return false; - } - return true; -} - -size_t GetPssBytes() { - FILE* maps = fopen("/proc/self/maps", "r"); - if (maps == nullptr) { - return 0; - } - - int pagecount_fd = open("/proc/kpagecount", O_RDONLY); - if (pagecount_fd == -1) { - fclose(maps); - return 0; - } - - int pagemap_fd = open("/proc/self/pagemap", O_RDONLY); - if (pagemap_fd == -1) { - fclose(maps); - close(pagecount_fd); - return 0; - } - - char line[4096]; - size_t total_pss = 0; - int pagesize = getpagesize(); - while (fgets(line, sizeof(line), maps)) { - uintptr_t start, end; - if (sscanf(line, "%" SCNxPTR "-%" SCNxPTR " ", &start, &end) != 2) { - total_pss = 0; - break; - } - for (size_t page = start/pagesize; page < end/pagesize; page++) { - uint64_t data; - if (ReadData(pagemap_fd, page, &data)) { - if (PAGEMAP_PRESENT(data) && !PAGEMAP_SWAPPED(data)) { - uint64_t count; - if (ReadData(pagecount_fd, PAGEMAP_PFN(data), &count)) { - total_pss += (count >= 1) ? pagesize / count : 0; - } - } - } - } - } - - fclose(maps); - - close(pagecount_fd); - close(pagemap_fd); - - return total_pss; -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/GetPss.h b/app/src/main/jni/crash_dump/libbacktrace/GetPss.h deleted file mode 100644 index 787c33d34..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/GetPss.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LIBBACKTRACE_GET_PSS_H -#define _LIBBACKTRACE_GET_PSS_H - -size_t GetPssBytes(); - -#endif // _LIBBACKTRACE_GET_PSS_H diff --git a/app/src/main/jni/crash_dump/libbacktrace/ThreadEntry.cpp b/app/src/main/jni/crash_dump/libbacktrace/ThreadEntry.cpp deleted file mode 100644 index 084c1aa91..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/ThreadEntry.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include - -#include "BacktraceLog.h" -#include "ThreadEntry.h" - -// Initialize static member variables. -ThreadEntry* ThreadEntry::list_ = nullptr; -pthread_mutex_t ThreadEntry::list_mutex_ = PTHREAD_MUTEX_INITIALIZER; - -// Assumes that ThreadEntry::list_mutex_ has already been locked before -// creating a ThreadEntry object. -ThreadEntry::ThreadEntry(pid_t pid, pid_t tid) - : pid_(pid), tid_(tid), ref_count_(1), mutex_(PTHREAD_MUTEX_INITIALIZER), - wait_mutex_(PTHREAD_MUTEX_INITIALIZER), wait_value_(0), - next_(ThreadEntry::list_), prev_(nullptr) { - pthread_condattr_t attr; - pthread_condattr_init(&attr); - pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); - pthread_cond_init(&wait_cond_, &attr); - - // Add ourselves to the list. - if (ThreadEntry::list_) { - ThreadEntry::list_->prev_ = this; - } - ThreadEntry::list_ = this; -} - -ThreadEntry* ThreadEntry::Get(pid_t pid, pid_t tid, bool create) { - pthread_mutex_lock(&ThreadEntry::list_mutex_); - ThreadEntry* entry = list_; - while (entry != nullptr) { - if (entry->Match(pid, tid)) { - break; - } - entry = entry->next_; - } - - if (!entry) { - if (create) { - entry = new ThreadEntry(pid, tid); - } - } else { - entry->ref_count_++; - } - pthread_mutex_unlock(&ThreadEntry::list_mutex_); - - return entry; -} - -void ThreadEntry::Remove(ThreadEntry* entry) { - entry->Unlock(); - - pthread_mutex_lock(&ThreadEntry::list_mutex_); - if (--entry->ref_count_ == 0) { - delete entry; - } - pthread_mutex_unlock(&ThreadEntry::list_mutex_); -} - -// Assumes that ThreadEntry::list_mutex_ has already been locked before -// deleting a ThreadEntry object. -ThreadEntry::~ThreadEntry() { - if (list_ == this) { - list_ = next_; - } else { - if (next_) { - next_->prev_ = prev_; - } - prev_->next_ = next_; - } - - next_ = nullptr; - prev_ = nullptr; - - pthread_cond_destroy(&wait_cond_); -} - -bool ThreadEntry::Wait(int value) { - timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - ts.tv_sec += 5; - - bool wait_completed = true; - pthread_mutex_lock(&wait_mutex_); - while (wait_value_ != value) { - int ret = pthread_cond_timedwait(&wait_cond_, &wait_mutex_, &ts); - if (ret != 0) { - BACK_LOGW("pthread_cond_timedwait for value %d failed: %s", value, strerror(ret)); - wait_completed = false; - break; - } - } - pthread_mutex_unlock(&wait_mutex_); - - return wait_completed; -} - -void ThreadEntry::Wake() { - pthread_mutex_lock(&wait_mutex_); - wait_value_++; - pthread_mutex_unlock(&wait_mutex_); - - pthread_cond_signal(&wait_cond_); -} - -void ThreadEntry::CopyUcontextFromSigcontext(void* sigcontext) { - ucontext_t* ucontext = reinterpret_cast(sigcontext); - // The only thing the unwinder cares about is the mcontext data. - memcpy(&ucontext_.uc_mcontext, &ucontext->uc_mcontext, sizeof(ucontext->uc_mcontext)); -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/ThreadEntry.h b/app/src/main/jni/crash_dump/libbacktrace/ThreadEntry.h deleted file mode 100644 index 11924a3ad..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/ThreadEntry.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LIBBACKTRACE_THREAD_ENTRY_H -#define _LIBBACKTRACE_THREAD_ENTRY_H - -#include -#include -#include - -class ThreadEntry { -public: - static ThreadEntry* Get(pid_t pid, pid_t tid, bool create = true); - - static void Remove(ThreadEntry* entry); - - void Wake(); - - bool Wait(int); - - void CopyUcontextFromSigcontext(void*); - - inline void Lock() { - pthread_mutex_lock(&mutex_); - - // Always reset the wait value since this could be the first or nth - // time this entry is locked. - wait_value_ = 0; - } - - inline void Unlock() { - pthread_mutex_unlock(&mutex_); - } - - inline ucontext_t* GetUcontext() { return &ucontext_; } - -private: - ThreadEntry(pid_t pid, pid_t tid); - ~ThreadEntry(); - - bool Match(pid_t chk_pid, pid_t chk_tid) { return (chk_pid == pid_ && chk_tid == tid_); } - - pid_t pid_; - pid_t tid_; - int ref_count_; - pthread_mutex_t mutex_; - pthread_mutex_t wait_mutex_; - pthread_cond_t wait_cond_; - int wait_value_; - ThreadEntry* next_; - ThreadEntry* prev_; - ucontext_t ucontext_; - - static ThreadEntry* list_; - static pthread_mutex_t list_mutex_; -}; - -#endif // _LIBBACKTRACE_THREAD_ENTRY_H diff --git a/app/src/main/jni/crash_dump/libbacktrace/UnwindCurrent.cpp b/app/src/main/jni/crash_dump/libbacktrace/UnwindCurrent.cpp deleted file mode 100644 index 666c481ce..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/UnwindCurrent.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include -#include - -#define UNW_LOCAL_ONLY -#include - -#include - -#include "BacktraceLog.h" -#include "UnwindCurrent.h" - -std::string UnwindCurrent::GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) { - *offset = 0; - char buf[512]; - unw_word_t value; - if (unw_get_proc_name_by_ip(unw_local_addr_space, pc, buf, sizeof(buf), - &value, &context_) >= 0 && buf[0] != '\0') { - *offset = static_cast(value); - return buf; - } - return ""; -} - -void UnwindCurrent::GetUnwContextFromUcontext(const ucontext_t* ucontext) { - unw_tdep_context_t* unw_context = reinterpret_cast(&context_); - -#if defined(__arm__) - unw_context->regs[0] = ucontext->uc_mcontext.arm_r0; - unw_context->regs[1] = ucontext->uc_mcontext.arm_r1; - unw_context->regs[2] = ucontext->uc_mcontext.arm_r2; - unw_context->regs[3] = ucontext->uc_mcontext.arm_r3; - unw_context->regs[4] = ucontext->uc_mcontext.arm_r4; - unw_context->regs[5] = ucontext->uc_mcontext.arm_r5; - unw_context->regs[6] = ucontext->uc_mcontext.arm_r6; - unw_context->regs[7] = ucontext->uc_mcontext.arm_r7; - unw_context->regs[8] = ucontext->uc_mcontext.arm_r8; - unw_context->regs[9] = ucontext->uc_mcontext.arm_r9; - unw_context->regs[10] = ucontext->uc_mcontext.arm_r10; - unw_context->regs[11] = ucontext->uc_mcontext.arm_fp; - unw_context->regs[12] = ucontext->uc_mcontext.arm_ip; - unw_context->regs[13] = ucontext->uc_mcontext.arm_sp; - unw_context->regs[14] = ucontext->uc_mcontext.arm_lr; - unw_context->regs[15] = ucontext->uc_mcontext.arm_pc; -#else - unw_context->uc_mcontext = ucontext->uc_mcontext; -#endif -} - -bool UnwindCurrent::UnwindFromContext(size_t num_ignore_frames, ucontext_t* ucontext) { - if (ucontext == nullptr) { - int ret = unw_getcontext(&context_); - if (ret < 0) { - BACK_LOGW("unw_getcontext failed %d", ret); - error_ = BACKTRACE_UNWIND_ERROR_SETUP_FAILED; - return false; - } - } else { - GetUnwContextFromUcontext(ucontext); - } - - // The cursor structure is pretty large, do not put it on the stack. - std::unique_ptr cursor(new unw_cursor_t); - int ret = unw_init_local(cursor.get(), &context_); - if (ret < 0) { - BACK_LOGW("unw_init_local failed %d", ret); - error_ = BACKTRACE_UNWIND_ERROR_SETUP_FAILED; - return false; - } - - size_t num_frames = 0; - do { - unw_word_t pc; - ret = unw_get_reg(cursor.get(), UNW_REG_IP, &pc); - if (ret < 0) { - BACK_LOGW("Failed to read IP %d", ret); - break; - } - unw_word_t sp; - ret = unw_get_reg(cursor.get(), UNW_REG_SP, &sp); - if (ret < 0) { - BACK_LOGW("Failed to read SP %d", ret); - break; - } - - frames_.resize(num_frames+1); - backtrace_frame_data_t* frame = &frames_.at(num_frames); - frame->num = num_frames; - frame->pc = static_cast(pc); - frame->sp = static_cast(sp); - frame->stack_size = 0; - - FillInMap(frame->pc, &frame->map); - // Check to see if we should skip this frame because it's coming - // from within the library, and we are doing a local unwind. - if (ucontext != nullptr || num_frames != 0 || !DiscardFrame(*frame)) { - if (num_ignore_frames == 0) { - // GetFunctionName is an expensive call, only do it if we are - // keeping the frame. - frame->func_name = GetFunctionName(frame->pc, &frame->func_offset); - if (num_frames > 0) { - // Set the stack size for the previous frame. - backtrace_frame_data_t* prev = &frames_.at(num_frames-1); - prev->stack_size = frame->sp - prev->sp; - } - num_frames++; - } else { - num_ignore_frames--; - } - } - ret = unw_step (cursor.get()); - } while (ret > 0 && num_frames < MAX_BACKTRACE_FRAMES); - - return true; -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/UnwindCurrent.h b/app/src/main/jni/crash_dump/libbacktrace/UnwindCurrent.h deleted file mode 100644 index 302399684..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/UnwindCurrent.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LIBBACKTRACE_UNWIND_CURRENT_H -#define _LIBBACKTRACE_UNWIND_CURRENT_H - -#include -#include -#include - -#include - -#include -#include - -#include "BacktraceCurrent.h" - -#define UNW_LOCAL_ONLY -#include - -class UnwindCurrent : public BacktraceCurrent { -public: - UnwindCurrent(pid_t pid, pid_t tid, BacktraceMap* map) : BacktraceCurrent(pid, tid, map) {} - virtual ~UnwindCurrent() {} - - std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) override; - -private: - void GetUnwContextFromUcontext(const ucontext_t* ucontext); - - bool UnwindFromContext(size_t num_ignore_frames, ucontext_t* ucontext) override; - - unw_context_t context_; -}; - -#endif // _LIBBACKTRACE_UNWIND_CURRENT_H diff --git a/app/src/main/jni/crash_dump/libbacktrace/UnwindMap.cpp b/app/src/main/jni/crash_dump/libbacktrace/UnwindMap.cpp deleted file mode 100644 index 34d79f970..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/UnwindMap.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -#include - -#include - -#include "BacktraceLog.h" -#include "UnwindMap.h" - -//------------------------------------------------------------------------- -// libunwind has a single shared address space for the current process -// aka local. If multiple maps are created for the current pid, then -// only update the local address space once, and keep a reference count -// of maps using the same map cursor. -//------------------------------------------------------------------------- -UnwindMap::UnwindMap(pid_t pid) : BacktraceMap(pid) { - unw_map_cursor_clear(&map_cursor_); -} - -UnwindMapRemote::UnwindMapRemote(pid_t pid) : UnwindMap(pid) { -} - -UnwindMapRemote::~UnwindMapRemote() { - unw_map_cursor_destroy(&map_cursor_); - unw_map_cursor_clear(&map_cursor_); -} - -bool UnwindMapRemote::GenerateMap() { - // Use the map_cursor information to construct the BacktraceMap data - // rather than reparsing /proc/self/maps. - unw_map_cursor_reset(&map_cursor_); - - unw_map_t unw_map; - while (unw_map_cursor_get_next(&map_cursor_, &unw_map)) { - backtrace_map_t map; - - map.start = unw_map.start; - map.end = unw_map.end; - map.offset = unw_map.offset; - map.load_base = unw_map.load_base; - map.flags = unw_map.flags; - map.name = unw_map.path; - - // The maps are in descending order, but we want them in ascending order. - maps_.push_front(map); - } - - return true; -} - -bool UnwindMapRemote::Build() { - return (unw_map_cursor_create(&map_cursor_, pid_) == 0) && GenerateMap(); -} - -UnwindMapLocal::UnwindMapLocal() : UnwindMap(getpid()), map_created_(false) { -} - -UnwindMapLocal::~UnwindMapLocal() { - if (map_created_) { - unw_map_local_destroy(); - unw_map_cursor_clear(&map_cursor_); - } -} - -bool UnwindMapLocal::GenerateMap() { - // It's possible for the map to be regenerated while this loop is occurring. - // If that happens, get the map again, but only try at most three times - // before giving up. - for (int i = 0; i < 3; i++) { - maps_.clear(); - - // Save the map data retrieved so we can tell if it changes. - unw_map_local_cursor_get(&map_cursor_); - - unw_map_t unw_map; - int ret; - while ((ret = unw_map_local_cursor_get_next(&map_cursor_, &unw_map)) > 0) { - backtrace_map_t map; - - map.start = unw_map.start; - map.end = unw_map.end; - map.offset = unw_map.offset; - map.load_base = unw_map.load_base; - map.flags = unw_map.flags; - map.name = unw_map.path; - - free(unw_map.path); - - // The maps are in descending order, but we want them in ascending order. - maps_.push_front(map); - } - // Check to see if the map changed while getting the data. - if (ret != -UNW_EINVAL) { - return true; - } - } - - BACK_LOGW("Unable to generate the map."); - return false; -} - -bool UnwindMapLocal::Build() { - return (map_created_ = (unw_map_local_create() == 0)) && GenerateMap();; -} - -void UnwindMapLocal::FillIn(uintptr_t addr, backtrace_map_t* map) { - BacktraceMap::FillIn(addr, map); - if (!IsValid(*map)) { - // Check to see if the underlying map changed and regenerate the map - // if it did. - if (unw_map_local_cursor_valid(&map_cursor_) < 0) { - if (GenerateMap()) { - BacktraceMap::FillIn(addr, map); - } - } - } -} - -//------------------------------------------------------------------------- -// BacktraceMap create function. -//------------------------------------------------------------------------- -BacktraceMap* BacktraceMap::Create(pid_t pid, bool uncached) { - BacktraceMap* map; - - if (uncached) { - // Force use of the base class to parse the maps when this call is made. - map = new BacktraceMap(pid); - } else if (pid == getpid()) { - map = new UnwindMapLocal(); - } else { - map = new UnwindMapRemote(pid); - } - if (!map->Build()) { - delete map; - return nullptr; - } - return map; -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/UnwindMap.h b/app/src/main/jni/crash_dump/libbacktrace/UnwindMap.h deleted file mode 100644 index 111401ffa..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/UnwindMap.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LIBBACKTRACE_UNWIND_MAP_H -#define _LIBBACKTRACE_UNWIND_MAP_H - -#include -#include - -#include - -// The unw_map_cursor_t structure is different depending on whether it is -// the local or remote version. In order to get the correct version, include -// libunwind.h first then this header. - -class UnwindMap : public BacktraceMap { -public: - UnwindMap(pid_t pid); - - unw_map_cursor_t* GetMapCursor() { return &map_cursor_; } - -protected: - unw_map_cursor_t map_cursor_; -}; - -class UnwindMapRemote : public UnwindMap { -public: - UnwindMapRemote(pid_t pid); - virtual ~UnwindMapRemote(); - - bool Build() override; - -private: - bool GenerateMap(); -}; - -class UnwindMapLocal : public UnwindMap { -public: - UnwindMapLocal(); - virtual ~UnwindMapLocal(); - - bool Build() override; - - void FillIn(uintptr_t addr, backtrace_map_t* map) override; - -private: - bool GenerateMap(); - - bool map_created_; -}; - -#endif // _LIBBACKTRACE_UNWIND_MAP_H diff --git a/app/src/main/jni/crash_dump/libbacktrace/UnwindPtrace.cpp b/app/src/main/jni/crash_dump/libbacktrace/UnwindPtrace.cpp deleted file mode 100644 index 306d2acf0..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/UnwindPtrace.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include -#include - -#include -#include - -#include "BacktraceLog.h" -#include "UnwindMap.h" -#include "UnwindPtrace.h" - -UnwindPtrace::UnwindPtrace(pid_t pid, pid_t tid, BacktraceMap* map) - : BacktracePtrace(pid, tid, map), addr_space_(nullptr), upt_info_(nullptr) { -} - -UnwindPtrace::~UnwindPtrace() { - if (upt_info_) { - _UPT_destroy(upt_info_); - upt_info_ = nullptr; - } - if (addr_space_) { - // Remove the map from the address space before destroying it. - // It will be freed in the UnwindMap destructor. - unw_map_set(addr_space_, nullptr); - - unw_destroy_addr_space(addr_space_); - addr_space_ = nullptr; - } -} - -bool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { - if (GetMap() == nullptr) { - // Without a map object, we can't do anything. - error_ = BACKTRACE_UNWIND_ERROR_MAP_MISSING; - return false; - } - - error_ = BACKTRACE_UNWIND_NO_ERROR; - - if (ucontext) { - BACK_LOGW("Unwinding from a specified context not supported yet."); - error_ = BACKTRACE_UNWIND_ERROR_UNSUPPORTED_OPERATION; - return false; - } - - addr_space_ = unw_create_addr_space(&_UPT_accessors, 0); - if (!addr_space_) { - BACK_LOGW("unw_create_addr_space failed."); - error_ = BACKTRACE_UNWIND_ERROR_SETUP_FAILED; - return false; - } - - UnwindMap* map = static_cast(GetMap()); - unw_map_set(addr_space_, map->GetMapCursor()); - - upt_info_ = reinterpret_cast(_UPT_create(Tid())); - if (!upt_info_) { - BACK_LOGW("Failed to create upt info."); - error_ = BACKTRACE_UNWIND_ERROR_SETUP_FAILED; - return false; - } - - unw_cursor_t cursor; - int ret = unw_init_remote(&cursor, addr_space_, upt_info_); - if (ret < 0) { - BACK_LOGW("unw_init_remote failed %d", ret); - error_ = BACKTRACE_UNWIND_ERROR_SETUP_FAILED; - return false; - } - - size_t num_frames = 0; - do { - unw_word_t pc; - ret = unw_get_reg(&cursor, UNW_REG_IP, &pc); - if (ret < 0) { - BACK_LOGW("Failed to read IP %d", ret); - break; - } - unw_word_t sp; - ret = unw_get_reg(&cursor, UNW_REG_SP, &sp); - if (ret < 0) { - BACK_LOGW("Failed to read SP %d", ret); - break; - } - - if (num_ignore_frames == 0) { - frames_.resize(num_frames+1); - backtrace_frame_data_t* frame = &frames_.at(num_frames); - frame->num = num_frames; - frame->pc = static_cast(pc); - frame->sp = static_cast(sp); - frame->stack_size = 0; - - if (num_frames > 0) { - backtrace_frame_data_t* prev = &frames_.at(num_frames-1); - prev->stack_size = frame->sp - prev->sp; - } - - frame->func_name = GetFunctionName(frame->pc, &frame->func_offset); - - FillInMap(frame->pc, &frame->map); - - num_frames++; - } else { - num_ignore_frames--; - } - ret = unw_step (&cursor); - } while (ret > 0 && num_frames < MAX_BACKTRACE_FRAMES); - - return true; -} - -std::string UnwindPtrace::GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) { - *offset = 0; - char buf[512]; - unw_word_t value; - if (unw_get_proc_name_by_ip(addr_space_, pc, buf, sizeof(buf), &value, - upt_info_) >= 0 && buf[0] != '\0') { - *offset = static_cast(value); - return buf; - } - return ""; -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/UnwindPtrace.h b/app/src/main/jni/crash_dump/libbacktrace/UnwindPtrace.h deleted file mode 100644 index ab04abf92..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/UnwindPtrace.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LIBBACKTRACE_UNWIND_PTRACE_H -#define _LIBBACKTRACE_UNWIND_PTRACE_H - -#include -#include - -#include - -#ifdef UNW_LOCAL_ONLY -#undef UNW_LOCAL_ONLY -#endif -#include - -#include "BacktracePtrace.h" - -class UnwindPtrace : public BacktracePtrace { -public: - UnwindPtrace(pid_t pid, pid_t tid, BacktraceMap* map); - virtual ~UnwindPtrace(); - - bool Unwind(size_t num_ignore_frames, ucontext_t* ucontext) override; - - std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) override; - -private: - unw_addr_space_t addr_space_; - struct UPT_info* upt_info_; -}; - -#endif // _LIBBACKTRACE_UNWIND_PTRACE_H diff --git a/app/src/main/jni/crash_dump/libbacktrace/backtrace_offline_test.cpp b/app/src/main/jni/crash_dump/libbacktrace/backtrace_offline_test.cpp deleted file mode 100644 index 88a3533a2..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/backtrace_offline_test.cpp +++ /dev/null @@ -1,189 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -extern "C" { -// Prototypes for functions in the test library. -int test_level_one(int, int, int, int, void (*)(void*), void*); -int test_level_two(int, int, int, int, void (*)(void*), void*); -int test_level_three(int, int, int, int, void (*)(void*), void*); -int test_level_four(int, int, int, int, void (*)(void*), void*); -int test_recursive_call(int, void (*)(void*), void*); -} - -static volatile bool g_exit_flag = false; - -static void GetContextAndExit(void* arg) { - unw_context_t* unw_context = reinterpret_cast(arg); - unw_getcontext(unw_context); - // Don't touch the stack anymore. - while (!g_exit_flag) { - } -} - -struct OfflineThreadArg { - unw_context_t unw_context; - pid_t tid; - std::function function; -}; - -static void* OfflineThreadFunc(void* arg) { - OfflineThreadArg* fn_arg = reinterpret_cast(arg); - fn_arg->tid = gettid(); - fn_arg->function(GetContextAndExit, &fn_arg->unw_context); - return nullptr; -} - -static ucontext_t GetUContextFromUnwContext(const unw_context_t& unw_context) { - ucontext_t ucontext; - memset(&ucontext, 0, sizeof(ucontext)); -#if defined(__arm__) - ucontext.uc_mcontext.arm_r0 = unw_context.regs[0]; - ucontext.uc_mcontext.arm_r1 = unw_context.regs[1]; - ucontext.uc_mcontext.arm_r2 = unw_context.regs[2]; - ucontext.uc_mcontext.arm_r3 = unw_context.regs[3]; - ucontext.uc_mcontext.arm_r4 = unw_context.regs[4]; - ucontext.uc_mcontext.arm_r5 = unw_context.regs[5]; - ucontext.uc_mcontext.arm_r6 = unw_context.regs[6]; - ucontext.uc_mcontext.arm_r7 = unw_context.regs[7]; - ucontext.uc_mcontext.arm_r8 = unw_context.regs[8]; - ucontext.uc_mcontext.arm_r9 = unw_context.regs[9]; - ucontext.uc_mcontext.arm_r10 = unw_context.regs[10]; - ucontext.uc_mcontext.arm_fp = unw_context.regs[11]; - ucontext.uc_mcontext.arm_ip = unw_context.regs[12]; - ucontext.uc_mcontext.arm_sp = unw_context.regs[13]; - ucontext.uc_mcontext.arm_lr = unw_context.regs[14]; - ucontext.uc_mcontext.arm_pc = unw_context.regs[15]; -#else - ucontext.uc_mcontext = unw_context.uc_mcontext; -#endif - return ucontext; -} - -static void OfflineBacktraceFunctionCall(std::function function, - std::vector* pc_values) { - // Create a thread to generate the needed stack and registers information. - g_exit_flag = false; - const size_t stack_size = 1024 * 1024; - void* stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - ASSERT_NE(MAP_FAILED, stack); - uintptr_t stack_addr = reinterpret_cast(stack); - pthread_attr_t attr; - ASSERT_EQ(0, pthread_attr_init(&attr)); - ASSERT_EQ(0, pthread_attr_setstack(&attr, reinterpret_cast(stack), stack_size)); - pthread_t thread; - OfflineThreadArg arg; - arg.function = function; - ASSERT_EQ(0, pthread_create(&thread, &attr, OfflineThreadFunc, &arg)); - // Wait for the offline thread to generate the stack and unw_context information. - sleep(1); - // Copy the stack information. - std::vector stack_data(reinterpret_cast(stack), - reinterpret_cast(stack) + stack_size); - g_exit_flag = true; - ASSERT_EQ(0, pthread_join(thread, nullptr)); - ASSERT_EQ(0, munmap(stack, stack_size)); - - // Do offline backtrace. - std::unique_ptr map(BacktraceMap::Create(getpid())); - ASSERT_TRUE(map != nullptr); - - backtrace_stackinfo_t stack_info; - stack_info.start = stack_addr; - stack_info.end = stack_addr + stack_size; - stack_info.data = stack_data.data(); - - std::unique_ptr backtrace( - Backtrace::CreateOffline(getpid(), arg.tid, map.get(), stack_info)); - ASSERT_TRUE(backtrace != nullptr); - - ucontext_t ucontext = GetUContextFromUnwContext(arg.unw_context); - ASSERT_TRUE(backtrace->Unwind(0, &ucontext)); - - // Collect pc values of the call stack frames. - for (size_t i = 0; i < backtrace->NumFrames(); ++i) { - pc_values->push_back(backtrace->GetFrame(i)->pc); - } -} - -// Return the name of the function which matches the address. Although we don't know the -// exact end of each function, it is accurate enough for the tests. -static std::string FunctionNameForAddress(uintptr_t addr) { - struct FunctionSymbol { - std::string name; - uintptr_t start; - uintptr_t end; - }; - - static std::vector symbols; - if (symbols.empty()) { - symbols = std::vector{ - {"unknown_start", 0, 0}, - {"test_level_one", reinterpret_cast(&test_level_one), 0}, - {"test_level_two", reinterpret_cast(&test_level_two), 0}, - {"test_level_three", reinterpret_cast(&test_level_three), 0}, - {"test_level_four", reinterpret_cast(&test_level_four), 0}, - {"test_recursive_call", reinterpret_cast(&test_recursive_call), 0}, - {"GetContextAndExit", reinterpret_cast(&GetContextAndExit), 0}, - {"unknown_end", static_cast(-1), static_cast(-1)}, - }; - std::sort( - symbols.begin(), symbols.end(), - [](const FunctionSymbol& s1, const FunctionSymbol& s2) { return s1.start < s2.start; }); - for (size_t i = 0; i + 1 < symbols.size(); ++i) { - symbols[i].end = symbols[i + 1].start; - } - } - for (auto& symbol : symbols) { - if (addr >= symbol.start && addr < symbol.end) { - return symbol.name; - } - } - return ""; -} - -TEST(libbacktrace, offline) { - std::function function = - std::bind(test_level_one, 1, 2, 3, 4, std::placeholders::_1, std::placeholders::_2); - std::vector pc_values; - OfflineBacktraceFunctionCall(function, &pc_values); - ASSERT_FALSE(pc_values.empty()); - ASSERT_LE(pc_values.size(), static_cast(MAX_BACKTRACE_FRAMES)); - - size_t test_one_index = 0; - for (size_t i = 0; i < pc_values.size(); ++i) { - if (FunctionNameForAddress(pc_values[i]) == "test_level_one") { - test_one_index = i; - break; - } - } - - ASSERT_GE(test_one_index, 3u); - ASSERT_EQ("test_level_one", FunctionNameForAddress(pc_values[test_one_index])); - ASSERT_EQ("test_level_two", FunctionNameForAddress(pc_values[test_one_index - 1])); - ASSERT_EQ("test_level_three", FunctionNameForAddress(pc_values[test_one_index - 2])); - ASSERT_EQ("test_level_four", FunctionNameForAddress(pc_values[test_one_index - 3])); -} - -TEST(libbacktrace, offline_max_trace) { - std::function function = std::bind( - test_recursive_call, MAX_BACKTRACE_FRAMES + 10, std::placeholders::_1, std::placeholders::_2); - std::vector pc_values; - OfflineBacktraceFunctionCall(function, &pc_values); - ASSERT_FALSE(pc_values.empty()); - ASSERT_EQ(static_cast(MAX_BACKTRACE_FRAMES), pc_values.size()); - ASSERT_EQ("test_recursive_call", FunctionNameForAddress(pc_values.back())); -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/backtrace_test.cpp b/app/src/main/jni/crash_dump/libbacktrace/backtrace_test.cpp deleted file mode 100644 index f6b2591a2..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/backtrace_test.cpp +++ /dev/null @@ -1,1495 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define _GNU_SOURCE 1 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -// For the THREAD_SIGNAL definition. -#include "BacktraceCurrent.h" -#include "thread_utils.h" - -// Number of microseconds per milliseconds. -#define US_PER_MSEC 1000 - -// Number of nanoseconds in a second. -#define NS_PER_SEC 1000000000ULL - -// Number of simultaneous dumping operations to perform. -#define NUM_THREADS 40 - -// Number of simultaneous threads running in our forked process. -#define NUM_PTRACE_THREADS 5 - -struct thread_t { - pid_t tid; - int32_t state; - pthread_t threadId; - void* data; -}; - -struct dump_thread_t { - thread_t thread; - Backtrace* backtrace; - int32_t* now; - int32_t done; -}; - -extern "C" { -// Prototypes for functions in the test library. -int test_level_one(int, int, int, int, void (*)(void*), void*); - -int test_recursive_call(int, void (*)(void*), void*); -} - -uint64_t NanoTime() { - struct timespec t = { 0, 0 }; - clock_gettime(CLOCK_MONOTONIC, &t); - return static_cast(t.tv_sec * NS_PER_SEC + t.tv_nsec); -} - -std::string DumpFrames(Backtrace* backtrace) { - if (backtrace->NumFrames() == 0) { - return " No frames to dump.\n"; - } - - std::string frame; - for (size_t i = 0; i < backtrace->NumFrames(); i++) { - frame += " " + backtrace->FormatFrameData(i) + '\n'; - } - return frame; -} - -void WaitForStop(pid_t pid) { - uint64_t start = NanoTime(); - - siginfo_t si; - while (ptrace(PTRACE_GETSIGINFO, pid, 0, &si) < 0 && (errno == EINTR || errno == ESRCH)) { - if ((NanoTime() - start) > NS_PER_SEC) { - printf("The process did not get to a stopping point in 1 second.\n"); - break; - } - usleep(US_PER_MSEC); - } -} - -bool ReadyLevelBacktrace(Backtrace* backtrace) { - // See if test_level_four is in the backtrace. - bool found = false; - for (Backtrace::const_iterator it = backtrace->begin(); it != backtrace->end(); ++it) { - if (it->func_name == "test_level_four") { - found = true; - break; - } - } - - return found; -} - -void VerifyLevelDump(Backtrace* backtrace) { - ASSERT_GT(backtrace->NumFrames(), static_cast(0)) - << DumpFrames(backtrace); - ASSERT_LT(backtrace->NumFrames(), static_cast(MAX_BACKTRACE_FRAMES)) - << DumpFrames(backtrace); - - // Look through the frames starting at the highest to find the - // frame we want. - size_t frame_num = 0; - for (size_t i = backtrace->NumFrames()-1; i > 2; i--) { - if (backtrace->GetFrame(i)->func_name == "test_level_one") { - frame_num = i; - break; - } - } - ASSERT_LT(static_cast(0), frame_num) << DumpFrames(backtrace); - ASSERT_LE(static_cast(3), frame_num) << DumpFrames(backtrace); - - ASSERT_EQ(backtrace->GetFrame(frame_num)->func_name, "test_level_one") - << DumpFrames(backtrace); - ASSERT_EQ(backtrace->GetFrame(frame_num-1)->func_name, "test_level_two") - << DumpFrames(backtrace); - ASSERT_EQ(backtrace->GetFrame(frame_num-2)->func_name, "test_level_three") - << DumpFrames(backtrace); - ASSERT_EQ(backtrace->GetFrame(frame_num-3)->func_name, "test_level_four") - << DumpFrames(backtrace); -} - -void VerifyLevelBacktrace(void*) { - std::unique_ptr backtrace( - Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - - VerifyLevelDump(backtrace.get()); -} - -bool ReadyMaxBacktrace(Backtrace* backtrace) { - return (backtrace->NumFrames() == MAX_BACKTRACE_FRAMES); -} - -void VerifyMaxDump(Backtrace* backtrace) { - ASSERT_EQ(backtrace->NumFrames(), static_cast(MAX_BACKTRACE_FRAMES)) - << DumpFrames(backtrace); - // Verify that the last frame is our recursive call. - ASSERT_EQ(backtrace->GetFrame(MAX_BACKTRACE_FRAMES-1)->func_name, "test_recursive_call") - << DumpFrames(backtrace); -} - -void VerifyMaxBacktrace(void*) { - std::unique_ptr backtrace( - Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - - VerifyMaxDump(backtrace.get()); -} - -void ThreadSetState(void* data) { - thread_t* thread = reinterpret_cast(data); - android_atomic_acquire_store(1, &thread->state); - volatile int i = 0; - while (thread->state) { - i++; - } -} - -void VerifyThreadTest(pid_t tid, void (*VerifyFunc)(Backtrace*)) { - std::unique_ptr backtrace(Backtrace::Create(getpid(), tid)); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - - VerifyFunc(backtrace.get()); -} - -bool WaitForNonZero(int32_t* value, uint64_t seconds) { - uint64_t start = NanoTime(); - do { - if (android_atomic_acquire_load(value)) { - return true; - } - } while ((NanoTime() - start) < seconds * NS_PER_SEC); - return false; -} - -TEST(libbacktrace, local_no_unwind_frames) { - // Verify that a local unwind does not include any frames within - // libunwind or libbacktrace. - std::unique_ptr backtrace(Backtrace::Create(getpid(), getpid())); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - - ASSERT_TRUE(backtrace->NumFrames() != 0); - for (const auto& frame : *backtrace ) { - if (BacktraceMap::IsValid(frame.map)) { - const std::string name = basename(frame.map.name.c_str()); - ASSERT_TRUE(name != "libunwind.so" && name != "libbacktrace.so") - << DumpFrames(backtrace.get()); - } - break; - } -} - -TEST(libbacktrace, local_trace) { - ASSERT_NE(test_level_one(1, 2, 3, 4, VerifyLevelBacktrace, nullptr), 0); -} - -void VerifyIgnoreFrames( - Backtrace* bt_all, Backtrace* bt_ign1, - Backtrace* bt_ign2, const char* cur_proc) { - EXPECT_EQ(bt_all->NumFrames(), bt_ign1->NumFrames() + 1) - << "All backtrace:\n" << DumpFrames(bt_all) << "Ignore 1 backtrace:\n" << DumpFrames(bt_ign1); - EXPECT_EQ(bt_all->NumFrames(), bt_ign2->NumFrames() + 2) - << "All backtrace:\n" << DumpFrames(bt_all) << "Ignore 2 backtrace:\n" << DumpFrames(bt_ign2); - - // Check all of the frames are the same > the current frame. - bool check = (cur_proc == nullptr); - for (size_t i = 0; i < bt_ign2->NumFrames(); i++) { - if (check) { - EXPECT_EQ(bt_ign2->GetFrame(i)->pc, bt_ign1->GetFrame(i+1)->pc); - EXPECT_EQ(bt_ign2->GetFrame(i)->sp, bt_ign1->GetFrame(i+1)->sp); - EXPECT_EQ(bt_ign2->GetFrame(i)->stack_size, bt_ign1->GetFrame(i+1)->stack_size); - - EXPECT_EQ(bt_ign2->GetFrame(i)->pc, bt_all->GetFrame(i+2)->pc); - EXPECT_EQ(bt_ign2->GetFrame(i)->sp, bt_all->GetFrame(i+2)->sp); - EXPECT_EQ(bt_ign2->GetFrame(i)->stack_size, bt_all->GetFrame(i+2)->stack_size); - } - if (!check && bt_ign2->GetFrame(i)->func_name == cur_proc) { - check = true; - } - } -} - -void VerifyLevelIgnoreFrames(void*) { - std::unique_ptr all( - Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(all.get() != nullptr); - ASSERT_TRUE(all->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, all->GetError()); - - std::unique_ptr ign1( - Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(ign1.get() != nullptr); - ASSERT_TRUE(ign1->Unwind(1)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, ign1->GetError()); - - std::unique_ptr ign2( - Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(ign2.get() != nullptr); - ASSERT_TRUE(ign2->Unwind(2)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, ign2->GetError()); - - VerifyIgnoreFrames(all.get(), ign1.get(), ign2.get(), "VerifyLevelIgnoreFrames"); -} - -TEST(libbacktrace, local_trace_ignore_frames) { - ASSERT_NE(test_level_one(1, 2, 3, 4, VerifyLevelIgnoreFrames, nullptr), 0); -} - -TEST(libbacktrace, local_max_trace) { - ASSERT_NE(test_recursive_call(MAX_BACKTRACE_FRAMES+10, VerifyMaxBacktrace, nullptr), 0); -} - -void VerifyProcTest(pid_t pid, pid_t tid, bool share_map, - bool (*ReadyFunc)(Backtrace*), - void (*VerifyFunc)(Backtrace*)) { - pid_t ptrace_tid; - if (tid < 0) { - ptrace_tid = pid; - } else { - ptrace_tid = tid; - } - uint64_t start = NanoTime(); - bool verified = false; - std::string last_dump; - do { - usleep(US_PER_MSEC); - if (ptrace(PTRACE_ATTACH, ptrace_tid, 0, 0) == 0) { - // Wait for the process to get to a stopping point. - WaitForStop(ptrace_tid); - - std::unique_ptr map; - if (share_map) { - map.reset(BacktraceMap::Create(pid)); - } - std::unique_ptr backtrace(Backtrace::Create(pid, tid, map.get())); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - if (ReadyFunc(backtrace.get())) { - VerifyFunc(backtrace.get()); - verified = true; - } else { - last_dump = DumpFrames(backtrace.get()); - } - - ASSERT_TRUE(ptrace(PTRACE_DETACH, ptrace_tid, 0, 0) == 0); - } - // If 5 seconds have passed, then we are done. - } while (!verified && (NanoTime() - start) <= 5 * NS_PER_SEC); - ASSERT_TRUE(verified) << "Last backtrace:\n" << last_dump; -} - -TEST(libbacktrace, ptrace_trace) { - pid_t pid; - if ((pid = fork()) == 0) { - ASSERT_NE(test_level_one(1, 2, 3, 4, nullptr, nullptr), 0); - _exit(1); - } - VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, false, ReadyLevelBacktrace, VerifyLevelDump); - - kill(pid, SIGKILL); - int status; - ASSERT_EQ(waitpid(pid, &status, 0), pid); -} - -TEST(libbacktrace, ptrace_trace_shared_map) { - pid_t pid; - if ((pid = fork()) == 0) { - ASSERT_NE(test_level_one(1, 2, 3, 4, nullptr, nullptr), 0); - _exit(1); - } - - VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, true, ReadyLevelBacktrace, VerifyLevelDump); - - kill(pid, SIGKILL); - int status; - ASSERT_EQ(waitpid(pid, &status, 0), pid); -} - -TEST(libbacktrace, ptrace_max_trace) { - pid_t pid; - if ((pid = fork()) == 0) { - ASSERT_NE(test_recursive_call(MAX_BACKTRACE_FRAMES+10, nullptr, nullptr), 0); - _exit(1); - } - VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, false, ReadyMaxBacktrace, VerifyMaxDump); - - kill(pid, SIGKILL); - int status; - ASSERT_EQ(waitpid(pid, &status, 0), pid); -} - -void VerifyProcessIgnoreFrames(Backtrace* bt_all) { - std::unique_ptr ign1(Backtrace::Create(bt_all->Pid(), BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(ign1.get() != nullptr); - ASSERT_TRUE(ign1->Unwind(1)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, ign1->GetError()); - - std::unique_ptr ign2(Backtrace::Create(bt_all->Pid(), BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(ign2.get() != nullptr); - ASSERT_TRUE(ign2->Unwind(2)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, ign2->GetError()); - - VerifyIgnoreFrames(bt_all, ign1.get(), ign2.get(), nullptr); -} - -TEST(libbacktrace, ptrace_ignore_frames) { - pid_t pid; - if ((pid = fork()) == 0) { - ASSERT_NE(test_level_one(1, 2, 3, 4, nullptr, nullptr), 0); - _exit(1); - } - VerifyProcTest(pid, BACKTRACE_CURRENT_THREAD, false, ReadyLevelBacktrace, VerifyProcessIgnoreFrames); - - kill(pid, SIGKILL); - int status; - ASSERT_EQ(waitpid(pid, &status, 0), pid); -} - -// Create a process with multiple threads and dump all of the threads. -void* PtraceThreadLevelRun(void*) { - EXPECT_NE(test_level_one(1, 2, 3, 4, nullptr, nullptr), 0); - return nullptr; -} - -void GetThreads(pid_t pid, std::vector* threads) { - // Get the list of tasks. - char task_path[128]; - snprintf(task_path, sizeof(task_path), "/proc/%d/task", pid); - - DIR* tasks_dir = opendir(task_path); - ASSERT_TRUE(tasks_dir != nullptr); - struct dirent* entry; - while ((entry = readdir(tasks_dir)) != nullptr) { - char* end; - pid_t tid = strtoul(entry->d_name, &end, 10); - if (*end == '\0') { - threads->push_back(tid); - } - } - closedir(tasks_dir); -} - -TEST(libbacktrace, ptrace_threads) { - pid_t pid; - if ((pid = fork()) == 0) { - for (size_t i = 0; i < NUM_PTRACE_THREADS; i++) { - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - pthread_t thread; - ASSERT_TRUE(pthread_create(&thread, &attr, PtraceThreadLevelRun, nullptr) == 0); - } - ASSERT_NE(test_level_one(1, 2, 3, 4, nullptr, nullptr), 0); - _exit(1); - } - - // Check to see that all of the threads are running before unwinding. - std::vector threads; - uint64_t start = NanoTime(); - do { - usleep(US_PER_MSEC); - threads.clear(); - GetThreads(pid, &threads); - } while ((threads.size() != NUM_PTRACE_THREADS + 1) && - ((NanoTime() - start) <= 5 * NS_PER_SEC)); - ASSERT_EQ(threads.size(), static_cast(NUM_PTRACE_THREADS + 1)); - - ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0); - WaitForStop(pid); - for (std::vector::const_iterator it = threads.begin(); it != threads.end(); ++it) { - // Skip the current forked process, we only care about the threads. - if (pid == *it) { - continue; - } - VerifyProcTest(pid, *it, false, ReadyLevelBacktrace, VerifyLevelDump); - } - ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0); - - kill(pid, SIGKILL); - int status; - ASSERT_EQ(waitpid(pid, &status, 0), pid); -} - -void VerifyLevelThread(void*) { - std::unique_ptr backtrace(Backtrace::Create(getpid(), gettid())); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - - VerifyLevelDump(backtrace.get()); -} - -TEST(libbacktrace, thread_current_level) { - ASSERT_NE(test_level_one(1, 2, 3, 4, VerifyLevelThread, nullptr), 0); -} - -void VerifyMaxThread(void*) { - std::unique_ptr backtrace(Backtrace::Create(getpid(), gettid())); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - - VerifyMaxDump(backtrace.get()); -} - -TEST(libbacktrace, thread_current_max) { - ASSERT_NE(test_recursive_call(MAX_BACKTRACE_FRAMES+10, VerifyMaxThread, nullptr), 0); -} - -void* ThreadLevelRun(void* data) { - thread_t* thread = reinterpret_cast(data); - - thread->tid = gettid(); - EXPECT_NE(test_level_one(1, 2, 3, 4, ThreadSetState, data), 0); - return nullptr; -} - -TEST(libbacktrace, thread_level_trace) { - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - thread_t thread_data = { 0, 0, 0, nullptr }; - pthread_t thread; - ASSERT_TRUE(pthread_create(&thread, &attr, ThreadLevelRun, &thread_data) == 0); - - // Wait up to 2 seconds for the tid to be set. - ASSERT_TRUE(WaitForNonZero(&thread_data.state, 2)); - - // Make sure that the thread signal used is not visible when compiled for - // the target. -#if !defined(__GLIBC__) - ASSERT_LT(THREAD_SIGNAL, SIGRTMIN); -#endif - - // Save the current signal action and make sure it is restored afterwards. - struct sigaction cur_action; - ASSERT_TRUE(sigaction(THREAD_SIGNAL, nullptr, &cur_action) == 0); - - std::unique_ptr backtrace(Backtrace::Create(getpid(), thread_data.tid)); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - - VerifyLevelDump(backtrace.get()); - - // Tell the thread to exit its infinite loop. - android_atomic_acquire_store(0, &thread_data.state); - - // Verify that the old action was restored. - struct sigaction new_action; - ASSERT_TRUE(sigaction(THREAD_SIGNAL, nullptr, &new_action) == 0); - EXPECT_EQ(cur_action.sa_sigaction, new_action.sa_sigaction); - // The SA_RESTORER flag gets set behind our back, so a direct comparison - // doesn't work unless we mask the value off. Mips doesn't have this - // flag, so skip this on that platform. -#if defined(SA_RESTORER) - cur_action.sa_flags &= ~SA_RESTORER; - new_action.sa_flags &= ~SA_RESTORER; -#elif defined(__GLIBC__) - // Our host compiler doesn't appear to define this flag for some reason. - cur_action.sa_flags &= ~0x04000000; - new_action.sa_flags &= ~0x04000000; -#endif - EXPECT_EQ(cur_action.sa_flags, new_action.sa_flags); -} - -TEST(libbacktrace, thread_ignore_frames) { - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - thread_t thread_data = { 0, 0, 0, nullptr }; - pthread_t thread; - ASSERT_TRUE(pthread_create(&thread, &attr, ThreadLevelRun, &thread_data) == 0); - - // Wait up to 2 seconds for the tid to be set. - ASSERT_TRUE(WaitForNonZero(&thread_data.state, 2)); - - std::unique_ptr all(Backtrace::Create(getpid(), thread_data.tid)); - ASSERT_TRUE(all.get() != nullptr); - ASSERT_TRUE(all->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, all->GetError()); - - std::unique_ptr ign1(Backtrace::Create(getpid(), thread_data.tid)); - ASSERT_TRUE(ign1.get() != nullptr); - ASSERT_TRUE(ign1->Unwind(1)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, ign1->GetError()); - - std::unique_ptr ign2(Backtrace::Create(getpid(), thread_data.tid)); - ASSERT_TRUE(ign2.get() != nullptr); - ASSERT_TRUE(ign2->Unwind(2)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, ign2->GetError()); - - VerifyIgnoreFrames(all.get(), ign1.get(), ign2.get(), nullptr); - - // Tell the thread to exit its infinite loop. - android_atomic_acquire_store(0, &thread_data.state); -} - -void* ThreadMaxRun(void* data) { - thread_t* thread = reinterpret_cast(data); - - thread->tid = gettid(); - EXPECT_NE(test_recursive_call(MAX_BACKTRACE_FRAMES+10, ThreadSetState, data), 0); - return nullptr; -} - -TEST(libbacktrace, thread_max_trace) { - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - thread_t thread_data = { 0, 0, 0, nullptr }; - pthread_t thread; - ASSERT_TRUE(pthread_create(&thread, &attr, ThreadMaxRun, &thread_data) == 0); - - // Wait for the tid to be set. - ASSERT_TRUE(WaitForNonZero(&thread_data.state, 2)); - - std::unique_ptr backtrace(Backtrace::Create(getpid(), thread_data.tid)); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - - VerifyMaxDump(backtrace.get()); - - // Tell the thread to exit its infinite loop. - android_atomic_acquire_store(0, &thread_data.state); -} - -void* ThreadDump(void* data) { - dump_thread_t* dump = reinterpret_cast(data); - while (true) { - if (android_atomic_acquire_load(dump->now)) { - break; - } - } - - // The status of the actual unwind will be checked elsewhere. - dump->backtrace = Backtrace::Create(getpid(), dump->thread.tid); - dump->backtrace->Unwind(0); - - android_atomic_acquire_store(1, &dump->done); - - return nullptr; -} - -TEST(libbacktrace, thread_multiple_dump) { - // Dump NUM_THREADS simultaneously. - std::vector runners(NUM_THREADS); - std::vector dumpers(NUM_THREADS); - - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - for (size_t i = 0; i < NUM_THREADS; i++) { - // Launch the runners, they will spin in hard loops doing nothing. - runners[i].tid = 0; - runners[i].state = 0; - ASSERT_TRUE(pthread_create(&runners[i].threadId, &attr, ThreadMaxRun, &runners[i]) == 0); - } - - // Wait for tids to be set. - for (std::vector::iterator it = runners.begin(); it != runners.end(); ++it) { - ASSERT_TRUE(WaitForNonZero(&it->state, 30)); - } - - // Start all of the dumpers at once, they will spin until they are signalled - // to begin their dump run. - int32_t dump_now = 0; - for (size_t i = 0; i < NUM_THREADS; i++) { - dumpers[i].thread.tid = runners[i].tid; - dumpers[i].thread.state = 0; - dumpers[i].done = 0; - dumpers[i].now = &dump_now; - - ASSERT_TRUE(pthread_create(&dumpers[i].thread.threadId, &attr, ThreadDump, &dumpers[i]) == 0); - } - - // Start all of the dumpers going at once. - android_atomic_acquire_store(1, &dump_now); - - for (size_t i = 0; i < NUM_THREADS; i++) { - ASSERT_TRUE(WaitForNonZero(&dumpers[i].done, 30)); - - // Tell the runner thread to exit its infinite loop. - android_atomic_acquire_store(0, &runners[i].state); - - ASSERT_TRUE(dumpers[i].backtrace != nullptr); - VerifyMaxDump(dumpers[i].backtrace); - - delete dumpers[i].backtrace; - dumpers[i].backtrace = nullptr; - } -} - -TEST(libbacktrace, thread_multiple_dump_same_thread) { - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - thread_t runner; - runner.tid = 0; - runner.state = 0; - ASSERT_TRUE(pthread_create(&runner.threadId, &attr, ThreadMaxRun, &runner) == 0); - - // Wait for tids to be set. - ASSERT_TRUE(WaitForNonZero(&runner.state, 30)); - - // Start all of the dumpers at once, they will spin until they are signalled - // to begin their dump run. - int32_t dump_now = 0; - // Dump the same thread NUM_THREADS simultaneously. - std::vector dumpers(NUM_THREADS); - for (size_t i = 0; i < NUM_THREADS; i++) { - dumpers[i].thread.tid = runner.tid; - dumpers[i].thread.state = 0; - dumpers[i].done = 0; - dumpers[i].now = &dump_now; - - ASSERT_TRUE(pthread_create(&dumpers[i].thread.threadId, &attr, ThreadDump, &dumpers[i]) == 0); - } - - // Start all of the dumpers going at once. - android_atomic_acquire_store(1, &dump_now); - - for (size_t i = 0; i < NUM_THREADS; i++) { - ASSERT_TRUE(WaitForNonZero(&dumpers[i].done, 30)); - - ASSERT_TRUE(dumpers[i].backtrace != nullptr); - VerifyMaxDump(dumpers[i].backtrace); - - delete dumpers[i].backtrace; - dumpers[i].backtrace = nullptr; - } - - // Tell the runner thread to exit its infinite loop. - android_atomic_acquire_store(0, &runner.state); -} - -// This test is for UnwindMaps that should share the same map cursor when -// multiple maps are created for the current process at the same time. -TEST(libbacktrace, simultaneous_maps) { - BacktraceMap* map1 = BacktraceMap::Create(getpid()); - BacktraceMap* map2 = BacktraceMap::Create(getpid()); - BacktraceMap* map3 = BacktraceMap::Create(getpid()); - - Backtrace* back1 = Backtrace::Create(getpid(), BACKTRACE_CURRENT_THREAD, map1); - ASSERT_TRUE(back1 != nullptr); - EXPECT_TRUE(back1->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, back1->GetError()); - delete back1; - delete map1; - - Backtrace* back2 = Backtrace::Create(getpid(), BACKTRACE_CURRENT_THREAD, map2); - ASSERT_TRUE(back2 != nullptr); - EXPECT_TRUE(back2->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, back2->GetError()); - delete back2; - delete map2; - - Backtrace* back3 = Backtrace::Create(getpid(), BACKTRACE_CURRENT_THREAD, map3); - ASSERT_TRUE(back3 != nullptr); - EXPECT_TRUE(back3->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, back3->GetError()); - delete back3; - delete map3; -} - -TEST(libbacktrace, fillin_erases) { - BacktraceMap* back_map = BacktraceMap::Create(getpid()); - - backtrace_map_t map; - - map.start = 1; - map.end = 3; - map.flags = 1; - map.name = "Initialized"; - back_map->FillIn(0, &map); - delete back_map; - - ASSERT_FALSE(BacktraceMap::IsValid(map)); - ASSERT_EQ(static_cast(0), map.start); - ASSERT_EQ(static_cast(0), map.end); - ASSERT_EQ(0, map.flags); - ASSERT_EQ("", map.name); -} - -TEST(libbacktrace, format_test) { - std::unique_ptr backtrace(Backtrace::Create(getpid(), BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(backtrace.get() != nullptr); - - backtrace_frame_data_t frame; - frame.num = 1; - frame.pc = 2; - frame.sp = 0; - frame.stack_size = 0; - frame.func_offset = 0; - - // Check no map set. - frame.num = 1; -#if defined(__LP64__) - EXPECT_EQ("#01 pc 0000000000000002 ", -#else - EXPECT_EQ("#01 pc 00000002 ", -#endif - backtrace->FormatFrameData(&frame)); - - // Check map name empty, but exists. - frame.pc = 0xb0020; - frame.map.start = 0xb0000; - frame.map.end = 0xbffff; - frame.map.load_base = 0; -#if defined(__LP64__) - EXPECT_EQ("#01 pc 0000000000000020 ", -#else - EXPECT_EQ("#01 pc 00000020 ", -#endif - backtrace->FormatFrameData(&frame)); - - // Check map name begins with a [. - frame.pc = 0xc0020; - frame.map.start = 0xc0000; - frame.map.end = 0xcffff; - frame.map.load_base = 0; - frame.map.name = "[anon:thread signal stack]"; -#if defined(__LP64__) - EXPECT_EQ("#01 pc 0000000000000020 [anon:thread signal stack:00000000000c0000]", -#else - EXPECT_EQ("#01 pc 00000020 [anon:thread signal stack:000c0000]", -#endif - backtrace->FormatFrameData(&frame)); - - // Check relative pc is set and map name is set. - frame.pc = 0x12345679; - frame.map.name = "MapFake"; - frame.map.start = 1; - frame.map.end = 1; -#if defined(__LP64__) - EXPECT_EQ("#01 pc 0000000012345678 MapFake", -#else - EXPECT_EQ("#01 pc 12345678 MapFake", -#endif - backtrace->FormatFrameData(&frame)); - - // Check func_name is set, but no func offset. - frame.func_name = "ProcFake"; -#if defined(__LP64__) - EXPECT_EQ("#01 pc 0000000012345678 MapFake (ProcFake)", -#else - EXPECT_EQ("#01 pc 12345678 MapFake (ProcFake)", -#endif - backtrace->FormatFrameData(&frame)); - - // Check func_name is set, and func offset is non-zero. - frame.func_offset = 645; -#if defined(__LP64__) - EXPECT_EQ("#01 pc 0000000012345678 MapFake (ProcFake+645)", -#else - EXPECT_EQ("#01 pc 12345678 MapFake (ProcFake+645)", -#endif - backtrace->FormatFrameData(&frame)); - - // Check func_name is set, func offset is non-zero, and load_base is non-zero. - frame.func_offset = 645; - frame.map.load_base = 100; -#if defined(__LP64__) - EXPECT_EQ("#01 pc 00000000123456dc MapFake (ProcFake+645)", -#else - EXPECT_EQ("#01 pc 123456dc MapFake (ProcFake+645)", -#endif - backtrace->FormatFrameData(&frame)); - - // Check a non-zero map offset. - frame.map.offset = 0x1000; -#if defined(__LP64__) - EXPECT_EQ("#01 pc 00000000123456dc MapFake (offset 0x1000) (ProcFake+645)", -#else - EXPECT_EQ("#01 pc 123456dc MapFake (offset 0x1000) (ProcFake+645)", -#endif - backtrace->FormatFrameData(&frame)); -} - -struct map_test_t { - uintptr_t start; - uintptr_t end; -}; - -bool map_sort(map_test_t i, map_test_t j) { - return i.start < j.start; -} - -void VerifyMap(pid_t pid) { - char buffer[4096]; - snprintf(buffer, sizeof(buffer), "/proc/%d/maps", pid); - - FILE* map_file = fopen(buffer, "r"); - ASSERT_TRUE(map_file != nullptr); - std::vector test_maps; - while (fgets(buffer, sizeof(buffer), map_file)) { - map_test_t map; - ASSERT_EQ(2, sscanf(buffer, "%" SCNxPTR "-%" SCNxPTR " ", &map.start, &map.end)); - test_maps.push_back(map); - } - fclose(map_file); - std::sort(test_maps.begin(), test_maps.end(), map_sort); - - std::unique_ptr map(BacktraceMap::Create(pid)); - - // Basic test that verifies that the map is in the expected order. - std::vector::const_iterator test_it = test_maps.begin(); - for (BacktraceMap::const_iterator it = map->begin(); it != map->end(); ++it) { - ASSERT_TRUE(test_it != test_maps.end()); - ASSERT_EQ(test_it->start, it->start); - ASSERT_EQ(test_it->end, it->end); - ++test_it; - } - ASSERT_TRUE(test_it == test_maps.end()); -} - -TEST(libbacktrace, verify_map_remote) { - pid_t pid; - - if ((pid = fork()) == 0) { - while (true) { - } - _exit(0); - } - ASSERT_LT(0, pid); - - ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0); - - // Wait for the process to get to a stopping point. - WaitForStop(pid); - - // The maps should match exactly since the forked process has been paused. - VerifyMap(pid); - - ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0); - - kill(pid, SIGKILL); - ASSERT_EQ(waitpid(pid, nullptr, 0), pid); -} - -void InitMemory(uint8_t* memory, size_t bytes) { - for (size_t i = 0; i < bytes; i++) { - memory[i] = i; - if (memory[i] == '\0') { - // Don't use '\0' in our data so we can verify that an overread doesn't - // occur by using a '\0' as the character after the read data. - memory[i] = 23; - } - } -} - -void* ThreadReadTest(void* data) { - thread_t* thread_data = reinterpret_cast(data); - - thread_data->tid = gettid(); - - // Create two map pages. - // Mark the second page as not-readable. - size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); - uint8_t* memory; - if (posix_memalign(reinterpret_cast(&memory), pagesize, 2 * pagesize) != 0) { - return reinterpret_cast(-1); - } - - if (mprotect(&memory[pagesize], pagesize, PROT_NONE) != 0) { - return reinterpret_cast(-1); - } - - // Set up a simple pattern in memory. - InitMemory(memory, pagesize); - - thread_data->data = memory; - - // Tell the caller it's okay to start reading memory. - android_atomic_acquire_store(1, &thread_data->state); - - // Loop waiting for the caller to finish reading the memory. - while (thread_data->state) { - } - - // Re-enable read-write on the page so that we don't crash if we try - // and access data on this page when freeing the memory. - if (mprotect(&memory[pagesize], pagesize, PROT_READ | PROT_WRITE) != 0) { - return reinterpret_cast(-1); - } - free(memory); - - android_atomic_acquire_store(1, &thread_data->state); - - return nullptr; -} - -void RunReadTest(Backtrace* backtrace, uintptr_t read_addr) { - size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); - - // Create a page of data to use to do quick compares. - uint8_t* expected = new uint8_t[pagesize]; - InitMemory(expected, pagesize); - - uint8_t* data = new uint8_t[2*pagesize]; - // Verify that we can only read one page worth of data. - size_t bytes_read = backtrace->Read(read_addr, data, 2 * pagesize); - ASSERT_EQ(pagesize, bytes_read); - ASSERT_TRUE(memcmp(data, expected, pagesize) == 0); - - // Verify unaligned reads. - for (size_t i = 1; i < sizeof(word_t); i++) { - bytes_read = backtrace->Read(read_addr + i, data, 2 * sizeof(word_t)); - ASSERT_EQ(2 * sizeof(word_t), bytes_read); - ASSERT_TRUE(memcmp(data, &expected[i], 2 * sizeof(word_t)) == 0) - << "Offset at " << i << " failed"; - } - - // Verify small unaligned reads. - for (size_t i = 1; i < sizeof(word_t); i++) { - for (size_t j = 1; j < sizeof(word_t); j++) { - // Set one byte past what we expect to read, to guarantee we don't overread. - data[j] = '\0'; - bytes_read = backtrace->Read(read_addr + i, data, j); - ASSERT_EQ(j, bytes_read); - ASSERT_TRUE(memcmp(data, &expected[i], j) == 0) - << "Offset at " << i << " length " << j << " miscompared"; - ASSERT_EQ('\0', data[j]) - << "Offset at " << i << " length " << j << " wrote too much data"; - } - } - delete[] data; - delete[] expected; -} - -TEST(libbacktrace, thread_read) { - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - pthread_t thread; - thread_t thread_data = { 0, 0, 0, nullptr }; - ASSERT_TRUE(pthread_create(&thread, &attr, ThreadReadTest, &thread_data) == 0); - - ASSERT_TRUE(WaitForNonZero(&thread_data.state, 10)); - - std::unique_ptr backtrace(Backtrace::Create(getpid(), thread_data.tid)); - ASSERT_TRUE(backtrace.get() != nullptr); - - RunReadTest(backtrace.get(), reinterpret_cast(thread_data.data)); - - android_atomic_acquire_store(0, &thread_data.state); - - ASSERT_TRUE(WaitForNonZero(&thread_data.state, 10)); -} - -volatile uintptr_t g_ready = 0; -volatile uintptr_t g_addr = 0; - -void ForkedReadTest() { - // Create two map pages. - size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); - uint8_t* memory; - if (posix_memalign(reinterpret_cast(&memory), pagesize, 2 * pagesize) != 0) { - perror("Failed to allocate memory\n"); - exit(1); - } - - // Mark the second page as not-readable. - if (mprotect(&memory[pagesize], pagesize, PROT_NONE) != 0) { - perror("Failed to mprotect memory\n"); - exit(1); - } - - // Set up a simple pattern in memory. - InitMemory(memory, pagesize); - - g_addr = reinterpret_cast(memory); - g_ready = 1; - - while (1) { - usleep(US_PER_MSEC); - } -} - -TEST(libbacktrace, process_read) { - g_ready = 0; - pid_t pid; - if ((pid = fork()) == 0) { - ForkedReadTest(); - exit(0); - } - ASSERT_NE(-1, pid); - - bool test_executed = false; - uint64_t start = NanoTime(); - while (1) { - if (ptrace(PTRACE_ATTACH, pid, 0, 0) == 0) { - WaitForStop(pid); - - std::unique_ptr backtrace(Backtrace::Create(pid, pid)); - ASSERT_TRUE(backtrace.get() != nullptr); - - uintptr_t read_addr; - size_t bytes_read = backtrace->Read(reinterpret_cast(&g_ready), - reinterpret_cast(&read_addr), - sizeof(uintptr_t)); - ASSERT_EQ(sizeof(uintptr_t), bytes_read); - if (read_addr) { - // The forked process is ready to be read. - bytes_read = backtrace->Read(reinterpret_cast(&g_addr), - reinterpret_cast(&read_addr), - sizeof(uintptr_t)); - ASSERT_EQ(sizeof(uintptr_t), bytes_read); - - RunReadTest(backtrace.get(), read_addr); - - test_executed = true; - break; - } - ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0); - } - if ((NanoTime() - start) > 5 * NS_PER_SEC) { - break; - } - usleep(US_PER_MSEC); - } - kill(pid, SIGKILL); - ASSERT_EQ(waitpid(pid, nullptr, 0), pid); - - ASSERT_TRUE(test_executed); -} - -void VerifyFunctionsFound(const std::vector& found_functions) { - // We expect to find these functions in libbacktrace_test. If we don't - // find them, that's a bug in the memory read handling code in libunwind. - std::list expected_functions; - expected_functions.push_back("test_recursive_call"); - expected_functions.push_back("test_level_one"); - expected_functions.push_back("test_level_two"); - expected_functions.push_back("test_level_three"); - expected_functions.push_back("test_level_four"); - for (const auto& found_function : found_functions) { - for (const auto& expected_function : expected_functions) { - if (found_function == expected_function) { - expected_functions.remove(found_function); - break; - } - } - } - ASSERT_TRUE(expected_functions.empty()) << "Not all functions found in shared library."; -} - -const char* CopySharedLibrary() { -#if defined(__LP64__) - const char* lib_name = "lib64"; -#else - const char* lib_name = "lib"; -#endif - -#if defined(__BIONIC__) - const char* tmp_so_name = "/data/local/tmp/libbacktrace_test.so"; - std::string cp_cmd = android::base::StringPrintf("cp /system/%s/libbacktrace_test.so %s", - lib_name, tmp_so_name); -#else - const char* tmp_so_name = "/tmp/libbacktrace_test.so"; - if (getenv("ANDROID_HOST_OUT") == NULL) { - fprintf(stderr, "ANDROID_HOST_OUT not set, make sure you run lunch."); - return nullptr; - } - std::string cp_cmd = android::base::StringPrintf("cp %s/%s/libbacktrace_test.so %s", - getenv("ANDROID_HOST_OUT"), lib_name, - tmp_so_name); -#endif - - // Copy the shared so to a tempory directory. - system(cp_cmd.c_str()); - - return tmp_so_name; -} - -TEST(libbacktrace, check_unreadable_elf_local) { - const char* tmp_so_name = CopySharedLibrary(); - ASSERT_TRUE(tmp_so_name != nullptr); - - struct stat buf; - ASSERT_TRUE(stat(tmp_so_name, &buf) != -1); - uintptr_t map_size = buf.st_size; - - int fd = open(tmp_so_name, O_RDONLY); - ASSERT_TRUE(fd != -1); - - void* map = mmap(NULL, map_size, PROT_READ | PROT_EXEC, MAP_PRIVATE, fd, 0); - ASSERT_TRUE(map != MAP_FAILED); - close(fd); - ASSERT_TRUE(unlink(tmp_so_name) != -1); - - std::vector found_functions; - std::unique_ptr backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, - BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(backtrace.get() != nullptr); - - // Needed before GetFunctionName will work. - backtrace->Unwind(0); - - // Loop through the entire map, and get every function we can find. - map_size += reinterpret_cast(map); - std::string last_func; - for (uintptr_t read_addr = reinterpret_cast(map); - read_addr < map_size; read_addr += 4) { - uintptr_t offset; - std::string func_name = backtrace->GetFunctionName(read_addr, &offset); - if (!func_name.empty() && last_func != func_name) { - found_functions.push_back(func_name); - } - last_func = func_name; - } - - ASSERT_TRUE(munmap(map, map_size - reinterpret_cast(map)) == 0); - - VerifyFunctionsFound(found_functions); -} - -TEST(libbacktrace, check_unreadable_elf_remote) { - const char* tmp_so_name = CopySharedLibrary(); - ASSERT_TRUE(tmp_so_name != nullptr); - - g_ready = 0; - - struct stat buf; - ASSERT_TRUE(stat(tmp_so_name, &buf) != -1); - uintptr_t map_size = buf.st_size; - - pid_t pid; - if ((pid = fork()) == 0) { - int fd = open(tmp_so_name, O_RDONLY); - if (fd == -1) { - fprintf(stderr, "Failed to open file %s: %s\n", tmp_so_name, strerror(errno)); - unlink(tmp_so_name); - exit(0); - } - - void* map = mmap(NULL, map_size, PROT_READ | PROT_EXEC, MAP_PRIVATE, fd, 0); - if (map == MAP_FAILED) { - fprintf(stderr, "Failed to map in memory: %s\n", strerror(errno)); - unlink(tmp_so_name); - exit(0); - } - close(fd); - if (unlink(tmp_so_name) == -1) { - fprintf(stderr, "Failed to unlink: %s\n", strerror(errno)); - exit(0); - } - - g_addr = reinterpret_cast(map); - g_ready = 1; - while (true) { - usleep(US_PER_MSEC); - } - exit(0); - } - ASSERT_TRUE(pid > 0); - - std::vector found_functions; - uint64_t start = NanoTime(); - while (true) { - ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0); - - // Wait for the process to get to a stopping point. - WaitForStop(pid); - - std::unique_ptr backtrace(Backtrace::Create(pid, BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(backtrace.get() != nullptr); - - uintptr_t read_addr; - ASSERT_EQ(sizeof(uintptr_t), backtrace->Read(reinterpret_cast(&g_ready), reinterpret_cast(&read_addr), sizeof(uintptr_t))); - if (read_addr) { - ASSERT_EQ(sizeof(uintptr_t), backtrace->Read(reinterpret_cast(&g_addr), reinterpret_cast(&read_addr), sizeof(uintptr_t))); - - // Needed before GetFunctionName will work. - backtrace->Unwind(0); - - // Loop through the entire map, and get every function we can find. - map_size += read_addr; - std::string last_func; - for (; read_addr < map_size; read_addr += 4) { - uintptr_t offset; - std::string func_name = backtrace->GetFunctionName(read_addr, &offset); - if (!func_name.empty() && last_func != func_name) { - found_functions.push_back(func_name); - } - last_func = func_name; - } - break; - } - ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0); - - if ((NanoTime() - start) > 5 * NS_PER_SEC) { - break; - } - usleep(US_PER_MSEC); - } - - kill(pid, SIGKILL); - ASSERT_EQ(waitpid(pid, nullptr, 0), pid); - - VerifyFunctionsFound(found_functions); -} - -bool FindFuncFrameInBacktrace(Backtrace* backtrace, uintptr_t test_func, size_t* frame_num) { - backtrace_map_t map; - backtrace->FillInMap(test_func, &map); - if (!BacktraceMap::IsValid(map)) { - return false; - } - - // Loop through the frames, and find the one that is in the map. - *frame_num = 0; - for (Backtrace::const_iterator it = backtrace->begin(); it != backtrace->end(); ++it) { - if (BacktraceMap::IsValid(it->map) && map.start == it->map.start && - it->pc >= test_func) { - *frame_num = it->num; - return true; - } - } - return false; -} - -void VerifyUnreadableElfFrame(Backtrace* backtrace, uintptr_t test_func, size_t frame_num) { - ASSERT_LT(backtrace->NumFrames(), static_cast(MAX_BACKTRACE_FRAMES)) - << DumpFrames(backtrace); - - ASSERT_TRUE(frame_num != 0) << DumpFrames(backtrace); - // Make sure that there is at least one more frame above the test func call. - ASSERT_LT(frame_num, backtrace->NumFrames()) << DumpFrames(backtrace); - - uintptr_t diff = backtrace->GetFrame(frame_num)->pc - test_func; - ASSERT_LT(diff, 200U) << DumpFrames(backtrace); -} - -void VerifyUnreadableElfBacktrace(uintptr_t test_func) { - std::unique_ptr backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, - BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - - size_t frame_num; - ASSERT_TRUE(FindFuncFrameInBacktrace(backtrace.get(), test_func, &frame_num)); - - VerifyUnreadableElfFrame(backtrace.get(), test_func, frame_num); -} - -typedef int (*test_func_t)(int, int, int, int, void (*)(uintptr_t), uintptr_t); - -TEST(libbacktrace, unwind_through_unreadable_elf_local) { - const char* tmp_so_name = CopySharedLibrary(); - ASSERT_TRUE(tmp_so_name != nullptr); - void* lib_handle = dlopen(tmp_so_name, RTLD_NOW); - ASSERT_TRUE(lib_handle != nullptr); - ASSERT_TRUE(unlink(tmp_so_name) != -1); - - test_func_t test_func; - test_func = reinterpret_cast(dlsym(lib_handle, "test_level_one")); - ASSERT_TRUE(test_func != nullptr); - - ASSERT_NE(test_func(1, 2, 3, 4, VerifyUnreadableElfBacktrace, - reinterpret_cast(test_func)), 0); - - ASSERT_TRUE(dlclose(lib_handle) == 0); -} - -TEST(libbacktrace, unwind_through_unreadable_elf_remote) { - const char* tmp_so_name = CopySharedLibrary(); - ASSERT_TRUE(tmp_so_name != nullptr); - void* lib_handle = dlopen(tmp_so_name, RTLD_NOW); - ASSERT_TRUE(lib_handle != nullptr); - ASSERT_TRUE(unlink(tmp_so_name) != -1); - - test_func_t test_func; - test_func = reinterpret_cast(dlsym(lib_handle, "test_level_one")); - ASSERT_TRUE(test_func != nullptr); - - pid_t pid; - if ((pid = fork()) == 0) { - test_func(1, 2, 3, 4, 0, 0); - exit(0); - } - ASSERT_TRUE(pid > 0); - ASSERT_TRUE(dlclose(lib_handle) == 0); - - uint64_t start = NanoTime(); - bool done = false; - while (!done) { - ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0); - - // Wait for the process to get to a stopping point. - WaitForStop(pid); - - std::unique_ptr backtrace(Backtrace::Create(pid, BACKTRACE_CURRENT_THREAD)); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - - size_t frame_num; - if (FindFuncFrameInBacktrace(backtrace.get(), - reinterpret_cast(test_func), &frame_num)) { - - VerifyUnreadableElfFrame(backtrace.get(), reinterpret_cast(test_func), frame_num); - done = true; - } - - ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0); - - if ((NanoTime() - start) > 5 * NS_PER_SEC) { - break; - } - usleep(US_PER_MSEC); - } - - kill(pid, SIGKILL); - ASSERT_EQ(waitpid(pid, nullptr, 0), pid); - - ASSERT_TRUE(done) << "Test function never found in unwind."; -} - -TEST(libbacktrace, unwind_thread_doesnt_exist) { - std::unique_ptr backtrace( - Backtrace::Create(BACKTRACE_CURRENT_PROCESS, 99999999)); - ASSERT_TRUE(backtrace.get() != nullptr); - ASSERT_FALSE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_ERROR_THREAD_DOESNT_EXIST, backtrace->GetError()); -} - -#if defined(ENABLE_PSS_TESTS) -#include "GetPss.h" - -#define MAX_LEAK_BYTES 32*1024UL - -void CheckForLeak(pid_t pid, pid_t tid) { - // Do a few runs to get the PSS stable. - for (size_t i = 0; i < 100; i++) { - Backtrace* backtrace = Backtrace::Create(pid, tid); - ASSERT_TRUE(backtrace != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - delete backtrace; - } - size_t stable_pss = GetPssBytes(); - ASSERT_TRUE(stable_pss != 0); - - // Loop enough that even a small leak should be detectable. - for (size_t i = 0; i < 4096; i++) { - Backtrace* backtrace = Backtrace::Create(pid, tid); - ASSERT_TRUE(backtrace != nullptr); - ASSERT_TRUE(backtrace->Unwind(0)); - ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError()); - delete backtrace; - } - size_t new_pss = GetPssBytes(); - ASSERT_TRUE(new_pss != 0); - size_t abs_diff = (new_pss > stable_pss) ? new_pss - stable_pss : stable_pss - new_pss; - // As long as the new pss is within a certain amount, consider everything okay. - ASSERT_LE(abs_diff, MAX_LEAK_BYTES); -} - -TEST(libbacktrace, check_for_leak_local) { - CheckForLeak(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD); -} - -TEST(libbacktrace, check_for_leak_local_thread) { - thread_t thread_data = { 0, 0, 0, nullptr }; - pthread_t thread; - ASSERT_TRUE(pthread_create(&thread, nullptr, ThreadLevelRun, &thread_data) == 0); - - // Wait up to 2 seconds for the tid to be set. - ASSERT_TRUE(WaitForNonZero(&thread_data.state, 2)); - - CheckForLeak(BACKTRACE_CURRENT_PROCESS, thread_data.tid); - - // Tell the thread to exit its infinite loop. - android_atomic_acquire_store(0, &thread_data.state); - - ASSERT_TRUE(pthread_join(thread, nullptr) == 0); -} - -TEST(libbacktrace, check_for_leak_remote) { - pid_t pid; - - if ((pid = fork()) == 0) { - while (true) { - } - _exit(0); - } - ASSERT_LT(0, pid); - - ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0); - - // Wait for the process to get to a stopping point. - WaitForStop(pid); - - CheckForLeak(pid, BACKTRACE_CURRENT_THREAD); - - ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0); - - kill(pid, SIGKILL); - ASSERT_EQ(waitpid(pid, nullptr, 0), pid); -} -#endif diff --git a/app/src/main/jni/crash_dump/libbacktrace/backtrace_testlib.c b/app/src/main/jni/crash_dump/libbacktrace/backtrace_testlib.c deleted file mode 100644 index d4d15dbba..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/backtrace_testlib.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -int test_level_four(int one, int two, int three, int four, - void (*callback_func)(void*), void* data) { - if (callback_func != NULL) { - callback_func(data); - } else { - while (1) { - } - } - return one + two + three + four; -} - -int test_level_three(int one, int two, int three, int four, - void (*callback_func)(void*), void* data) { - return test_level_four(one+3, two+6, three+9, four+12, callback_func, data) + 3; -} - -int test_level_two(int one, int two, int three, int four, - void (*callback_func)(void*), void* data) { - return test_level_three(one+2, two+4, three+6, four+8, callback_func, data) + 2; -} - -int test_level_one(int one, int two, int three, int four, - void (*callback_func)(void*), void* data) { - return test_level_two(one+1, two+2, three+3, four+4, callback_func, data) + 1; -} - -int test_recursive_call(int level, void (*callback_func)(void*), void* data) { - if (level > 0) { - return test_recursive_call(level - 1, callback_func, data) + level; - } else if (callback_func != NULL) { - callback_func(data); - } else { - while (1) { - } - } - return 0; -} diff --git a/app/src/main/jni/crash_dump/libbacktrace/thread_utils.c b/app/src/main/jni/crash_dump/libbacktrace/thread_utils.c deleted file mode 100644 index e75f56e39..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/thread_utils.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "thread_utils.h" - -#if !defined(__BIONIC__) - -// glibc doesn't implement or export tgkill. -#include -#include - -int tgkill(int tgid, int tid, int sig) { - return syscall(__NR_tgkill, tgid, tid, sig); -} - -#endif diff --git a/app/src/main/jni/crash_dump/libbacktrace/thread_utils.h b/app/src/main/jni/crash_dump/libbacktrace/thread_utils.h deleted file mode 100644 index 9590657e3..000000000 --- a/app/src/main/jni/crash_dump/libbacktrace/thread_utils.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LIBBACKTRACE_THREAD_UTILS_H -#define _LIBBACKTRACE_THREAD_UTILS_H - -#include - -#if !defined(__ANDROID__) -#include -#endif - -__BEGIN_DECLS - -int tgkill(int tgid, int tid, int sig); - -__END_DECLS - -#endif /* _LIBBACKTRACE_THREAD_UTILS_H */ diff --git a/app/src/main/jni/crash_dump/libbase/.clang-format b/app/src/main/jni/crash_dump/libbase/.clang-format deleted file mode 100644 index 2b83a1f41..000000000 --- a/app/src/main/jni/crash_dump/libbase/.clang-format +++ /dev/null @@ -1,11 +0,0 @@ -BasedOnStyle: Google -AllowShortBlocksOnASingleLine: false -AllowShortFunctionsOnASingleLine: false - -CommentPragmas: NOLINT:.* -DerivePointerAlignment: false -IndentWidth: 2 -PointerAlignment: Left -TabWidth: 2 -UseTab: Never -PenaltyExcessCharacter: 32 diff --git a/app/src/main/jni/crash_dump/libbase/Android.mk b/app/src/main/jni/crash_dump/libbase/Android.mk deleted file mode 100644 index 5e929491e..000000000 --- a/app/src/main/jni/crash_dump/libbase/Android.mk +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright (C) 2015 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -LOCAL_PATH := $(call my-dir) - -libbase_src_files := \ - file.cpp \ - logging.cpp \ - parsenetaddress.cpp \ - stringprintf.cpp \ - strings.cpp \ - test_utils.cpp \ - -libbase_cppflags := \ - -Wall \ - -Wextra \ - -Werror \ - -libbase_linux_cppflags := \ - -Wexit-time-destructors \ - -libbase_darwin_cppflags := \ - -Wexit-time-destructors \ - -# Device -# ------------------------------------------------------------------------------ -include $(CLEAR_VARS) -LOCAL_MODULE := libcrashdumpbase_static -LOCAL_CLANG := true -LOCAL_SRC_FILES := $(libbase_src_files) $(libbase_linux_src_files) -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_CPPFLAGS := $(libbase_cppflags) $(libbase_linux_cppflags) -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include -LOCAL_LDLIBS := -llog -LOCAL_MULTILIB := both -include $(BUILD_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libcrashdumpbase -LOCAL_CLANG := true -LOCAL_WHOLE_STATIC_LIBRARIES := libcrashdumpbase_static -LOCAL_LDLIBS := -llog -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include -LOCAL_MULTILIB := both -include $(BUILD_SHARED_LIBRARY) - diff --git a/app/src/main/jni/crash_dump/libbase/CPPLINT.cfg b/app/src/main/jni/crash_dump/libbase/CPPLINT.cfg deleted file mode 100644 index d94a89c34..000000000 --- a/app/src/main/jni/crash_dump/libbase/CPPLINT.cfg +++ /dev/null @@ -1,2 +0,0 @@ -set noparent -filter=-build/header_guard,-build/include,-build/c++11,-whitespace/operators diff --git a/app/src/main/jni/crash_dump/libbase/errors_test.cpp b/app/src/main/jni/crash_dump/libbase/errors_test.cpp deleted file mode 100644 index 8e7cdd1da..000000000 --- a/app/src/main/jni/crash_dump/libbase/errors_test.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/errors.h" - -#include - -namespace android { -namespace base { - -// Error strings aren't consistent enough across systems to test the output, -// just make sure we can compile correctly and nothing crashes even if we send -// it possibly bogus error codes. -TEST(ErrorsTest, TestSystemErrorString) { - SystemErrorCodeToString(-1); - SystemErrorCodeToString(0); - SystemErrorCodeToString(1); -} - -} // namespace base -} // namespace android diff --git a/app/src/main/jni/crash_dump/libbase/errors_unix.cpp b/app/src/main/jni/crash_dump/libbase/errors_unix.cpp deleted file mode 100644 index 296995efe..000000000 --- a/app/src/main/jni/crash_dump/libbase/errors_unix.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/errors.h" - -#include - -namespace android { -namespace base { - -std::string SystemErrorCodeToString(int error_code) { - return strerror(error_code); -} - -} // namespace base -} // namespace android diff --git a/app/src/main/jni/crash_dump/libbase/errors_windows.cpp b/app/src/main/jni/crash_dump/libbase/errors_windows.cpp deleted file mode 100644 index a5ff51188..000000000 --- a/app/src/main/jni/crash_dump/libbase/errors_windows.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/errors.h" - -#include - -#include "android-base/stringprintf.h" -#include "android-base/strings.h" -#include "android-base/utf8.h" - -// A Windows error code is a DWORD. It's simpler to use an int error code for -// both Unix and Windows if possible, but if this fails we'll need a different -// function signature for each. -static_assert(sizeof(int) >= sizeof(DWORD), - "Windows system error codes are too large to fit in an int."); - -namespace android { -namespace base { - -static constexpr DWORD kErrorMessageBufferSize = 256; - -std::string SystemErrorCodeToString(int int_error_code) { - WCHAR msgbuf[kErrorMessageBufferSize]; - DWORD error_code = int_error_code; - DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; - DWORD len = FormatMessageW(flags, nullptr, error_code, 0, msgbuf, - kErrorMessageBufferSize, nullptr); - if (len == 0) { - return android::base::StringPrintf( - "Error %lu while retrieving message for error %lu", GetLastError(), - error_code); - } - - // Convert UTF-16 to UTF-8. - std::string msg; - if (!android::base::WideToUTF8(msgbuf, &msg)) { - return android::base::StringPrintf( - "Error %lu while converting message for error %lu from UTF-16 to UTF-8", - GetLastError(), error_code); - } - - // Messages returned by the system end with line breaks. - msg = android::base::Trim(msg); - - // There are many Windows error messages compared to POSIX, so include the - // numeric error code for easier, quicker, accurate identification. Use - // decimal instead of hex because there are decimal ranges like 10000-11999 - // for Winsock. - android::base::StringAppendF(&msg, " (%lu)", error_code); - return msg; -} - -} // namespace base -} // namespace android diff --git a/app/src/main/jni/crash_dump/libbase/file.cpp b/app/src/main/jni/crash_dump/libbase/file.cpp deleted file mode 100644 index da1adba19..000000000 --- a/app/src/main/jni/crash_dump/libbase/file.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/file.h" - -#include -#include -#include -#include - -#include - -#include "android-base/macros.h" // For TEMP_FAILURE_RETRY on Darwin. -#include "android-base/utf8.h" -#define LOG_TAG "base.file" -#include "cutils/log.h" -#include "utils/Compat.h" - -namespace android { -namespace base { - -// Versions of standard library APIs that support UTF-8 strings. -using namespace android::base::utf8; - -bool ReadFdToString(int fd, std::string* content) { - content->clear(); - - char buf[BUFSIZ]; - ssize_t n; - while ((n = TEMP_FAILURE_RETRY(read(fd, &buf[0], sizeof(buf)))) > 0) { - content->append(buf, n); - } - return (n == 0) ? true : false; -} - -bool ReadFileToString(const std::string& path, std::string* content) { - content->clear(); - - int fd = TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_CLOEXEC | O_NOFOLLOW | O_BINARY)); - if (fd == -1) { - return false; - } - bool result = ReadFdToString(fd, content); - close(fd); - return result; -} - -bool WriteStringToFd(const std::string& content, int fd) { - const char* p = content.data(); - size_t left = content.size(); - while (left > 0) { - ssize_t n = TEMP_FAILURE_RETRY(write(fd, p, left)); - if (n == -1) { - return false; - } - p += n; - left -= n; - } - return true; -} - -static bool CleanUpAfterFailedWrite(const std::string& path) { - // Something went wrong. Let's not leave a corrupt file lying around. - int saved_errno = errno; - unlink(path.c_str()); - errno = saved_errno; - return false; -} - -#if !defined(_WIN32) -bool WriteStringToFile(const std::string& content, const std::string& path, - mode_t mode, uid_t owner, gid_t group) { - int flags = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_BINARY; - int fd = TEMP_FAILURE_RETRY(open(path.c_str(), flags, mode)); - if (fd == -1) { - ALOGE("android::WriteStringToFile open failed: %s", strerror(errno)); - return false; - } - - // We do an explicit fchmod here because we assume that the caller really - // meant what they said and doesn't want the umask-influenced mode. - if (fchmod(fd, mode) == -1) { - ALOGE("android::WriteStringToFile fchmod failed: %s", strerror(errno)); - return CleanUpAfterFailedWrite(path); - } - if (fchown(fd, owner, group) == -1) { - ALOGE("android::WriteStringToFile fchown failed: %s", strerror(errno)); - return CleanUpAfterFailedWrite(path); - } - if (!WriteStringToFd(content, fd)) { - ALOGE("android::WriteStringToFile write failed: %s", strerror(errno)); - return CleanUpAfterFailedWrite(path); - } - close(fd); - return true; -} -#endif - -bool WriteStringToFile(const std::string& content, const std::string& path) { - int flags = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_BINARY; - int fd = TEMP_FAILURE_RETRY(open(path.c_str(), flags, DEFFILEMODE)); - if (fd == -1) { - return false; - } - - bool result = WriteStringToFd(content, fd); - close(fd); - return result || CleanUpAfterFailedWrite(path); -} - -bool ReadFully(int fd, void* data, size_t byte_count) { - uint8_t* p = reinterpret_cast(data); - size_t remaining = byte_count; - while (remaining > 0) { - ssize_t n = TEMP_FAILURE_RETRY(read(fd, p, remaining)); - if (n <= 0) return false; - p += n; - remaining -= n; - } - return true; -} - -bool WriteFully(int fd, const void* data, size_t byte_count) { - const uint8_t* p = reinterpret_cast(data); - size_t remaining = byte_count; - while (remaining > 0) { - ssize_t n = TEMP_FAILURE_RETRY(write(fd, p, remaining)); - if (n == -1) return false; - p += n; - remaining -= n; - } - return true; -} - -bool RemoveFileIfExists(const std::string& path, std::string* err) { - struct stat st; -#if defined(_WIN32) - //TODO: Windows version can't handle symbol link correctly. - int result = stat(path.c_str(), &st); - bool file_type_removable = (result == 0 && S_ISREG(st.st_mode)); -#else - int result = lstat(path.c_str(), &st); - bool file_type_removable = (result == 0 && (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))); -#endif - if (result == 0) { - if (!file_type_removable) { - if (err != nullptr) { - *err = "is not a regular or symbol link file"; - } - return false; - } - if (unlink(path.c_str()) == -1) { - if (err != nullptr) { - *err = strerror(errno); - } - return false; - } - } - return true; -} - -} // namespace base -} // namespace android diff --git a/app/src/main/jni/crash_dump/libbase/file_test.cpp b/app/src/main/jni/crash_dump/libbase/file_test.cpp deleted file mode 100644 index 17755bfed..000000000 --- a/app/src/main/jni/crash_dump/libbase/file_test.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/file.h" - -#include - -#include -#include -#include - -#include - -#include "android-base/test_utils.h" - -TEST(file, ReadFileToString_ENOENT) { - std::string s("hello"); - errno = 0; - ASSERT_FALSE(android::base::ReadFileToString("/proc/does-not-exist", &s)); - EXPECT_EQ(ENOENT, errno); - EXPECT_EQ("", s); // s was cleared. -} - -TEST(file, ReadFileToString_WriteStringToFile) { - TemporaryFile tf; - ASSERT_TRUE(tf.fd != -1); - ASSERT_TRUE(android::base::WriteStringToFile("abc", tf.path)) - << strerror(errno); - std::string s; - ASSERT_TRUE(android::base::ReadFileToString(tf.path, &s)) - << strerror(errno); - EXPECT_EQ("abc", s); -} - -// WriteStringToFile2 is explicitly for setting Unix permissions, which make no -// sense on Windows. -#if !defined(_WIN32) -TEST(file, WriteStringToFile2) { - TemporaryFile tf; - ASSERT_TRUE(tf.fd != -1); - ASSERT_TRUE(android::base::WriteStringToFile("abc", tf.path, 0660, - getuid(), getgid())) - << strerror(errno); - struct stat sb; - ASSERT_EQ(0, stat(tf.path, &sb)); - ASSERT_EQ(0660U, static_cast(sb.st_mode & ~S_IFMT)); - ASSERT_EQ(getuid(), sb.st_uid); - ASSERT_EQ(getgid(), sb.st_gid); - std::string s; - ASSERT_TRUE(android::base::ReadFileToString(tf.path, &s)) - << strerror(errno); - EXPECT_EQ("abc", s); -} -#endif - -TEST(file, WriteStringToFd) { - TemporaryFile tf; - ASSERT_TRUE(tf.fd != -1); - ASSERT_TRUE(android::base::WriteStringToFd("abc", tf.fd)); - - ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_SET)) << strerror(errno); - - std::string s; - ASSERT_TRUE(android::base::ReadFdToString(tf.fd, &s)) << strerror(errno); - EXPECT_EQ("abc", s); -} - -TEST(file, WriteFully) { - TemporaryFile tf; - ASSERT_TRUE(tf.fd != -1); - ASSERT_TRUE(android::base::WriteFully(tf.fd, "abc", 3)); - - ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_SET)) << strerror(errno); - - std::string s; - s.resize(3); - ASSERT_TRUE(android::base::ReadFully(tf.fd, &s[0], s.size())) - << strerror(errno); - EXPECT_EQ("abc", s); - - ASSERT_EQ(0, lseek(tf.fd, 0, SEEK_SET)) << strerror(errno); - - s.resize(1024); - ASSERT_FALSE(android::base::ReadFully(tf.fd, &s[0], s.size())); -} - -TEST(file, RemoveFileIfExist) { - TemporaryFile tf; - ASSERT_TRUE(tf.fd != -1); - close(tf.fd); - tf.fd = -1; - std::string err; - ASSERT_TRUE(android::base::RemoveFileIfExists(tf.path, &err)) << err; - ASSERT_TRUE(android::base::RemoveFileIfExists(tf.path)); - TemporaryDir td; - ASSERT_FALSE(android::base::RemoveFileIfExists(td.path)); - ASSERT_FALSE(android::base::RemoveFileIfExists(td.path, &err)); - ASSERT_EQ("is not a regular or symbol link file", err); -} diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/errors.h b/app/src/main/jni/crash_dump/libbase/include/android-base/errors.h deleted file mode 100644 index 04c299c86..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/errors.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Portable error handling functions. This is only necessary for host-side -// code that needs to be cross-platform; code that is only run on Unix should -// just use errno and strerror() for simplicity. -// -// There is some complexity since Windows has (at least) three different error -// numbers, not all of which share the same type: -// * errno: for C runtime errors. -// * GetLastError(): Windows non-socket errors. -// * WSAGetLastError(): Windows socket errors. -// errno can be passed to strerror() on all platforms, but the other two require -// special handling to get the error string. Refer to Microsoft documentation -// to determine which error code to check for each function. - -#ifndef ANDROID_BASE_ERRORS_H -#define ANDROID_BASE_ERRORS_H - -#include - -namespace android { -namespace base { - -// Returns a string describing the given system error code. |error_code| must -// be errno on Unix or GetLastError()/WSAGetLastError() on Windows. Passing -// errno on Windows has undefined behavior. -std::string SystemErrorCodeToString(int error_code); - -} // namespace base -} // namespace android - -#endif // ANDROID_BASE_ERRORS_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/file.h b/app/src/main/jni/crash_dump/libbase/include/android-base/file.h deleted file mode 100644 index aa18ea796..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/file.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_FILE_H -#define ANDROID_BASE_FILE_H - -#include -#include - -#if !defined(_WIN32) && !defined(O_BINARY) -#define O_BINARY 0 -#endif - -namespace android { -namespace base { - -bool ReadFdToString(int fd, std::string* content); -bool ReadFileToString(const std::string& path, std::string* content); - -bool WriteStringToFile(const std::string& content, const std::string& path); -bool WriteStringToFd(const std::string& content, int fd); - -#if !defined(_WIN32) -bool WriteStringToFile(const std::string& content, const std::string& path, - mode_t mode, uid_t owner, gid_t group); -#endif - -bool ReadFully(int fd, void* data, size_t byte_count); -bool WriteFully(int fd, const void* data, size_t byte_count); - -bool RemoveFileIfExists(const std::string& path, std::string* err = nullptr); - -} // namespace base -} // namespace android - -#endif // ANDROID_BASE_FILE_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/logging.h b/app/src/main/jni/crash_dump/libbase/include/android-base/logging.h deleted file mode 100644 index d3f9d0cdc..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/logging.h +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_LOGGING_H -#define ANDROID_BASE_LOGGING_H - -// NOTE: For Windows, you must include logging.h after windows.h to allow the -// following code to suppress the evil ERROR macro: -#ifdef _WIN32 -// windows.h includes wingdi.h which defines an evil macro ERROR. -#ifdef ERROR -#undef ERROR -#endif -#endif - -#include -#include -#include - -#include "android-base/macros.h" - -namespace android { -namespace base { - -enum LogSeverity { - VERBOSE, - DEBUG, - INFO, - WARNING, - ERROR, - FATAL, -}; - -enum LogId { - DEFAULT, - MAIN, - SYSTEM, -}; - -typedef std::function LogFunction; - -extern void StderrLogger(LogId, LogSeverity, const char*, const char*, - unsigned int, const char*); - -#ifdef __ANDROID__ -// We expose this even though it is the default because a user that wants to -// override the default log buffer will have to construct this themselves. -class LogdLogger { - public: - explicit LogdLogger(LogId default_log_id = android::base::MAIN); - - void operator()(LogId, LogSeverity, const char* tag, const char* file, - unsigned int line, const char* message); - - private: - LogId default_log_id_; -}; -#endif - -// Configure logging based on ANDROID_LOG_TAGS environment variable. -// We need to parse a string that looks like -// -// *:v jdwp:d dalvikvm:d dalvikvm-gc:i dalvikvmi:i -// -// The tag (or '*' for the global level) comes first, followed by a colon and a -// letter indicating the minimum priority level we're expected to log. This can -// be used to reveal or conceal logs with specific tags. -extern void InitLogging(char* argv[], LogFunction&& logger); - -// Configures logging using the default logger (logd for the device, stderr for -// the host). -extern void InitLogging(char* argv[]); - -// Replace the current logger. -extern void SetLogger(LogFunction&& logger); - -// Get the minimum severity level for logging. -extern LogSeverity GetMinimumLogSeverity(); - -class ErrnoRestorer { - public: - ErrnoRestorer() - : saved_errno_(errno) { - } - - ~ErrnoRestorer() { - errno = saved_errno_; - } - - // Allow this object to be used as part of && operation. - operator bool() const { - return true; - } - - private: - const int saved_errno_; - - DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer); -}; - -// Logs a message to logcat on Android otherwise to stderr. If the severity is -// FATAL it also causes an abort. For example: -// -// LOG(FATAL) << "We didn't expect to reach here"; -#define LOG(severity) LOG_TO(DEFAULT, severity) - -// Logs a message to logcat with the specified log ID on Android otherwise to -// stderr. If the severity is FATAL it also causes an abort. -// Use an if-else statement instead of just an if statement here. So if there is a -// else statement after LOG() macro, it won't bind to the if statement in the macro. -// do-while(0) statement doesn't work here. Because we need to support << operator -// following the macro, like "LOG(DEBUG) << xxx;". -#define LOG_TO(dest, severity) \ - UNLIKELY(::android::base::severity >= ::android::base::GetMinimumLogSeverity()) && \ - ::android::base::ErrnoRestorer() && \ - ::android::base::LogMessage(__FILE__, __LINE__, \ - ::android::base::dest, \ - ::android::base::severity, -1).stream() - -// A variant of LOG that also logs the current errno value. To be used when -// library calls fail. -#define PLOG(severity) PLOG_TO(DEFAULT, severity) - -// Behaves like PLOG, but logs to the specified log ID. -#define PLOG_TO(dest, severity) \ - UNLIKELY(::android::base::severity >= ::android::base::GetMinimumLogSeverity()) && \ - ::android::base::ErrnoRestorer() && \ - ::android::base::LogMessage(__FILE__, __LINE__, \ - ::android::base::dest, \ - ::android::base::severity, errno).stream() - -// Marker that code is yet to be implemented. -#define UNIMPLEMENTED(level) \ - LOG(level) << __PRETTY_FUNCTION__ << " unimplemented " - -// Check whether condition x holds and LOG(FATAL) if not. The value of the -// expression x is only evaluated once. Extra logging can be appended using << -// after. For example: -// -// CHECK(false == true) results in a log message of -// "Check failed: false == true". -#define CHECK(x) \ - LIKELY((x)) || \ - ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \ - ::android::base::FATAL, -1).stream() \ - << "Check failed: " #x << " " - -// Helper for CHECK_xx(x,y) macros. -#define CHECK_OP(LHS, RHS, OP) \ - for (auto _values = ::android::base::MakeEagerEvaluator(LHS, RHS); \ - UNLIKELY(!(_values.lhs OP _values.rhs)); \ - /* empty */) \ - ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \ - ::android::base::FATAL, -1).stream() \ - << "Check failed: " << #LHS << " " << #OP << " " << #RHS \ - << " (" #LHS "=" << _values.lhs << ", " #RHS "=" << _values.rhs << ") " - -// Check whether a condition holds between x and y, LOG(FATAL) if not. The value -// of the expressions x and y is evaluated once. Extra logging can be appended -// using << after. For example: -// -// CHECK_NE(0 == 1, false) results in -// "Check failed: false != false (0==1=false, false=false) ". -#define CHECK_EQ(x, y) CHECK_OP(x, y, == ) -#define CHECK_NE(x, y) CHECK_OP(x, y, != ) -#define CHECK_LE(x, y) CHECK_OP(x, y, <= ) -#define CHECK_LT(x, y) CHECK_OP(x, y, < ) -#define CHECK_GE(x, y) CHECK_OP(x, y, >= ) -#define CHECK_GT(x, y) CHECK_OP(x, y, > ) - -// Helper for CHECK_STRxx(s1,s2) macros. -#define CHECK_STROP(s1, s2, sense) \ - if (LIKELY((strcmp(s1, s2) == 0) == sense)) \ - ; \ - else \ - LOG(FATAL) << "Check failed: " \ - << "\"" << s1 << "\"" \ - << (sense ? " == " : " != ") << "\"" << s2 << "\"" - -// Check for string (const char*) equality between s1 and s2, LOG(FATAL) if not. -#define CHECK_STREQ(s1, s2) CHECK_STROP(s1, s2, true) -#define CHECK_STRNE(s1, s2) CHECK_STROP(s1, s2, false) - -// Perform the pthread function call(args), LOG(FATAL) on error. -#define CHECK_PTHREAD_CALL(call, args, what) \ - do { \ - int rc = call args; \ - if (rc != 0) { \ - errno = rc; \ - PLOG(FATAL) << #call << " failed for " << what; \ - } \ - } while (false) - -// CHECK that can be used in a constexpr function. For example: -// -// constexpr int half(int n) { -// return -// DCHECK_CONSTEXPR(n >= 0, , 0) -// CHECK_CONSTEXPR((n & 1) == 0), -// << "Extra debugging output: n = " << n, 0) -// n / 2; -// } -#define CHECK_CONSTEXPR(x, out, dummy) \ - (UNLIKELY(!(x))) \ - ? (LOG(FATAL) << "Check failed: " << #x out, dummy) \ - : - -// DCHECKs are debug variants of CHECKs only enabled in debug builds. Generally -// CHECK should be used unless profiling identifies a CHECK as being in -// performance critical code. -#if defined(NDEBUG) -static constexpr bool kEnableDChecks = false; -#else -static constexpr bool kEnableDChecks = true; -#endif - -#define DCHECK(x) \ - if (::android::base::kEnableDChecks) CHECK(x) -#define DCHECK_EQ(x, y) \ - if (::android::base::kEnableDChecks) CHECK_EQ(x, y) -#define DCHECK_NE(x, y) \ - if (::android::base::kEnableDChecks) CHECK_NE(x, y) -#define DCHECK_LE(x, y) \ - if (::android::base::kEnableDChecks) CHECK_LE(x, y) -#define DCHECK_LT(x, y) \ - if (::android::base::kEnableDChecks) CHECK_LT(x, y) -#define DCHECK_GE(x, y) \ - if (::android::base::kEnableDChecks) CHECK_GE(x, y) -#define DCHECK_GT(x, y) \ - if (::android::base::kEnableDChecks) CHECK_GT(x, y) -#define DCHECK_STREQ(s1, s2) \ - if (::android::base::kEnableDChecks) CHECK_STREQ(s1, s2) -#define DCHECK_STRNE(s1, s2) \ - if (::android::base::kEnableDChecks) CHECK_STRNE(s1, s2) -#if defined(NDEBUG) -#define DCHECK_CONSTEXPR(x, out, dummy) -#else -#define DCHECK_CONSTEXPR(x, out, dummy) CHECK_CONSTEXPR(x, out, dummy) -#endif - -// Temporary class created to evaluate the LHS and RHS, used with -// MakeEagerEvaluator to infer the types of LHS and RHS. -template -struct EagerEvaluator { - EagerEvaluator(LHS l, RHS r) : lhs(l), rhs(r) { - } - LHS lhs; - RHS rhs; -}; - -// Helper function for CHECK_xx. -template -static inline EagerEvaluator MakeEagerEvaluator(LHS lhs, RHS rhs) { - return EagerEvaluator(lhs, rhs); -} - -// Explicitly instantiate EagerEvalue for pointers so that char*s aren't treated -// as strings. To compare strings use CHECK_STREQ and CHECK_STRNE. We rely on -// signed/unsigned warnings to protect you against combinations not explicitly -// listed below. -#define EAGER_PTR_EVALUATOR(T1, T2) \ - template <> \ - struct EagerEvaluator { \ - EagerEvaluator(T1 l, T2 r) \ - : lhs(reinterpret_cast(l)), \ - rhs(reinterpret_cast(r)) { \ - } \ - const void* lhs; \ - const void* rhs; \ - } -EAGER_PTR_EVALUATOR(const char*, const char*); -EAGER_PTR_EVALUATOR(const char*, char*); -EAGER_PTR_EVALUATOR(char*, const char*); -EAGER_PTR_EVALUATOR(char*, char*); -EAGER_PTR_EVALUATOR(const unsigned char*, const unsigned char*); -EAGER_PTR_EVALUATOR(const unsigned char*, unsigned char*); -EAGER_PTR_EVALUATOR(unsigned char*, const unsigned char*); -EAGER_PTR_EVALUATOR(unsigned char*, unsigned char*); -EAGER_PTR_EVALUATOR(const signed char*, const signed char*); -EAGER_PTR_EVALUATOR(const signed char*, signed char*); -EAGER_PTR_EVALUATOR(signed char*, const signed char*); -EAGER_PTR_EVALUATOR(signed char*, signed char*); - -// Data for the log message, not stored in LogMessage to avoid increasing the -// stack size. -class LogMessageData; - -// A LogMessage is a temporarily scoped object used by LOG and the unlikely part -// of a CHECK. The destructor will abort if the severity is FATAL. -class LogMessage { - public: - LogMessage(const char* file, unsigned int line, LogId id, - LogSeverity severity, int error); - - ~LogMessage(); - - // Returns the stream associated with the message, the LogMessage performs - // output when it goes out of scope. - std::ostream& stream(); - - // The routine that performs the actual logging. - static void LogLine(const char* file, unsigned int line, LogId id, - LogSeverity severity, const char* msg); - - private: - const std::unique_ptr data_; - - DISALLOW_COPY_AND_ASSIGN(LogMessage); -}; - -// Allows to temporarily change the minimum severity level for logging. -class ScopedLogSeverity { - public: - explicit ScopedLogSeverity(LogSeverity level); - ~ScopedLogSeverity(); - - private: - LogSeverity old_; -}; - -} // namespace base -} // namespace android - -#endif // ANDROID_BASE_LOGGING_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/macros.h b/app/src/main/jni/crash_dump/libbase/include/android-base/macros.h deleted file mode 100644 index 913a9a03e..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/macros.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_MACROS_H -#define ANDROID_BASE_MACROS_H - -#include // for size_t -#include // for TEMP_FAILURE_RETRY - -// bionic and glibc both have TEMP_FAILURE_RETRY, but eg Mac OS' libc doesn't. -#ifndef TEMP_FAILURE_RETRY -#define TEMP_FAILURE_RETRY(exp) \ - ({ \ - decltype(exp) _rc; \ - do { \ - _rc = (exp); \ - } while (_rc == -1 && errno == EINTR); \ - _rc; \ - }) -#endif - -// A macro to disallow the copy constructor and operator= functions -// This must be placed in the private: declarations for a class. -// -// For disallowing only assign or copy, delete the relevant operator or -// constructor, for example: -// void operator=(const TypeName&) = delete; -// Note, that most uses of DISALLOW_ASSIGN and DISALLOW_COPY are broken -// semantically, one should either use disallow both or neither. Try to -// avoid these in new code. -// -// When building with C++11 toolchains, just use the language support -// for explicitly deleted methods. -#if __cplusplus >= 201103L -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&) = delete; \ - void operator=(const TypeName&) = delete -#else -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&) -#endif - -// A macro to disallow all the implicit constructors, namely the -// default constructor, copy constructor and operator= functions. -// -// This should be used in the private: declarations for a class -// that wants to prevent anyone from instantiating it. This is -// especially useful for classes containing only static methods. -#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ - TypeName(); \ - DISALLOW_COPY_AND_ASSIGN(TypeName) - -// The arraysize(arr) macro returns the # of elements in an array arr. -// The expression is a compile-time constant, and therefore can be -// used in defining new arrays, for example. If you use arraysize on -// a pointer by mistake, you will get a compile-time error. -// -// One caveat is that arraysize() doesn't accept any array of an -// anonymous type or a type defined inside a function. In these rare -// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is -// due to a limitation in C++'s template system. The limitation might -// eventually be removed, but it hasn't happened yet. - -// This template function declaration is used in defining arraysize. -// Note that the function doesn't need an implementation, as we only -// use its type. -template -char(&ArraySizeHelper(T(&array)[N]))[N]; // NOLINT(readability/casting) - -#define arraysize(array) (sizeof(ArraySizeHelper(array))) - -// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize, -// but can be used on anonymous types or types defined inside -// functions. It's less safe than arraysize as it accepts some -// (although not all) pointers. Therefore, you should use arraysize -// whenever possible. -// -// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type -// size_t. -// -// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error -// -// "warning: division by zero in ..." -// -// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer. -// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays. -// -// The following comments are on the implementation details, and can -// be ignored by the users. -// -// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in -// the array) and sizeof(*(arr)) (the # of bytes in one array -// element). If the former is divisible by the latter, perhaps arr is -// indeed an array, in which case the division result is the # of -// elements in the array. Otherwise, arr cannot possibly be an array, -// and we generate a compiler error to prevent the code from -// compiling. -// -// Since the size of bool is implementation-defined, we need to cast -// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final -// result has type size_t. -// -// This macro is not perfect as it wrongfully accepts certain -// pointers, namely where the pointer size is divisible by the pointee -// size. Since all our code has to go through a 32-bit compiler, -// where a pointer is 4 bytes, this means all pointers to a type whose -// size is 3 or greater than 4 will be (righteously) rejected. -#define ARRAYSIZE_UNSAFE(a) \ - ((sizeof(a) / sizeof(*(a))) / \ - static_cast(!(sizeof(a) % sizeof(*(a))))) - -#define LIKELY(x) __builtin_expect((x), true) -#define UNLIKELY(x) __builtin_expect((x), false) - -#define WARN_UNUSED __attribute__((warn_unused_result)) - -// A deprecated function to call to create a false use of the parameter, for -// example: -// int foo(int x) { UNUSED(x); return 10; } -// to avoid compiler warnings. Going forward we prefer ATTRIBUTE_UNUSED. -template -void UNUSED(const T&...) { -} - -// An attribute to place on a parameter to a function, for example: -// int foo(int x ATTRIBUTE_UNUSED) { return 10; } -// to avoid compiler warnings. -#define ATTRIBUTE_UNUSED __attribute__((__unused__)) - -// The FALLTHROUGH_INTENDED macro can be used to annotate implicit fall-through -// between switch labels: -// switch (x) { -// case 40: -// case 41: -// if (truth_is_out_there) { -// ++x; -// FALLTHROUGH_INTENDED; // Use instead of/along with annotations in -// // comments. -// } else { -// return x; -// } -// case 42: -// ... -// -// As shown in the example above, the FALLTHROUGH_INTENDED macro should be -// followed by a semicolon. It is designed to mimic control-flow statements -// like 'break;', so it can be placed in most places where 'break;' can, but -// only if there are no statements on the execution path between it and the -// next switch label. -// -// When compiled with clang in C++11 mode, the FALLTHROUGH_INTENDED macro is -// expanded to [[clang::fallthrough]] attribute, which is analysed when -// performing switch labels fall-through diagnostic ('-Wimplicit-fallthrough'). -// See clang documentation on language extensions for details: -// http://clang.llvm.org/docs/LanguageExtensions.html#clang__fallthrough -// -// When used with unsupported compilers, the FALLTHROUGH_INTENDED macro has no -// effect on diagnostics. -// -// In either case this macro has no effect on runtime behavior and performance -// of code. -#if defined(__clang__) && __cplusplus >= 201103L && defined(__has_warning) -#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") -#define FALLTHROUGH_INTENDED [[clang::fallthrough]] // NOLINT -#endif -#endif - -#ifndef FALLTHROUGH_INTENDED -#define FALLTHROUGH_INTENDED \ - do { \ - } while (0) -#endif - -#endif // ANDROID_BASE_MACROS_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/memory.h b/app/src/main/jni/crash_dump/libbase/include/android-base/memory.h deleted file mode 100644 index 3a2f8fad6..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/memory.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_MEMORY_H -#define ANDROID_BASE_MEMORY_H - -namespace android { -namespace base { - -// Use packed structures for access to unaligned data on targets with alignment -// restrictions. The compiler will generate appropriate code to access these -// structures without generating alignment exceptions. -template -static inline T get_unaligned(const T* address) { - struct unaligned { - T v; - } __attribute__((packed)); - const unaligned* p = reinterpret_cast(address); - return p->v; -} - -template -static inline void put_unaligned(T* address, T v) { - struct unaligned { - T v; - } __attribute__((packed)); - unaligned* p = reinterpret_cast(address); - p->v = v; -} - -} // namespace base -} // namespace android - -#endif // ANDROID_BASE_MEMORY_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/parseint.h b/app/src/main/jni/crash_dump/libbase/include/android-base/parseint.h deleted file mode 100644 index ed75e2d48..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/parseint.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_PARSEINT_H -#define ANDROID_BASE_PARSEINT_H - -#include -#include - -#include - -namespace android { -namespace base { - -// Parses the unsigned decimal integer in the string 's' and sets 'out' to -// that value. Optionally allows the caller to define a 'max' beyond which -// otherwise valid values will be rejected. Returns boolean success. -template -bool ParseUint(const char* s, T* out, - T max = std::numeric_limits::max()) { - int base = (s[0] == '0' && s[1] == 'x') ? 16 : 10; - errno = 0; - char* end; - unsigned long long int result = strtoull(s, &end, base); - if (errno != 0 || s == end || *end != '\0') { - return false; - } - if (max < result) { - return false; - } - *out = static_cast(result); - return true; -} - -// Parses the signed decimal integer in the string 's' and sets 'out' to -// that value. Optionally allows the caller to define a 'min' and 'max -// beyond which otherwise valid values will be rejected. Returns boolean -// success. -template -bool ParseInt(const char* s, T* out, - T min = std::numeric_limits::min(), - T max = std::numeric_limits::max()) { - int base = (s[0] == '0' && s[1] == 'x') ? 16 : 10; - errno = 0; - char* end; - long long int result = strtoll(s, &end, base); - if (errno != 0 || s == end || *end != '\0') { - return false; - } - if (result < min || max < result) { - return false; - } - *out = static_cast(result); - return true; -} - -} // namespace base -} // namespace android - -#endif // ANDROID_BASE_PARSEINT_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/parsenetaddress.h b/app/src/main/jni/crash_dump/libbase/include/android-base/parsenetaddress.h deleted file mode 100644 index b4ac0256b..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/parsenetaddress.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_PARSENETADDRESS_H -#define ANDROID_BASE_PARSENETADDRESS_H - -#include - -namespace android { -namespace base { - -// Parses |address| into |host| and |port|. -// -// If |address| doesn't contain a port number, the default value is taken from -// |port|. If |canonical_address| is non-null it will be set to "host:port" or -// "[host]:port" as appropriate. -// -// On failure, returns false and fills |error|. -bool ParseNetAddress(const std::string& address, std::string* host, int* port, - std::string* canonical_address, std::string* error); - -} // namespace base -} // namespace android - -#endif // ANDROID_BASE_PARSENETADDRESS_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/stringprintf.h b/app/src/main/jni/crash_dump/libbase/include/android-base/stringprintf.h deleted file mode 100644 index cf666abe0..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/stringprintf.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_STRINGPRINTF_H -#define ANDROID_BASE_STRINGPRINTF_H - -#include -#include - -namespace android { -namespace base { - -// These printf-like functions are implemented in terms of vsnprintf, so they -// use the same attribute for compile-time format string checking. On Windows, -// if the mingw version of vsnprintf is used, use `gnu_printf' which allows z -// in %zd and PRIu64 (and related) to be recognized by the compile-time -// checking. -#define FORMAT_ARCHETYPE __printf__ -#ifdef __USE_MINGW_ANSI_STDIO -#if __USE_MINGW_ANSI_STDIO -#undef FORMAT_ARCHETYPE -#define FORMAT_ARCHETYPE gnu_printf -#endif -#endif - -// Returns a string corresponding to printf-like formatting of the arguments. -std::string StringPrintf(const char* fmt, ...) - __attribute__((__format__(FORMAT_ARCHETYPE, 1, 2))); - -// Appends a printf-like formatting of the arguments to 'dst'. -void StringAppendF(std::string* dst, const char* fmt, ...) - __attribute__((__format__(FORMAT_ARCHETYPE, 2, 3))); - -// Appends a printf-like formatting of the arguments to 'dst'. -void StringAppendV(std::string* dst, const char* format, va_list ap) - __attribute__((__format__(FORMAT_ARCHETYPE, 2, 0))); - -#undef FORMAT_ARCHETYPE - -} // namespace base -} // namespace android - -#endif // ANDROID_BASE_STRINGPRINTF_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/strings.h b/app/src/main/jni/crash_dump/libbase/include/android-base/strings.h deleted file mode 100644 index 69781cd40..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/strings.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_STRINGS_H -#define ANDROID_BASE_STRINGS_H - -#include -#include -#include - -namespace android { -namespace base { - -// Splits a string into a vector of strings. -// -// The string is split at each occurrence of a character in delimiters. -// -// The empty string is not a valid delimiter list. -std::vector Split(const std::string& s, - const std::string& delimiters); - -// Trims whitespace off both ends of the given string. -std::string Trim(const std::string& s); - -// Joins a container of things into a single string, using the given separator. -template -std::string Join(const ContainerT& things, SeparatorT separator) { - if (things.empty()) { - return ""; - } - - std::ostringstream result; - result << *things.begin(); - for (auto it = std::next(things.begin()); it != things.end(); ++it) { - result << separator << *it; - } - return result.str(); -} - -// We instantiate the common cases in strings.cpp. -extern template std::string Join(const std::vector&, char); -extern template std::string Join(const std::vector&, char); -extern template std::string Join(const std::vector&, const std::string&); -extern template std::string Join(const std::vector&, const std::string&); - -// Tests whether 's' starts with 'prefix'. -bool StartsWith(const std::string& s, const char* prefix); - -// Tests whether 's' ends with 'suffix'. -bool EndsWith(const std::string& s, const char* suffix); - -} // namespace base -} // namespace android - -#endif // ANDROID_BASE_STRINGS_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/test_utils.h b/app/src/main/jni/crash_dump/libbase/include/android-base/test_utils.h deleted file mode 100644 index 4ea3c8e48..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/test_utils.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_TEST_UTILS_H -#define ANDROID_BASE_TEST_UTILS_H - -#include - -#include - -class TemporaryFile { - public: - TemporaryFile(); - ~TemporaryFile(); - - int fd; - char path[1024]; - - private: - void init(const std::string& tmp_dir); - - DISALLOW_COPY_AND_ASSIGN(TemporaryFile); -}; - -class TemporaryDir { - public: - TemporaryDir(); - ~TemporaryDir(); - - char path[1024]; - - private: - bool init(const std::string& tmp_dir); - - DISALLOW_COPY_AND_ASSIGN(TemporaryDir); -}; - -#endif // ANDROID_BASE_TEST_UTILS_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/thread_annotations.h b/app/src/main/jni/crash_dump/libbase/include/android-base/thread_annotations.h deleted file mode 100644 index 24221024c..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/thread_annotations.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_THREAD_ANNOTATIONS_H -#define ANDROID_BASE_THREAD_ANNOTATIONS_H - -#if defined(__SUPPORT_TS_ANNOTATION__) || defined(__clang__) -#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) -#else -#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op -#endif - -#define CAPABILITY(x) \ - THREAD_ANNOTATION_ATTRIBUTE__(capability(x)) - -#define SCOPED_CAPABILITY \ - THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) - -#define GUARDED_BY(x) \ - THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) - -#define PT_GUARDED_BY(x) \ - THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) - -#define ACQUIRED_BEFORE(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__)) - -#define ACQUIRED_AFTER(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__)) - -#define REQUIRES(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__)) - -#define REQUIRES_SHARED(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__)) - -#define ACQUIRE(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__)) - -#define ACQUIRE_SHARED(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__)) - -#define RELEASE(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__)) - -#define RELEASE_SHARED(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__)) - -#define TRY_ACQUIRE(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__)) - -#define TRY_ACQUIRE_SHARED(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__)) - -#define EXCLUDES(...) \ - THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) - -#define ASSERT_CAPABILITY(x) \ - THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) - -#define ASSERT_SHARED_CAPABILITY(x) \ - THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) - -#define RETURN_CAPABILITY(x) \ - THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) - -#define NO_THREAD_SAFETY_ANALYSIS \ - THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) - -#endif // ANDROID_BASE_THREAD_ANNOTATIONS_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/unique_fd.h b/app/src/main/jni/crash_dump/libbase/include/android-base/unique_fd.h deleted file mode 100644 index 869e60f58..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/unique_fd.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_UNIQUE_FD_H -#define ANDROID_BASE_UNIQUE_FD_H - -#include - -// DO NOT INCLUDE OTHER LIBBASE HEADERS! -// This file gets used in libbinder, and libbinder is used everywhere. -// Including other headers from libbase frequently results in inclusion of -// android-base/macros.h, which causes macro collisions. - -// Container for a file descriptor that automatically closes the descriptor as -// it goes out of scope. -// -// unique_fd ufd(open("/some/path", "r")); -// if (ufd.get() == -1) return error; -// -// // Do something useful, possibly including 'return'. -// -// return 0; // Descriptor is closed for you. -// -// unique_fd is also known as ScopedFd/ScopedFD/scoped_fd; mentioned here to help -// you find this class if you're searching for one of those names. -namespace android { -namespace base { - -struct DefaultCloser { - static void Close(int fd) { - // Even if close(2) fails with EINTR, the fd will have been closed. - // Using TEMP_FAILURE_RETRY will either lead to EBADF or closing someone - // else's fd. - // http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html - ::close(fd); - } -}; - -template -class unique_fd_impl final { - public: - unique_fd_impl() : value_(-1) {} - - explicit unique_fd_impl(int value) : value_(value) {} - ~unique_fd_impl() { clear(); } - - unique_fd_impl(unique_fd_impl&& other) : value_(other.release()) {} - unique_fd_impl& operator=(unique_fd_impl&& s) { - reset(s.release()); - return *this; - } - - void reset(int new_value) { - if (value_ != -1) { - Closer::Close(value_); - } - value_ = new_value; - } - - void clear() { - reset(-1); - } - - int get() const { return value_; } - operator int() const { return get(); } - - int release() __attribute__((warn_unused_result)) { - int ret = value_; - value_ = -1; - return ret; - } - - private: - int value_; - - unique_fd_impl(const unique_fd_impl&); - void operator=(const unique_fd_impl&); -}; - -using unique_fd = unique_fd_impl; - -} // namespace base -} // namespace android - -#endif // ANDROID_BASE_UNIQUE_FD_H diff --git a/app/src/main/jni/crash_dump/libbase/include/android-base/utf8.h b/app/src/main/jni/crash_dump/libbase/include/android-base/utf8.h deleted file mode 100644 index 2d5a6f6d7..000000000 --- a/app/src/main/jni/crash_dump/libbase/include/android-base/utf8.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_BASE_UTF8_H -#define ANDROID_BASE_UTF8_H - -#ifdef _WIN32 -#include -#else -// Bring in prototypes for standard APIs so that we can import them into the utf8 namespace. -#include // open -#include // unlink -#endif - -namespace android { -namespace base { - -// Only available on Windows because this is only needed on Windows. -#ifdef _WIN32 -// Convert size number of UTF-16 wchar_t's to UTF-8. Returns whether the -// conversion was done successfully. -bool WideToUTF8(const wchar_t* utf16, const size_t size, std::string* utf8); - -// Convert a NULL-terminated string of UTF-16 characters to UTF-8. Returns -// whether the conversion was done successfully. -bool WideToUTF8(const wchar_t* utf16, std::string* utf8); - -// Convert a UTF-16 std::wstring (including any embedded NULL characters) to -// UTF-8. Returns whether the conversion was done successfully. -bool WideToUTF8(const std::wstring& utf16, std::string* utf8); - -// Convert size number of UTF-8 char's to UTF-16. Returns whether the conversion -// was done successfully. -bool UTF8ToWide(const char* utf8, const size_t size, std::wstring* utf16); - -// Convert a NULL-terminated string of UTF-8 characters to UTF-16. Returns -// whether the conversion was done successfully. -bool UTF8ToWide(const char* utf8, std::wstring* utf16); - -// Convert a UTF-8 std::string (including any embedded NULL characters) to -// UTF-16. Returns whether the conversion was done successfully. -bool UTF8ToWide(const std::string& utf8, std::wstring* utf16); -#endif - -// The functions in the utf8 namespace take UTF-8 strings. For Windows, these -// are wrappers, for non-Windows these just expose existing APIs. To call these -// functions, use: -// -// // anonymous namespace to avoid conflict with existing open(), unlink(), etc. -// namespace { -// // Import functions into anonymous namespace. -// using namespace android::base::utf8; -// -// void SomeFunction(const char* name) { -// int fd = open(name, ...); // Calls android::base::utf8::open(). -// ... -// unlink(name); // Calls android::base::utf8::unlink(). -// } -// } -namespace utf8 { - -#ifdef _WIN32 -int open(const char* name, int flags, ...); -int unlink(const char* name); -#else -using ::open; -using ::unlink; -#endif - -} // namespace utf8 -} // namespace base -} // namespace android - -#endif // ANDROID_BASE_UTF8_H diff --git a/app/src/main/jni/crash_dump/libbase/logging.cpp b/app/src/main/jni/crash_dump/libbase/logging.cpp deleted file mode 100644 index 174187149..000000000 --- a/app/src/main/jni/crash_dump/libbase/logging.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef _WIN32 -#include -#endif - -#include "android-base/logging.h" - -#include - -// For getprogname(3) or program_invocation_short_name. -#if defined(__ANDROID__) || defined(__APPLE__) -#include -#elif defined(__GLIBC__) -#include -#endif - -#include -#include -#include -#include -#include -#include - -#ifndef _WIN32 -#include -#endif - -#include "android-base/macros.h" -#include "android-base/strings.h" -#include "cutils/threads.h" - -// Headers for LogMessage::LogLine. -#ifdef __ANDROID__ -#include -#include "cutils/log.h" -#else -#include -#include -#endif - -// For gettid. -#if defined(__APPLE__) -#include "AvailabilityMacros.h" // For MAC_OS_X_VERSION_MAX_ALLOWED -#include -#include -#include -#include -#include -#elif defined(__linux__) && !defined(__ANDROID__) -#include -#include -#elif defined(_WIN32) -#include -#endif - -#if defined(_WIN32) -typedef uint32_t thread_id; -#else -typedef pid_t thread_id; -#endif - -static thread_id GetThreadId() { -#if defined(__BIONIC__) - return gettid(); -#elif defined(__APPLE__) - return syscall(SYS_thread_selfid); -#elif defined(__linux__) - return syscall(__NR_gettid); -#elif defined(_WIN32) - return GetCurrentThreadId(); -#endif -} - -namespace { -#ifndef _WIN32 -using std::mutex; -using std::lock_guard; - -#if defined(__GLIBC__) -const char* getprogname() { - return program_invocation_short_name; -} -#endif - -#else -const char* getprogname() { - static bool first = true; - static char progname[MAX_PATH] = {}; - - if (first) { - CHAR longname[MAX_PATH]; - DWORD nchars = GetModuleFileNameA(nullptr, longname, arraysize(longname)); - if ((nchars >= arraysize(longname)) || (nchars == 0)) { - // String truncation or some other error. - strcpy(progname, ""); - } else { - strcpy(progname, basename(longname)); - } - first = false; - } - - return progname; -} - -class mutex { - public: - mutex() { - InitializeCriticalSection(&critical_section_); - } - ~mutex() { - DeleteCriticalSection(&critical_section_); - } - - void lock() { - EnterCriticalSection(&critical_section_); - } - - void unlock() { - LeaveCriticalSection(&critical_section_); - } - - private: - CRITICAL_SECTION critical_section_; -}; - -template -class lock_guard { - public: - explicit lock_guard(LockT& lock) : lock_(lock) { - lock_.lock(); - } - - ~lock_guard() { - lock_.unlock(); - } - - private: - LockT& lock_; - - DISALLOW_COPY_AND_ASSIGN(lock_guard); -}; -#endif -} // namespace - -namespace android { -namespace base { - -static auto& logging_lock = *new mutex(); - -#ifdef __ANDROID__ -static auto& gLogger = *new LogFunction(LogdLogger()); -#else -static auto& gLogger = *new LogFunction(StderrLogger); -#endif - -static bool gInitialized = false; -static LogSeverity gMinimumLogSeverity = INFO; -static auto& gProgramInvocationName = *new std::unique_ptr(); - -LogSeverity GetMinimumLogSeverity() { - return gMinimumLogSeverity; -} - -static const char* ProgramInvocationName() { - if (gProgramInvocationName == nullptr) { - gProgramInvocationName.reset(new std::string(getprogname())); - } - - return gProgramInvocationName->c_str(); -} - -void StderrLogger(LogId, LogSeverity severity, const char*, const char* file, - unsigned int line, const char* message) { - static const char log_characters[] = "VDIWEF"; - static_assert(arraysize(log_characters) - 1 == FATAL + 1, - "Mismatch in size of log_characters and values in LogSeverity"); - char severity_char = log_characters[severity]; - fprintf(stderr, "%s %c %5d %5d %s:%u] %s\n", ProgramInvocationName(), - severity_char, getpid(), GetThreadId(), file, line, message); -} - - -#ifdef __ANDROID__ -LogdLogger::LogdLogger(LogId default_log_id) : default_log_id_(default_log_id) { -} - -static const android_LogPriority kLogSeverityToAndroidLogPriority[] = { - ANDROID_LOG_VERBOSE, ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, - ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL, -}; -static_assert(arraysize(kLogSeverityToAndroidLogPriority) == FATAL + 1, - "Mismatch in size of kLogSeverityToAndroidLogPriority and values " - "in LogSeverity"); - -static const log_id kLogIdToAndroidLogId[] = { - LOG_ID_MAX, LOG_ID_MAIN, LOG_ID_SYSTEM, -}; -static_assert(arraysize(kLogIdToAndroidLogId) == SYSTEM + 1, - "Mismatch in size of kLogIdToAndroidLogId and values in LogId"); - -void LogdLogger::operator()(LogId id, LogSeverity severity, const char* tag, - const char* file, unsigned int line, - const char* message) { - int priority = kLogSeverityToAndroidLogPriority[severity]; - if (id == DEFAULT) { - id = default_log_id_; - } - - log_id lg_id = kLogIdToAndroidLogId[id]; - - if (priority == ANDROID_LOG_FATAL) { - __android_log_buf_print(lg_id, priority, tag, "%s:%u] %s", file, line, - message); - } else { - __android_log_buf_print(lg_id, priority, tag, "%s", message); - } -} -#endif - -void InitLogging(char* argv[], LogFunction&& logger) { - SetLogger(std::forward(logger)); - InitLogging(argv); -} - -void InitLogging(char* argv[]) { - if (gInitialized) { - return; - } - - gInitialized = true; - - // Stash the command line for later use. We can use /proc/self/cmdline on - // Linux to recover this, but we don't have that luxury on the Mac/Windows, - // and there are a couple of argv[0] variants that are commonly used. - if (argv != nullptr) { - gProgramInvocationName.reset(new std::string(basename(argv[0]))); - } - - const char* tags = getenv("ANDROID_LOG_TAGS"); - if (tags == nullptr) { - return; - } - - std::vector specs = Split(tags, " "); - for (size_t i = 0; i < specs.size(); ++i) { - // "tag-pattern:[vdiwefs]" - std::string spec(specs[i]); - if (spec.size() == 3 && StartsWith(spec, "*:")) { - switch (spec[2]) { - case 'v': - gMinimumLogSeverity = VERBOSE; - continue; - case 'd': - gMinimumLogSeverity = DEBUG; - continue; - case 'i': - gMinimumLogSeverity = INFO; - continue; - case 'w': - gMinimumLogSeverity = WARNING; - continue; - case 'e': - gMinimumLogSeverity = ERROR; - continue; - case 'f': - gMinimumLogSeverity = FATAL; - continue; - // liblog will even suppress FATAL if you say 's' for silent, but that's - // crazy! - case 's': - gMinimumLogSeverity = FATAL; - continue; - } - } - LOG(FATAL) << "unsupported '" << spec << "' in ANDROID_LOG_TAGS (" << tags - << ")"; - } -} - -void SetLogger(LogFunction&& logger) { - lock_guard lock(logging_lock); - gLogger = std::move(logger); -} - -static const char* GetFileBasename(const char* file) { - // We can't use basename(3) even on Unix because the Mac doesn't - // have a non-modifying basename. - const char* last_slash = strrchr(file, '/'); - if (last_slash != nullptr) { - return last_slash + 1; - } -#if defined(_WIN32) - const char* last_backslash = strrchr(file, '\\'); - if (last_backslash != nullptr) { - return last_backslash + 1; - } -#endif - return file; -} - -// This indirection greatly reduces the stack impact of having lots of -// checks/logging in a function. -class LogMessageData { - public: - LogMessageData(const char* file, unsigned int line, LogId id, - LogSeverity severity, int error) - : file_(GetFileBasename(file)), - line_number_(line), - id_(id), - severity_(severity), - error_(error) { - } - - const char* GetFile() const { - return file_; - } - - unsigned int GetLineNumber() const { - return line_number_; - } - - LogSeverity GetSeverity() const { - return severity_; - } - - LogId GetId() const { - return id_; - } - - int GetError() const { - return error_; - } - - std::ostream& GetBuffer() { - return buffer_; - } - - std::string ToString() const { - return buffer_.str(); - } - - private: - std::ostringstream buffer_; - const char* const file_; - const unsigned int line_number_; - const LogId id_; - const LogSeverity severity_; - const int error_; - - DISALLOW_COPY_AND_ASSIGN(LogMessageData); -}; - -LogMessage::LogMessage(const char* file, unsigned int line, LogId id, - LogSeverity severity, int error) - : data_(new LogMessageData(file, line, id, severity, error)) { -} - -LogMessage::~LogMessage() { - // Finish constructing the message. - if (data_->GetError() != -1) { - data_->GetBuffer() << ": " << strerror(data_->GetError()); - } - std::string msg(data_->ToString()); - - { - // Do the actual logging with the lock held. - lock_guard lock(logging_lock); - if (msg.find('\n') == std::string::npos) { - LogLine(data_->GetFile(), data_->GetLineNumber(), data_->GetId(), - data_->GetSeverity(), msg.c_str()); - } else { - msg += '\n'; - size_t i = 0; - while (i < msg.size()) { - size_t nl = msg.find('\n', i); - msg[nl] = '\0'; - LogLine(data_->GetFile(), data_->GetLineNumber(), data_->GetId(), - data_->GetSeverity(), &msg[i]); - i = nl + 1; - } - } - } - - // Abort if necessary. - if (data_->GetSeverity() == FATAL) { -#ifdef __ANDROID__ - android_set_abort_message(msg.c_str()); -#endif - abort(); - } -} - -std::ostream& LogMessage::stream() { - return data_->GetBuffer(); -} - -void LogMessage::LogLine(const char* file, unsigned int line, LogId id, - LogSeverity severity, const char* message) { - const char* tag = ProgramInvocationName(); - gLogger(id, severity, tag, file, line, message); -} - -ScopedLogSeverity::ScopedLogSeverity(LogSeverity level) { - old_ = gMinimumLogSeverity; - gMinimumLogSeverity = level; -} - -ScopedLogSeverity::~ScopedLogSeverity() { - gMinimumLogSeverity = old_; -} - -} // namespace base -} // namespace android diff --git a/app/src/main/jni/crash_dump/libbase/logging_test.cpp b/app/src/main/jni/crash_dump/libbase/logging_test.cpp deleted file mode 100644 index 3de42b774..000000000 --- a/app/src/main/jni/crash_dump/libbase/logging_test.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/logging.h" - -#include - -#if defined(_WIN32) -#include -#endif - -#include -#include - -#include "android-base/file.h" -#include "android-base/stringprintf.h" -#include "android-base/test_utils.h" - -#include - -#ifdef __ANDROID__ -#define HOST_TEST(suite, name) TEST(suite, DISABLED_ ## name) -#else -#define HOST_TEST(suite, name) TEST(suite, name) -#endif - -class CapturedStderr { - public: - CapturedStderr() : old_stderr_(-1) { - init(); - } - - ~CapturedStderr() { - reset(); - } - - int fd() const { - return temp_file_.fd; - } - - private: - void init() { -#if defined(_WIN32) - // On Windows, stderr is often buffered, so make sure it is unbuffered so - // that we can immediately read back what was written to stderr. - ASSERT_EQ(0, setvbuf(stderr, NULL, _IONBF, 0)); -#endif - old_stderr_ = dup(STDERR_FILENO); - ASSERT_NE(-1, old_stderr_); - ASSERT_NE(-1, dup2(fd(), STDERR_FILENO)); - } - - void reset() { - ASSERT_NE(-1, dup2(old_stderr_, STDERR_FILENO)); - ASSERT_EQ(0, close(old_stderr_)); - // Note: cannot restore prior setvbuf() setting. - } - - TemporaryFile temp_file_; - int old_stderr_; -}; - -#if defined(_WIN32) -static void ExitSignalAbortHandler(int) { - _exit(3); -} -#endif - -static void SuppressAbortUI() { -#if defined(_WIN32) - // We really just want to call _set_abort_behavior(0, _CALL_REPORTFAULT) to - // suppress the Windows Error Reporting dialog box, but that API is not - // available in the OS-supplied C Runtime, msvcrt.dll, that we currently - // use (it is available in the Visual Studio C runtime). - // - // Instead, we setup a SIGABRT handler, which is called in abort() right - // before calling Windows Error Reporting. In the handler, we exit the - // process just like abort() does. - ASSERT_NE(SIG_ERR, signal(SIGABRT, ExitSignalAbortHandler)); -#endif -} - -TEST(logging, CHECK) { - ASSERT_DEATH({SuppressAbortUI(); CHECK(false);}, "Check failed: false "); - CHECK(true); - - ASSERT_DEATH({SuppressAbortUI(); CHECK_EQ(0, 1);}, "Check failed: 0 == 1 "); - CHECK_EQ(0, 0); - - ASSERT_DEATH({SuppressAbortUI(); CHECK_STREQ("foo", "bar");}, - R"(Check failed: "foo" == "bar")"); - CHECK_STREQ("foo", "foo"); - - // Test whether CHECK() and CHECK_STREQ() have a dangling if with no else. - bool flag = false; - if (true) - CHECK(true); - else - flag = true; - EXPECT_FALSE(flag) << "CHECK macro probably has a dangling if with no else"; - - flag = false; - if (true) - CHECK_STREQ("foo", "foo"); - else - flag = true; - EXPECT_FALSE(flag) << "CHECK_STREQ probably has a dangling if with no else"; -} - -std::string make_log_pattern(android::base::LogSeverity severity, - const char* message) { - static const char* log_characters = "VDIWEF"; - char log_char = log_characters[severity]; - std::string holder(__FILE__); - return android::base::StringPrintf( - "%c[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+ %s:[[:digit:]]+] %s", - log_char, basename(&holder[0]), message); -} - -TEST(logging, LOG) { - ASSERT_DEATH({SuppressAbortUI(); LOG(FATAL) << "foobar";}, "foobar"); - - // We can't usefully check the output of any of these on Windows because we - // don't have std::regex, but we can at least make sure we printed at least as - // many characters are in the log message. - { - CapturedStderr cap; - LOG(WARNING) << "foobar"; - ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET)); - - std::string output; - android::base::ReadFdToString(cap.fd(), &output); - ASSERT_GT(output.length(), strlen("foobar")); - -#if !defined(_WIN32) - std::regex message_regex( - make_log_pattern(android::base::WARNING, "foobar")); - ASSERT_TRUE(std::regex_search(output, message_regex)) << output; -#endif - } - - { - CapturedStderr cap; - LOG(INFO) << "foobar"; - ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET)); - - std::string output; - android::base::ReadFdToString(cap.fd(), &output); - ASSERT_GT(output.length(), strlen("foobar")); - -#if !defined(_WIN32) - std::regex message_regex( - make_log_pattern(android::base::INFO, "foobar")); - ASSERT_TRUE(std::regex_search(output, message_regex)) << output; -#endif - } - - { - CapturedStderr cap; - LOG(DEBUG) << "foobar"; - ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET)); - - std::string output; - android::base::ReadFdToString(cap.fd(), &output); - ASSERT_TRUE(output.empty()); - } - - { - android::base::ScopedLogSeverity severity(android::base::DEBUG); - CapturedStderr cap; - LOG(DEBUG) << "foobar"; - ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET)); - - std::string output; - android::base::ReadFdToString(cap.fd(), &output); - ASSERT_GT(output.length(), strlen("foobar")); - -#if !defined(_WIN32) - std::regex message_regex( - make_log_pattern(android::base::DEBUG, "foobar")); - ASSERT_TRUE(std::regex_search(output, message_regex)) << output; -#endif - } - - // Test whether LOG() saves and restores errno. - { - CapturedStderr cap; - errno = 12345; - LOG(INFO) << (errno = 67890); - EXPECT_EQ(12345, errno) << "errno was not restored"; - - ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET)); - - std::string output; - android::base::ReadFdToString(cap.fd(), &output); - EXPECT_NE(nullptr, strstr(output.c_str(), "67890")) << output; - -#if !defined(_WIN32) - std::regex message_regex( - make_log_pattern(android::base::INFO, "67890")); - ASSERT_TRUE(std::regex_search(output, message_regex)) << output; -#endif - } - - // Test whether LOG() has a dangling if with no else. - { - CapturedStderr cap; - - // Do the test two ways: once where we hypothesize that LOG()'s if - // will evaluate to true (when severity is high enough) and once when we - // expect it to evaluate to false (when severity is not high enough). - bool flag = false; - if (true) - LOG(INFO) << "foobar"; - else - flag = true; - - EXPECT_FALSE(flag) << "LOG macro probably has a dangling if with no else"; - - flag = false; - if (true) - LOG(VERBOSE) << "foobar"; - else - flag = true; - - EXPECT_FALSE(flag) << "LOG macro probably has a dangling if with no else"; - } -} - -TEST(logging, PLOG) { - { - CapturedStderr cap; - errno = ENOENT; - PLOG(INFO) << "foobar"; - ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET)); - - std::string output; - android::base::ReadFdToString(cap.fd(), &output); - ASSERT_GT(output.length(), strlen("foobar")); - -#if !defined(_WIN32) - std::regex message_regex(make_log_pattern( - android::base::INFO, "foobar: No such file or directory")); - ASSERT_TRUE(std::regex_search(output, message_regex)) << output; -#endif - } -} - -TEST(logging, UNIMPLEMENTED) { - { - CapturedStderr cap; - errno = ENOENT; - UNIMPLEMENTED(ERROR); - ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET)); - - std::string output; - android::base::ReadFdToString(cap.fd(), &output); - ASSERT_GT(output.length(), strlen("unimplemented")); - -#if !defined(_WIN32) - std::string expected_message = - android::base::StringPrintf("%s unimplemented ", __PRETTY_FUNCTION__); - std::regex message_regex( - make_log_pattern(android::base::ERROR, expected_message.c_str())); - ASSERT_TRUE(std::regex_search(output, message_regex)) << output; -#endif - } -} diff --git a/app/src/main/jni/crash_dump/libbase/parseint_test.cpp b/app/src/main/jni/crash_dump/libbase/parseint_test.cpp deleted file mode 100644 index 6a3ba316d..000000000 --- a/app/src/main/jni/crash_dump/libbase/parseint_test.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/parseint.h" - -#include - -TEST(parseint, signed_smoke) { - int i; - ASSERT_FALSE(android::base::ParseInt("x", &i)); - ASSERT_FALSE(android::base::ParseInt("123x", &i)); - - ASSERT_TRUE(android::base::ParseInt("123", &i)); - ASSERT_EQ(123, i); - ASSERT_TRUE(android::base::ParseInt("-123", &i)); - ASSERT_EQ(-123, i); - - short s; - ASSERT_TRUE(android::base::ParseInt("1234", &s)); - ASSERT_EQ(1234, s); - - ASSERT_TRUE(android::base::ParseInt("12", &i, 0, 15)); - ASSERT_EQ(12, i); - ASSERT_FALSE(android::base::ParseInt("-12", &i, 0, 15)); - ASSERT_FALSE(android::base::ParseInt("16", &i, 0, 15)); -} - -TEST(parseint, unsigned_smoke) { - unsigned int i; - ASSERT_FALSE(android::base::ParseUint("x", &i)); - ASSERT_FALSE(android::base::ParseUint("123x", &i)); - - ASSERT_TRUE(android::base::ParseUint("123", &i)); - ASSERT_EQ(123u, i); - ASSERT_FALSE(android::base::ParseUint("-123", &i)); - - unsigned short s; - ASSERT_TRUE(android::base::ParseUint("1234", &s)); - ASSERT_EQ(1234u, s); - - ASSERT_TRUE(android::base::ParseUint("12", &i, 15u)); - ASSERT_EQ(12u, i); - ASSERT_FALSE(android::base::ParseUint("-12", &i, 15u)); - ASSERT_FALSE(android::base::ParseUint("16", &i, 15u)); -} - -TEST(parseint, no_implicit_octal) { - int i; - ASSERT_TRUE(android::base::ParseInt("0123", &i)); - ASSERT_EQ(123, i); - - unsigned int u; - ASSERT_TRUE(android::base::ParseUint("0123", &u)); - ASSERT_EQ(123u, u); -} - -TEST(parseint, explicit_hex) { - int i; - ASSERT_TRUE(android::base::ParseInt("0x123", &i)); - ASSERT_EQ(0x123, i); - - unsigned int u; - ASSERT_TRUE(android::base::ParseUint("0x123", &u)); - ASSERT_EQ(0x123u, u); -} diff --git a/app/src/main/jni/crash_dump/libbase/parsenetaddress.cpp b/app/src/main/jni/crash_dump/libbase/parsenetaddress.cpp deleted file mode 100644 index dd80f6da2..000000000 --- a/app/src/main/jni/crash_dump/libbase/parsenetaddress.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/parsenetaddress.h" - -#include - -#include "android-base/stringprintf.h" -#include "android-base/strings.h" - -namespace android { -namespace base { - -bool ParseNetAddress(const std::string& address, std::string* host, int* port, - std::string* canonical_address, std::string* error) { - host->clear(); - - bool ipv6 = true; - bool saw_port = false; - size_t colons = std::count(address.begin(), address.end(), ':'); - size_t dots = std::count(address.begin(), address.end(), '.'); - std::string port_str; - if (address[0] == '[') { - // [::1]:123 - if (address.rfind("]:") == std::string::npos) { - *error = StringPrintf("bad IPv6 address '%s'", address.c_str()); - return false; - } - *host = address.substr(1, (address.find("]:") - 1)); - port_str = address.substr(address.rfind("]:") + 2); - saw_port = true; - } else if (dots == 0 && colons >= 2 && colons <= 7) { - // ::1 - *host = address; - } else if (colons <= 1) { - // 1.2.3.4 or some.accidental.domain.com - ipv6 = false; - std::vector pieces = Split(address, ":"); - *host = pieces[0]; - if (pieces.size() > 1) { - port_str = pieces[1]; - saw_port = true; - } - } - - if (host->empty()) { - *error = StringPrintf("no host in '%s'", address.c_str()); - return false; - } - - if (saw_port) { - if (sscanf(port_str.c_str(), "%d", port) != 1 || *port <= 0 || - *port > 65535) { - *error = StringPrintf("bad port number '%s' in '%s'", port_str.c_str(), - address.c_str()); - return false; - } - } - - if (canonical_address != nullptr) { - *canonical_address = - StringPrintf(ipv6 ? "[%s]:%d" : "%s:%d", host->c_str(), *port); - } - - return true; -} - -} // namespace base -} // namespace android diff --git a/app/src/main/jni/crash_dump/libbase/parsenetaddress_test.cpp b/app/src/main/jni/crash_dump/libbase/parsenetaddress_test.cpp deleted file mode 100644 index a3bfac860..000000000 --- a/app/src/main/jni/crash_dump/libbase/parsenetaddress_test.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/parsenetaddress.h" - -#include - -using android::base::ParseNetAddress; - -TEST(ParseNetAddressTest, TestUrl) { - std::string canonical, host, error; - int port = 123; - - EXPECT_TRUE( - ParseNetAddress("www.google.com", &host, &port, &canonical, &error)); - EXPECT_EQ("www.google.com:123", canonical); - EXPECT_EQ("www.google.com", host); - EXPECT_EQ(123, port); - - EXPECT_TRUE( - ParseNetAddress("www.google.com:666", &host, &port, &canonical, &error)); - EXPECT_EQ("www.google.com:666", canonical); - EXPECT_EQ("www.google.com", host); - EXPECT_EQ(666, port); -} - -TEST(ParseNetAddressTest, TestIpv4) { - std::string canonical, host, error; - int port = 123; - - EXPECT_TRUE(ParseNetAddress("1.2.3.4", &host, &port, &canonical, &error)); - EXPECT_EQ("1.2.3.4:123", canonical); - EXPECT_EQ("1.2.3.4", host); - EXPECT_EQ(123, port); - - EXPECT_TRUE(ParseNetAddress("1.2.3.4:666", &host, &port, &canonical, &error)); - EXPECT_EQ("1.2.3.4:666", canonical); - EXPECT_EQ("1.2.3.4", host); - EXPECT_EQ(666, port); -} - -TEST(ParseNetAddressTest, TestIpv6) { - std::string canonical, host, error; - int port = 123; - - EXPECT_TRUE(ParseNetAddress("::1", &host, &port, &canonical, &error)); - EXPECT_EQ("[::1]:123", canonical); - EXPECT_EQ("::1", host); - EXPECT_EQ(123, port); - - EXPECT_TRUE(ParseNetAddress("fe80::200:5aee:feaa:20a2", &host, &port, - &canonical, &error)); - EXPECT_EQ("[fe80::200:5aee:feaa:20a2]:123", canonical); - EXPECT_EQ("fe80::200:5aee:feaa:20a2", host); - EXPECT_EQ(123, port); - - EXPECT_TRUE(ParseNetAddress("[::1]:666", &host, &port, &canonical, &error)); - EXPECT_EQ("[::1]:666", canonical); - EXPECT_EQ("::1", host); - EXPECT_EQ(666, port); - - EXPECT_TRUE(ParseNetAddress("[fe80::200:5aee:feaa:20a2]:666", &host, &port, - &canonical, &error)); - EXPECT_EQ("[fe80::200:5aee:feaa:20a2]:666", canonical); - EXPECT_EQ("fe80::200:5aee:feaa:20a2", host); - EXPECT_EQ(666, port); -} - -TEST(ParseNetAddressTest, TestInvalidAddress) { - std::string canonical, host; - int port; - - std::string failure_cases[] = { - // Invalid IPv4. - "1.2.3.4:", - "1.2.3.4::", - ":123", - - // Invalid IPv6. - ":1", - "::::::::1", - "[::1", - "[::1]", - "[::1]:", - "[::1]::", - - // Invalid port. - "1.2.3.4:-1", - "1.2.3.4:0", - "1.2.3.4:65536" - "1.2.3.4:hello", - "[::1]:-1", - "[::1]:0", - "[::1]:65536", - "[::1]:hello", - }; - - for (const auto& address : failure_cases) { - // Failure should give some non-empty error string. - std::string error; - EXPECT_FALSE(ParseNetAddress(address, &host, &port, &canonical, &error)); - EXPECT_NE("", error); - } -} - -// Null canonical address argument. -TEST(ParseNetAddressTest, TestNullCanonicalAddress) { - std::string host, error; - int port = 42; - - EXPECT_TRUE(ParseNetAddress("www.google.com", &host, &port, nullptr, &error)); - EXPECT_TRUE(ParseNetAddress("1.2.3.4", &host, &port, nullptr, &error)); - EXPECT_TRUE(ParseNetAddress("::1", &host, &port, nullptr, &error)); -} diff --git a/app/src/main/jni/crash_dump/libbase/stringprintf.cpp b/app/src/main/jni/crash_dump/libbase/stringprintf.cpp deleted file mode 100644 index 78e1e8d14..000000000 --- a/app/src/main/jni/crash_dump/libbase/stringprintf.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/stringprintf.h" - -#include - -#include - -namespace android { -namespace base { - -void StringAppendV(std::string* dst, const char* format, va_list ap) { - // First try with a small fixed size buffer - char space[1024]; - - // It's possible for methods that use a va_list to invalidate - // the data in it upon use. The fix is to make a copy - // of the structure before using it and use that copy instead. - va_list backup_ap; - va_copy(backup_ap, ap); - int result = vsnprintf(space, sizeof(space), format, backup_ap); - va_end(backup_ap); - - if (result < static_cast(sizeof(space))) { - if (result >= 0) { - // Normal case -- everything fit. - dst->append(space, result); - return; - } - - if (result < 0) { - // Just an error. - return; - } - } - - // Increase the buffer size to the size requested by vsnprintf, - // plus one for the closing \0. - int length = result + 1; - char* buf = new char[length]; - - // Restore the va_list before we use it again - va_copy(backup_ap, ap); - result = vsnprintf(buf, length, format, backup_ap); - va_end(backup_ap); - - if (result >= 0 && result < length) { - // It fit - dst->append(buf, result); - } - delete[] buf; -} - -std::string StringPrintf(const char* fmt, ...) { - va_list ap; - va_start(ap, fmt); - std::string result; - StringAppendV(&result, fmt, ap); - va_end(ap); - return result; -} - -void StringAppendF(std::string* dst, const char* format, ...) { - va_list ap; - va_start(ap, format); - StringAppendV(dst, format, ap); - va_end(ap); -} - -} // namespace base -} // namespace android diff --git a/app/src/main/jni/crash_dump/libbase/stringprintf_test.cpp b/app/src/main/jni/crash_dump/libbase/stringprintf_test.cpp deleted file mode 100644 index fc009b1d7..000000000 --- a/app/src/main/jni/crash_dump/libbase/stringprintf_test.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/stringprintf.h" - -#include - -#include - -TEST(StringPrintfTest, HexSizeT) { - size_t size = 0x00107e59; - EXPECT_EQ("00107e59", android::base::StringPrintf("%08zx", size)); - EXPECT_EQ("0x00107e59", android::base::StringPrintf("0x%08zx", size)); -} - -TEST(StringPrintfTest, StringAppendF) { - std::string s("a"); - android::base::StringAppendF(&s, "b"); - EXPECT_EQ("ab", s); -} - -TEST(StringPrintfTest, Errno) { - errno = 123; - android::base::StringPrintf("hello %s", "world"); - EXPECT_EQ(123, errno); -} - -void TestN(size_t n) { - char* buf = new char[n + 1]; - memset(buf, 'x', n); - buf[n] = '\0'; - std::string s(android::base::StringPrintf("%s", buf)); - EXPECT_EQ(buf, s); - delete[] buf; -} - -TEST(StringPrintfTest, At1023) { - TestN(1023); -} - -TEST(StringPrintfTest, At1024) { - TestN(1024); -} - -TEST(StringPrintfTest, At1025) { - TestN(1025); -} diff --git a/app/src/main/jni/crash_dump/libbase/strings.cpp b/app/src/main/jni/crash_dump/libbase/strings.cpp deleted file mode 100644 index b8775df21..000000000 --- a/app/src/main/jni/crash_dump/libbase/strings.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/strings.h" - -#include -#include - -#include -#include - -namespace android { -namespace base { - -#define CHECK_NE(a, b) \ - if ((a) == (b)) abort(); - -std::vector Split(const std::string& s, - const std::string& delimiters) { - CHECK_NE(delimiters.size(), 0U); - - std::vector result; - - size_t base = 0; - size_t found; - do { - found = s.find_first_of(delimiters, base); - result.push_back(s.substr(base, found - base)); - base = found + 1; - } while (found != s.npos); - - return result; -} - -std::string Trim(const std::string& s) { - std::string result; - - if (s.size() == 0) { - return result; - } - - size_t start_index = 0; - size_t end_index = s.size() - 1; - - // Skip initial whitespace. - while (start_index < s.size()) { - if (!isspace(s[start_index])) { - break; - } - start_index++; - } - - // Skip terminating whitespace. - while (end_index >= start_index) { - if (!isspace(s[end_index])) { - break; - } - end_index--; - } - - // All spaces, no beef. - if (end_index < start_index) { - return ""; - } - // Start_index is the first non-space, end_index is the last one. - return s.substr(start_index, end_index - start_index + 1); -} - -// These cases are probably the norm, so we mark them extern in the header to -// aid compile time and binary size. -template std::string Join(const std::vector&, char); -template std::string Join(const std::vector&, char); -template std::string Join(const std::vector&, const std::string&); -template std::string Join(const std::vector&, const std::string&); - -bool StartsWith(const std::string& s, const char* prefix) { - return s.compare(0, strlen(prefix), prefix) == 0; -} - -bool EndsWith(const std::string& s, const char* suffix) { - size_t suffix_length = strlen(suffix); - size_t string_length = s.size(); - if (suffix_length > string_length) { - return false; - } - size_t offset = string_length - suffix_length; - return s.compare(offset, suffix_length, suffix) == 0; -} - -} // namespace base -} // namespace android diff --git a/app/src/main/jni/crash_dump/libbase/strings_test.cpp b/app/src/main/jni/crash_dump/libbase/strings_test.cpp deleted file mode 100644 index 30ae29e71..000000000 --- a/app/src/main/jni/crash_dump/libbase/strings_test.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/strings.h" - -#include - -#include -#include -#include -#include - -TEST(strings, split_empty) { - std::vector parts = android::base::Split("", ","); - ASSERT_EQ(1U, parts.size()); - ASSERT_EQ("", parts[0]); -} - -TEST(strings, split_single) { - std::vector parts = android::base::Split("foo", ","); - ASSERT_EQ(1U, parts.size()); - ASSERT_EQ("foo", parts[0]); -} - -TEST(strings, split_simple) { - std::vector parts = android::base::Split("foo,bar,baz", ","); - ASSERT_EQ(3U, parts.size()); - ASSERT_EQ("foo", parts[0]); - ASSERT_EQ("bar", parts[1]); - ASSERT_EQ("baz", parts[2]); -} - -TEST(strings, split_with_empty_part) { - std::vector parts = android::base::Split("foo,,bar", ","); - ASSERT_EQ(3U, parts.size()); - ASSERT_EQ("foo", parts[0]); - ASSERT_EQ("", parts[1]); - ASSERT_EQ("bar", parts[2]); -} - -TEST(strings, split_null_char) { - std::vector parts = - android::base::Split(std::string("foo\0bar", 7), std::string("\0", 1)); - ASSERT_EQ(2U, parts.size()); - ASSERT_EQ("foo", parts[0]); - ASSERT_EQ("bar", parts[1]); -} - -TEST(strings, split_any) { - std::vector parts = android::base::Split("foo:bar,baz", ",:"); - ASSERT_EQ(3U, parts.size()); - ASSERT_EQ("foo", parts[0]); - ASSERT_EQ("bar", parts[1]); - ASSERT_EQ("baz", parts[2]); -} - -TEST(strings, split_any_with_empty_part) { - std::vector parts = android::base::Split("foo:,bar", ",:"); - ASSERT_EQ(3U, parts.size()); - ASSERT_EQ("foo", parts[0]); - ASSERT_EQ("", parts[1]); - ASSERT_EQ("bar", parts[2]); -} - -TEST(strings, trim_empty) { - ASSERT_EQ("", android::base::Trim("")); -} - -TEST(strings, trim_already_trimmed) { - ASSERT_EQ("foo", android::base::Trim("foo")); -} - -TEST(strings, trim_left) { - ASSERT_EQ("foo", android::base::Trim(" foo")); -} - -TEST(strings, trim_right) { - ASSERT_EQ("foo", android::base::Trim("foo ")); -} - -TEST(strings, trim_both) { - ASSERT_EQ("foo", android::base::Trim(" foo ")); -} - -TEST(strings, trim_no_trim_middle) { - ASSERT_EQ("foo bar", android::base::Trim("foo bar")); -} - -TEST(strings, trim_other_whitespace) { - ASSERT_EQ("foo", android::base::Trim("\v\tfoo\n\f")); -} - -TEST(strings, join_nothing) { - std::vector list = {}; - ASSERT_EQ("", android::base::Join(list, ',')); -} - -TEST(strings, join_single) { - std::vector list = {"foo"}; - ASSERT_EQ("foo", android::base::Join(list, ',')); -} - -TEST(strings, join_simple) { - std::vector list = {"foo", "bar", "baz"}; - ASSERT_EQ("foo,bar,baz", android::base::Join(list, ',')); -} - -TEST(strings, join_separator_in_vector) { - std::vector list = {",", ","}; - ASSERT_EQ(",,,", android::base::Join(list, ',')); -} - -TEST(strings, join_simple_ints) { - std::set list = {1, 2, 3}; - ASSERT_EQ("1,2,3", android::base::Join(list, ',')); -} - -TEST(strings, join_unordered_set) { - std::unordered_set list = {1, 2}; - ASSERT_TRUE("1,2" == android::base::Join(list, ',') || - "2,1" == android::base::Join(list, ',')); -} - -TEST(strings, startswith_empty) { - ASSERT_FALSE(android::base::StartsWith("", "foo")); - ASSERT_TRUE(android::base::StartsWith("", "")); -} - -TEST(strings, startswith_simple) { - ASSERT_TRUE(android::base::StartsWith("foo", "")); - ASSERT_TRUE(android::base::StartsWith("foo", "f")); - ASSERT_TRUE(android::base::StartsWith("foo", "fo")); - ASSERT_TRUE(android::base::StartsWith("foo", "foo")); -} - -TEST(strings, startswith_prefix_too_long) { - ASSERT_FALSE(android::base::StartsWith("foo", "foobar")); -} - -TEST(strings, startswith_contains_prefix) { - ASSERT_FALSE(android::base::StartsWith("foobar", "oba")); - ASSERT_FALSE(android::base::StartsWith("foobar", "bar")); -} - -TEST(strings, endswith_empty) { - ASSERT_FALSE(android::base::EndsWith("", "foo")); - ASSERT_TRUE(android::base::EndsWith("", "")); -} - -TEST(strings, endswith_simple) { - ASSERT_TRUE(android::base::EndsWith("foo", "")); - ASSERT_TRUE(android::base::EndsWith("foo", "o")); - ASSERT_TRUE(android::base::EndsWith("foo", "oo")); - ASSERT_TRUE(android::base::EndsWith("foo", "foo")); -} - -TEST(strings, endswith_prefix_too_long) { - ASSERT_FALSE(android::base::EndsWith("foo", "foobar")); -} - -TEST(strings, endswith_contains_prefix) { - ASSERT_FALSE(android::base::EndsWith("foobar", "oba")); - ASSERT_FALSE(android::base::EndsWith("foobar", "foo")); -} diff --git a/app/src/main/jni/crash_dump/libbase/test_main.cpp b/app/src/main/jni/crash_dump/libbase/test_main.cpp deleted file mode 100644 index 7fa6a8425..000000000 --- a/app/src/main/jni/crash_dump/libbase/test_main.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "android-base/logging.h" - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - android::base::InitLogging(argv, android::base::StderrLogger); - return RUN_ALL_TESTS(); -} diff --git a/app/src/main/jni/crash_dump/libbase/test_utils.cpp b/app/src/main/jni/crash_dump/libbase/test_utils.cpp deleted file mode 100644 index 337ba7c44..000000000 --- a/app/src/main/jni/crash_dump/libbase/test_utils.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "android-base/logging.h" -#include "android-base/test_utils.h" -#include "utils/Compat.h" // For OS_PATH_SEPARATOR. - -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#include -#include -#endif - -#include - -#ifdef _WIN32 -int mkstemp(char* template_name) { - if (_mktemp(template_name) == nullptr) { - return -1; - } - // Use open() to match the close() that TemporaryFile's destructor does. - // Use O_BINARY to match base file APIs. - return open(template_name, O_CREAT | O_EXCL | O_RDWR | O_BINARY, - S_IRUSR | S_IWUSR); -} - -char* mkdtemp(char* template_name) { - if (_mktemp(template_name) == nullptr) { - return nullptr; - } - if (_mkdir(template_name) == -1) { - return nullptr; - } - return template_name; -} -#endif - -static std::string GetSystemTempDir() { -#if defined(__ANDROID__) - return "/data/local/tmp"; -#elif defined(_WIN32) - char tmp_dir[MAX_PATH]; - DWORD result = GetTempPathA(sizeof(tmp_dir), tmp_dir); - CHECK_NE(result, 0ul) << "GetTempPathA failed, error: " << GetLastError(); - CHECK_LT(result, sizeof(tmp_dir)) << "path truncated to: " << result; - - // GetTempPath() returns a path with a trailing slash, but init() - // does not expect that, so remove it. - CHECK_EQ(tmp_dir[result - 1], '\\'); - tmp_dir[result - 1] = '\0'; - return tmp_dir; -#else - return "/tmp"; -#endif -} - -TemporaryFile::TemporaryFile() { - init(GetSystemTempDir()); -} - -TemporaryFile::~TemporaryFile() { - close(fd); - unlink(path); -} - -void TemporaryFile::init(const std::string& tmp_dir) { - snprintf(path, sizeof(path), "%s%cTemporaryFile-XXXXXX", tmp_dir.c_str(), - OS_PATH_SEPARATOR); - fd = mkstemp(path); -} - -TemporaryDir::TemporaryDir() { - init(GetSystemTempDir()); -} - -TemporaryDir::~TemporaryDir() { - rmdir(path); -} - -bool TemporaryDir::init(const std::string& tmp_dir) { - snprintf(path, sizeof(path), "%s%cTemporaryDir-XXXXXX", tmp_dir.c_str(), - OS_PATH_SEPARATOR); - return (mkdtemp(path) != nullptr); -} diff --git a/app/src/main/jni/crash_dump/libbase/utf8.cpp b/app/src/main/jni/crash_dump/libbase/utf8.cpp deleted file mode 100644 index 3cca70026..000000000 --- a/app/src/main/jni/crash_dump/libbase/utf8.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "android-base/utf8.h" - -#include - -#include - -#include "android-base/logging.h" - -namespace android { -namespace base { - -// Helper to set errno based on GetLastError() after WideCharToMultiByte()/MultiByteToWideChar(). -static void SetErrnoFromLastError() { - switch (GetLastError()) { - case ERROR_NO_UNICODE_TRANSLATION: - errno = EILSEQ; - break; - default: - errno = EINVAL; - break; - } -} - -bool WideToUTF8(const wchar_t* utf16, const size_t size, std::string* utf8) { - utf8->clear(); - - if (size == 0) { - return true; - } - - // TODO: Consider using std::wstring_convert once libcxx is supported on - // Windows. - - // Only Vista or later has this flag that causes WideCharToMultiByte() to - // return an error on invalid characters. - const DWORD flags = -#if (WINVER >= 0x0600) - WC_ERR_INVALID_CHARS; -#else - 0; -#endif - - const int chars_required = WideCharToMultiByte(CP_UTF8, flags, utf16, size, - NULL, 0, NULL, NULL); - if (chars_required <= 0) { - SetErrnoFromLastError(); - return false; - } - - // This could potentially throw a std::bad_alloc exception. - utf8->resize(chars_required); - - const int result = WideCharToMultiByte(CP_UTF8, flags, utf16, size, - &(*utf8)[0], chars_required, NULL, - NULL); - if (result != chars_required) { - SetErrnoFromLastError(); - CHECK_LE(result, chars_required) << "WideCharToMultiByte wrote " << result - << " chars to buffer of " << chars_required << " chars"; - utf8->clear(); - return false; - } - - return true; -} - -bool WideToUTF8(const wchar_t* utf16, std::string* utf8) { - // Compute string length of NULL-terminated string with wcslen(). - return WideToUTF8(utf16, wcslen(utf16), utf8); -} - -bool WideToUTF8(const std::wstring& utf16, std::string* utf8) { - // Use the stored length of the string which allows embedded NULL characters - // to be converted. - return WideToUTF8(utf16.c_str(), utf16.length(), utf8); -} - -// Internal helper function that takes MultiByteToWideChar() flags. -static bool UTF8ToWideWithFlags(const char* utf8, const size_t size, std::wstring* utf16, - const DWORD flags) { - utf16->clear(); - - if (size == 0) { - return true; - } - - // TODO: Consider using std::wstring_convert once libcxx is supported on - // Windows. - const int chars_required = MultiByteToWideChar(CP_UTF8, flags, utf8, size, - NULL, 0); - if (chars_required <= 0) { - SetErrnoFromLastError(); - return false; - } - - // This could potentially throw a std::bad_alloc exception. - utf16->resize(chars_required); - - const int result = MultiByteToWideChar(CP_UTF8, flags, utf8, size, - &(*utf16)[0], chars_required); - if (result != chars_required) { - SetErrnoFromLastError(); - CHECK_LE(result, chars_required) << "MultiByteToWideChar wrote " << result - << " chars to buffer of " << chars_required << " chars"; - utf16->clear(); - return false; - } - - return true; -} - -bool UTF8ToWide(const char* utf8, const size_t size, std::wstring* utf16) { - // If strictly interpreting as UTF-8 succeeds, return success. - if (UTF8ToWideWithFlags(utf8, size, utf16, MB_ERR_INVALID_CHARS)) { - return true; - } - - const int saved_errno = errno; - - // Fallback to non-strict interpretation, allowing invalid characters and - // converting as best as possible, and return false to signify a problem. - (void)UTF8ToWideWithFlags(utf8, size, utf16, 0); - errno = saved_errno; - return false; -} - -bool UTF8ToWide(const char* utf8, std::wstring* utf16) { - // Compute string length of NULL-terminated string with strlen(). - return UTF8ToWide(utf8, strlen(utf8), utf16); -} - -bool UTF8ToWide(const std::string& utf8, std::wstring* utf16) { - // Use the stored length of the string which allows embedded NULL characters - // to be converted. - return UTF8ToWide(utf8.c_str(), utf8.length(), utf16); -} - -// Versions of standard library APIs that support UTF-8 strings. -namespace utf8 { - -int open(const char* name, int flags, ...) { - std::wstring name_utf16; - if (!UTF8ToWide(name, &name_utf16)) { - return -1; - } - - int mode = 0; - if ((flags & O_CREAT) != 0) { - va_list args; - va_start(args, flags); - mode = va_arg(args, int); - va_end(args); - } - - return _wopen(name_utf16.c_str(), flags, mode); -} - -int unlink(const char* name) { - std::wstring name_utf16; - if (!UTF8ToWide(name, &name_utf16)) { - return -1; - } - - return _wunlink(name_utf16.c_str()); -} - -} // namespace utf8 -} // namespace base -} // namespace android diff --git a/app/src/main/jni/crash_dump/libbase/utf8_test.cpp b/app/src/main/jni/crash_dump/libbase/utf8_test.cpp deleted file mode 100644 index ae8fc8c79..000000000 --- a/app/src/main/jni/crash_dump/libbase/utf8_test.cpp +++ /dev/null @@ -1,412 +0,0 @@ -/* -* Copyright (C) 2015 The Android Open Source Project -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "android-base/utf8.h" - -#include - -#include "android-base/macros.h" - -namespace android { -namespace base { - -TEST(UTFStringConversionsTest, ConvertInvalidUTF8) { - std::wstring wide; - - errno = 0; - - // Standalone \xa2 is an invalid UTF-8 sequence, so this should return an - // error. Concatenate two C/C++ literal string constants to prevent the - // compiler from giving an error about "\xa2af" containing a "hex escape - // sequence out of range". - EXPECT_FALSE(android::base::UTF8ToWide("before\xa2" "after", &wide)); - - EXPECT_EQ(EILSEQ, errno); - - // Even if an invalid character is encountered, UTF8ToWide() should still do - // its best to convert the rest of the string. sysdeps_win32.cpp: - // _console_write_utf8() depends on this behavior. - // - // Thus, we verify that the valid characters are converted, but we ignore the - // specific replacement character that UTF8ToWide() may replace the invalid - // UTF-8 characters with because we want to allow that to change if the - // implementation changes. - EXPECT_EQ(0U, wide.find(L"before")); - const wchar_t after_wide[] = L"after"; - EXPECT_EQ(wide.length() - (arraysize(after_wide) - 1), wide.find(after_wide)); -} - -// Below is adapted from https://chromium.googlesource.com/chromium/src/+/master/base/strings/utf_string_conversions_unittest.cc - -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// The tests below from utf_string_conversions_unittest.cc check for this -// preprocessor symbol, so define it, as it is appropriate for Windows. -#define WCHAR_T_IS_UTF16 -static_assert(sizeof(wchar_t) == 2, "wchar_t is not 2 bytes"); - -// The tests below from utf_string_conversions_unittest.cc call versions of -// UTF8ToWide() and WideToUTF8() that don't return success/failure, so these are -// stub implementations with that signature. These are just for testing and -// should not be moved to base because they assert/expect no errors which is -// probably not a good idea (or at least it is something that should be left -// up to the caller, not a base library). - -static std::wstring UTF8ToWide(const std::string& utf8) { - std::wstring utf16; - EXPECT_TRUE(UTF8ToWide(utf8, &utf16)); - return utf16; -} - -static std::string WideToUTF8(const std::wstring& utf16) { - std::string utf8; - EXPECT_TRUE(WideToUTF8(utf16, &utf8)); - return utf8; -} - -namespace { - -const wchar_t* const kConvertRoundtripCases[] = { - L"Google Video", - // "网页 图片 资讯更多 »" - L"\x7f51\x9875\x0020\x56fe\x7247\x0020\x8d44\x8baf\x66f4\x591a\x0020\x00bb", - // "Παγκόσμιος Ιστός" - L"\x03a0\x03b1\x03b3\x03ba\x03cc\x03c3\x03bc\x03b9" - L"\x03bf\x03c2\x0020\x0399\x03c3\x03c4\x03cc\x03c2", - // "Поиск страниц на русском" - L"\x041f\x043e\x0438\x0441\x043a\x0020\x0441\x0442" - L"\x0440\x0430\x043d\x0438\x0446\x0020\x043d\x0430" - L"\x0020\x0440\x0443\x0441\x0441\x043a\x043e\x043c", - // "전체서비스" - L"\xc804\xccb4\xc11c\xbe44\xc2a4", - - // Test characters that take more than 16 bits. This will depend on whether - // wchar_t is 16 or 32 bits. -#if defined(WCHAR_T_IS_UTF16) - L"\xd800\xdf00", - // ????? (Mathematical Alphanumeric Symbols (U+011d40 - U+011d44 : A,B,C,D,E) - L"\xd807\xdd40\xd807\xdd41\xd807\xdd42\xd807\xdd43\xd807\xdd44", -#elif defined(WCHAR_T_IS_UTF32) - L"\x10300", - // ????? (Mathematical Alphanumeric Symbols (U+011d40 - U+011d44 : A,B,C,D,E) - L"\x11d40\x11d41\x11d42\x11d43\x11d44", -#endif -}; - -} // namespace - -TEST(UTFStringConversionsTest, ConvertUTF8AndWide) { - // we round-trip all the wide strings through UTF-8 to make sure everything - // agrees on the conversion. This uses the stream operators to test them - // simultaneously. - for (size_t i = 0; i < arraysize(kConvertRoundtripCases); ++i) { - std::ostringstream utf8; - utf8 << WideToUTF8(kConvertRoundtripCases[i]); - std::wostringstream wide; - wide << UTF8ToWide(utf8.str()); - - EXPECT_EQ(kConvertRoundtripCases[i], wide.str()); - } -} - -TEST(UTFStringConversionsTest, ConvertUTF8AndWideEmptyString) { - // An empty std::wstring should be converted to an empty std::string, - // and vice versa. - std::wstring wempty; - std::string empty; - EXPECT_EQ(empty, WideToUTF8(wempty)); - EXPECT_EQ(wempty, UTF8ToWide(empty)); -} - -TEST(UTFStringConversionsTest, ConvertUTF8ToWide) { - struct UTF8ToWideCase { - const char* utf8; - const wchar_t* wide; - bool success; - } convert_cases[] = { - // Regular UTF-8 input. - {"\xe4\xbd\xa0\xe5\xa5\xbd", L"\x4f60\x597d", true}, - // Non-character is passed through. - {"\xef\xbf\xbfHello", L"\xffffHello", true}, - // Truncated UTF-8 sequence. - {"\xe4\xa0\xe5\xa5\xbd", L"\xfffd\x597d", false}, - // Truncated off the end. - {"\xe5\xa5\xbd\xe4\xa0", L"\x597d\xfffd", false}, - // Non-shortest-form UTF-8. - {"\xf0\x84\xbd\xa0\xe5\xa5\xbd", L"\xfffd\x597d", false}, - // This UTF-8 character decodes to a UTF-16 surrogate, which is illegal. - // Note that for whatever reason, this test fails on Windows XP. - {"\xed\xb0\x80", L"\xfffd", false}, - // Non-BMP characters. The second is a non-character regarded as valid. - // The result will either be in UTF-16 or UTF-32. -#if defined(WCHAR_T_IS_UTF16) - {"A\xF0\x90\x8C\x80z", L"A\xd800\xdf00z", true}, - {"A\xF4\x8F\xBF\xBEz", L"A\xdbff\xdffez", true}, -#elif defined(WCHAR_T_IS_UTF32) - {"A\xF0\x90\x8C\x80z", L"A\x10300z", true}, - {"A\xF4\x8F\xBF\xBEz", L"A\x10fffez", true}, -#endif - }; - - for (size_t i = 0; i < arraysize(convert_cases); i++) { - std::wstring converted; - errno = 0; - const bool success = UTF8ToWide(convert_cases[i].utf8, - strlen(convert_cases[i].utf8), - &converted); - EXPECT_EQ(convert_cases[i].success, success); - // The original test always compared expected and converted, but don't do - // that because our implementation of UTF8ToWide() does not guarantee to - // produce the same output in error situations. - if (success) { - std::wstring expected(convert_cases[i].wide); - EXPECT_EQ(expected, converted); - } else { - EXPECT_EQ(EILSEQ, errno); - } - } - - // Manually test an embedded NULL. - std::wstring converted; - EXPECT_TRUE(UTF8ToWide("\00Z\t", 3, &converted)); - ASSERT_EQ(3U, converted.length()); - EXPECT_EQ(static_cast(0), converted[0]); - EXPECT_EQ('Z', converted[1]); - EXPECT_EQ('\t', converted[2]); - - // Make sure that conversion replaces, not appends. - EXPECT_TRUE(UTF8ToWide("B", 1, &converted)); - ASSERT_EQ(1U, converted.length()); - EXPECT_EQ('B', converted[0]); -} - -#if defined(WCHAR_T_IS_UTF16) -// This test is only valid when wchar_t == UTF-16. -TEST(UTFStringConversionsTest, ConvertUTF16ToUTF8) { - struct WideToUTF8Case { - const wchar_t* utf16; - const char* utf8; - bool success; - } convert_cases[] = { - // Regular UTF-16 input. - {L"\x4f60\x597d", "\xe4\xbd\xa0\xe5\xa5\xbd", true}, - // Test a non-BMP character. - {L"\xd800\xdf00", "\xF0\x90\x8C\x80", true}, - // Non-characters are passed through. - {L"\xffffHello", "\xEF\xBF\xBFHello", true}, - {L"\xdbff\xdffeHello", "\xF4\x8F\xBF\xBEHello", true}, - // The first character is a truncated UTF-16 character. - // Note that for whatever reason, this test fails on Windows XP. - {L"\xd800\x597d", "\xef\xbf\xbd\xe5\xa5\xbd", -#if (WINVER >= 0x0600) - // Only Vista and later has a new API/flag that correctly returns false. - false -#else - true -#endif - }, - // Truncated at the end. - // Note that for whatever reason, this test fails on Windows XP. - {L"\x597d\xd800", "\xe5\xa5\xbd\xef\xbf\xbd", -#if (WINVER >= 0x0600) - // Only Vista and later has a new API/flag that correctly returns false. - false -#else - true -#endif - }, - }; - - for (size_t i = 0; i < arraysize(convert_cases); i++) { - std::string converted; - errno = 0; - const bool success = WideToUTF8(convert_cases[i].utf16, - wcslen(convert_cases[i].utf16), - &converted); - EXPECT_EQ(convert_cases[i].success, success); - // The original test always compared expected and converted, but don't do - // that because our implementation of WideToUTF8() does not guarantee to - // produce the same output in error situations. - if (success) { - std::string expected(convert_cases[i].utf8); - EXPECT_EQ(expected, converted); - } else { - EXPECT_EQ(EILSEQ, errno); - } - } -} - -#elif defined(WCHAR_T_IS_UTF32) -// This test is only valid when wchar_t == UTF-32. -TEST(UTFStringConversionsTest, ConvertUTF32ToUTF8) { - struct WideToUTF8Case { - const wchar_t* utf32; - const char* utf8; - bool success; - } convert_cases[] = { - // Regular 16-bit input. - {L"\x4f60\x597d", "\xe4\xbd\xa0\xe5\xa5\xbd", true}, - // Test a non-BMP character. - {L"A\x10300z", "A\xF0\x90\x8C\x80z", true}, - // Non-characters are passed through. - {L"\xffffHello", "\xEF\xBF\xBFHello", true}, - {L"\x10fffeHello", "\xF4\x8F\xBF\xBEHello", true}, - // Invalid Unicode code points. - {L"\xfffffffHello", "\xEF\xBF\xBDHello", false}, - // The first character is a truncated UTF-16 character. - {L"\xd800\x597d", "\xef\xbf\xbd\xe5\xa5\xbd", false}, - {L"\xdc01Hello", "\xef\xbf\xbdHello", false}, - }; - - for (size_t i = 0; i < arraysize(convert_cases); i++) { - std::string converted; - EXPECT_EQ(convert_cases[i].success, - WideToUTF8(convert_cases[i].utf32, - wcslen(convert_cases[i].utf32), - &converted)); - std::string expected(convert_cases[i].utf8); - EXPECT_EQ(expected, converted); - } -} -#endif // defined(WCHAR_T_IS_UTF32) - -// The test below uses these types and functions, so just do enough to get the -// test running. -typedef wchar_t char16; -typedef std::wstring string16; - -template -static void* WriteInto(T* t, size_t size) { - // std::(w)string::resize() already includes space for a NULL terminator. - t->resize(size - 1); - return &(*t)[0]; -} - -// A stub implementation that calls a helper from above, just to get the test -// below working. This is just for testing and should not be moved to base -// because this ignores errors which is probably not a good idea, plus it takes -// a string16 type which we don't really have. -static std::string UTF16ToUTF8(const string16& utf16) { - return WideToUTF8(utf16); -} - -TEST(UTFStringConversionsTest, ConvertMultiString) { - static char16 multi16[] = { - 'f', 'o', 'o', '\0', - 'b', 'a', 'r', '\0', - 'b', 'a', 'z', '\0', - '\0' - }; - static char multi[] = { - 'f', 'o', 'o', '\0', - 'b', 'a', 'r', '\0', - 'b', 'a', 'z', '\0', - '\0' - }; - string16 multistring16; - memcpy(WriteInto(&multistring16, arraysize(multi16)), multi16, - sizeof(multi16)); - EXPECT_EQ(arraysize(multi16) - 1, multistring16.length()); - std::string expected; - memcpy(WriteInto(&expected, arraysize(multi)), multi, sizeof(multi)); - EXPECT_EQ(arraysize(multi) - 1, expected.length()); - const std::string& converted = UTF16ToUTF8(multistring16); - EXPECT_EQ(arraysize(multi) - 1, converted.length()); - EXPECT_EQ(expected, converted); -} - -// The tests below from sys_string_conversions_unittest.cc call SysWideToUTF8() -// and SysUTF8ToWide(), so these are stub implementations that call the helpers -// above. These are just for testing and should not be moved to base because -// they ignore errors which is probably not a good idea. - -static std::string SysWideToUTF8(const std::wstring& utf16) { - return WideToUTF8(utf16); -} - -static std::wstring SysUTF8ToWide(const std::string& utf8) { - return UTF8ToWide(utf8); -} - -// Below is adapted from https://chromium.googlesource.com/chromium/src/+/master/base/strings/sys_string_conversions_unittest.cc - -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifdef WCHAR_T_IS_UTF32 -static const std::wstring kSysWideOldItalicLetterA = L"\x10300"; -#else -static const std::wstring kSysWideOldItalicLetterA = L"\xd800\xdf00"; -#endif - -TEST(SysStrings, SysWideToUTF8) { - EXPECT_EQ("Hello, world", SysWideToUTF8(L"Hello, world")); - EXPECT_EQ("\xe4\xbd\xa0\xe5\xa5\xbd", SysWideToUTF8(L"\x4f60\x597d")); - - // >16 bits - EXPECT_EQ("\xF0\x90\x8C\x80", SysWideToUTF8(kSysWideOldItalicLetterA)); - - // Error case. When Windows finds a UTF-16 character going off the end of - // a string, it just converts that literal value to UTF-8, even though this - // is invalid. - // - // This is what XP does, but Vista has different behavior, so we don't bother - // verifying it: - // EXPECT_EQ("\xE4\xBD\xA0\xED\xA0\x80zyxw", - // SysWideToUTF8(L"\x4f60\xd800zyxw")); - - // Test embedded NULLs. - std::wstring wide_null(L"a"); - wide_null.push_back(0); - wide_null.push_back('b'); - - std::string expected_null("a"); - expected_null.push_back(0); - expected_null.push_back('b'); - - EXPECT_EQ(expected_null, SysWideToUTF8(wide_null)); -} - -TEST(SysStrings, SysUTF8ToWide) { - EXPECT_EQ(L"Hello, world", SysUTF8ToWide("Hello, world")); - EXPECT_EQ(L"\x4f60\x597d", SysUTF8ToWide("\xe4\xbd\xa0\xe5\xa5\xbd")); - // >16 bits - EXPECT_EQ(kSysWideOldItalicLetterA, SysUTF8ToWide("\xF0\x90\x8C\x80")); - - // Error case. When Windows finds an invalid UTF-8 character, it just skips - // it. This seems weird because it's inconsistent with the reverse conversion. - // - // This is what XP does, but Vista has different behavior, so we don't bother - // verifying it: - // EXPECT_EQ(L"\x4f60zyxw", SysUTF8ToWide("\xe4\xbd\xa0\xe5\xa5zyxw")); - - // Test embedded NULLs. - std::string utf8_null("a"); - utf8_null.push_back(0); - utf8_null.push_back('b'); - - std::wstring expected_null(L"a"); - expected_null.push_back(0); - expected_null.push_back('b'); - - EXPECT_EQ(expected_null, SysUTF8ToWide(utf8_null)); -} - -} // namespace base -} // namespace android diff --git a/app/src/main/jni/crash_dump/libunwind/include/compiler.h b/app/src/main/jni/crash_dump/libunwind/include/compiler.h deleted file mode 100644 index 312ac1509..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/compiler.h +++ /dev/null @@ -1,74 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Compiler specific useful bits that are used in libunwind, and also in the - * tests. */ - -#ifndef COMPILER_H -#define COMPILER_H - -#ifdef __GNUC__ -# define ALIGNED(x) __attribute__((aligned(x))) -# define CONST_ATTR __attribute__((__const__)) -# define UNUSED __attribute__((unused)) -# define NOINLINE __attribute__((noinline)) -# define NORETURN __attribute__((noreturn)) -# define ALIAS(name) __attribute__((alias (#name))) -# if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 2) -# define ALWAYS_INLINE inline __attribute__((always_inline)) -# define HIDDEN __attribute__((visibility ("hidden"))) -# define PROTECTED __attribute__((visibility ("protected"))) -# else -# define ALWAYS_INLINE -# define HIDDEN -# define PROTECTED -# endif -# define WEAK __attribute__((weak)) -# if (__GNUC__ >= 3) -# define likely(x) __builtin_expect ((x), 1) -# define unlikely(x) __builtin_expect ((x), 0) -# else -# define likely(x) (x) -# define unlikely(x) (x) -# endif -#else -# define ALIGNED(x) -# define ALWAYS_INLINE -# define CONST_ATTR -# define UNUSED -# define NOINLINE -# define NORETURN -# define ALIAS(name) -# define HIDDEN -# define PROTECTED -# define WEAK -# define likely(x) (x) -# define unlikely(x) (x) -#endif - -#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) - -#endif /* COMPILER_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/config.h b/app/src/main/jni/crash_dump/libunwind/include/config.h deleted file mode 100644 index 48549f6a5..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/config.h +++ /dev/null @@ -1,255 +0,0 @@ -/* include/config.h. Generated from config.h.in by configure. */ -/* include/config.h.in. Generated from configure.ac by autoheader. */ - -/* Block signals before mutex operations */ -/* #undef CONFIG_BLOCK_SIGNALS */ - -/* Enable Debug Frame */ -#define CONFIG_DEBUG_FRAME 1 - -/* Support for Microsoft ABI extensions */ -/* This is required to understand floating point registers on x86-64 */ -#define CONFIG_MSABI_SUPPORT 1 - -/* Define to 1 if you want every memory access validated */ -#define CONSERVATIVE_CHECKS 1 - -/* Allocate large structures rather than place them on the stack. */ -#define CONSERVE_STACK /**/ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_ASM_PTRACE_OFFSETS_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_ATOMIC_OPS_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_BYTESWAP_H 1 - -/* Define to 1 if you have the declaration of `PTRACE_CONT', and to 0 if you - don't. */ -#define HAVE_DECL_PTRACE_CONT 1 - -/* Define to 1 if you have the declaration of `PTRACE_POKEDATA', and to 0 if - you don't. */ -#define HAVE_DECL_PTRACE_POKEDATA 1 - -/* Define to 1 if you have the declaration of `PTRACE_POKEUSER', and to 0 if - you don't. */ -#if defined(__aarch64__) || defined(__mips__) -#define HAVE_DECL_PTRACE_POKEUSER 0 -#else -#define HAVE_DECL_PTRACE_POKEUSER 1 -#endif - -/* Define to 1 if you have the declaration of `PTRACE_SINGLESTEP', and to 0 if - you don't. */ -#define HAVE_DECL_PTRACE_SINGLESTEP 1 - -/* Define to 1 if you have the declaration of `PTRACE_SYSCALL', and to 0 if - you don't. */ -#define HAVE_DECL_PTRACE_SYSCALL 1 - -/* Define to 1 if you have the declaration of `PTRACE_TRACEME', and to 0 if - you don't. */ -#define HAVE_DECL_PTRACE_TRACEME 1 - -/* Define to 1 if you have the declaration of `PT_CONTINUE', and to 0 if you - don't. */ -#define HAVE_DECL_PT_CONTINUE 0 - -/* Define to 1 if you have the declaration of `PT_GETFPREGS', and to 0 if you - don't. */ -#define HAVE_DECL_PT_GETFPREGS 0 - -/* Define to 1 if you have the declaration of `PT_GETREGS', and to 0 if you - don't. */ -#if defined(__mips__) -#define HAVE_DECL_PT_GETREGS 1 -#else -#define HAVE_DECL_PT_GETREGS 0 -#endif - -/* Define to 1 if you have the declaration of `PT_GETREGSET', and to 0 if you - don't. */ -#if defined(__aarch64__) -#define HAVE_DECL_PT_GETREGSET 1 -#else -#define HAVE_DECL_PT_GETREGSET 0 -#endif - -/* Define to 1 if you have the declaration of `PT_IO', and to 0 if you don't. - */ -#define HAVE_DECL_PT_IO 0 - -/* Define to 1 if you have the declaration of `PT_STEP', and to 0 if you - don't. */ -#define HAVE_DECL_PT_STEP 0 - -/* Define to 1 if you have the declaration of `PT_SYSCALL', and to 0 if you - don't. */ -#define HAVE_DECL_PT_SYSCALL 0 - -/* Define to 1 if you have the declaration of `PT_TRACE_ME', and to 0 if you - don't. */ -#define HAVE_DECL_PT_TRACE_ME 0 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the `dlmodinfo' function. */ -#define HAVE_DLMODINFO 1 - -/* Define to 1 if you have the `dl_iterate_phdr' function. */ -#define HAVE_DL_ITERATE_PHDR 1 - -/* Define to 1 if you have the `dl_phdr_removals_counter' function. */ -#define HAVE_DL_PHDR_REMOVALS_COUNTER 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ELF_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ENDIAN_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_EXECINFO_H */ - -/* Define to 1 if you have the `getunwind' function. */ -#define HAVE_GETUNWIND 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_IA64INTRIN_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `uca' library (-luca). */ -/* #undef HAVE_LIBUCA */ - -/* Define to 1 if you have the header file. */ -#define HAVE_LINK_H 1 - -/* Define if you have liblzma */ -#define HAVE_LZMA 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mincore' function. */ -#define HAVE_MINCORE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if `dlpi_subs' is a member of `struct dl_phdr_info'. */ -/* #undef HAVE_STRUCT_DL_PHDR_INFO_DLPI_SUBS */ - -/* Define to 1 if the system has the type `struct elf_prstatus'. */ -/* #undef HAVE_STRUCT_ELF_PRSTATUS */ - -/* Define to 1 if the system has the type `struct prstatus'. */ -/* #undef HAVE_STRUCT_PRSTATUS */ - -/* Defined if __sync atomics are available */ -#define HAVE_SYNC_ATOMICS 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_ELF_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_ENDIAN_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_LINK_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_PROCFS_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PTRACE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_UC_ACCESS_H */ - -/* Define to 1 if you have the `ttrace' function. */ -/* #undef HAVE_TTRACE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Defined if __builtin_unreachable() is available */ -#define HAVE__BUILTIN_UNREACHABLE 1 - -/* Defined if __builtin___clear_cache() is available */ -#define HAVE__BUILTIN___CLEAR_CACHE 1 - -/* Define to 1 if __thread keyword is supported by the C compiler. */ -#define HAVE___THREAD 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - -/* Name of package */ -#define PACKAGE "libunwind" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "libunwind-devel@nongnu.org" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "libunwind" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libunwind 1.1" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "libunwind" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "1.1" - -/* The size of `off_t', as computed by sizeof. */ -#define SIZEOF_OFF_T 4 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "1.1" - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/dwarf-eh.h b/app/src/main/jni/crash_dump/libunwind/include/dwarf-eh.h deleted file mode 100644 index 405e394a6..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/dwarf-eh.h +++ /dev/null @@ -1,128 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef dwarf_eh_h -#define dwarf_eh_h - -#include "dwarf.h" - -/* This header file defines the format of a DWARF exception-header - section (.eh_frame_hdr, pointed to by program-header - PT_GNU_EH_FRAME). The exception-header is self-describing in the - sense that the format of the addresses contained in it is expressed - as a one-byte type-descriptor called a "pointer-encoding" (PE). - - The exception header encodes the address of the .eh_frame section - and optionally contains a binary search table for the - Frame Descriptor Entries (FDEs) in the .eh_frame. The contents of - .eh_frame has the format described by the DWARF v3 standard - (http://www.eagercon.com/dwarf/dwarf3std.htm), except that code - addresses may be encoded in different ways. Also, .eh_frame has - augmentations that allow encoding a language-specific data-area - (LSDA) pointer and a pointer to a personality-routine. - - Details: - - The Common Information Entry (CIE) associated with an FDE may - contain an augmentation string. Each character in this string has - a specific meaning and either one or two associated operands. The - operands are stored in an augmentation body which appears right - after the "return_address_register" member and before the - "initial_instructions" member. The operands appear in the order - in which the characters appear in the string. For example, if the - augmentation string is "zL", the operand for 'z' would be first in - the augmentation body and the operand for 'L' would be second. - The following characters are supported for the CIE augmentation - string: - - 'z': The operand for this character is a uleb128 value that gives the - length of the CIE augmentation body, not counting the length - of the uleb128 operand itself. If present, this code must - appear as the first character in the augmentation body. - - 'L': Indicates that the FDE's augmentation body contains an LSDA - pointer. The operand for this character is a single byte - that specifies the pointer-encoding (PE) that is used for - the LSDA pointer. - - 'R': Indicates that the code-pointers (FDE members - "initial_location" and "address_range" and the operand for - DW_CFA_set_loc) in the FDE have a non-default encoding. The - operand for this character is a single byte that specifies - the pointer-encoding (PE) that is used for the - code-pointers. Note: the "address_range" member is always - encoded as an absolute value. Apart from that, the specified - FDE pointer-encoding applies. - - 'P': Indicates the presence of a personality routine (handler). - The first operand for this character specifies the - pointer-encoding (PE) that is used for the second operand, - which specifies the address of the personality routine. - - If the augmentation string contains any other characters, the - remainder of the augmentation string should be ignored. - Furthermore, if the size of the augmentation body is unknown - (i.e., 'z' is not the first character of the augmentation string), - then the entire CIE as well all associated FDEs must be ignored. - - A Frame Descriptor Entries (FDE) may contain an augmentation body - which, if present, appears right after the "address_range" member - and before the "instructions" member. The contents of this body - is implicitly defined by the augmentation string of the associated - CIE. The meaning of the characters in the CIE's augmentation - string as far as FDEs are concerned is as follows: - - 'z': The first operand in the FDE's augmentation body specifies - the total length of the augmentation body as a uleb128 (not - counting the length of the uleb128 operand itself). - - 'L': The operand for this character is an LSDA pointer, encoded - in the format specified by the corresponding operand in the - CIE's augmentation body. - -*/ - -#define DW_EH_VERSION 1 /* The version we're implementing */ - -struct dwarf_eh_frame_hdr - { - unsigned char version; - unsigned char eh_frame_ptr_enc; - unsigned char fde_count_enc; - unsigned char table_enc; - /* The rest of the header is variable-length and consists of the - following members: - - encoded_t eh_frame_ptr; - encoded_t fde_count; - struct - { - encoded_t start_ip; // first address covered by this FDE - encoded_t fde_addr; // address of the FDE - } - binary_search_table[fde_count]; */ - }; - -#endif /* dwarf_eh_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/dwarf.h b/app/src/main/jni/crash_dump/libunwind/include/dwarf.h deleted file mode 100644 index 96eaaab03..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/dwarf.h +++ /dev/null @@ -1,443 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef dwarf_h -#define dwarf_h - -#include - -struct dwarf_cursor; /* forward-declaration */ -struct elf_dyn_info; -/* ANDROID support update. */ -struct elf_image; - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "dwarf-config.h" -/* End of ANDROID update. */ - -#ifndef UNW_REMOTE_ONLY - #if defined(HAVE_LINK_H) - #include - #elif defined(HAVE_SYS_LINK_H) - #include - #else - #error Could not find - #endif -#endif - -#include - -/* DWARF expression opcodes. */ - -typedef enum - { - DW_OP_addr = 0x03, - DW_OP_deref = 0x06, - DW_OP_const1u = 0x08, - DW_OP_const1s = 0x09, - DW_OP_const2u = 0x0a, - DW_OP_const2s = 0x0b, - DW_OP_const4u = 0x0c, - DW_OP_const4s = 0x0d, - DW_OP_const8u = 0x0e, - DW_OP_const8s = 0x0f, - DW_OP_constu = 0x10, - DW_OP_consts = 0x11, - DW_OP_dup = 0x12, - DW_OP_drop = 0x13, - DW_OP_over = 0x14, - DW_OP_pick = 0x15, - DW_OP_swap = 0x16, - DW_OP_rot = 0x17, - DW_OP_xderef = 0x18, - DW_OP_abs = 0x19, - DW_OP_and = 0x1a, - DW_OP_div = 0x1b, - DW_OP_minus = 0x1c, - DW_OP_mod = 0x1d, - DW_OP_mul = 0x1e, - DW_OP_neg = 0x1f, - DW_OP_not = 0x20, - DW_OP_or = 0x21, - DW_OP_plus = 0x22, - DW_OP_plus_uconst = 0x23, - DW_OP_shl = 0x24, - DW_OP_shr = 0x25, - DW_OP_shra = 0x26, - DW_OP_xor = 0x27, - DW_OP_skip = 0x2f, - DW_OP_bra = 0x28, - DW_OP_eq = 0x29, - DW_OP_ge = 0x2a, - DW_OP_gt = 0x2b, - DW_OP_le = 0x2c, - DW_OP_lt = 0x2d, - DW_OP_ne = 0x2e, - DW_OP_lit0 = 0x30, - DW_OP_lit1, DW_OP_lit2, DW_OP_lit3, DW_OP_lit4, DW_OP_lit5, - DW_OP_lit6, DW_OP_lit7, DW_OP_lit8, DW_OP_lit9, DW_OP_lit10, - DW_OP_lit11, DW_OP_lit12, DW_OP_lit13, DW_OP_lit14, DW_OP_lit15, - DW_OP_lit16, DW_OP_lit17, DW_OP_lit18, DW_OP_lit19, DW_OP_lit20, - DW_OP_lit21, DW_OP_lit22, DW_OP_lit23, DW_OP_lit24, DW_OP_lit25, - DW_OP_lit26, DW_OP_lit27, DW_OP_lit28, DW_OP_lit29, DW_OP_lit30, - DW_OP_lit31, - DW_OP_reg0 = 0x50, - DW_OP_reg1, DW_OP_reg2, DW_OP_reg3, DW_OP_reg4, DW_OP_reg5, - DW_OP_reg6, DW_OP_reg7, DW_OP_reg8, DW_OP_reg9, DW_OP_reg10, - DW_OP_reg11, DW_OP_reg12, DW_OP_reg13, DW_OP_reg14, DW_OP_reg15, - DW_OP_reg16, DW_OP_reg17, DW_OP_reg18, DW_OP_reg19, DW_OP_reg20, - DW_OP_reg21, DW_OP_reg22, DW_OP_reg23, DW_OP_reg24, DW_OP_reg25, - DW_OP_reg26, DW_OP_reg27, DW_OP_reg28, DW_OP_reg29, DW_OP_reg30, - DW_OP_reg31, - DW_OP_breg0 = 0x70, - DW_OP_breg1, DW_OP_breg2, DW_OP_breg3, DW_OP_breg4, DW_OP_breg5, - DW_OP_breg6, DW_OP_breg7, DW_OP_breg8, DW_OP_breg9, DW_OP_breg10, - DW_OP_breg11, DW_OP_breg12, DW_OP_breg13, DW_OP_breg14, DW_OP_breg15, - DW_OP_breg16, DW_OP_breg17, DW_OP_breg18, DW_OP_breg19, DW_OP_breg20, - DW_OP_breg21, DW_OP_breg22, DW_OP_breg23, DW_OP_breg24, DW_OP_breg25, - DW_OP_breg26, DW_OP_breg27, DW_OP_breg28, DW_OP_breg29, DW_OP_breg30, - DW_OP_breg31, - DW_OP_regx = 0x90, - DW_OP_fbreg = 0x91, - DW_OP_bregx = 0x92, - DW_OP_piece = 0x93, - DW_OP_deref_size = 0x94, - DW_OP_xderef_size = 0x95, - DW_OP_nop = 0x96, - DW_OP_push_object_address = 0x97, - DW_OP_call2 = 0x98, - DW_OP_call4 = 0x99, - DW_OP_call_ref = 0x9a, - DW_OP_lo_user = 0xe0, - DW_OP_hi_user = 0xff - } -dwarf_expr_op_t; - -#define DWARF_CIE_VERSION 3 /* GCC emits version 1??? */ - -#define DWARF_CFA_OPCODE_MASK 0xc0 -#define DWARF_CFA_OPERAND_MASK 0x3f - -typedef enum - { - DW_CFA_advance_loc = 0x40, - DW_CFA_offset = 0x80, - DW_CFA_restore = 0xc0, - DW_CFA_nop = 0x00, - DW_CFA_set_loc = 0x01, - DW_CFA_advance_loc1 = 0x02, - DW_CFA_advance_loc2 = 0x03, - DW_CFA_advance_loc4 = 0x04, - DW_CFA_offset_extended = 0x05, - DW_CFA_restore_extended = 0x06, - DW_CFA_undefined = 0x07, - DW_CFA_same_value = 0x08, - DW_CFA_register = 0x09, - DW_CFA_remember_state = 0x0a, - DW_CFA_restore_state = 0x0b, - DW_CFA_def_cfa = 0x0c, - DW_CFA_def_cfa_register = 0x0d, - DW_CFA_def_cfa_offset = 0x0e, - DW_CFA_def_cfa_expression = 0x0f, - DW_CFA_expression = 0x10, - DW_CFA_offset_extended_sf = 0x11, - DW_CFA_def_cfa_sf = 0x12, - DW_CFA_def_cfa_offset_sf = 0x13, - DW_CFA_lo_user = 0x1c, - DW_CFA_MIPS_advance_loc8 = 0x1d, - DW_CFA_GNU_window_save = 0x2d, - DW_CFA_GNU_args_size = 0x2e, - DW_CFA_GNU_negative_offset_extended = 0x2f, - DW_CFA_hi_user = 0x3c - } -dwarf_cfa_t; - -/* DWARF Pointer-Encoding (PEs). - - Pointer-Encodings were invented for the GCC exception-handling - support for C++, but they represent a rather generic way of - describing the format in which an address/pointer is stored and - hence we include the definitions here, in the main dwarf.h file. - The Pointer-Encoding format is partially documented in Linux Base - Spec v1.3 (http://www.linuxbase.org/spec/). The rest is reverse - engineered from GCC. - -*/ -#define DW_EH_PE_FORMAT_MASK 0x0f /* format of the encoded value */ -#define DW_EH_PE_APPL_MASK 0x70 /* how the value is to be applied */ -/* Flag bit. If set, the resulting pointer is the address of the word - that contains the final address. */ -#define DW_EH_PE_indirect 0x80 - -/* Pointer-encoding formats: */ -#define DW_EH_PE_omit 0xff -#define DW_EH_PE_ptr 0x00 /* pointer-sized unsigned value */ -#define DW_EH_PE_uleb128 0x01 /* unsigned LE base-128 value */ -#define DW_EH_PE_udata2 0x02 /* unsigned 16-bit value */ -#define DW_EH_PE_udata4 0x03 /* unsigned 32-bit value */ -#define DW_EH_PE_udata8 0x04 /* unsigned 64-bit value */ -#define DW_EH_PE_sleb128 0x09 /* signed LE base-128 value */ -#define DW_EH_PE_sdata2 0x0a /* signed 16-bit value */ -#define DW_EH_PE_sdata4 0x0b /* signed 32-bit value */ -#define DW_EH_PE_sdata8 0x0c /* signed 64-bit value */ - -/* Pointer-encoding application: */ -#define DW_EH_PE_absptr 0x00 /* absolute value */ -#define DW_EH_PE_pcrel 0x10 /* rel. to addr. of encoded value */ -#define DW_EH_PE_textrel 0x20 /* text-relative (GCC-specific???) */ -#define DW_EH_PE_datarel 0x30 /* data-relative */ -/* The following are not documented by LSB v1.3, yet they are used by - GCC, presumably they aren't documented by LSB since they aren't - used on Linux: */ -#define DW_EH_PE_funcrel 0x40 /* start-of-procedure-relative */ -#define DW_EH_PE_aligned 0x50 /* aligned pointer */ - -extern struct mempool dwarf_reg_state_pool; -extern struct mempool dwarf_cie_info_pool; - -typedef enum - { - DWARF_WHERE_UNDEF, /* register isn't saved at all */ - DWARF_WHERE_SAME, /* register has same value as in prev. frame */ - DWARF_WHERE_CFAREL, /* register saved at CFA-relative address */ - DWARF_WHERE_REG, /* register saved in another register */ - DWARF_WHERE_EXPR, /* register saved */ - } -dwarf_where_t; - -typedef struct - { - dwarf_where_t where; /* how is the register saved? */ - unw_word_t val; /* where it's saved */ - } -dwarf_save_loc_t; - -/* For uniformity, we'd like to treat the CFA save-location like any - other register save-location, but this doesn't quite work, because - the CFA can be expressed as a (REGISTER,OFFSET) pair. To handle - this, we use two dwarf_save_loc structures to describe the CFA. - The first one (CFA_REG_COLUMN), tells us where the CFA is saved. - In the case of DWARF_WHERE_EXPR, the CFA is defined by a DWARF - location expression whose address is given by member "val". In the - case of DWARF_WHERE_REG, member "val" gives the number of the - base-register and the "val" member of DWARF_CFA_OFF_COLUMN gives - the offset value. */ -#define DWARF_CFA_REG_COLUMN DWARF_NUM_PRESERVED_REGS -#define DWARF_CFA_OFF_COLUMN (DWARF_NUM_PRESERVED_REGS + 1) - -typedef struct dwarf_reg_state - { - struct dwarf_reg_state *next; /* for rs_stack */ - dwarf_save_loc_t reg[DWARF_NUM_PRESERVED_REGS + 2]; - unw_word_t ip; /* ip this rs is for */ - unw_word_t ret_addr_column; /* indicates which column in the rule table represents return address */ - unsigned short lru_chain; /* used for least-recently-used chain */ - unsigned short coll_chain; /* used for hash collisions */ - unsigned short hint; /* hint for next rs to try (or -1) */ - unsigned short valid : 1; /* optional machine-dependent signal info */ - unsigned short signal_frame : 1; /* optional machine-dependent signal info */ - } -dwarf_reg_state_t; - -typedef struct dwarf_cie_info - { - unw_word_t cie_instr_start; /* start addr. of CIE "initial_instructions" */ - unw_word_t cie_instr_end; /* end addr. of CIE "initial_instructions" */ - unw_word_t fde_instr_start; /* start addr. of FDE "instructions" */ - unw_word_t fde_instr_end; /* end addr. of FDE "instructions" */ - unw_word_t code_align; /* code-alignment factor */ - unw_word_t data_align; /* data-alignment factor */ - unw_word_t ret_addr_column; /* column of return-address register */ - unw_word_t handler; /* address of personality-routine */ - uint16_t abi; - uint16_t tag; - uint8_t fde_encoding; - uint8_t lsda_encoding; - unsigned int sized_augmentation : 1; - unsigned int have_abi_marker : 1; - unsigned int signal_frame : 1; - } -dwarf_cie_info_t; - -typedef struct dwarf_state_record - { - unsigned char fde_encoding; - unw_word_t args_size; - - dwarf_reg_state_t rs_initial; /* reg-state after CIE instructions */ - dwarf_reg_state_t rs_current; /* current reg-state */ - } -dwarf_state_record_t; - -typedef struct dwarf_cursor - { - void *as_arg; /* argument to address-space callbacks */ - unw_addr_space_t as; /* reference to per-address-space info */ - - unw_word_t cfa; /* canonical frame address; aka frame-/stack-pointer */ - unw_word_t ip; /* instruction pointer */ - unw_word_t args_size; /* size of arguments */ - unw_word_t ret_addr_column; /* column for return-address */ - unw_word_t eh_args[UNW_TDEP_NUM_EH_REGS]; - unsigned int eh_valid_mask; - /* ANDROID support update. */ - unsigned int frame; - /* End of ANDROID update. */ - - dwarf_loc_t loc[DWARF_NUM_PRESERVED_REGS]; - - unsigned int stash_frames :1; /* stash frames for fast lookup */ - unsigned int use_prev_instr :1; /* use previous (= call) or current (= signal) instruction? */ - unsigned int pi_valid :1; /* is proc_info valid? */ - unsigned int pi_is_dynamic :1; /* proc_info found via dynamic proc info? */ - unw_proc_info_t pi; /* info about current procedure */ - - short hint; /* faster lookup of the rs cache */ - short prev_rs; - } -dwarf_cursor_t; - -#define DWARF_LOG_UNW_CACHE_SIZE 7 -#define DWARF_UNW_CACHE_SIZE (1 << DWARF_LOG_UNW_CACHE_SIZE) - -#define DWARF_LOG_UNW_HASH_SIZE (DWARF_LOG_UNW_CACHE_SIZE + 1) -#define DWARF_UNW_HASH_SIZE (1 << DWARF_LOG_UNW_HASH_SIZE) - -typedef unsigned char unw_hash_index_t; - -struct dwarf_rs_cache - { - pthread_mutex_t lock; - unsigned short lru_head; /* index of lead-recently used rs */ - unsigned short lru_tail; /* index of most-recently used rs */ - - /* hash table that maps instruction pointer to rs index: */ - unsigned short hash[DWARF_UNW_HASH_SIZE]; - - uint32_t generation; /* generation number */ - - /* rs cache: */ - dwarf_reg_state_t buckets[DWARF_UNW_CACHE_SIZE]; - }; - -/* A list of descriptors for loaded .debug_frame sections. */ - -struct unw_debug_frame_list - { - /* The start (inclusive) and end (exclusive) of the described region. */ - unw_word_t start; - unw_word_t end; - /* The debug frame itself. */ - char *debug_frame; - size_t debug_frame_size; - /* Relocation amount since debug_frame was compressed. */ - unw_word_t segbase_bias; - /* Index (for binary search). */ - struct table_entry *index; - size_t index_size; - /* Pointer to next descriptor. */ - struct unw_debug_frame_list *next; - }; - -struct dwarf_callback_data - { - /* in: */ - unw_word_t ip; /* instruction-pointer we're looking for */ - unw_proc_info_t *pi; /* proc-info pointer */ - int need_unwind_info; - /* out: */ - int single_fde; /* did we find a single FDE? (vs. a table) */ - unw_dyn_info_t di; /* table info (if single_fde is false) */ - unw_dyn_info_t di_debug; /* additional table info for .debug_frame */ - }; - -/* Convenience macros: */ -#define dwarf_init UNW_ARCH_OBJ (dwarf_init) -#define dwarf_callback UNW_OBJ (dwarf_callback) -#define dwarf_find_proc_info UNW_OBJ (dwarf_find_proc_info) -#define dwarf_find_debug_frame UNW_OBJ (dwarf_find_debug_frame) -#define dwarf_search_unwind_table UNW_OBJ (dwarf_search_unwind_table) -#define dwarf_find_unwind_table UNW_OBJ (dwarf_find_unwind_table) -#define dwarf_put_unwind_info UNW_OBJ (dwarf_put_unwind_info) -#define dwarf_put_unwind_info UNW_OBJ (dwarf_put_unwind_info) -#define dwarf_eval_expr UNW_OBJ (dwarf_eval_expr) -#define dwarf_extract_proc_info_from_fde \ - UNW_OBJ (dwarf_extract_proc_info_from_fde) -#define dwarf_find_save_locs UNW_OBJ (dwarf_find_save_locs) -#define dwarf_create_state_record UNW_OBJ (dwarf_create_state_record) -#define dwarf_make_proc_info UNW_OBJ (dwarf_make_proc_info) -#define dwarf_read_encoded_pointer UNW_OBJ (dwarf_read_encoded_pointer) -#define dwarf_step UNW_OBJ (dwarf_step) - -extern int dwarf_init (void); -#ifndef UNW_REMOTE_ONLY -extern int dwarf_callback (struct dl_phdr_info *info, size_t size, void *ptr); -extern int dwarf_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); -#endif /* !UNW_REMOTE_ONLY */ -extern int dwarf_find_debug_frame (int found, unw_dyn_info_t *di_debug, - unw_word_t ip, unw_word_t segbase, - const char* obj_name, unw_word_t start, - unw_word_t end); -extern int dwarf_search_unwind_table (unw_addr_space_t as, - unw_word_t ip, - unw_dyn_info_t *di, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); -/* ANDROID support update. */ -extern int dwarf_find_unwind_table (struct elf_dyn_info *edi, struct elf_image *ei, - unw_addr_space_t as, char *path, - unw_word_t segbase, unw_word_t mapoff, - unw_word_t ip); -/* End of ANDROID update. */ -extern void dwarf_put_unwind_info (unw_addr_space_t as, - unw_proc_info_t *pi, void *arg); -extern int dwarf_eval_expr (struct dwarf_cursor *c, unw_word_t *addr, - unw_word_t len, unw_word_t *valp, - int *is_register); -extern int dwarf_extract_proc_info_from_fde (unw_addr_space_t as, - unw_accessors_t *a, - unw_word_t *fde_addr, - unw_proc_info_t *pi, - int need_unwind_info, - unw_word_t base, - void *arg); -extern int dwarf_find_save_locs (struct dwarf_cursor *c); -extern int dwarf_create_state_record (struct dwarf_cursor *c, - dwarf_state_record_t *sr); -extern int dwarf_make_proc_info (struct dwarf_cursor *c); -extern int dwarf_read_encoded_pointer (unw_addr_space_t as, - unw_accessors_t *a, - unw_word_t *addr, - unsigned char encoding, - const unw_proc_info_t *pi, - unw_word_t *valp, void *arg); -extern int dwarf_step (struct dwarf_cursor *c); - -#endif /* dwarf_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/dwarf_i.h b/app/src/main/jni/crash_dump/libunwind/include/dwarf_i.h deleted file mode 100644 index 0e728457e..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/dwarf_i.h +++ /dev/null @@ -1,490 +0,0 @@ -#ifndef DWARF_I_H -#define DWARF_I_H - -/* This file contains definitions that cannot be used in code outside - of libunwind. In particular, most inline functions are here - because otherwise they'd generate unresolved references when the - files are compiled with inlining disabled. */ - -#include "dwarf.h" -#include "libunwind_i.h" - -/* Unless we are told otherwise, assume that a "machine address" is - the size of an unw_word_t. */ -#ifndef dwarf_addr_size -# define dwarf_addr_size(as) (sizeof (unw_word_t)) -#endif - -#ifndef dwarf_to_unw_regnum -# define dwarf_to_unw_regnum_map UNW_OBJ (dwarf_to_unw_regnum_map) -extern const uint8_t dwarf_to_unw_regnum_map[DWARF_REGNUM_MAP_LENGTH]; -/* REG is evaluated multiple times; it better be side-effects free! */ -# define dwarf_to_unw_regnum(reg) \ - (((reg) <= DWARF_REGNUM_MAP_LENGTH) ? dwarf_to_unw_regnum_map[reg] : 0) -#endif - -#ifdef UNW_LOCAL_ONLY - -/* In the local-only case, we can let the compiler directly access - memory and don't need to worry about differing byte-order. */ - -typedef union __attribute__ ((packed)) - { - int8_t s8; - int16_t s16; - int32_t s32; - int64_t s64; - uint8_t u8; - uint16_t u16; - uint32_t u32; - uint64_t u64; - void *ptr; - } -dwarf_misaligned_value_t; - -static inline int -dwarf_reads8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int8_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->s8; - *addr += sizeof (mvp->s8); - return 0; -} - -static inline int -dwarf_reads16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int16_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->s16; - *addr += sizeof (mvp->s16); - return 0; -} - -static inline int -dwarf_reads32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int32_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->s32; - *addr += sizeof (mvp->s32); - return 0; -} - -static inline int -dwarf_reads64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int64_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->s64; - *addr += sizeof (mvp->s64); - return 0; -} - -static inline int -dwarf_readu8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint8_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->u8; - *addr += sizeof (mvp->u8); - return 0; -} - -static inline int -dwarf_readu16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint16_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->u16; - *addr += sizeof (mvp->u16); - return 0; -} - -static inline int -dwarf_readu32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint32_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->u32; - *addr += sizeof (mvp->u32); - return 0; -} - -static inline int -dwarf_readu64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint64_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->u64; - *addr += sizeof (mvp->u64); - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ - -static inline int -dwarf_readu8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint8_t *valp, void *arg) -{ - unw_word_t val, aligned_addr = *addr & -sizeof (unw_word_t); - unw_word_t off = *addr - aligned_addr; - int ret; - - *addr += 1; - ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg); -#if __BYTE_ORDER == __LITTLE_ENDIAN - val >>= 8*off; -#else - val >>= 8*(sizeof (unw_word_t) - 1 - off); -#endif - *valp = (uint8_t) val; - return ret; -} - -static inline int -dwarf_readu16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint16_t *val, void *arg) -{ - uint8_t v0, v1; - int ret; - - if ((ret = dwarf_readu8 (as, a, addr, &v0, arg)) < 0 - || (ret = dwarf_readu8 (as, a, addr, &v1, arg)) < 0) - return ret; - - if (tdep_big_endian (as)) - *val = (uint16_t) v0 << 8 | v1; - else - *val = (uint16_t) v1 << 8 | v0; - return 0; -} - -static inline int -dwarf_readu32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint32_t *val, void *arg) -{ - uint16_t v0, v1; - int ret; - - if ((ret = dwarf_readu16 (as, a, addr, &v0, arg)) < 0 - || (ret = dwarf_readu16 (as, a, addr, &v1, arg)) < 0) - return ret; - - if (tdep_big_endian (as)) - *val = (uint32_t) v0 << 16 | v1; - else - *val = (uint32_t) v1 << 16 | v0; - return 0; -} - -static inline int -dwarf_readu64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint64_t *val, void *arg) -{ - uint32_t v0, v1; - int ret; - - if ((ret = dwarf_readu32 (as, a, addr, &v0, arg)) < 0 - || (ret = dwarf_readu32 (as, a, addr, &v1, arg)) < 0) - return ret; - - if (tdep_big_endian (as)) - *val = (uint64_t) v0 << 32 | v1; - else - *val = (uint64_t) v1 << 32 | v0; - return 0; -} - -static inline int -dwarf_reads8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int8_t *val, void *arg) -{ - uint8_t uval; - int ret; - - if ((ret = dwarf_readu8 (as, a, addr, &uval, arg)) < 0) - return ret; - *val = (int8_t) uval; - return 0; -} - -static inline int -dwarf_reads16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int16_t *val, void *arg) -{ - uint16_t uval; - int ret; - - if ((ret = dwarf_readu16 (as, a, addr, &uval, arg)) < 0) - return ret; - *val = (int16_t) uval; - return 0; -} - -static inline int -dwarf_reads32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int32_t *val, void *arg) -{ - uint32_t uval; - int ret; - - if ((ret = dwarf_readu32 (as, a, addr, &uval, arg)) < 0) - return ret; - *val = (int32_t) uval; - return 0; -} - -static inline int -dwarf_reads64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int64_t *val, void *arg) -{ - uint64_t uval; - int ret; - - if ((ret = dwarf_readu64 (as, a, addr, &uval, arg)) < 0) - return ret; - *val = (int64_t) uval; - return 0; -} - -#endif /* !UNW_LOCAL_ONLY */ - -static inline int -dwarf_readw (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - unw_word_t *val, void *arg) -{ - uint32_t u32; - uint64_t u64; - int ret; - - switch (dwarf_addr_size (as)) - { - case 4: - ret = dwarf_readu32 (as, a, addr, &u32, arg); - if (ret < 0) - return ret; - *val = u32; - return ret; - - case 8: - ret = dwarf_readu64 (as, a, addr, &u64, arg); - if (ret < 0) - return ret; - *val = u64; - return ret; - - default: - abort (); - } -} - -/* Read an unsigned "little-endian base 128" value. See Chapter 7.6 - of DWARF spec v3. */ - -static inline int -dwarf_read_uleb128 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - unw_word_t *valp, void *arg) -{ - unw_word_t val = 0, shift = 0; - unsigned char byte; - int ret; - - do - { - if ((ret = dwarf_readu8 (as, a, addr, &byte, arg)) < 0) - return ret; - - val |= ((unw_word_t) byte & 0x7f) << shift; - shift += 7; - } - while (byte & 0x80); - - *valp = val; - return 0; -} - -/* Read a signed "little-endian base 128" value. See Chapter 7.6 of - DWARF spec v3. */ - -static inline int -dwarf_read_sleb128 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - unw_word_t *valp, void *arg) -{ - unw_word_t val = 0, shift = 0; - unsigned char byte; - int ret; - - do - { - if ((ret = dwarf_readu8 (as, a, addr, &byte, arg)) < 0) - return ret; - - val |= ((unw_word_t) byte & 0x7f) << shift; - shift += 7; - } - while (byte & 0x80); - - if (shift < 8 * sizeof (unw_word_t) && (byte & 0x40) != 0) - /* sign-extend negative value */ - val |= ((unw_word_t) -1) << shift; - - *valp = val; - return 0; -} - -static ALWAYS_INLINE int -dwarf_read_encoded_pointer_inlined (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, unsigned char encoding, - const unw_proc_info_t *pi, - unw_word_t *valp, void *arg) -{ - unw_word_t val, initial_addr = *addr; - uint16_t uval16; - uint32_t uval32; - uint64_t uval64; - int16_t sval16; - int32_t sval32; - int64_t sval64; - int ret; - - /* DW_EH_PE_omit and DW_EH_PE_aligned don't follow the normal - format/application encoding. Handle them first. */ - if (encoding == DW_EH_PE_omit) - { - *valp = 0; - return 0; - } - else if (encoding == DW_EH_PE_aligned) - { - int size = dwarf_addr_size (as); - *addr = (initial_addr + size - 1) & -size; - return dwarf_readw (as, a, addr, valp, arg); - } - - switch (encoding & DW_EH_PE_FORMAT_MASK) - { - case DW_EH_PE_ptr: - if ((ret = dwarf_readw (as, a, addr, &val, arg)) < 0) - return ret; - break; - - case DW_EH_PE_uleb128: - if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0) - return ret; - break; - - case DW_EH_PE_udata2: - if ((ret = dwarf_readu16 (as, a, addr, &uval16, arg)) < 0) - return ret; - val = uval16; - break; - - case DW_EH_PE_udata4: - if ((ret = dwarf_readu32 (as, a, addr, &uval32, arg)) < 0) - return ret; - val = uval32; - break; - - case DW_EH_PE_udata8: - if ((ret = dwarf_readu64 (as, a, addr, &uval64, arg)) < 0) - return ret; - val = uval64; - break; - - case DW_EH_PE_sleb128: - if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0) - return ret; - break; - - case DW_EH_PE_sdata2: - if ((ret = dwarf_reads16 (as, a, addr, &sval16, arg)) < 0) - return ret; - val = sval16; - break; - - case DW_EH_PE_sdata4: - if ((ret = dwarf_reads32 (as, a, addr, &sval32, arg)) < 0) - return ret; - val = sval32; - break; - - case DW_EH_PE_sdata8: - if ((ret = dwarf_reads64 (as, a, addr, &sval64, arg)) < 0) - return ret; - val = sval64; - break; - - default: - Debug (1, "unexpected encoding format 0x%x\n", - encoding & DW_EH_PE_FORMAT_MASK); - return -UNW_EINVAL; - } - - if (val == 0) - { - /* 0 is a special value and always absolute. */ - *valp = 0; - return 0; - } - - switch (encoding & DW_EH_PE_APPL_MASK) - { - case DW_EH_PE_absptr: - break; - - case DW_EH_PE_pcrel: - val += initial_addr; - break; - - case DW_EH_PE_datarel: - /* XXX For now, assume that data-relative addresses are relative - to the global pointer. */ - val += pi->gp; - break; - - case DW_EH_PE_funcrel: - val += pi->start_ip; - break; - - case DW_EH_PE_textrel: - /* XXX For now we don't support text-rel values. If there is a - platform which needs this, we probably would have to add a - "segbase" member to unw_proc_info_t. */ - default: - Debug (1, "unexpected application type 0x%x\n", - encoding & DW_EH_PE_APPL_MASK); - return -UNW_EINVAL; - } - - /* Trim off any extra bits. Assume that sign extension isn't - required; the only place it is needed is MIPS kernel space - addresses. */ - if (sizeof (val) > dwarf_addr_size (as)) - { - assert (dwarf_addr_size (as) == 4); - val = (uint32_t) val; - } - - if (encoding & DW_EH_PE_indirect) - { - unw_word_t indirect_addr = val; - - if ((ret = dwarf_readw (as, a, &indirect_addr, &val, arg)) < 0) - return ret; - } - - *valp = val; - return 0; -} - -#endif /* DWARF_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-aarch64.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-aarch64.h deleted file mode 100644 index 9883cf3dc..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-aarch64.h +++ /dev/null @@ -1,219 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include -#include - -#define UNW_TARGET aarch64 -#define UNW_TARGET_AARCH64 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ - -#define UNW_TDEP_CURSOR_LEN 4096 - -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; - -typedef long double unw_tdep_fpreg_t; - -typedef struct - { - /* no aarch64-specific auxiliary proc-info */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_proc_info_t; - -typedef enum - { - /* 64-bit general registers. */ - UNW_AARCH64_X0, - UNW_AARCH64_X1, - UNW_AARCH64_X2, - UNW_AARCH64_X3, - UNW_AARCH64_X4, - UNW_AARCH64_X5, - UNW_AARCH64_X6, - UNW_AARCH64_X7, - UNW_AARCH64_X8, - - /* Temporary registers. */ - UNW_AARCH64_X9, - UNW_AARCH64_X10, - UNW_AARCH64_X11, - UNW_AARCH64_X12, - UNW_AARCH64_X13, - UNW_AARCH64_X14, - UNW_AARCH64_X15, - - /* Intra-procedure-call temporary registers. */ - UNW_AARCH64_X16, - UNW_AARCH64_X17, - - /* Callee-saved registers. */ - UNW_AARCH64_X18, - UNW_AARCH64_X19, - UNW_AARCH64_X20, - UNW_AARCH64_X21, - UNW_AARCH64_X22, - UNW_AARCH64_X23, - UNW_AARCH64_X24, - UNW_AARCH64_X25, - UNW_AARCH64_X26, - UNW_AARCH64_X27, - UNW_AARCH64_X28, - - /* 64-bit frame pointer. */ - UNW_AARCH64_X29, - - /* 64-bit link register. */ - UNW_AARCH64_X30, - - /* 64-bit stack pointer. */ - UNW_AARCH64_SP = 31, - UNW_AARCH64_PC, - UNW_AARCH64_PSTATE, - - /* 128-bit FP/Advanced SIMD registers. */ - UNW_AARCH64_V0 = 64, - UNW_AARCH64_V1, - UNW_AARCH64_V2, - UNW_AARCH64_V3, - UNW_AARCH64_V4, - UNW_AARCH64_V5, - UNW_AARCH64_V6, - UNW_AARCH64_V7, - UNW_AARCH64_V8, - UNW_AARCH64_V9, - UNW_AARCH64_V10, - UNW_AARCH64_V11, - UNW_AARCH64_V12, - UNW_AARCH64_V13, - UNW_AARCH64_V14, - UNW_AARCH64_V15, - UNW_AARCH64_V16, - UNW_AARCH64_V17, - UNW_AARCH64_V18, - UNW_AARCH64_V19, - UNW_AARCH64_V20, - UNW_AARCH64_V21, - UNW_AARCH64_V22, - UNW_AARCH64_V23, - UNW_AARCH64_V24, - UNW_AARCH64_V25, - UNW_AARCH64_V26, - UNW_AARCH64_V27, - UNW_AARCH64_V28, - UNW_AARCH64_V29, - UNW_AARCH64_V30, - UNW_AARCH64_V31, - - UNW_AARCH64_FPSR, - UNW_AARCH64_FPCR, - - /* For AArch64, the CFA is the value of SP (x31) at the call site of the - previous frame. */ - UNW_AARCH64_CFA = UNW_AARCH64_SP, - - UNW_TDEP_LAST_REG = UNW_AARCH64_FPCR, - - UNW_TDEP_IP = UNW_AARCH64_X30, - UNW_TDEP_SP = UNW_AARCH64_SP, - UNW_TDEP_EH = UNW_AARCH64_X0, - - } -aarch64_regnum_t; - -/* Use R0 through R3 to pass exception handling information. */ -#define UNW_TDEP_NUM_EH_REGS 4 - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_save_loc_t; - - -/* On AArch64, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -#include "libunwind-common.h" -#include "libunwind-dynamic.h" - -/* ANDROID support update. */ -/* There is no getcontext in Android. */ -#define unw_tdep_getcontext(uc) (({ \ - unw_tdep_context_t *unw_ctx = (uc); \ - register uint64_t *unw_base asm ("x0") = (uint64_t*) unw_ctx->uc_mcontext.regs; \ - __asm__ __volatile__ ( \ - "stp x0, x1, [%[base], #0]\n" \ - "stp x2, x3, [%[base], #16]\n" \ - "stp x4, x5, [%[base], #32]\n" \ - "stp x6, x7, [%[base], #48]\n" \ - "stp x8, x9, [%[base], #64]\n" \ - "stp x10, x11, [%[base], #80]\n" \ - "stp x12, x13, [%[base], #96]\n" \ - "stp x14, x15, [%[base], #112]\n" \ - "stp x16, x17, [%[base], #128]\n" \ - "stp x18, x19, [%[base], #144]\n" \ - "stp x20, x21, [%[base], #160]\n" \ - "stp x22, x23, [%[base], #176]\n" \ - "stp x24, x25, [%[base], #192]\n" \ - "stp x26, x27, [%[base], #208]\n" \ - "stp x28, x29, [%[base], #224]\n" \ - "str x30, [%[base], #240]\n" \ - "mov x1, sp\n" \ - "stp x1, x30, [%[base], #248]\n" \ - : [base] "+r" (unw_base) : : "x1", "memory"); \ - }), 0) -/* End of ANDROID update. */ -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) - -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-arm.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-arm.h deleted file mode 100644 index 495948e70..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-arm.h +++ /dev/null @@ -1,308 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#define UNW_TARGET arm -#define UNW_TARGET_ARM 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ - -/* FIXME for ARM. Too big? What do other things use for similar tasks? */ -#define UNW_TDEP_CURSOR_LEN 4096 - -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; - -typedef long double unw_tdep_fpreg_t; - -typedef enum - { - UNW_ARM_R0, - UNW_ARM_R1, - UNW_ARM_R2, - UNW_ARM_R3, - UNW_ARM_R4, - UNW_ARM_R5, - UNW_ARM_R6, - UNW_ARM_R7, - UNW_ARM_R8, - UNW_ARM_R9, - UNW_ARM_R10, - UNW_ARM_R11, - UNW_ARM_R12, - UNW_ARM_R13, - UNW_ARM_R14, - UNW_ARM_R15, - - /* VFPv2 s0-s31 (obsolescent numberings). */ - UNW_ARM_S0 = 64, - UNW_ARM_S1, - UNW_ARM_S2, - UNW_ARM_S3, - UNW_ARM_S4, - UNW_ARM_S5, - UNW_ARM_S6, - UNW_ARM_S7, - UNW_ARM_S8, - UNW_ARM_S9, - UNW_ARM_S10, - UNW_ARM_S11, - UNW_ARM_S12, - UNW_ARM_S13, - UNW_ARM_S14, - UNW_ARM_S15, - UNW_ARM_S16, - UNW_ARM_S17, - UNW_ARM_S18, - UNW_ARM_S19, - UNW_ARM_S20, - UNW_ARM_S21, - UNW_ARM_S22, - UNW_ARM_S23, - UNW_ARM_S24, - UNW_ARM_S25, - UNW_ARM_S26, - UNW_ARM_S27, - UNW_ARM_S28, - UNW_ARM_S29, - UNW_ARM_S30, - UNW_ARM_S31, - - /* FPA register numberings. */ - UNW_ARM_F0 = 96, - UNW_ARM_F1, - UNW_ARM_F2, - UNW_ARM_F3, - UNW_ARM_F4, - UNW_ARM_F5, - UNW_ARM_F6, - UNW_ARM_F7, - - /* iWMMXt GR register numberings. */ - UNW_ARM_wCGR0 = 104, - UNW_ARM_wCGR1, - UNW_ARM_wCGR2, - UNW_ARM_wCGR3, - UNW_ARM_wCGR4, - UNW_ARM_wCGR5, - UNW_ARM_wCGR6, - UNW_ARM_wCGR7, - - /* iWMMXt register numberings. */ - UNW_ARM_wR0 = 112, - UNW_ARM_wR1, - UNW_ARM_wR2, - UNW_ARM_wR3, - UNW_ARM_wR4, - UNW_ARM_wR5, - UNW_ARM_wR6, - UNW_ARM_wR7, - UNW_ARM_wR8, - UNW_ARM_wR9, - UNW_ARM_wR10, - UNW_ARM_wR11, - UNW_ARM_wR12, - UNW_ARM_wR13, - UNW_ARM_wR14, - UNW_ARM_wR15, - - /* Two-byte encodings from here on. */ - - /* SPSR. */ - UNW_ARM_SPSR = 128, - UNW_ARM_SPSR_FIQ, - UNW_ARM_SPSR_IRQ, - UNW_ARM_SPSR_ABT, - UNW_ARM_SPSR_UND, - UNW_ARM_SPSR_SVC, - - /* User mode registers. */ - UNW_ARM_R8_USR = 144, - UNW_ARM_R9_USR, - UNW_ARM_R10_USR, - UNW_ARM_R11_USR, - UNW_ARM_R12_USR, - UNW_ARM_R13_USR, - UNW_ARM_R14_USR, - - /* FIQ registers. */ - UNW_ARM_R8_FIQ = 151, - UNW_ARM_R9_FIQ, - UNW_ARM_R10_FIQ, - UNW_ARM_R11_FIQ, - UNW_ARM_R12_FIQ, - UNW_ARM_R13_FIQ, - UNW_ARM_R14_FIQ, - - /* IRQ registers. */ - UNW_ARM_R13_IRQ = 158, - UNW_ARM_R14_IRQ, - - /* ABT registers. */ - UNW_ARM_R13_ABT = 160, - UNW_ARM_R14_ABT, - - /* UND registers. */ - UNW_ARM_R13_UND = 162, - UNW_ARM_R14_UND, - - /* SVC registers. */ - UNW_ARM_R13_SVC = 164, - UNW_ARM_R14_SVC, - - /* iWMMXt control registers. */ - UNW_ARM_wC0 = 192, - UNW_ARM_wC1, - UNW_ARM_wC2, - UNW_ARM_wC3, - UNW_ARM_wC4, - UNW_ARM_wC5, - UNW_ARM_wC6, - UNW_ARM_wC7, - - /* VFPv3/Neon 64-bit registers. */ - UNW_ARM_D0 = 256, - UNW_ARM_D1, - UNW_ARM_D2, - UNW_ARM_D3, - UNW_ARM_D4, - UNW_ARM_D5, - UNW_ARM_D6, - UNW_ARM_D7, - UNW_ARM_D8, - UNW_ARM_D9, - UNW_ARM_D10, - UNW_ARM_D11, - UNW_ARM_D12, - UNW_ARM_D13, - UNW_ARM_D14, - UNW_ARM_D15, - UNW_ARM_D16, - UNW_ARM_D17, - UNW_ARM_D18, - UNW_ARM_D19, - UNW_ARM_D20, - UNW_ARM_D21, - UNW_ARM_D22, - UNW_ARM_D23, - UNW_ARM_D24, - UNW_ARM_D25, - UNW_ARM_D26, - UNW_ARM_D27, - UNW_ARM_D28, - UNW_ARM_D29, - UNW_ARM_D30, - UNW_ARM_D31, - - /* For ARM, the CFA is the value of SP (r13) at the call site in the - previous frame. */ - UNW_ARM_CFA, - - UNW_TDEP_LAST_REG = UNW_ARM_D31, - - UNW_TDEP_IP = UNW_ARM_R14, /* A little white lie. */ - UNW_TDEP_SP = UNW_ARM_R13, - UNW_TDEP_EH = UNW_ARM_R0 /* FIXME. */ - } -arm_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 2 /* FIXME for ARM. */ - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_save_loc_t; - -/* On ARM, we define our own unw_tdep_context instead of using ucontext_t. - This allows us to support systems that don't support getcontext and - therefore do not define ucontext_t. */ -typedef struct unw_tdep_context - { - unsigned long regs[16]; - } -unw_tdep_context_t; - -/* There is no getcontext() on ARM. Use a stub version which only saves GP - registers. FIXME: Not ideal, may not be sufficient for all libunwind - use cases. Stores pc+8, which is only approximately correct, really. */ -#ifndef __thumb__ -#define unw_tdep_getcontext(uc) (({ \ - unw_tdep_context_t *unw_ctx = (uc); \ - register unsigned long *unw_base asm ("r0") = unw_ctx->regs; \ - __asm__ __volatile__ ( \ - "stmia %[base], {r0-r15}" \ - : : [base] "r" (unw_base) : "memory"); \ - }), 0) -#else /* __thumb__ */ -#define unw_tdep_getcontext(uc) (({ \ - unw_tdep_context_t *unw_ctx = (uc); \ - register unsigned long *unw_base asm ("r0") = unw_ctx->regs; \ - __asm__ __volatile__ ( \ - ".align 2\nbx pc\nnop\n.code 32\n" \ - "stmia %[base], {r0-r15}\n" \ - "orr %[base], pc, #1\nbx %[base]" \ - : [base] "+r" (unw_base) : : "memory", "cc"); \ - }), 0) -#endif - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no arm-specific auxiliary proc-info */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-common.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-common.h deleted file mode 100644 index f4cbc88af..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-common.h +++ /dev/null @@ -1,308 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* ANDROID support update. */ -#include -/* End of ANDROID update. */ - -#define UNW_VERSION_MAJOR 1 -#define UNW_VERSION_MINOR 1 -#define UNW_VERSION_EXTRA - -#define UNW_VERSION_CODE(maj,min) (((maj) << 16) | (min)) -#define UNW_VERSION UNW_VERSION_CODE(UNW_VERSION_MAJOR, UNW_VERSION_MINOR) - -#define UNW_PASTE2(x,y) x##y -#define UNW_PASTE(x,y) UNW_PASTE2(x,y) -#define UNW_OBJ(fn) UNW_PASTE(UNW_PREFIX, fn) -#define UNW_ARCH_OBJ(fn) UNW_PASTE(UNW_PASTE(UNW_PASTE(_U,UNW_TARGET),_), fn) - -#ifdef UNW_LOCAL_ONLY -# ifdef UNW_ADDITIONAL_PREFIX -# define UNW_PREFIX UNW_PASTE(UNW_PASTE(_UUL,UNW_TARGET),_) -# else -# define UNW_PREFIX UNW_PASTE(UNW_PASTE(_UL,UNW_TARGET),_) -# endif -#else /* !UNW_LOCAL_ONLY */ -# ifdef UNW_ADDITIONAL_PREFIX -# define UNW_PREFIX UNW_PASTE(UNW_PASTE(_UU,UNW_TARGET),_) -# else -# define UNW_PREFIX UNW_PASTE(UNW_PASTE(_U,UNW_TARGET),_) -# endif -#endif /* !UNW_LOCAL_ONLY */ - -/* Error codes. The unwind routines return the *negated* values of - these error codes on error and a non-negative value on success. */ -typedef enum - { - UNW_ESUCCESS = 0, /* no error */ - UNW_EUNSPEC, /* unspecified (general) error */ - UNW_ENOMEM, /* out of memory */ - UNW_EBADREG, /* bad register number */ - UNW_EREADONLYREG, /* attempt to write read-only register */ - UNW_ESTOPUNWIND, /* stop unwinding */ - UNW_EINVALIDIP, /* invalid IP */ - UNW_EBADFRAME, /* bad frame */ - UNW_EINVAL, /* unsupported operation or bad value */ - UNW_EBADVERSION, /* unwind info has unsupported version */ - UNW_ENOINFO /* no unwind info found */ - } -unw_error_t; - -/* The following enum defines the indices for a couple of - (pseudo-)registers which have the same meaning across all - platforms. (RO) means read-only. (RW) means read-write. General - registers (aka "integer registers") are expected to start with - index 0. The number of such registers is architecture-dependent. - The remaining indices can be used as an architecture sees fit. The - last valid register index is given by UNW_REG_LAST. */ -typedef enum - { - UNW_REG_IP = UNW_TDEP_IP, /* (rw) instruction pointer (pc) */ - UNW_REG_SP = UNW_TDEP_SP, /* (ro) stack pointer */ - UNW_REG_EH = UNW_TDEP_EH, /* (rw) exception-handling reg base */ - UNW_REG_LAST = UNW_TDEP_LAST_REG - } -unw_frame_regnum_t; - -/* Number of exception-handler argument registers: */ -#define UNW_NUM_EH_REGS UNW_TDEP_NUM_EH_REGS - -typedef enum - { - UNW_CACHE_NONE, /* no caching */ - UNW_CACHE_GLOBAL, /* shared global cache */ - UNW_CACHE_PER_THREAD /* per-thread caching */ - } -unw_caching_policy_t; - -typedef int unw_regnum_t; - -/* The unwind cursor starts at the youngest (most deeply nested) frame - and is used to track the frame state as the unwinder steps from - frame to frame. It is safe to make (shallow) copies of variables - of this type. */ -typedef struct unw_cursor - { - unw_word_t opaque[UNW_TDEP_CURSOR_LEN]; - } -unw_cursor_t; - -/* This type encapsulates the entire (preserved) machine-state. */ -typedef unw_tdep_context_t unw_context_t; - -/* unw_getcontext() fills the unw_context_t pointed to by UC with the - machine state as it exists at the call-site. For implementation - reasons, this needs to be a target-dependent macro. It's easiest - to think of unw_getcontext() as being identical to getcontext(). */ -#define unw_getcontext(uc) unw_tdep_getcontext(uc) - -/* Return 1 if register number R is a floating-point register, zero - otherwise. - This routine is signal-safe. */ -#define unw_is_fpreg(r) unw_tdep_is_fpreg(r) - -typedef unw_tdep_fpreg_t unw_fpreg_t; - -typedef struct unw_addr_space *unw_addr_space_t; - -/* Each target may define it's own set of flags, but bits 0-15 are - reserved for general libunwind-use. */ -#define UNW_PI_FLAG_FIRST_TDEP_BIT 16 -/* The information comes from a .debug_frame section. */ -#define UNW_PI_FLAG_DEBUG_FRAME 32 - -typedef struct unw_proc_info - { - unw_word_t start_ip; /* first IP covered by this procedure */ - unw_word_t end_ip; /* first IP NOT covered by this procedure */ - unw_word_t lsda; /* address of lang.-spec. data area (if any) */ - unw_word_t handler; /* optional personality routine */ - unw_word_t gp; /* global-pointer value for this procedure */ - unw_word_t flags; /* misc. flags */ - - int format; /* unwind-info format (arch-specific) */ - int unwind_info_size; /* size of the information (if applicable) */ - void *unwind_info; /* unwind-info (arch-specific) */ - unw_tdep_proc_info_t extra; /* target-dependent auxiliary proc-info */ - } -unw_proc_info_t; - -/* These are backend callback routines that provide access to the - state of a "remote" process. This can be used, for example, to - unwind another process through the ptrace() interface. */ -typedef struct unw_accessors - { - /* Look up the unwind info associated with instruction-pointer IP. - On success, the routine fills in the PROC_INFO structure. */ - int (*find_proc_info) (unw_addr_space_t, unw_word_t, unw_proc_info_t *, - int, void *); - - /* Release any resources (e.g., memory) that were allocated for - the unwind info returned in by a previous call to - find_proc_info() with NEED_UNWIND_INFO set to 1. */ - void (*put_unwind_info) (unw_addr_space_t, unw_proc_info_t *, void *); - - /* Return the list-head of the dynamically registered unwind - info. */ - int (*get_dyn_info_list_addr) (unw_addr_space_t, unw_word_t *, void *); - - /* Access aligned word at address ADDR. The value is returned - according to the endianness of the host (e.g., if the host is - little-endian and the target is big-endian, access_mem() needs - to byte-swap the value before returning it). */ - int (*access_mem) (unw_addr_space_t, unw_word_t, unw_word_t *, int, - void *); - - /* Access register number REG at address ADDR. */ - int (*access_reg) (unw_addr_space_t, unw_regnum_t, unw_word_t *, int, - void *); - - /* Access register number REG at address ADDR. */ - int (*access_fpreg) (unw_addr_space_t, unw_regnum_t, - unw_fpreg_t *, int, void *); - - int (*resume) (unw_addr_space_t, unw_cursor_t *, void *); - - /* Optional call back to obtain the name of a (static) procedure. - Dynamically generated procedures are handled automatically by - libunwind. This callback is optional and may be set to - NULL. */ - int (*get_proc_name) (unw_addr_space_t, unw_word_t, char *, size_t, - unw_word_t *, void *); - } -unw_accessors_t; - -typedef enum unw_save_loc_type - { - UNW_SLT_NONE, /* register is not saved ("not an l-value") */ - UNW_SLT_MEMORY, /* register has been saved in memory */ - UNW_SLT_REG /* register has been saved in (another) register */ - } -unw_save_loc_type_t; - -typedef struct unw_save_loc - { - unw_save_loc_type_t type; - union - { - unw_word_t addr; /* valid if type==UNW_SLT_MEMORY */ - unw_regnum_t regnum; /* valid if type==UNW_SLT_REG */ - } - u; - unw_tdep_save_loc_t extra; /* target-dependent additional information */ - } -unw_save_loc_t; - -/* ANDROID support update. */ -typedef struct unw_map_cursor - { - void *map_list; - void *cur_map; - } -unw_map_cursor_t; - -typedef struct unw_map - { - unw_word_t start; - unw_word_t end; - unw_word_t offset; - unw_word_t load_base; - char *path; - int flags; - } -unw_map_t; -/* End of ANDROID update. */ - -/* These routines work both for local and remote unwinding. */ - -#define unw_local_access_addr_space_init UNW_OBJ(local_access_addr_space_init) -#define unw_local_addr_space UNW_OBJ(local_addr_space) -#define unw_create_addr_space UNW_OBJ(create_addr_space) -#define unw_destroy_addr_space UNW_OBJ(destroy_addr_space) -#define unw_get_accessors UNW_ARCH_OBJ(get_accessors) -#define unw_init_local UNW_OBJ(init_local) -#define unw_init_remote UNW_OBJ(init_remote) -#define unw_step UNW_OBJ(step) -#define unw_resume UNW_OBJ(resume) -#define unw_get_proc_info UNW_OBJ(get_proc_info) -#define unw_get_proc_info_by_ip UNW_OBJ(get_proc_info_by_ip) -#define unw_get_reg UNW_OBJ(get_reg) -#define unw_set_reg UNW_OBJ(set_reg) -#define unw_get_fpreg UNW_OBJ(get_fpreg) -#define unw_set_fpreg UNW_OBJ(set_fpreg) -#define unw_get_save_loc UNW_OBJ(get_save_loc) -#define unw_is_signal_frame UNW_OBJ(is_signal_frame) -#define unw_handle_signal_frame UNW_OBJ(handle_signal_frame) -#define unw_get_proc_name UNW_OBJ(get_proc_name) -#define unw_get_proc_name_by_ip UNW_OBJ(get_proc_name_by_ip) -#define unw_set_caching_policy UNW_OBJ(set_caching_policy) -#define unw_regname UNW_ARCH_OBJ(regname) -#define unw_flush_cache UNW_ARCH_OBJ(flush_cache) -#define unw_strerror UNW_ARCH_OBJ(strerror) - -extern void unw_local_access_addr_space_init (unw_addr_space_t); -extern unw_addr_space_t unw_create_addr_space (unw_accessors_t *, int); -extern void unw_destroy_addr_space (unw_addr_space_t); -extern unw_accessors_t *unw_get_accessors (unw_addr_space_t); -extern void unw_flush_cache (unw_addr_space_t, unw_word_t, unw_word_t); -extern int unw_set_caching_policy (unw_addr_space_t, unw_caching_policy_t); -extern const char *unw_regname (unw_regnum_t); - -extern int unw_init_local (unw_cursor_t *, unw_context_t *); -extern int unw_init_remote (unw_cursor_t *, unw_addr_space_t, void *); -extern int unw_step (unw_cursor_t *); -extern int unw_resume (unw_cursor_t *); -extern int unw_get_proc_info (unw_cursor_t *, unw_proc_info_t *); -extern int unw_get_proc_info_by_ip (unw_addr_space_t, unw_word_t, - unw_proc_info_t *, void *); -extern int unw_get_reg (unw_cursor_t *, int, unw_word_t *); -extern int unw_set_reg (unw_cursor_t *, int, unw_word_t); -extern int unw_get_fpreg (unw_cursor_t *, int, unw_fpreg_t *); -extern int unw_set_fpreg (unw_cursor_t *, int, unw_fpreg_t); -extern int unw_get_save_loc (unw_cursor_t *, int, unw_save_loc_t *); -extern int unw_is_signal_frame (unw_cursor_t *); -extern int unw_handle_signal_frame (unw_cursor_t *); -extern int unw_get_proc_name (unw_cursor_t *, char *, size_t, unw_word_t *); -extern int unw_get_proc_name_by_ip (unw_addr_space_t, unw_word_t, char *, - size_t, unw_word_t *, void *); -extern const char *unw_strerror (int); -extern int unw_backtrace (void **, int); - -/* ANDROID support update. */ -extern int unw_map_local_cursor_valid (unw_map_cursor_t *); -extern void unw_map_local_cursor_get (unw_map_cursor_t *); -extern int unw_map_local_cursor_get_next (unw_map_cursor_t *, unw_map_t *); -extern int unw_map_local_create (void); -extern void unw_map_local_destroy (void); -extern void unw_map_set (unw_addr_space_t, unw_map_cursor_t *); -extern void unw_map_cursor_reset (unw_map_cursor_t *); -extern void unw_map_cursor_clear (unw_map_cursor_t *); -extern int unw_map_cursor_create (unw_map_cursor_t *, pid_t); -extern void unw_map_cursor_destroy (unw_map_cursor_t *); -extern int unw_map_cursor_get_next (unw_map_cursor_t *, unw_map_t *); -/* End of ANDROID update. */ - -extern unw_addr_space_t unw_local_addr_space; diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-common.h.in b/app/src/main/jni/crash_dump/libunwind/include/libunwind-common.h.in deleted file mode 100644 index fa753ba15..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-common.h.in +++ /dev/null @@ -1,257 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#define UNW_VERSION_MAJOR @PKG_MAJOR@ -#define UNW_VERSION_MINOR @PKG_MINOR@ -#define UNW_VERSION_EXTRA @PKG_EXTRA@ - -#define UNW_VERSION_CODE(maj,min) (((maj) << 16) | (min)) -#define UNW_VERSION UNW_VERSION_CODE(UNW_VERSION_MAJOR, UNW_VERSION_MINOR) - -#define UNW_PASTE2(x,y) x##y -#define UNW_PASTE(x,y) UNW_PASTE2(x,y) -#define UNW_OBJ(fn) UNW_PASTE(UNW_PREFIX, fn) -#define UNW_ARCH_OBJ(fn) UNW_PASTE(UNW_PASTE(UNW_PASTE(_U,UNW_TARGET),_), fn) - -#ifdef UNW_LOCAL_ONLY -# define UNW_PREFIX UNW_PASTE(UNW_PASTE(_UL,UNW_TARGET),_) -#else /* !UNW_LOCAL_ONLY */ -# define UNW_PREFIX UNW_PASTE(UNW_PASTE(_U,UNW_TARGET),_) -#endif /* !UNW_LOCAL_ONLY */ - -/* Error codes. The unwind routines return the *negated* values of - these error codes on error and a non-negative value on success. */ -typedef enum - { - UNW_ESUCCESS = 0, /* no error */ - UNW_EUNSPEC, /* unspecified (general) error */ - UNW_ENOMEM, /* out of memory */ - UNW_EBADREG, /* bad register number */ - UNW_EREADONLYREG, /* attempt to write read-only register */ - UNW_ESTOPUNWIND, /* stop unwinding */ - UNW_EINVALIDIP, /* invalid IP */ - UNW_EBADFRAME, /* bad frame */ - UNW_EINVAL, /* unsupported operation or bad value */ - UNW_EBADVERSION, /* unwind info has unsupported version */ - UNW_ENOINFO /* no unwind info found */ - } -unw_error_t; - -/* The following enum defines the indices for a couple of - (pseudo-)registers which have the same meaning across all - platforms. (RO) means read-only. (RW) means read-write. General - registers (aka "integer registers") are expected to start with - index 0. The number of such registers is architecture-dependent. - The remaining indices can be used as an architecture sees fit. The - last valid register index is given by UNW_REG_LAST. */ -typedef enum - { - UNW_REG_IP = UNW_TDEP_IP, /* (rw) instruction pointer (pc) */ - UNW_REG_SP = UNW_TDEP_SP, /* (ro) stack pointer */ - UNW_REG_EH = UNW_TDEP_EH, /* (rw) exception-handling reg base */ - UNW_REG_LAST = UNW_TDEP_LAST_REG - } -unw_frame_regnum_t; - -/* Number of exception-handler argument registers: */ -#define UNW_NUM_EH_REGS UNW_TDEP_NUM_EH_REGS - -typedef enum - { - UNW_CACHE_NONE, /* no caching */ - UNW_CACHE_GLOBAL, /* shared global cache */ - UNW_CACHE_PER_THREAD /* per-thread caching */ - } -unw_caching_policy_t; - -typedef int unw_regnum_t; - -/* The unwind cursor starts at the youngest (most deeply nested) frame - and is used to track the frame state as the unwinder steps from - frame to frame. It is safe to make (shallow) copies of variables - of this type. */ -typedef struct unw_cursor - { - unw_word_t opaque[UNW_TDEP_CURSOR_LEN]; - } -unw_cursor_t; - -/* This type encapsulates the entire (preserved) machine-state. */ -typedef unw_tdep_context_t unw_context_t; - -/* unw_getcontext() fills the unw_context_t pointed to by UC with the - machine state as it exists at the call-site. For implementation - reasons, this needs to be a target-dependent macro. It's easiest - to think of unw_getcontext() as being identical to getcontext(). */ -#define unw_getcontext(uc) unw_tdep_getcontext(uc) - -/* Return 1 if register number R is a floating-point register, zero - otherwise. - This routine is signal-safe. */ -#define unw_is_fpreg(r) unw_tdep_is_fpreg(r) - -typedef unw_tdep_fpreg_t unw_fpreg_t; - -typedef struct unw_addr_space *unw_addr_space_t; - -/* Each target may define it's own set of flags, but bits 0-15 are - reserved for general libunwind-use. */ -#define UNW_PI_FLAG_FIRST_TDEP_BIT 16 -/* The information comes from a .debug_frame section. */ -#define UNW_PI_FLAG_DEBUG_FRAME 32 - -typedef struct unw_proc_info - { - unw_word_t start_ip; /* first IP covered by this procedure */ - unw_word_t end_ip; /* first IP NOT covered by this procedure */ - unw_word_t lsda; /* address of lang.-spec. data area (if any) */ - unw_word_t handler; /* optional personality routine */ - unw_word_t gp; /* global-pointer value for this procedure */ - unw_word_t flags; /* misc. flags */ - - int format; /* unwind-info format (arch-specific) */ - int unwind_info_size; /* size of the information (if applicable) */ - void *unwind_info; /* unwind-info (arch-specific) */ - unw_tdep_proc_info_t extra; /* target-dependent auxiliary proc-info */ - } -unw_proc_info_t; - -/* These are backend callback routines that provide access to the - state of a "remote" process. This can be used, for example, to - unwind another process through the ptrace() interface. */ -typedef struct unw_accessors - { - /* Look up the unwind info associated with instruction-pointer IP. - On success, the routine fills in the PROC_INFO structure. */ - int (*find_proc_info) (unw_addr_space_t, unw_word_t, unw_proc_info_t *, - int, void *); - - /* Release any resources (e.g., memory) that were allocated for - the unwind info returned in by a previous call to - find_proc_info() with NEED_UNWIND_INFO set to 1. */ - void (*put_unwind_info) (unw_addr_space_t, unw_proc_info_t *, void *); - - /* Return the list-head of the dynamically registered unwind - info. */ - int (*get_dyn_info_list_addr) (unw_addr_space_t, unw_word_t *, void *); - - /* Access aligned word at address ADDR. The value is returned - according to the endianness of the host (e.g., if the host is - little-endian and the target is big-endian, access_mem() needs - to byte-swap the value before returning it). */ - int (*access_mem) (unw_addr_space_t, unw_word_t, unw_word_t *, int, - void *); - - /* Access register number REG at address ADDR. */ - int (*access_reg) (unw_addr_space_t, unw_regnum_t, unw_word_t *, int, - void *); - - /* Access register number REG at address ADDR. */ - int (*access_fpreg) (unw_addr_space_t, unw_regnum_t, - unw_fpreg_t *, int, void *); - - int (*resume) (unw_addr_space_t, unw_cursor_t *, void *); - - /* Optional call back to obtain the name of a (static) procedure. - Dynamically generated procedures are handled automatically by - libunwind. This callback is optional and may be set to - NULL. */ - int (*get_proc_name) (unw_addr_space_t, unw_word_t, char *, size_t, - unw_word_t *, void *); - } -unw_accessors_t; - -typedef enum unw_save_loc_type - { - UNW_SLT_NONE, /* register is not saved ("not an l-value") */ - UNW_SLT_MEMORY, /* register has been saved in memory */ - UNW_SLT_REG /* register has been saved in (another) register */ - } -unw_save_loc_type_t; - -typedef struct unw_save_loc - { - unw_save_loc_type_t type; - union - { - unw_word_t addr; /* valid if type==UNW_SLT_MEMORY */ - unw_regnum_t regnum; /* valid if type==UNW_SLT_REG */ - } - u; - unw_tdep_save_loc_t extra; /* target-dependent additional information */ - } -unw_save_loc_t; - -/* These routines work both for local and remote unwinding. */ - -#define unw_local_addr_space UNW_OBJ(local_addr_space) -#define unw_create_addr_space UNW_OBJ(create_addr_space) -#define unw_destroy_addr_space UNW_OBJ(destroy_addr_space) -#define unw_get_accessors UNW_ARCH_OBJ(get_accessors) -#define unw_init_local UNW_OBJ(init_local) -#define unw_init_remote UNW_OBJ(init_remote) -#define unw_step UNW_OBJ(step) -#define unw_resume UNW_OBJ(resume) -#define unw_get_proc_info UNW_OBJ(get_proc_info) -#define unw_get_proc_info_by_ip UNW_OBJ(get_proc_info_by_ip) -#define unw_get_reg UNW_OBJ(get_reg) -#define unw_set_reg UNW_OBJ(set_reg) -#define unw_get_fpreg UNW_OBJ(get_fpreg) -#define unw_set_fpreg UNW_OBJ(set_fpreg) -#define unw_get_save_loc UNW_OBJ(get_save_loc) -#define unw_is_signal_frame UNW_OBJ(is_signal_frame) -#define unw_handle_signal_frame UNW_OBJ(handle_signal_frame) -#define unw_get_proc_name UNW_OBJ(get_proc_name) -#define unw_set_caching_policy UNW_OBJ(set_caching_policy) -#define unw_regname UNW_ARCH_OBJ(regname) -#define unw_flush_cache UNW_ARCH_OBJ(flush_cache) -#define unw_strerror UNW_ARCH_OBJ(strerror) - -extern unw_addr_space_t unw_create_addr_space (unw_accessors_t *, int); -extern void unw_destroy_addr_space (unw_addr_space_t); -extern unw_accessors_t *unw_get_accessors (unw_addr_space_t); -extern void unw_flush_cache (unw_addr_space_t, unw_word_t, unw_word_t); -extern int unw_set_caching_policy (unw_addr_space_t, unw_caching_policy_t); -extern const char *unw_regname (unw_regnum_t); - -extern int unw_init_local (unw_cursor_t *, unw_context_t *); -extern int unw_init_remote (unw_cursor_t *, unw_addr_space_t, void *); -extern int unw_step (unw_cursor_t *); -extern int unw_resume (unw_cursor_t *); -extern int unw_get_proc_info (unw_cursor_t *, unw_proc_info_t *); -extern int unw_get_proc_info_by_ip (unw_addr_space_t, unw_word_t, - unw_proc_info_t *, void *); -extern int unw_get_reg (unw_cursor_t *, int, unw_word_t *); -extern int unw_set_reg (unw_cursor_t *, int, unw_word_t); -extern int unw_get_fpreg (unw_cursor_t *, int, unw_fpreg_t *); -extern int unw_set_fpreg (unw_cursor_t *, int, unw_fpreg_t); -extern int unw_get_save_loc (unw_cursor_t *, int, unw_save_loc_t *); -extern int unw_is_signal_frame (unw_cursor_t *); -extern int unw_handle_signal_frame (unw_cursor_t *); -extern int unw_get_proc_name (unw_cursor_t *, char *, size_t, unw_word_t *); -extern const char *unw_strerror (int); -extern int unw_backtrace (void **, int); - -extern unw_addr_space_t unw_local_addr_space; diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-coredump.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-coredump.h deleted file mode 100644 index d2b05e71c..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-coredump.h +++ /dev/null @@ -1,73 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef libunwind_coredump_h -#define libunwind_coredump_h - -#include - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -/* Helper routines which make it easy to use libunwind on a coredump. - They're available only if UNW_REMOTE_ONLY is _not_ defined and they - aren't really part of the libunwind API. They are implemented in a - archive library called libunwind-coredump.a. */ - -struct UCD_info; - -extern struct UCD_info *_UCD_create(const char *filename); -extern void _UCD_destroy(struct UCD_info *); - -extern int _UCD_get_num_threads(struct UCD_info *); -extern void _UCD_select_thread(struct UCD_info *, int); -extern pid_t _UCD_get_pid(struct UCD_info *); -extern int _UCD_get_cursig(struct UCD_info *); -extern int _UCD_add_backing_file_at_segment(struct UCD_info *, int phdr_no, const char *filename); -extern int _UCD_add_backing_file_at_vaddr(struct UCD_info *, - unsigned long vaddr, - const char *filename); - -extern int _UCD_find_proc_info (unw_addr_space_t, unw_word_t, - unw_proc_info_t *, int, void *); -extern void _UCD_put_unwind_info (unw_addr_space_t, unw_proc_info_t *, void *); -extern int _UCD_get_dyn_info_list_addr (unw_addr_space_t, unw_word_t *, - void *); -extern int _UCD_access_mem (unw_addr_space_t, unw_word_t, unw_word_t *, int, - void *); -extern int _UCD_access_reg (unw_addr_space_t, unw_regnum_t, unw_word_t *, - int, void *); -extern int _UCD_access_fpreg (unw_addr_space_t, unw_regnum_t, unw_fpreg_t *, - int, void *); -extern int _UCD_get_proc_name (unw_addr_space_t, unw_word_t, char *, size_t, - unw_word_t *, void *); -extern int _UCD_resume (unw_addr_space_t, unw_cursor_t *, void *); -extern unw_accessors_t _UCD_accessors; - - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* libunwind_coredump_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-dynamic.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-dynamic.h deleted file mode 100644 index 584f392c5..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-dynamic.h +++ /dev/null @@ -1,210 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* This file defines the runtime-support routines for dynamically -generated code. Even though it is implemented as part of libunwind, -it is logically separate from the interface to perform the actual -unwinding. In particular, this interface is always used in the -context of the unwind target, whereas the rest of the unwind API is -used in context of the process that is doing the unwind (which may be -a debugger running on another machine, for example). - -Note that the data-structures declared here server a dual purpose: -when a program registers a dynamically generated procedure, it uses -these structures directly. On the other hand, with remote-unwinding, -the data-structures are read from the remote process's memory and -translated into internalized versions. To facilitate remote-access, -the following rules should be followed in declaring these structures: - - (1) Declare a member as a pointer only if the the information the - member points to needs to be internalized as well (e.g., a - string representing a procedure name should be declared as - "const char *", but the instruction pointer should be declared - as unw_word_t). - - (2) Provide sufficient padding to ensure that no implicit padding - will be needed on any of the supported target architectures. For - the time being, padding data structures with the assumption that - sizeof (unw_word_t) == 8 should be sufficient. (Note: it's not - impossible to internalize structures with internal padding, but - it does make the process a bit harder). - - (3) Don't declare members that contain bitfields or floating-point - values. - - (4) Don't declare members with enumeration types. Declare them as - int32_t instead. */ - -typedef enum - { - UNW_DYN_STOP = 0, /* end-of-unwind-info marker */ - UNW_DYN_SAVE_REG, /* save register to another register */ - UNW_DYN_SPILL_FP_REL, /* frame-pointer-relative register spill */ - UNW_DYN_SPILL_SP_REL, /* stack-pointer-relative register spill */ - UNW_DYN_ADD, /* add constant value to a register */ - UNW_DYN_POP_FRAMES, /* drop one or more stack frames */ - UNW_DYN_LABEL_STATE, /* name the current state */ - UNW_DYN_COPY_STATE, /* set the region's entry-state */ - UNW_DYN_ALIAS /* get unwind info from an alias */ - } -unw_dyn_operation_t; - -typedef enum - { - UNW_INFO_FORMAT_DYNAMIC, /* unw_dyn_proc_info_t */ - UNW_INFO_FORMAT_TABLE, /* unw_dyn_table_t */ - UNW_INFO_FORMAT_REMOTE_TABLE, /* unw_dyn_remote_table_t */ - UNW_INFO_FORMAT_ARM_EXIDX /* ARM specific unwind info */ - } -unw_dyn_info_format_t; - -typedef struct unw_dyn_op - { - int8_t tag; /* what operation? */ - int8_t qp; /* qualifying predicate register */ - int16_t reg; /* what register */ - int32_t when; /* when does it take effect? */ - unw_word_t val; /* auxiliary value */ - } -unw_dyn_op_t; - -typedef struct unw_dyn_region_info - { - struct unw_dyn_region_info *next; /* linked list of regions */ - int32_t insn_count; /* region length (# of instructions) */ - uint32_t op_count; /* length of op-array */ - unw_dyn_op_t op[1]; /* variable-length op-array */ - } -unw_dyn_region_info_t; - -typedef struct unw_dyn_proc_info - { - unw_word_t name_ptr; /* address of human-readable procedure name */ - unw_word_t handler; /* address of personality routine */ - uint32_t flags; - int32_t pad0; - unw_dyn_region_info_t *regions; - } -unw_dyn_proc_info_t; - -typedef struct unw_dyn_table_info - { - unw_word_t name_ptr; /* addr. of table name (e.g., library name) */ - unw_word_t segbase; /* segment base */ - unw_word_t table_len; /* must be a multiple of sizeof(unw_word_t)! */ - unw_word_t *table_data; - } -unw_dyn_table_info_t; - -typedef struct unw_dyn_remote_table_info - { - unw_word_t name_ptr; /* addr. of table name (e.g., library name) */ - unw_word_t segbase; /* segment base */ - unw_word_t table_len; /* must be a multiple of sizeof(unw_word_t)! */ - unw_word_t table_data; - } -unw_dyn_remote_table_info_t; - -typedef struct unw_dyn_info - { - /* doubly-linked list of dyn-info structures: */ - struct unw_dyn_info *next; - struct unw_dyn_info *prev; - unw_word_t start_ip; /* first IP covered by this entry */ - unw_word_t end_ip; /* first IP NOT covered by this entry */ - unw_word_t gp; /* global-pointer in effect for this entry */ - int32_t format; /* real type: unw_dyn_info_format_t */ - int32_t pad; - union - { - unw_dyn_proc_info_t pi; - unw_dyn_table_info_t ti; - unw_dyn_remote_table_info_t rti; - } - u; - } -unw_dyn_info_t; - -typedef struct unw_dyn_info_list - { - uint32_t version; - uint32_t generation; - unw_dyn_info_t *first; - } -unw_dyn_info_list_t; - -/* Return the size (in bytes) of an unw_dyn_region_info_t structure that can - hold OP_COUNT ops. */ -#define _U_dyn_region_info_size(op_count) \ - ((char *) (((unw_dyn_region_info_t *) NULL)->op + (op_count)) \ - - (char *) NULL) - -/* Register the unwind info for a single procedure. - This routine is NOT signal-safe. */ -extern void _U_dyn_register (unw_dyn_info_t *); - -/* Cancel the unwind info for a single procedure. - This routine is NOT signal-safe. */ -extern void _U_dyn_cancel (unw_dyn_info_t *); - - -/* Convenience routines. */ - -#define _U_dyn_op(_tag, _qp, _when, _reg, _val) \ - ((unw_dyn_op_t) { (_tag), (_qp), (_reg), (_when), (_val) }) - -#define _U_dyn_op_save_reg(op, qp, when, reg, dst) \ - (*(op) = _U_dyn_op (UNW_DYN_SAVE_REG, (qp), (when), (reg), (dst))) - -#define _U_dyn_op_spill_fp_rel(op, qp, when, reg, offset) \ - (*(op) = _U_dyn_op (UNW_DYN_SPILL_FP_REL, (qp), (when), (reg), \ - (offset))) - -#define _U_dyn_op_spill_sp_rel(op, qp, when, reg, offset) \ - (*(op) = _U_dyn_op (UNW_DYN_SPILL_SP_REL, (qp), (when), (reg), \ - (offset))) - -#define _U_dyn_op_add(op, qp, when, reg, value) \ - (*(op) = _U_dyn_op (UNW_DYN_ADD, (qp), (when), (reg), (value))) - -#define _U_dyn_op_pop_frames(op, qp, when, num_frames) \ - (*(op) = _U_dyn_op (UNW_DYN_POP_FRAMES, (qp), (when), 0, (num_frames))) - -#define _U_dyn_op_label_state(op, label) \ - (*(op) = _U_dyn_op (UNW_DYN_LABEL_STATE, _U_QP_TRUE, -1, 0, (label))) - -#define _U_dyn_op_copy_state(op, label) \ - (*(op) = _U_dyn_op (UNW_DYN_COPY_STATE, _U_QP_TRUE, -1, 0, (label))) - -#define _U_dyn_op_alias(op, qp, when, addr) \ - (*(op) = _U_dyn_op (UNW_DYN_ALIAS, (qp), (when), 0, (addr))) - -#define _U_dyn_op_stop(op) \ - (*(op) = _U_dyn_op (UNW_DYN_STOP, _U_QP_TRUE, -1, 0, 0)) - -/* The target-dependent qualifying predicate which is always TRUE. On - IA-64, that's p0 (0), on non-predicated architectures, the value is - ignored. */ -#define _U_QP_TRUE _U_TDEP_QP_TRUE diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-hppa.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-hppa.h deleted file mode 100644 index b5fba5627..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-hppa.h +++ /dev/null @@ -1,131 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#define UNW_TARGET hppa -#define UNW_TARGET_HPPA 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ -#define UNW_TDEP_CURSOR_LEN 511 - -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; - -typedef union - { - struct { unw_word_t bits[2]; } raw; - double val; - } -unw_tdep_fpreg_t; - -typedef enum - { - /* Note: general registers are expected to start with index 0. - This convention facilitates architecture-independent - implementation of the C++ exception handling ABI. See - _Unwind_SetGR() and _Unwind_GetGR() for details. */ - UNW_HPPA_GR = 0, - UNW_HPPA_RP = 2, /* return pointer */ - UNW_HPPA_FP = 3, /* frame pointer */ - UNW_HPPA_SP = UNW_HPPA_GR + 30, - - UNW_HPPA_FR = UNW_HPPA_GR + 32, - - UNW_HPPA_IP = UNW_HPPA_FR + 32, /* instruction pointer */ - - /* other "preserved" registers (fpsr etc.)... */ - - /* PA-RISC has 4 exception-argument registers but they're not - contiguous. To deal with this, we define 4 pseudo - exception-handling registers which we then alias to the actual - physical register. */ - - UNW_HPPA_EH0 = UNW_HPPA_IP + 1, /* alias for UNW_HPPA_GR + 20 */ - UNW_HPPA_EH1 = UNW_HPPA_EH0 + 1, /* alias for UNW_HPPA_GR + 21 */ - UNW_HPPA_EH2 = UNW_HPPA_EH1 + 1, /* alias for UNW_HPPA_GR + 22 */ - UNW_HPPA_EH3 = UNW_HPPA_EH2 + 1, /* alias for UNW_HPPA_GR + 31 */ - - /* frame info (read-only) */ - UNW_HPPA_CFA, - - UNW_TDEP_LAST_REG = UNW_HPPA_IP, - - UNW_TDEP_IP = UNW_HPPA_IP, - UNW_TDEP_SP = UNW_HPPA_SP, - UNW_TDEP_EH = UNW_HPPA_EH0 - } -hppa_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 4 - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_save_loc_t; - -/* On PA-RISC, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -#define unw_tdep_is_fpreg(r) ((unsigned) ((r) - UNW_HPPA_FR) < 32) - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no PA-RISC-specific auxiliary proc-info */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_getcontext UNW_ARCH_OBJ (getcontext) -extern int unw_tdep_getcontext (unw_tdep_context_t *); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-ia64.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-ia64.h deleted file mode 100644 index 4dcc4f9c3..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-ia64.h +++ /dev/null @@ -1,197 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#include -#include - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#ifdef ia64 - /* This works around a bug in Intel's ECC v7.0 which defines "ia64" - as "1". */ -# undef ia64 -#endif - -#ifdef __hpux - /* On HP-UX, there is no hope of supporting UNW_LOCAL_ONLY, because - it's impossible to obtain the address of the members in the - sigcontext structure. */ -# undef UNW_LOCAL_ONLY -# define UNW_GENERIC_ONLY -#endif - -#define UNW_TARGET ia64 -#define UNW_TARGET_IA64 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ -#define UNW_TDEP_CURSOR_LEN 511 - -/* If this bit is it indicates that the procedure saved all of ar.bsp, - ar.bspstore, and ar.rnat. If, additionally, ar.bsp != saved ar.bsp, - then this procedure has performed a register-backing-store switch. */ -#define UNW_PI_FLAG_IA64_RBS_SWITCH_BIT (UNW_PI_FLAG_FIRST_TDEP_BIT + 0) - -#define UNW_PI_FLAG_IA64_RBS_SWITCH (1 << UNW_PI_FLAG_IA64_RBS_SWITCH_BIT) - -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; - -/* On IA-64, we want to access the contents of floating-point - registers as a pair of "words", but to ensure 16-byte alignment, we - make it a union that contains a "long double". This will do the - Right Thing on all known IA-64 platforms, including HP-UX. */ -typedef union - { - struct { unw_word_t bits[2]; } raw; - long double dummy; /* dummy to force 16-byte alignment */ - } -unw_tdep_fpreg_t; - -typedef struct - { - /* no ia64-specific auxiliary proc-info */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_proc_info_t; - -typedef enum - { - /* Note: general registers are excepted to start with index 0. - This convention facilitates architecture-independent - implementation of the C++ exception handling ABI. See - _Unwind_SetGR() and _Unwind_GetGR() for details. */ - UNW_IA64_GR = 0, /* general registers (r0..r127) */ - UNW_IA64_GP = UNW_IA64_GR + 1, - UNW_IA64_TP = UNW_IA64_GR + 13, - - UNW_IA64_NAT = UNW_IA64_GR + 128, /* NaT registers (nat0..nat127) */ - - UNW_IA64_FR = UNW_IA64_NAT + 128, /* fp registers (f0..f127) */ - - UNW_IA64_AR = UNW_IA64_FR + 128, /* application registers (ar0..r127) */ - UNW_IA64_AR_RSC = UNW_IA64_AR + 16, - UNW_IA64_AR_BSP = UNW_IA64_AR + 17, - UNW_IA64_AR_BSPSTORE = UNW_IA64_AR + 18, - UNW_IA64_AR_RNAT = UNW_IA64_AR + 19, - UNW_IA64_AR_CSD = UNW_IA64_AR + 25, - UNW_IA64_AR_26 = UNW_IA64_AR + 26, - UNW_IA64_AR_SSD = UNW_IA64_AR_26, - UNW_IA64_AR_CCV = UNW_IA64_AR + 32, - UNW_IA64_AR_UNAT = UNW_IA64_AR + 36, - UNW_IA64_AR_FPSR = UNW_IA64_AR + 40, - UNW_IA64_AR_PFS = UNW_IA64_AR + 64, - UNW_IA64_AR_LC = UNW_IA64_AR + 65, - UNW_IA64_AR_EC = UNW_IA64_AR + 66, - - UNW_IA64_BR = UNW_IA64_AR + 128, /* branch registers (b0..p7) */ - UNW_IA64_RP = UNW_IA64_BR + 0, /* return pointer (rp) */ - UNW_IA64_PR = UNW_IA64_BR + 8, /* predicate registers (p0..p63) */ - UNW_IA64_CFM, - - /* frame info: */ - UNW_IA64_BSP, - UNW_IA64_IP, - UNW_IA64_SP, - - UNW_TDEP_LAST_REG = UNW_IA64_SP, - - UNW_TDEP_IP = UNW_IA64_IP, - UNW_TDEP_SP = UNW_IA64_SP, - UNW_TDEP_EH = UNW_IA64_GR + 15 - } -ia64_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 4 /* r15-r18 are exception args */ - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. On IA-64, - we use this to provide the bit number in which a NaT bit gets - saved. */ - uint8_t nat_bitnr; - - /* Padding reserved for future use. */ - uint8_t reserved[7]; - } -unw_tdep_save_loc_t; - -/* On IA-64, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -#define unw_tdep_is_fpreg(r) ((unsigned) ((r) - UNW_IA64_FR) < 128) - -#include "libunwind-dynamic.h" -#include "libunwind-common.h" - -#ifdef __hpux - /* In theory, we could use _Uia64_getcontext() on HP-UX as well, but - the benefit of doing so would be marginal given that it can't - support UNW_LOCAL_ONLY. */ -# define unw_tdep_getcontext getcontext -#else -# define unw_tdep_getcontext UNW_ARCH_OBJ (getcontext) - extern int unw_tdep_getcontext (unw_tdep_context_t *); -#endif - -/* This is a helper routine to search an ia64 unwind table. If the - address-space argument AS points to something other than the local - address-space, the memory for the unwind-info will be allocated - with malloc(), and should be free()d during the put_unwind_info() - callback. This routine is signal-safe for the local-address-space - case ONLY. */ -#define unw_search_ia64_unwind_table UNW_OBJ(search_unwind_table) -extern int unw_search_ia64_unwind_table (unw_addr_space_t, unw_word_t, - unw_dyn_info_t *, unw_proc_info_t *, - int, void *); - -/* This is a helper routine which the get_dyn_info_list_addr() - callback can use to locate the special dynamic-info list entry in - an IA-64 unwind table. If the entry exists in the table, the - list-address is returned. In all other cases, 0 is returned. */ -extern unw_word_t _Uia64_find_dyn_list (unw_addr_space_t, unw_dyn_info_t *, - void *); - -/* This is a helper routine to obtain the kernel-unwind info. It is - signal-safe. */ -extern int _Uia64_get_kernel_table (unw_dyn_info_t *); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-mips.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-mips.h deleted file mode 100644 index 83e44dead..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-mips.h +++ /dev/null @@ -1,163 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#ifdef mips -# undef mips -#endif - -#define UNW_TARGET mips -#define UNW_TARGET_MIPS 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ - -/* FIXME for MIPS. Too big? What do other things use for similar tasks? */ -#define UNW_TDEP_CURSOR_LEN 4096 - -/* The size of a "word" varies on MIPS. This type is used for memory - addresses and register values. To allow a single library to support - multiple ABIs, and to support N32 at all, we must use a 64-bit type - even when addresses are only 32 bits. */ -typedef uint64_t unw_word_t; -typedef int32_t unw_sword_t; - -/* FIXME: MIPS ABIs. */ -typedef long double unw_tdep_fpreg_t; - -typedef enum - { - UNW_MIPS_R0, - UNW_MIPS_R1, - UNW_MIPS_R2, - UNW_MIPS_R3, - UNW_MIPS_R4, - UNW_MIPS_R5, - UNW_MIPS_R6, - UNW_MIPS_R7, - UNW_MIPS_R8, - UNW_MIPS_R9, - UNW_MIPS_R10, - UNW_MIPS_R11, - UNW_MIPS_R12, - UNW_MIPS_R13, - UNW_MIPS_R14, - UNW_MIPS_R15, - UNW_MIPS_R16, - UNW_MIPS_R17, - UNW_MIPS_R18, - UNW_MIPS_R19, - UNW_MIPS_R20, - UNW_MIPS_R21, - UNW_MIPS_R22, - UNW_MIPS_R23, - UNW_MIPS_R24, - UNW_MIPS_R25, - UNW_MIPS_R26, - UNW_MIPS_R27, - UNW_MIPS_R28, - UNW_MIPS_R29, - UNW_MIPS_R30, - UNW_MIPS_R31, - - UNW_MIPS_PC = 34, - - /* FIXME: Other registers! */ - - /* For MIPS, the CFA is the value of SP (r29) at the call site in the - previous frame. */ - UNW_MIPS_CFA, - - UNW_TDEP_LAST_REG = UNW_MIPS_R31, - - UNW_TDEP_IP = UNW_MIPS_R31, - UNW_TDEP_SP = UNW_MIPS_R29, - UNW_TDEP_EH = UNW_MIPS_R0 /* FIXME. */ - } -mips_regnum_t; - -typedef enum - { - UNW_MIPS_ABI_O32, - UNW_MIPS_ABI_N32, - UNW_MIPS_ABI_N64 - } -mips_abi_t; - -#define UNW_TDEP_NUM_EH_REGS 2 /* FIXME for MIPS. */ - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_save_loc_t; - -/* On x86, we can directly use ucontext_t as the unwind context. FIXME for - MIPS. */ -typedef ucontext_t unw_tdep_context_t; - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no mips-specific auxiliary proc-info */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -/* There is no getcontext() on MIPS. Use a stub version which only saves GP - registers. FIXME: Not ideal, may not be sufficient for all libunwind - use cases. */ -#define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext) -extern int unw_tdep_getcontext (ucontext_t *uc); - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-ppc32.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-ppc32.h deleted file mode 100644 index 51852e865..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-ppc32.h +++ /dev/null @@ -1,213 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#define UNW_TARGET ppc32 -#define UNW_TARGET_PPC32 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* - * This needs to be big enough to accommodate "struct cursor", while - * leaving some slack for future expansion. Changing this value will - * require recompiling all users of this library. Stack allocation is - * relatively cheap and unwind-state copying is relatively rare, so we want - * to err on making it rather too big than too small. - * - * To simplify this whole process, we are at least initially taking the - * tack that UNW_PPC32_* map straight across to the .eh_frame column register - * numbers. These register numbers come from gcc's source in - * gcc/config/rs6000/rs6000.h - * - * UNW_TDEP_CURSOR_LEN is in terms of unw_word_t size. Since we have 115 - * elements in the loc array, each sized 2 * unw_word_t, plus the rest of - * the cursor struct, this puts us at about 2 * 115 + 40 = 270. Let's - * round that up to 280. - */ - -#define UNW_TDEP_CURSOR_LEN 280 - -#if __WORDSIZE==32 -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; -#else -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; -#endif - -typedef long double unw_tdep_fpreg_t; - -typedef enum - { - UNW_PPC32_R0, - UNW_PPC32_R1, /* called STACK_POINTER in gcc */ - UNW_PPC32_R2, - UNW_PPC32_R3, - UNW_PPC32_R4, - UNW_PPC32_R5, - UNW_PPC32_R6, - UNW_PPC32_R7, - UNW_PPC32_R8, - UNW_PPC32_R9, - UNW_PPC32_R10, - UNW_PPC32_R11, /* called STATIC_CHAIN in gcc */ - UNW_PPC32_R12, - UNW_PPC32_R13, - UNW_PPC32_R14, - UNW_PPC32_R15, - UNW_PPC32_R16, - UNW_PPC32_R17, - UNW_PPC32_R18, - UNW_PPC32_R19, - UNW_PPC32_R20, - UNW_PPC32_R21, - UNW_PPC32_R22, - UNW_PPC32_R23, - UNW_PPC32_R24, - UNW_PPC32_R25, - UNW_PPC32_R26, - UNW_PPC32_R27, - UNW_PPC32_R28, - UNW_PPC32_R29, - UNW_PPC32_R30, - UNW_PPC32_R31, /* called HARD_FRAME_POINTER in gcc */ - - /* Count Register */ - UNW_PPC32_CTR = 32, - /* Fixed-Point Status and Control Register */ - UNW_PPC32_XER = 33, - /* Condition Register */ - UNW_PPC32_CCR = 34, - /* Machine State Register */ - //UNW_PPC32_MSR = 35, - /* MQ or SPR0, not part of generic Power, part of MPC601 */ - //UNW_PPC32_MQ = 36, - /* Link Register */ - UNW_PPC32_LR = 36, - /* Floating Pointer Status and Control Register */ - UNW_PPC32_FPSCR = 37, - - UNW_PPC32_F0 = 48, - UNW_PPC32_F1, - UNW_PPC32_F2, - UNW_PPC32_F3, - UNW_PPC32_F4, - UNW_PPC32_F5, - UNW_PPC32_F6, - UNW_PPC32_F7, - UNW_PPC32_F8, - UNW_PPC32_F9, - UNW_PPC32_F10, - UNW_PPC32_F11, - UNW_PPC32_F12, - UNW_PPC32_F13, - UNW_PPC32_F14, - UNW_PPC32_F15, - UNW_PPC32_F16, - UNW_PPC32_F17, - UNW_PPC32_F18, - UNW_PPC32_F19, - UNW_PPC32_F20, - UNW_PPC32_F21, - UNW_PPC32_F22, - UNW_PPC32_F23, - UNW_PPC32_F24, - UNW_PPC32_F25, - UNW_PPC32_F26, - UNW_PPC32_F27, - UNW_PPC32_F28, - UNW_PPC32_F29, - UNW_PPC32_F30, - UNW_PPC32_F31, - - UNW_TDEP_LAST_REG = UNW_PPC32_F31, - - UNW_TDEP_IP = UNW_PPC32_LR, - UNW_TDEP_SP = UNW_PPC32_R1, - UNW_TDEP_EH = UNW_PPC32_R12 - } -ppc32_regnum_t; - -/* - * According to David Edelsohn, GNU gcc uses R3, R4, R5, and maybe R6 for - * passing parameters to exception handlers. - */ - -#define UNW_TDEP_NUM_EH_REGS 4 - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_save_loc_t; - -/* On ppc, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -/* XXX this is not ideal: an application should not be prevented from - using the "getcontext" name just because it's using libunwind. We - can't just use __getcontext() either, because that isn't exported - by glibc... */ -#define unw_tdep_getcontext(uc) (getcontext (uc), 0) - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no ppc32-specific auxiliary proc-info */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-ppc64.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-ppc64.h deleted file mode 100644 index e0dbaaa9e..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-ppc64.h +++ /dev/null @@ -1,270 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#define UNW_TARGET ppc64 -#define UNW_TARGET_PPC64 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* - * This needs to be big enough to accommodate "struct cursor", while - * leaving some slack for future expansion. Changing this value will - * require recompiling all users of this library. Stack allocation is - * relatively cheap and unwind-state copying is relatively rare, so we want - * to err on making it rather too big than too small. - * - * To simplify this whole process, we are at least initially taking the - * tack that UNW_PPC64_* map straight across to the .eh_frame column register - * numbers. These register numbers come from gcc's source in - * gcc/config/rs6000/rs6000.h - * - * UNW_TDEP_CURSOR_LEN is in terms of unw_word_t size. Since we have 115 - * elements in the loc array, each sized 2 * unw_word_t, plus the rest of - * the cursor struct, this puts us at about 2 * 115 + 40 = 270. Let's - * round that up to 280. - */ - -#define UNW_TDEP_CURSOR_LEN 280 - -#if __WORDSIZE==32 -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; -#else -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; -#endif - -typedef long double unw_tdep_fpreg_t; - -/* - * Vector register (in PowerPC64 used for AltiVec registers) - */ -typedef struct { - uint64_t halves[2]; -} unw_tdep_vreg_t; - -typedef enum - { - UNW_PPC64_R0, - UNW_PPC64_R1, /* called STACK_POINTER in gcc */ - UNW_PPC64_R2, - UNW_PPC64_R3, - UNW_PPC64_R4, - UNW_PPC64_R5, - UNW_PPC64_R6, - UNW_PPC64_R7, - UNW_PPC64_R8, - UNW_PPC64_R9, - UNW_PPC64_R10, - UNW_PPC64_R11, /* called STATIC_CHAIN in gcc */ - UNW_PPC64_R12, - UNW_PPC64_R13, - UNW_PPC64_R14, - UNW_PPC64_R15, - UNW_PPC64_R16, - UNW_PPC64_R17, - UNW_PPC64_R18, - UNW_PPC64_R19, - UNW_PPC64_R20, - UNW_PPC64_R21, - UNW_PPC64_R22, - UNW_PPC64_R23, - UNW_PPC64_R24, - UNW_PPC64_R25, - UNW_PPC64_R26, - UNW_PPC64_R27, - UNW_PPC64_R28, - UNW_PPC64_R29, - UNW_PPC64_R30, - UNW_PPC64_R31, /* called HARD_FRAME_POINTER in gcc */ - - UNW_PPC64_F0 = 32, - UNW_PPC64_F1, - UNW_PPC64_F2, - UNW_PPC64_F3, - UNW_PPC64_F4, - UNW_PPC64_F5, - UNW_PPC64_F6, - UNW_PPC64_F7, - UNW_PPC64_F8, - UNW_PPC64_F9, - UNW_PPC64_F10, - UNW_PPC64_F11, - UNW_PPC64_F12, - UNW_PPC64_F13, - UNW_PPC64_F14, - UNW_PPC64_F15, - UNW_PPC64_F16, - UNW_PPC64_F17, - UNW_PPC64_F18, - UNW_PPC64_F19, - UNW_PPC64_F20, - UNW_PPC64_F21, - UNW_PPC64_F22, - UNW_PPC64_F23, - UNW_PPC64_F24, - UNW_PPC64_F25, - UNW_PPC64_F26, - UNW_PPC64_F27, - UNW_PPC64_F28, - UNW_PPC64_F29, - UNW_PPC64_F30, - UNW_PPC64_F31, - /* Note that there doesn't appear to be an .eh_frame register column - for the FPSCR register. I don't know why this is. Since .eh_frame - info is what this implementation uses for unwinding, we have no way - to unwind this register, and so we will not expose an FPSCR register - number in the libunwind API. - */ - - UNW_PPC64_LR = 65, - UNW_PPC64_CTR = 66, - UNW_PPC64_ARG_POINTER = 67, - - UNW_PPC64_CR0 = 68, - UNW_PPC64_CR1, - UNW_PPC64_CR2, - UNW_PPC64_CR3, - UNW_PPC64_CR4, - /* CR5 .. CR7 are currently unused */ - UNW_PPC64_CR5, - UNW_PPC64_CR6, - UNW_PPC64_CR7, - - UNW_PPC64_XER = 76, - - UNW_PPC64_V0 = 77, - UNW_PPC64_V1, - UNW_PPC64_V2, - UNW_PPC64_V3, - UNW_PPC64_V4, - UNW_PPC64_V5, - UNW_PPC64_V6, - UNW_PPC64_V7, - UNW_PPC64_V8, - UNW_PPC64_V9, - UNW_PPC64_V10, - UNW_PPC64_V11, - UNW_PPC64_V12, - UNW_PPC64_V13, - UNW_PPC64_V14, - UNW_PPC64_V15, - UNW_PPC64_V16, - UNW_PPC64_V17, - UNW_PPC64_V18, - UNW_PPC64_V19, - UNW_PPC64_V20, - UNW_PPC64_V21, - UNW_PPC64_V22, - UNW_PPC64_V23, - UNW_PPC64_V24, - UNW_PPC64_V25, - UNW_PPC64_V26, - UNW_PPC64_V27, - UNW_PPC64_V28, - UNW_PPC64_V29, - UNW_PPC64_V30, - UNW_PPC64_V31, - - UNW_PPC64_VRSAVE = 109, - UNW_PPC64_VSCR = 110, - UNW_PPC64_SPE_ACC = 111, - UNW_PPC64_SPEFSCR = 112, - - /* frame info (read-only) */ - UNW_PPC64_FRAME_POINTER, - UNW_PPC64_NIP, - - - UNW_TDEP_LAST_REG = UNW_PPC64_NIP, - - UNW_TDEP_IP = UNW_PPC64_NIP, - UNW_TDEP_SP = UNW_PPC64_R1, - UNW_TDEP_EH = UNW_PPC64_R12 - } -ppc64_regnum_t; - -/* - * According to David Edelsohn, GNU gcc uses R3, R4, R5, and maybe R6 for - * passing parameters to exception handlers. - */ - -#define UNW_TDEP_NUM_EH_REGS 4 - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_save_loc_t; - -/* On ppc64, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -/* XXX this is not ideal: an application should not be prevented from - using the "getcontext" name just because it's using libunwind. We - can't just use __getcontext() either, because that isn't exported - by glibc... */ -#define unw_tdep_getcontext(uc) (getcontext (uc), 0) - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no ppc64-specific auxiliary proc-info */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-ptrace.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-ptrace.h deleted file mode 100644 index 7fca205e5..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-ptrace.h +++ /dev/null @@ -1,63 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef libunwind_ptrace_h -#define libunwind_ptrace_h - -#include - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -/* Helper routines which make it easy to use libunwind via ptrace(). - They're available only if UNW_REMOTE_ONLY is _not_ defined and they - aren't really part of the libunwind API. They are implemented in a - archive library called libunwind-ptrace.a. */ - -extern void *_UPT_create (pid_t); -extern void _UPT_destroy (void *); -extern int _UPT_find_proc_info (unw_addr_space_t, unw_word_t, - unw_proc_info_t *, int, void *); -extern void _UPT_put_unwind_info (unw_addr_space_t, unw_proc_info_t *, void *); -extern int _UPT_get_dyn_info_list_addr (unw_addr_space_t, unw_word_t *, - void *); -extern int _UPT_access_mem (unw_addr_space_t, unw_word_t, unw_word_t *, int, - void *); -extern int _UPT_access_reg (unw_addr_space_t, unw_regnum_t, unw_word_t *, - int, void *); -extern int _UPT_access_fpreg (unw_addr_space_t, unw_regnum_t, unw_fpreg_t *, - int, void *); -extern int _UPT_get_proc_name (unw_addr_space_t, unw_word_t, char *, size_t, - unw_word_t *, void *); -extern int _UPT_resume (unw_addr_space_t, unw_cursor_t *, void *); -extern unw_accessors_t _UPT_accessors; - - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* libunwind_ptrace_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-sh.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-sh.h deleted file mode 100644 index 8f36a258d..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-sh.h +++ /dev/null @@ -1,120 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include -#include - -#define UNW_TARGET sh -#define UNW_TARGET_SH 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ - -#define UNW_TDEP_CURSOR_LEN 4096 - -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; - -typedef long double unw_tdep_fpreg_t; - -typedef enum - { - UNW_SH_R0, - UNW_SH_R1, - UNW_SH_R2, - UNW_SH_R3, - UNW_SH_R4, - UNW_SH_R5, - UNW_SH_R6, - UNW_SH_R7, - UNW_SH_R8, - UNW_SH_R9, - UNW_SH_R10, - UNW_SH_R11, - UNW_SH_R12, - UNW_SH_R13, - UNW_SH_R14, - UNW_SH_R15, - - UNW_SH_PC, - UNW_SH_PR, - - UNW_TDEP_LAST_REG = UNW_SH_PR, - - UNW_TDEP_IP = UNW_SH_PR, - UNW_TDEP_SP = UNW_SH_R15, - UNW_TDEP_EH = UNW_SH_R0 - } -sh_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 2 - -typedef ucontext_t unw_tdep_context_t; - -#define unw_tdep_getcontext(uc) (getcontext (uc), 0) - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_save_loc_t; - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no sh-specific auxiliary proc-info */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-x86.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-x86.h deleted file mode 100644 index e46632d51..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-x86.h +++ /dev/null @@ -1,193 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include -#include - -#define UNW_TARGET x86 -#define UNW_TARGET_X86 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ -#define UNW_TDEP_CURSOR_LEN 127 - -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; - -typedef union { - struct { uint8_t b[4]; } val32; - struct { uint8_t b[10]; } val80; - struct { uint8_t b[16]; } val128; -} unw_tdep_fpreg_t; - -typedef enum - { - /* Note: general registers are expected to start with index 0. - This convention facilitates architecture-independent - implementation of the C++ exception handling ABI. See - _Unwind_SetGR() and _Unwind_GetGR() for details. - - The described register usage convention is based on "System V - Application Binary Interface, Intel386 Architecture Processor - Supplement, Fourth Edition" at - - http://www.linuxbase.org/spec/refspecs/elf/abi386-4.pdf - - It would have been nice to use the same register numbering as - DWARF, but that doesn't work because the libunwind requires - that the exception argument registers be consecutive, which the - wouldn't be with the DWARF numbering. */ - UNW_X86_EAX, /* scratch (exception argument 1) */ - UNW_X86_EDX, /* scratch (exception argument 2) */ - UNW_X86_ECX, /* scratch */ - UNW_X86_EBX, /* preserved */ - UNW_X86_ESI, /* preserved */ - UNW_X86_EDI, /* preserved */ - UNW_X86_EBP, /* (optional) frame-register */ - UNW_X86_ESP, /* (optional) frame-register */ - UNW_X86_EIP, /* frame-register */ - UNW_X86_EFLAGS, /* scratch (except for "direction", which is fixed */ - UNW_X86_TRAPNO, /* scratch */ - - /* MMX/stacked-fp registers */ - UNW_X86_ST0, /* fp return value */ - UNW_X86_ST1, /* scratch */ - UNW_X86_ST2, /* scratch */ - UNW_X86_ST3, /* scratch */ - UNW_X86_ST4, /* scratch */ - UNW_X86_ST5, /* scratch */ - UNW_X86_ST6, /* scratch */ - UNW_X86_ST7, /* scratch */ - - UNW_X86_FCW, /* scratch */ - UNW_X86_FSW, /* scratch */ - UNW_X86_FTW, /* scratch */ - UNW_X86_FOP, /* scratch */ - UNW_X86_FCS, /* scratch */ - UNW_X86_FIP, /* scratch */ - UNW_X86_FEA, /* scratch */ - UNW_X86_FDS, /* scratch */ - - /* SSE registers */ - UNW_X86_XMM0_lo, /* scratch */ - UNW_X86_XMM0_hi, /* scratch */ - UNW_X86_XMM1_lo, /* scratch */ - UNW_X86_XMM1_hi, /* scratch */ - UNW_X86_XMM2_lo, /* scratch */ - UNW_X86_XMM2_hi, /* scratch */ - UNW_X86_XMM3_lo, /* scratch */ - UNW_X86_XMM3_hi, /* scratch */ - UNW_X86_XMM4_lo, /* scratch */ - UNW_X86_XMM4_hi, /* scratch */ - UNW_X86_XMM5_lo, /* scratch */ - UNW_X86_XMM5_hi, /* scratch */ - UNW_X86_XMM6_lo, /* scratch */ - UNW_X86_XMM6_hi, /* scratch */ - UNW_X86_XMM7_lo, /* scratch */ - UNW_X86_XMM7_hi, /* scratch */ - - UNW_X86_MXCSR, /* scratch */ - - /* segment registers */ - UNW_X86_GS, /* special */ - UNW_X86_FS, /* special */ - UNW_X86_ES, /* special */ - UNW_X86_DS, /* special */ - UNW_X86_SS, /* special */ - UNW_X86_CS, /* special */ - UNW_X86_TSS, /* special */ - UNW_X86_LDT, /* special */ - - /* frame info (read-only) */ - UNW_X86_CFA, - - UNW_X86_XMM0, /* scratch */ - UNW_X86_XMM1, /* scratch */ - UNW_X86_XMM2, /* scratch */ - UNW_X86_XMM3, /* scratch */ - UNW_X86_XMM4, /* scratch */ - UNW_X86_XMM5, /* scratch */ - UNW_X86_XMM6, /* scratch */ - UNW_X86_XMM7, /* scratch */ - - UNW_TDEP_LAST_REG = UNW_X86_XMM7, - - UNW_TDEP_IP = UNW_X86_EIP, - UNW_TDEP_SP = UNW_X86_ESP, - UNW_TDEP_EH = UNW_X86_EAX - } -x86_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 2 /* eax and edx are exception args */ - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_save_loc_t; - -/* On x86, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no x86-specific auxiliary proc-info */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext) -extern int unw_tdep_getcontext (unw_tdep_context_t *); - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind-x86_64.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind-x86_64.h deleted file mode 100644 index ed8cb11fb..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind-x86_64.h +++ /dev/null @@ -1,145 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include -#include - -#define UNW_TARGET x86_64 -#define UNW_TARGET_X86_64 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ -#define UNW_TDEP_CURSOR_LEN 127 - -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; - -typedef long double unw_tdep_fpreg_t; - -typedef enum - { - UNW_X86_64_RAX, - UNW_X86_64_RDX, - UNW_X86_64_RCX, - UNW_X86_64_RBX, - UNW_X86_64_RSI, - UNW_X86_64_RDI, - UNW_X86_64_RBP, - UNW_X86_64_RSP, - UNW_X86_64_R8, - UNW_X86_64_R9, - UNW_X86_64_R10, - UNW_X86_64_R11, - UNW_X86_64_R12, - UNW_X86_64_R13, - UNW_X86_64_R14, - UNW_X86_64_R15, - UNW_X86_64_RIP, -#ifdef CONFIG_MSABI_SUPPORT - UNW_X86_64_XMM0, - UNW_X86_64_XMM1, - UNW_X86_64_XMM2, - UNW_X86_64_XMM3, - UNW_X86_64_XMM4, - UNW_X86_64_XMM5, - UNW_X86_64_XMM6, - UNW_X86_64_XMM7, - UNW_X86_64_XMM8, - UNW_X86_64_XMM9, - UNW_X86_64_XMM10, - UNW_X86_64_XMM11, - UNW_X86_64_XMM12, - UNW_X86_64_XMM13, - UNW_X86_64_XMM14, - UNW_X86_64_XMM15, - UNW_TDEP_LAST_REG = UNW_X86_64_XMM15, -#else - UNW_TDEP_LAST_REG = UNW_X86_64_RIP, -#endif - - /* XXX Add other regs here */ - - /* frame info (read-only) */ - UNW_X86_64_CFA, - - UNW_TDEP_IP = UNW_X86_64_RIP, - UNW_TDEP_SP = UNW_X86_64_RSP, - UNW_TDEP_BP = UNW_X86_64_RBP, - UNW_TDEP_EH = UNW_X86_64_RAX - } -x86_64_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 2 /* XXX Not sure what this means */ - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_save_loc_t; - -/* On x86_64, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -typedef struct - { - /* no x86-64-specific auxiliary proc-info */ - /* ANDROID support update. */ - char __reserved; - /* End of ANDROID update. */ - } -unw_tdep_proc_info_t; - -#include "libunwind-dynamic.h" -#include "libunwind-common.h" - -#define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext) -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) - -extern int unw_tdep_getcontext (unw_tdep_context_t *); -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind.h deleted file mode 100644 index 0fafda653..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Provide a real file - not a symlink - as it would cause multiarch conflicts - when multiple different arch releases are installed simultaneously. */ - -#ifndef UNW_REMOTE_ONLY - -#if defined __aarch64__ -#include "libunwind-aarch64.h" -#elif defined __arm__ -# include "libunwind-arm.h" -#elif defined __hppa__ -# include "libunwind-hppa.h" -#elif defined __ia64__ -# include "libunwind-ia64.h" -#elif defined __mips__ -# include "libunwind-mips.h" -#elif defined __powerpc__ && !defined __powerpc64__ -# include "libunwind-ppc32.h" -#elif defined __powerpc64__ -# include "libunwind-ppc64.h" -#elif defined __sh__ -# include "libunwind-sh.h" -#elif defined __i386__ -# include "libunwind-x86.h" -#elif defined __x86_64__ -# include "libunwind-x86_64.h" -#else -# error "Unsupported arch" -#endif - -#else /* UNW_REMOTE_ONLY */ - -# include "libunwind-arm.h" - -#endif /* UNW_REMOTE_ONLY */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind.h.in b/app/src/main/jni/crash_dump/libunwind/include/libunwind.h.in deleted file mode 100644 index 64b1457b0..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind.h.in +++ /dev/null @@ -1,34 +0,0 @@ -/* Provide a real file - not a symlink - as it would cause multiarch conflicts - when multiple different arch releases are installed simultaneously. */ - -#ifndef UNW_REMOTE_ONLY - -#if defined __aarch64__ -#include "libunwind-aarch64.h" -#elif defined __arm__ -# include "libunwind-arm.h" -#elif defined __hppa__ -# include "libunwind-hppa.h" -#elif defined __ia64__ -# include "libunwind-ia64.h" -#elif defined __mips__ -# include "libunwind-mips.h" -#elif defined __powerpc__ && !defined __powerpc64__ -# include "libunwind-ppc32.h" -#elif defined __powerpc64__ -# include "libunwind-ppc64.h" -#elif defined __sh__ -# include "libunwind-sh.h" -#elif defined __i386__ -# include "libunwind-x86.h" -#elif defined __x86_64__ -# include "libunwind-x86_64.h" -#else -# error "Unsupported arch" -#endif - -#else /* UNW_REMOTE_ONLY */ - -# include "libunwind-@arch@.h" - -#endif /* UNW_REMOTE_ONLY */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/libunwind_i.h deleted file mode 100644 index 1eb7b8030..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/libunwind_i.h +++ /dev/null @@ -1,416 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* This files contains libunwind-internal definitions which are - subject to frequent change and are not to be exposed to - libunwind-users. */ - -#ifndef libunwind_i_h -#define libunwind_i_h - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "compiler.h" - -#ifdef HAVE___THREAD - /* For now, turn off per-thread caching. It uses up too much TLS - memory per thread even when the thread never uses libunwind at - all. */ -# undef HAVE___THREAD -#endif - -/* Platform-independent libunwind-internal declarations. */ - -#include /* HP-UX needs this before include of pthread.h */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(HAVE_ELF_H) -# include -#elif defined(HAVE_SYS_ELF_H) -# include -#else -# error Could not locate -#endif - -#if defined(HAVE_ENDIAN_H) -# include -#elif defined(HAVE_SYS_ENDIAN_H) -# include -#else -# define __LITTLE_ENDIAN 1234 -# define __BIG_ENDIAN 4321 -# if defined(__hpux) -# define __BYTE_ORDER __BIG_ENDIAN -# elif defined(__QNX__) -# if defined(__BIGENDIAN__) -# define __BYTE_ORDER __BIG_ENDIAN -# elif defined(__LITTLEENDIAN__) -# define __BYTE_ORDER __LITTLE_ENDIAN -# else -# error Host has unknown byte-order. -# endif -# else -# error Host has unknown byte-order. -# endif -#endif - -#if defined(HAVE__BUILTIN_UNREACHABLE) -# define unreachable() __builtin_unreachable() -#else -# define unreachable() do { } while (1) -#endif - -#ifdef DEBUG -# define UNW_DEBUG 1 -#else -# define UNW_DEBUG 0 -#endif - -/* Make it easy to write thread-safe code which may or may not be - linked against libpthread. The macros below can be used - unconditionally and if -lpthread is around, they'll call the - corresponding routines otherwise, they do nothing. */ - -#pragma weak pthread_mutex_init -#pragma weak pthread_mutex_lock -#pragma weak pthread_mutex_unlock - -#define mutex_init(l) \ - (pthread_mutex_init != NULL ? pthread_mutex_init ((l), NULL) : 0) -#define mutex_lock(l) \ - (pthread_mutex_lock != NULL ? pthread_mutex_lock (l) : 0) -#define mutex_unlock(l) \ - (pthread_mutex_unlock != NULL ? pthread_mutex_unlock (l) : 0) - -#ifdef HAVE_ATOMIC_OPS_H -# include -static inline int -cmpxchg_ptr (void *addr, void *old, void *new) -{ - union - { - void *vp; - AO_t *aop; - } - u; - - u.vp = addr; - return AO_compare_and_swap(u.aop, (AO_t) old, (AO_t) new); -} -# define fetch_and_add1(_ptr) AO_fetch_and_add1(_ptr) -# define fetch_and_add(_ptr, value) AO_fetch_and_add(_ptr, value) - /* GCC 3.2.0 on HP-UX crashes on cmpxchg_ptr() */ -# if !(defined(__hpux) && __GNUC__ == 3 && __GNUC_MINOR__ == 2) -# define HAVE_CMPXCHG -# endif -# define HAVE_FETCH_AND_ADD -#elif defined(HAVE_SYNC_ATOMICS) || defined(HAVE_IA64INTRIN_H) -# ifdef HAVE_IA64INTRIN_H -# include -# endif -static inline int -cmpxchg_ptr (void *addr, void *old, void *new) -{ - union - { - void *vp; - long *vlp; - } - u; - - u.vp = addr; - return __sync_bool_compare_and_swap(u.vlp, (long) old, (long) new); -} -# define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1) -# define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value) -# define HAVE_CMPXCHG -# define HAVE_FETCH_AND_ADD -#endif -#define atomic_read(ptr) (*(ptr)) - -#define UNWI_OBJ(fn) UNW_PASTE(UNW_PREFIX,UNW_PASTE(I,fn)) -#define UNWI_ARCH_OBJ(fn) UNW_PASTE(UNW_PASTE(UNW_PASTE(_UI,UNW_TARGET),_), fn) - -#define unwi_full_mask UNWI_ARCH_OBJ(full_mask) - -/* Type of a mask that can be used to inhibit preemption. At the - userlevel, preemption is caused by signals and hence sigset_t is - appropriate. In constrast, the Linux kernel uses "unsigned long" - to hold the processor "flags" instead. */ -typedef sigset_t intrmask_t; - -extern intrmask_t unwi_full_mask; - -/* Silence compiler warnings about variables which are used only if libunwind - is configured in a certain way */ -static inline void mark_as_used(void *v UNUSED) { -} - -#if defined(CONFIG_BLOCK_SIGNALS) -# define SIGPROCMASK(how, new_mask, old_mask) \ - sigprocmask((how), (new_mask), (old_mask)) -#else -# define SIGPROCMASK(how, new_mask, old_mask) mark_as_used(old_mask) -#endif - -/* ANDROID support update. */ -#define __lock_acquire_internal(l, m, acquire_func) \ -do { \ - SIGPROCMASK (SIG_SETMASK, &unwi_full_mask, &(m)); \ - acquire_func (l); \ -} while (0) -#define __lock_release_internal(l, m, release_func) \ -do { \ - release_func (l); \ - SIGPROCMASK (SIG_SETMASK, &(m), NULL); \ -} while (0) - -#define lock_rdwr_var(name) \ - pthread_rwlock_t name -#define lock_rdwr_init(l) pthread_rwlock_init (l, NULL) -#define lock_rdwr_wr_acquire(l, m) \ - __lock_acquire_internal(l, m, pthread_rwlock_wrlock) -#define lock_rdwr_rd_acquire(l, m) \ - __lock_acquire_internal(l, m, pthread_rwlock_rdlock) -#define lock_rdwr_release(l, m) \ - __lock_release_internal(l, m, pthread_rwlock_unlock) - -#define lock_var(name) \ - pthread_mutex_t name -#define define_lock(name) \ - lock_var (name) = PTHREAD_MUTEX_INITIALIZER -#define lock_init(l) mutex_init (l) -#define lock_acquire(l,m) \ - __lock_acquire_internal(l, m, mutex_lock) -#define lock_release(l,m) \ - __lock_release_internal(l, m, mutex_unlock) -/* End of ANDROID update. */ - -#define SOS_MEMORY_SIZE 16384 /* see src/mi/mempool.c */ - -#ifndef MAP_ANONYMOUS -# define MAP_ANONYMOUS MAP_ANON -#endif -#define GET_MEMORY(mem, size) \ -do { \ - /* Hopefully, mmap() goes straight through to a system call stub... */ \ - mem = mmap (NULL, size, PROT_READ | PROT_WRITE, \ - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \ - if (mem == MAP_FAILED) \ - mem = NULL; \ -} while (0) - -#define unwi_find_dynamic_proc_info UNWI_OBJ(find_dynamic_proc_info) -#define unwi_extract_dynamic_proc_info UNWI_OBJ(extract_dynamic_proc_info) -#define unwi_put_dynamic_unwind_info UNWI_OBJ(put_dynamic_unwind_info) -#define unwi_dyn_remote_find_proc_info UNWI_OBJ(dyn_remote_find_proc_info) -#define unwi_dyn_remote_put_unwind_info UNWI_OBJ(dyn_remote_put_unwind_info) -#define unwi_dyn_validate_cache UNWI_OBJ(dyn_validate_cache) - -extern int unwi_find_dynamic_proc_info (unw_addr_space_t as, - unw_word_t ip, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern int unwi_extract_dynamic_proc_info (unw_addr_space_t as, - unw_word_t ip, - unw_proc_info_t *pi, - unw_dyn_info_t *di, - int need_unwind_info, - void *arg); -extern void unwi_put_dynamic_unwind_info (unw_addr_space_t as, - unw_proc_info_t *pi, void *arg); - -/* These handle the remote (cross-address-space) case of accessing - dynamic unwind info. */ - -extern int unwi_dyn_remote_find_proc_info (unw_addr_space_t as, - unw_word_t ip, - unw_proc_info_t *pi, - int need_unwind_info, - void *arg); -extern void unwi_dyn_remote_put_unwind_info (unw_addr_space_t as, - unw_proc_info_t *pi, - void *arg); -extern int unwi_dyn_validate_cache (unw_addr_space_t as, void *arg); - -extern unw_dyn_info_list_t _U_dyn_info_list; -extern pthread_mutex_t _U_dyn_info_list_lock; - -#if UNW_DEBUG -# define unwi_debug_level UNWI_ARCH_OBJ(debug_level) -extern long unwi_debug_level; - -# ifdef ANDROID -# define LOG_TAG "libunwind" -# include - -# define Debug(level, format, ...) \ -do { \ - if (unwi_debug_level >= (level)) \ - { \ - ALOGI("%*c>%s: " format, ((level) <= 16) ? (level) : 16, ' ', \ - __FUNCTION__, ##__VA_ARGS__); \ - } \ -} while (0) -# define Dprintf(format, ...) ALOGI(format, ##__VA_ARGS__); -#else -# include -# define Debug(level,format...) \ -do { \ - if (unwi_debug_level >= level) \ - { \ - int _n = level; \ - if (_n > 16) \ - _n = 16; \ - fprintf (stderr, "%*c>%s: ", _n, ' ', __FUNCTION__); \ - fprintf (stderr, format); \ - } \ -} while (0) -# define Dprintf(format...) fprintf (stderr, format) -# ifdef __GNUC__ -# undef inline -# define inline UNUSED -# endif -# endif -#else -# define Debug(level,format...) -# define Dprintf(format...) -#endif - -static ALWAYS_INLINE int -print_error (const char *string) -{ - return write (2, string, strlen (string)); -} - -#define mi_init UNWI_ARCH_OBJ(mi_init) - -extern void mi_init (void); /* machine-independent initializations */ -extern unw_word_t _U_dyn_info_list_addr (void); - -/* This is needed/used by ELF targets only. */ - -/* This structure should contain memory that will not change during local - * unwinds. For example, if a new member is added, then the function - * move_cached_elf_data must be updated to make sure that the data is - * properly copied. Any pointers in this structures must persist until - * the map is destroyed in map_destroy_list and moved in the previously - * mentioned move_cached_elf_data. - */ -struct elf_image - { - bool valid; /* true if the image is a valid elf image */ - bool load_attempted; /* true if we've already attempted to load the elf */ - bool mapped; /* true if the elf image was mmap'd in */ - void* mini_debug_info_data; /* decompressed .gnu_debugdata section */ - size_t mini_debug_info_size; - union - { - struct - { - void *image; /* pointer to mmap'd image */ - size_t size; /* (file-) size of the image */ - } - mapped; - struct - { - unw_addr_space_t as; /* address space containing the access_mem function */ - void *as_arg; /* arg used with access_mem */ - uintptr_t start; /* The map start address. */ - uintptr_t end; /* The map end address. */ - } - memory; - } - u; - }; - -struct elf_dyn_info - { - /* ANDROID support update.*/ - /* Removed: struct elf_image ei; */ - /* End of ANDROID update. */ - unw_dyn_info_t di_cache; - unw_dyn_info_t di_debug; /* additional table info for .debug_frame */ -#if UNW_TARGET_IA64 - unw_dyn_info_t ktab; -#endif -#if UNW_TARGET_ARM - unw_dyn_info_t di_arm; /* additional table info for .ARM.exidx */ -#endif - }; - -static inline void invalidate_edi (struct elf_dyn_info *edi) -{ - /* ANDROID support update.*/ - /* Removed: if (edi->ei.image) */ - /* munmap (edi->ei.image, edi->ei.size); */ - /* End of ANDROID update. */ - memset (edi, 0, sizeof (*edi)); - edi->di_cache.format = -1; - edi->di_debug.format = -1; -#if UNW_TARGET_ARM - edi->di_arm.format = -1; -#endif -} - - -/* Provide a place holder for architecture to override for fast access - to memory when known not to need to validate and know the access - will be local to the process. A suitable override will improve - unw_tdep_trace() performance in particular. */ -#define ACCESS_MEM_FAST(ret,validate,cur,addr,to) \ - do { (ret) = dwarf_get ((cur), DWARF_MEM_LOC ((cur), (addr)), &(to)); } \ - while (0) - -/* Define GNU and processor specific values for the Phdr p_type field in case - they aren't defined by . */ -#ifndef PT_GNU_EH_FRAME -# define PT_GNU_EH_FRAME 0x6474e550 -#endif /* !PT_GNU_EH_FRAME */ -#ifndef PT_ARM_EXIDX -# define PT_ARM_EXIDX 0x70000001 /* ARM unwind segment */ -#endif /* !PT_ARM_EXIDX */ - -#include "tdep/libunwind_i.h" - -#ifndef tdep_get_func_addr -# define tdep_get_func_addr(as,addr,v) (*(v) = addr, 0) -#endif - -#define UNW_ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL)) - -#endif /* libunwind_i_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/map_info.h b/app/src/main/jni/crash_dump/libunwind/include/map_info.h deleted file mode 100644 index a76ca15e9..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/map_info.h +++ /dev/null @@ -1,73 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2013 The Android Open Source Project - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef map_info_h -#define map_info_h - -/* Must not conflict with PROT_{NONE,READ,WRITE}. */ -#define MAP_FLAGS_DEVICE_MEM 0x8000 - -enum map_create_type - { - UNW_MAP_CREATE_REMOTE, - UNW_MAP_CREATE_LOCAL, - }; - -struct map_info - { - uintptr_t start; - uintptr_t end; - uintptr_t offset; - uintptr_t load_base; - int flags; - char *path; - - lock_var (ei_lock); - struct elf_image ei; - - struct map_info *next; - }; - -extern struct mempool map_pool; -extern struct map_info *local_map_list; - -void map_local_init (void); - -int map_local_is_readable (unw_word_t, size_t); - -int map_local_is_writable (unw_word_t, size_t); - -char *map_local_get_image_name (unw_word_t); - -struct map_info *map_alloc_info (void); - -void map_free_info (struct map_info *); - -struct map_info *map_find_from_addr (struct map_info *, unw_word_t); - -struct map_info *map_create_list (int, pid_t); - -void map_destroy_list (struct map_info *); - -#endif /* map_info_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/mempool.h b/app/src/main/jni/crash_dump/libunwind/include/mempool.h deleted file mode 100644 index 4b55974ff..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/mempool.h +++ /dev/null @@ -1,89 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef mempool_h -#define mempool_h - -/* Memory pools provide simple memory management of fixed-size - objects. Memory pools are used for two purposes: - - o To ensure a stack can be unwound even when a process - is out of memory. - - o To ensure a stack can be unwound at any time in a - multi-threaded process (e.g., even at a time when the normal - malloc-lock is taken, possibly by the very thread that is - being unwind). - - - To achieve the second objective, memory pools allocate memory - directly via mmap() system call (or an equivalent facility). - - The first objective is accomplished by reserving memory ahead of - time. Since the memory requirements of stack unwinding generally - depends on the complexity of the procedures being unwind, there is - no absolute guarantee that unwinding will always work, but in - practice, this should not be a serious problem. */ - -#include - -#include "libunwind_i.h" - -#define sos_alloc(s) UNWI_ARCH_OBJ(_sos_alloc)(s) -#define mempool_init(p,s,r) UNWI_ARCH_OBJ(_mempool_init)(p,s,r) -#define mempool_alloc(p) UNWI_ARCH_OBJ(_mempool_alloc)(p) -#define mempool_free(p,o) UNWI_ARCH_OBJ(_mempool_free)(p,o) - -/* The mempool structure should be treated as an opaque object. It's - declared here only to enable static allocation of mempools. */ -struct mempool - { - pthread_mutex_t lock; - size_t obj_size; /* object size (rounded up for alignment) */ - size_t chunk_size; /* allocation granularity */ - unsigned int reserve; /* minimum (desired) size of the free-list */ - unsigned int num_free; /* number of objects on the free-list */ - struct object - { - struct object *next; - } - *free_list; - }; - -/* Emergency allocation for one-time stuff that doesn't fit the memory - pool model. A limited amount of memory is available in this - fashion and once allocated, there is no way to free it. */ -extern void *sos_alloc (size_t size); - -/* Initialize POOL for an object size of OBJECT_SIZE bytes. RESERVE - is the number of objects that should be reserved for use under - tight memory situations. If it is zero, mempool attempts to pick a - reasonable default value. */ -extern void mempool_init (struct mempool *pool, - size_t obj_size, size_t reserve); -extern void *mempool_alloc (struct mempool *pool); -extern void mempool_free (struct mempool *pool, void *object); - -#endif /* mempool_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/remote.h b/app/src/main/jni/crash_dump/libunwind/include/remote.h deleted file mode 100644 index 9fb90c3dc..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/remote.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef REMOTE_H -#define REMOTE_H - -/* Helper functions for accessing (remote) memory. These functions - assume that all addresses are naturally aligned (e.g., 32-bit - quantity is stored at a 32-bit-aligned address. */ - -#ifdef UNW_LOCAL_ONLY - -static inline int -fetch8 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int8_t *valp, void *arg) -{ - *valp = *(int8_t *) (uintptr_t) *addr; - *addr += 1; - return 0; -} - -static inline int -fetch16 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int16_t *valp, void *arg) -{ - *valp = *(int16_t *) (uintptr_t) *addr; - *addr += 2; - return 0; -} - -static inline int -fetch32 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int32_t *valp, void *arg) -{ - *valp = *(int32_t *) (uintptr_t) *addr; - *addr += 4; - return 0; -} - -static inline int -fetchw (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, unw_word_t *valp, void *arg) -{ - *valp = *(unw_word_t *) (uintptr_t) *addr; - *addr += sizeof (unw_word_t); - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ - -#define WSIZE (sizeof (unw_word_t)) - -static inline int -fetch8 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int8_t *valp, void *arg) -{ - unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr; - int ret; - - *addr += 1; - - ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg); - -#if __BYTE_ORDER == __LITTLE_ENDIAN - val >>= 8*off; -#else - val >>= 8*(WSIZE - 1 - off); -#endif - *valp = val & 0xff; - return ret; -} - -static inline int -fetch16 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int16_t *valp, void *arg) -{ - unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr; - int ret; - - assert ((off & 0x1) == 0); - - *addr += 2; - - ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg); - -#if __BYTE_ORDER == __LITTLE_ENDIAN - val >>= 8*off; -#else - val >>= 8*(WSIZE - 2 - off); -#endif - *valp = val & 0xffff; - return ret; -} - -static inline int -fetch32 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int32_t *valp, void *arg) -{ - unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr; - int ret; - - assert ((off & 0x3) == 0); - - *addr += 4; - - ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg); - -#if __BYTE_ORDER == __LITTLE_ENDIAN - val >>= 8*off; -#else - val >>= 8*(WSIZE - 4 - off); -#endif - *valp = val & 0xffffffff; - return ret; -} - -static inline int -fetchw (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, unw_word_t *valp, void *arg) -{ - int ret; - - ret = (*a->access_mem) (as, *addr, valp, 0, arg); - *addr += WSIZE; - return ret; -} - -#endif /* !UNW_LOCAL_ONLY */ - -#endif /* REMOTE_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-aarch64/dwarf-config.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-aarch64/dwarf-config.h deleted file mode 100644 index 1876c483c..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-aarch64/dwarf-config.h +++ /dev/null @@ -1,52 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* This matches the value udes by GCC (see - gcc/config/aarch64/aarch64.h:DWARF_FRAME_REGISTERS. */ -#define DWARF_NUM_PRESERVED_REGS 97 - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 0 - -#define dwarf_to_unw_regnum(reg) (((reg) <= UNW_AARCH64_V31) ? (reg) : 0) - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-aarch64/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-aarch64/jmpbuf.h deleted file mode 100644 index 2eb53a799..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-aarch64/jmpbuf.h +++ /dev/null @@ -1,33 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -/* FIXME for AArch64 */ - -#define JB_SP 13 -#define JB_RP 14 -#define JB_MASK_SAVED 15 -#define JB_MASK 16 diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-aarch64/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-aarch64/libunwind_i.h deleted file mode 100644 index d3d69ab14..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-aarch64/libunwind_i.h +++ /dev/null @@ -1,315 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef AARCH64_LIBUNWIND_I_H -#define AARCH64_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf64.h" -/* ANDROID support update. */ -#include "map_info.h" -/* End of ANDROID update. */ -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no aarch64-specific fast trace */ - } -unw_tdep_frame_t; - -#ifdef UNW_LOCAL_ONLY - -typedef unw_word_t aarch64_loc_t; - -#else /* !UNW_LOCAL_ONLY */ - -typedef struct aarch64_loc - { - unw_word_t w0, w1; - } -aarch64_loc_t; - -#endif /* !UNW_LOCAL_ONLY */ - -struct unw_addr_space - { - struct unw_accessors acc; - int big_endian; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - /* ANDROID support update. */ - struct map_info *map_list; - /* End of ANDROID update. */ - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - enum - { - AARCH64_SCF_NONE, - AARCH64_SCF_LINUX_RT_SIGFRAME, - } - sigcontext_format; - unw_word_t sigcontext_addr; - unw_word_t sigcontext_sp; - unw_word_t sigcontext_pc; - }; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ -/* ANDROID support update. */ - unw_fpreg_t *addr = (unw_fpreg_t *) (uintptr_t) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_readable ((unw_word_t) (uintptr_t) addr, sizeof(unw_fpreg_t))) - return -1; - - *val = *addr; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ -/* ANDROID support update. */ - unw_fpreg_t *addr = (unw_fpreg_t *) (uintptr_t) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_writable ((unw_word_t) (uintptr_t) addr, sizeof(unw_fpreg_t))) - return -1; - - *addr = val; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ -/* ANDROID support update. */ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -/* End of ANDROID update. */ -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ -/* ANDROID support update. */ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -/* End of ANDROID update. */ -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - - - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c,rs) do {} while(0) -#define tdep_reuse_frame(c,rs) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) ((as)->big_endian) - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg); -/* ANDROID support update. */ -extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char **path, void *as_arg); -/* End of ANDROID update. */ -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -#endif /* AARCH64_LIBUNWIND_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/dwarf-config.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/dwarf-config.h deleted file mode 100644 index c997f3a7c..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/dwarf-config.h +++ /dev/null @@ -1,51 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* This is FIRST_PSEUDO_REGISTER in GCC, since DWARF_FRAME_REGISTERS is not - explicitly defined. */ -#define DWARF_NUM_PRESERVED_REGS 128 - -#define dwarf_to_unw_regnum(reg) (((reg) < 16) ? (reg) : 0) - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 0 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/ex_tables.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/ex_tables.h deleted file mode 100644 index 8906f13a2..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/ex_tables.h +++ /dev/null @@ -1,55 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright 2011 Linaro Limited - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef ARM_EX_TABLES_H -#define ARM_EX_TABLES_H - -typedef enum arm_exbuf_cmd { - ARM_EXIDX_CMD_FINISH, - ARM_EXIDX_CMD_DATA_PUSH, - ARM_EXIDX_CMD_DATA_POP, - ARM_EXIDX_CMD_REG_POP, - ARM_EXIDX_CMD_REG_TO_SP, - ARM_EXIDX_CMD_VFP_POP, - ARM_EXIDX_CMD_WREG_POP, - ARM_EXIDX_CMD_WCGR_POP, - ARM_EXIDX_CMD_RESERVED, - ARM_EXIDX_CMD_REFUSED, -} arm_exbuf_cmd_t; - -struct arm_exbuf_data -{ - arm_exbuf_cmd_t cmd; - uint32_t data; -}; - -#define arm_exidx_extract UNW_OBJ(arm_exidx_extract) -#define arm_exidx_decode UNW_OBJ(arm_exidx_decode) -#define arm_exidx_apply_cmd UNW_OBJ(arm_exidx_apply_cmd) - -int arm_exidx_extract (struct dwarf_cursor *c, uint8_t *buf); -int arm_exidx_decode (const uint8_t *buf, uint8_t len, struct dwarf_cursor *c); -int arm_exidx_apply_cmd (struct arm_exbuf_data *edata, struct dwarf_cursor *c); - -#endif // ARM_EX_TABLES_H diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/jmpbuf.h deleted file mode 100644 index 499e7deb7..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/jmpbuf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -/* FIXME for ARM! */ - -#define JB_SP 4 -#define JB_RP 5 -#define JB_MASK_SAVED 6 -#define JB_MASK 7 diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/libunwind_i.h deleted file mode 100644 index c140c0568..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-arm/libunwind_i.h +++ /dev/null @@ -1,322 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef ARM_LIBUNWIND_I_H -#define ARM_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf32.h" -/* ANDROID support update. */ -#include "map_info.h" -/* End of ANDROID update. */ -#include "mempool.h" -#include "dwarf.h" -#include "ex_tables.h" - -typedef struct - { - /* no arm-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - int big_endian; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - /* ANDROID support update. */ - struct map_info *map_list; - /* End of ANDROID update. */ - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - enum - { - ARM_SCF_NONE, /* no signal frame */ - ARM_SCF_LINUX_SIGFRAME, /* non-RT signal frame, kernel >=2.6.18 */ - ARM_SCF_LINUX_RT_SIGFRAME, /* RT signal frame, kernel >=2.6.18 */ - ARM_SCF_LINUX_OLD_SIGFRAME, /* non-RT signal frame, kernel < 2.6.18 */ - ARM_SCF_LINUX_OLD_RT_SIGFRAME /* RT signal frame, kernel < 2.6.18 */ - } - sigcontext_format; - unw_word_t sigcontext_addr; - unw_word_t sigcontext_sp; - unw_word_t sigcontext_pc; - }; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ -/* ANDROID support update. */ - unw_fpreg_t *addr = (unw_fpreg_t *) (uintptr_t) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_readable ((unw_word_t) (uintptr_t) addr, sizeof(unw_fpreg_t))) - return -1; - - *val = *addr; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ -/* ANDROID support update. */ - unw_fpreg_t *addr = (unw_fpreg_t *) (uintptr_t) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_writable ((unw_word_t) (uintptr_t) addr, sizeof(unw_fpreg_t))) - return -1; - - *addr = val; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ -/* ANDROID support update. */ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -/* End of ANDROID update. */ -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ -/* ANDROID support update. */ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -/* End of ANDROID update. */ -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -#define arm_find_proc_info UNW_OBJ(find_proc_info) -#define arm_put_unwind_info UNW_OBJ(put_unwind_info) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table UNW_OBJ(search_unwind_table) -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c,rs) do {} while(0) -#define tdep_reuse_frame(c,rs) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - arm_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - arm_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) ((as)->big_endian) - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int arm_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, int need_unwind_info, - void *arg); -extern void arm_put_unwind_info (unw_addr_space_t as, - unw_proc_info_t *pi, void *arg); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg); -/* ANDROID support update. */ -extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char **path, void *as_arg); -/* End of ANDROID update. */ -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -/* unwinding method selection support */ -#define UNW_ARM_METHOD_ALL 0xFF -#define UNW_ARM_METHOD_DWARF 0x01 -#define UNW_ARM_METHOD_FRAME 0x02 -#define UNW_ARM_METHOD_EXIDX 0x04 -/* ANDROID support update. */ -#define UNW_ARM_METHOD_LR 0x08 -/* End of ANDROID update. */ - -#define unwi_unwind_method UNW_OBJ(unwind_method) -extern int unwi_unwind_method; - -#define UNW_TRY_METHOD(x) (unwi_unwind_method & x) - -#endif /* ARM_LIBUNWIND_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-hppa/dwarf-config.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-hppa/dwarf-config.h deleted file mode 100644 index 29f9eee4b..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-hppa/dwarf-config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* See DWARF_FRAME_REGNUM() macro in gcc/config/pa/pa32-regs.h: */ -#define dwarf_to_unw_regnum(reg) \ - (((reg) < DWARF_NUM_PRESERVED_REGS) ? (reg) : 0) - -/* This matches the value used by GCC (see - gcc/config/pa/pa32-regs.h:FIRST_PSEUDO_REGISTER), which leaves - plenty of room for expansion. */ -#define DWARF_NUM_PRESERVED_REGS 89 - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 1 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see X86_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-hppa/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-hppa/jmpbuf.h deleted file mode 100644 index 6735b21af..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-hppa/jmpbuf.h +++ /dev/null @@ -1,33 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#ifndef JB_SP -# define JB_SP 19 -#endif -#define JB_RP 20 -#define JB_MASK_SAVED 21 -#define JB_MASK 22 diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-hppa/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-hppa/libunwind_i.h deleted file mode 100644 index ab737a83a..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-hppa/libunwind_i.h +++ /dev/null @@ -1,298 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef HPPA_LIBUNWIND_I_H -#define HPPA_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf32.h" -/* ANDROID support update. */ -#include "map_info.h" -/* End of ANDROID update. */ -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no hppa-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - /* ANDROID support update. */ - struct map_info *map_list; - /* End of ANDROID update. */ - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - - /* Format of sigcontext structure and address at which it is - stored: */ - enum - { - HPPA_SCF_NONE, /* no signal frame encountered */ - HPPA_SCF_LINUX_RT_SIGFRAME /* POSIX ucontext_t */ - } - sigcontext_format; - unw_word_t sigcontext_addr; - }; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ -/* ANDROID support update. */ - unw_fpreg_t *addr = (unw_fpreg_t *) (uintptr_t) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_readable ((unw_word_t) (uintptr_t) addr, sizeof(unw_fpreg_t))) - return -1; - - *val = *addr; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ -/* ANDROID support update. */ - unw_fpreg_t *addr = (unw_fpreg_t *) (uintptr_t) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_writable ((unw_word_t) (uintptr_t) addr, sizeof(unw_fpreg_t))) - return -1; - - *addr = val; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ -/* ANDROID support update. */ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -/* End of ANDROID update. */ -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ -/* ANDROID support update. */ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -/* End of ANDROID update. */ -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c,rs) do {} while(0) -#define tdep_reuse_frame(c,rs) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) 1 - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (ucontext_t *uc, int reg); -/* ANDROID support update. */ -extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char **path, void *as_arg); -/* End of ANDROID update. */ -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -#endif /* HPPA_LIBUNWIND_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/jmpbuf.h deleted file mode 100644 index faa1f3440..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/jmpbuf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP and BSP: */ - -#define JB_SP 0 -#define JB_RP 8 -#define JB_BSP 17 -#define JB_MASK_SAVED 70 -#define JB_MASK 71 diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/libunwind_i.h deleted file mode 100644 index 41056c0d0..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/libunwind_i.h +++ /dev/null @@ -1,289 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef IA64_LIBUNWIND_I_H -#define IA64_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include "elf64.h" -/* ANDROID support update. */ -#include "map_info.h" -/* End of ANDROID update. */ -#include "mempool.h" - -typedef struct - { - /* no ia64-specific fast trace */ - } -unw_tdep_frame_t; - -enum ia64_pregnum - { - /* primary unat: */ - IA64_REG_PRI_UNAT_GR, - IA64_REG_PRI_UNAT_MEM, - - /* memory stack (order matters: see build_script() */ - IA64_REG_PSP, /* previous memory stack pointer */ - /* register stack */ - IA64_REG_BSP, /* register stack pointer */ - IA64_REG_BSPSTORE, - IA64_REG_PFS, /* previous function state */ - IA64_REG_RNAT, - /* instruction pointer: */ - IA64_REG_IP, - - /* preserved registers: */ - IA64_REG_R4, IA64_REG_R5, IA64_REG_R6, IA64_REG_R7, - IA64_REG_NAT4, IA64_REG_NAT5, IA64_REG_NAT6, IA64_REG_NAT7, - IA64_REG_UNAT, IA64_REG_PR, IA64_REG_LC, IA64_REG_FPSR, - IA64_REG_B1, IA64_REG_B2, IA64_REG_B3, IA64_REG_B4, IA64_REG_B5, - IA64_REG_F2, IA64_REG_F3, IA64_REG_F4, IA64_REG_F5, - IA64_REG_F16, IA64_REG_F17, IA64_REG_F18, IA64_REG_F19, - IA64_REG_F20, IA64_REG_F21, IA64_REG_F22, IA64_REG_F23, - IA64_REG_F24, IA64_REG_F25, IA64_REG_F26, IA64_REG_F27, - IA64_REG_F28, IA64_REG_F29, IA64_REG_F30, IA64_REG_F31, - IA64_NUM_PREGS - }; - -#ifdef UNW_LOCAL_ONLY - -typedef unw_word_t ia64_loc_t; - -#else /* !UNW_LOCAL_ONLY */ - -typedef struct ia64_loc - { - unw_word_t w0, w1; - } -ia64_loc_t; - -#endif /* !UNW_LOCAL_ONLY */ - -#include "script.h" - -#define ABI_UNKNOWN 0 -#define ABI_LINUX 1 -#define ABI_HPUX 2 -#define ABI_FREEBSD 3 -#define ABI_OPENVMS 4 -#define ABI_NSK 5 /* Tandem/HP Non-Stop Kernel */ -#define ABI_WINDOWS 6 - -struct unw_addr_space - { - struct unw_accessors acc; - int big_endian; - int abi; /* abi < 0 => unknown, 0 => SysV, 1 => HP-UX, 2 => Windows */ - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ -#ifndef UNW_REMOTE_ONLY - unsigned long long shared_object_removals; -#endif - - struct ia64_script_cache global_cache; - - /* ANDROID support update. */ - struct map_info *map_list; - /* End of ANDROID update. */ - }; - -/* Note: The ABI numbers in the ABI-markers (.unwabi directive) are - not the same as the above ABI numbers. */ -#define ABI_MARKER_OLD_LINUX_SIGTRAMP ((0 << 8) | 's') -#define ABI_MARKER_OLD_LINUX_INTERRUPT ((0 << 8) | 'i') -#define ABI_MARKER_HP_UX_SIGTRAMP ((1 << 8) | 1) -#define ABI_MARKER_LINUX_SIGTRAMP ((3 << 8) | 's') -#define ABI_MARKER_LINUX_INTERRUPT ((3 << 8) | 'i') - -struct cursor - { - void *as_arg; /* argument to address-space callbacks */ - unw_addr_space_t as; /* reference to per-address-space info */ - - /* IP, CFM, and predicate cache (these are always equal to the - values stored in ip_loc, cfm_loc, and pr_loc, - respectively). */ - unw_word_t ip; /* instruction pointer value */ - unw_word_t cfm; /* current frame mask */ - unw_word_t pr; /* current predicate values */ - - /* current frame info: */ - unw_word_t bsp; /* backing store pointer value */ - unw_word_t sp; /* stack pointer value */ - unw_word_t psp; /* previous sp value */ - ia64_loc_t cfm_loc; /* cfm save location (or NULL) */ - ia64_loc_t ec_loc; /* ar.ec save location (usually cfm_loc) */ - ia64_loc_t loc[IA64_NUM_PREGS]; - - unw_word_t eh_args[4]; /* exception handler arguments */ - unw_word_t sigcontext_addr; /* address of sigcontext or 0 */ - unw_word_t sigcontext_off; /* sigcontext-offset relative to signal sp */ - - short hint; - short prev_script; - - uint8_t nat_bitnr[4]; /* NaT bit numbers for r4-r7 */ - uint16_t abi_marker; /* abi_marker for current frame (if any) */ - uint16_t last_abi_marker; /* last abi_marker encountered so far */ - uint8_t eh_valid_mask; - - unsigned int pi_valid :1; /* is proc_info valid? */ - unsigned int pi_is_dynamic :1; /* proc_info found via dynamic proc info? */ - unw_proc_info_t pi; /* info about current procedure */ - - /* In case of stack-discontiguities, such as those introduced by - signal-delivery on an alternate signal-stack (see - sigaltstack(2)), we use the following data-structure to keep - track of the register-backing-store areas across on which the - current frame may be backed up. Since there are at most 96 - stacked registers and since we only have to track the current - frame and only areas that are not empty, this puts an upper - limit on the # of backing-store areas we have to track. - - Note that the rbs-area indexed by rbs_curr identifies the - rbs-area that was in effect at the time AR.BSP had the value - c->bsp. However, this rbs area may not actually contain the - value in the register that c->bsp corresponds to because that - register may not have gotten spilled until much later, when a - possibly different rbs-area might have been in effect - already. */ - uint8_t rbs_curr; /* index of curr. rbs-area (contains c->bsp) */ - uint8_t rbs_left_edge; /* index of inner-most valid rbs-area */ - struct rbs_area - { - unw_word_t end; - unw_word_t size; - ia64_loc_t rnat_loc; - } - rbs_area[96 + 2]; /* 96 stacked regs + 1 extra stack on each side... */ -}; - -struct ia64_global_unwind_state - { - pthread_mutex_t lock; /* global data lock */ - - volatile char init_done; - - /* Table of registers that prologues can save (and order in which - they're saved). */ - const unsigned char save_order[8]; - - /* - * uc_addr() may return pointers to these variables. We need to - * make sure they don't get written via ia64_put() or - * ia64_putfp(). To make it possible to test for these variables - * quickly, we collect them in a single sub-structure. - */ - struct - { - unw_word_t r0; /* r0 is byte-order neutral */ - unw_fpreg_t f0; /* f0 is byte-order neutral */ - unw_fpreg_t f1_le, f1_be; /* f1 is byte-order dependent */ - } - read_only; - unw_fpreg_t nat_val_le, nat_val_be; - unw_fpreg_t int_val_le, int_val_be; - - struct mempool reg_state_pool; - struct mempool labeled_state_pool; - -# if UNW_DEBUG - const char *preg_name[IA64_NUM_PREGS]; -# endif - }; - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done unw.init_done -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table unw_search_ia64_unwind_table -#define tdep_find_unwind_table ia64_find_unwind_table -#define tdep_find_proc_info UNW_OBJ(find_proc_info) -#define tdep_uc_addr UNW_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c,rs) do {} while(0) -#define tdep_reuse_frame(c,rs) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) -#define tdep_get_as(c) ((c)->as) -#define tdep_get_as_arg(c) ((c)->as_arg) -#define tdep_get_ip(c) ((c)->ip) -#define tdep_big_endian(as) ((c)->as->big_endian != 0) - -#ifndef UNW_LOCAL_ONLY -# define tdep_put_unwind_info UNW_OBJ(put_unwind_info) -#endif - -/* This can't be an UNW_ARCH_OBJ() because we need separate - unw.initialized flags for the local-only and generic versions of - the library. Also, if we wanted to have a single, shared global - data structure, we couldn't declare "unw" as HIDDEN/PROTECTED. */ -#define unw UNW_OBJ(data) - -extern void tdep_init (void); -extern int tdep_find_unwind_table (struct elf_dyn_info *edi, - unw_addr_space_t as, char *path, - unw_word_t segbase, unw_word_t mapoff, - unw_word_t ip); -extern int tdep_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, int need_unwind_info, - void *arg); -extern void tdep_put_unwind_info (unw_addr_space_t as, - unw_proc_info_t *pi, void *arg); -extern void *tdep_uc_addr (ucontext_t *uc, unw_regnum_t regnum, - uint8_t *nat_bitnr); -/* ANDROID support update. */ -extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char **path, void *as_arg); -/* End of ANDROID update. */ -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -extern struct ia64_global_unwind_state unw; - -/* In user-level, we have no reasonable way of determining the base of - an arbitrary backing-store. We default to half the - address-space. */ -#define rbs_get_base(c,bspstore,rbs_basep) \ - (*(rbs_basep) = (bspstore) - (((unw_word_t) 1) << 63), 0) - -#endif /* IA64_LIBUNWIND_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/rse.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/rse.h deleted file mode 100644 index c5fe4b589..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/rse.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 1998, 1999, 2002, 2003, 2005 Hewlett-Packard Co - * David Mosberger-Tang - * - * Register stack engine related helper functions. This file may be - * used in applications, so be careful about the name-space and give - * some consideration to non-GNU C compilers (though __inline__ is - * fine). - */ -#ifndef RSE_H -#define RSE_H - -#include - -static inline uint64_t -rse_slot_num (uint64_t addr) -{ - return (addr >> 3) & 0x3f; -} - -/* - * Return TRUE if ADDR is the address of an RNAT slot. - */ -static inline uint64_t -rse_is_rnat_slot (uint64_t addr) -{ - return rse_slot_num (addr) == 0x3f; -} - -/* - * Returns the address of the RNAT slot that covers the slot at - * address SLOT_ADDR. - */ -static inline uint64_t -rse_rnat_addr (uint64_t slot_addr) -{ - return slot_addr | (0x3f << 3); -} - -/* - * Calculate the number of registers in the dirty partition starting at - * BSPSTORE and ending at BSP. This isn't simply (BSP-BSPSTORE)/8 - * because every 64th slot stores ar.rnat. - */ -static inline uint64_t -rse_num_regs (uint64_t bspstore, uint64_t bsp) -{ - uint64_t slots = (bsp - bspstore) >> 3; - - return slots - (rse_slot_num(bspstore) + slots)/0x40; -} - -/* - * The inverse of the above: given bspstore and the number of - * registers, calculate ar.bsp. - */ -static inline uint64_t -rse_skip_regs (uint64_t addr, long num_regs) -{ - long delta = rse_slot_num(addr) + num_regs; - - if (num_regs < 0) - delta -= 0x3e; - return addr + ((num_regs + delta/0x3f) << 3); -} - -#endif /* RSE_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/script.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/script.h deleted file mode 100644 index 48a9fe561..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-ia64/script.h +++ /dev/null @@ -1,85 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#define IA64_LOG_UNW_CACHE_SIZE 7 -#define IA64_UNW_CACHE_SIZE (1 << IA64_LOG_UNW_CACHE_SIZE) - -#define IA64_LOG_UNW_HASH_SIZE (IA64_LOG_UNW_CACHE_SIZE + 1) -#define IA64_UNW_HASH_SIZE (1 << IA64_LOG_UNW_HASH_SIZE) - -typedef unsigned char unw_hash_index_t; - -struct ia64_script_insn - { - unsigned int opc; /* see enum ia64_script_insn_opcode */ - unsigned int dst; - unw_word_t val; - }; - -/* Updating each preserved register may result in one script - instruction each. At the end of the script, psp gets popped, - accounting for one more instruction. */ -#define IA64_MAX_SCRIPT_LEN (IA64_NUM_PREGS + 1) - -struct ia64_script - { - unw_word_t ip; /* ip this script is for */ - unw_word_t pr_mask; /* mask of predicates script depends on */ - unw_word_t pr_val; /* predicate values this script is for */ - unw_proc_info_t pi; /* info about underlying procedure */ - unsigned short lru_chain; /* used for least-recently-used chain */ - unsigned short coll_chain; /* used for hash collisions */ - unsigned short hint; /* hint for next script to try (or -1) */ - unsigned short count; /* number of instructions in script */ - unsigned short abi_marker; - struct ia64_script_insn insn[IA64_MAX_SCRIPT_LEN]; - }; - -struct ia64_script_cache - { -#ifdef HAVE_ATOMIC_OPS_H - AO_TS_t busy; /* is the script-cache busy? */ -#else - pthread_mutex_t lock; -#endif - unsigned short lru_head; /* index of lead-recently used script */ - unsigned short lru_tail; /* index of most-recently used script */ - - /* hash table that maps instruction pointer to script index: */ - unsigned short hash[IA64_UNW_HASH_SIZE]; - - uint32_t generation; /* generation number */ - - /* script cache: */ - struct ia64_script buckets[IA64_UNW_CACHE_SIZE]; - }; - -#define ia64_cache_proc_info UNW_OBJ(cache_proc_info) -#define ia64_get_cached_proc_info UNW_OBJ(get_cached_proc_info) - -struct cursor; /* forward declaration */ - -extern int ia64_cache_proc_info (struct cursor *c); -extern int ia64_get_cached_proc_info (struct cursor *c); diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-mips/dwarf-config.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-mips/dwarf-config.h deleted file mode 100644 index 0dbdc5a0b..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-mips/dwarf-config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* This is FIRST_PSEUDO_REGISTER in GCC, since DWARF_FRAME_REGISTERS is not - explicitly defined. */ -#define DWARF_NUM_PRESERVED_REGS 188 - -#define dwarf_to_unw_regnum(reg) (((reg) < 32) ? (reg) : 0) - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) ((addr_space)->big_endian) - -/* Return the size of an address, for DWARF purposes. */ -#define dwarf_addr_size(addr_space) ((addr_space)->addr_size) - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-mips/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-mips/jmpbuf.h deleted file mode 100644 index 1adb2bca4..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-mips/jmpbuf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -/* FIXME for MIPS! */ - -#define JB_SP 4 -#define JB_RP 5 -#define JB_MASK_SAVED 6 -#define JB_MASK 7 diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-mips/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-mips/libunwind_i.h deleted file mode 100644 index c4059b27b..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-mips/libunwind_i.h +++ /dev/null @@ -1,354 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef MIPS_LIBUNWIND_I_H -#define MIPS_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#if !defined(UNW_REMOTE_ONLY) && _MIPS_SIM == _ABI64 -# include "elf64.h" -#else -# include "elf32.h" -#endif -/* ANDROID support update. */ -#include "map_info.h" -/* End of ANDROID update. */ -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no mips-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - - int big_endian; - mips_abi_t abi; - unsigned int addr_size; - - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - /* ANDROID support update. */ - struct map_info *map_list; - /* End of ANDROID update. */ -}; - -#define tdep_big_endian(as) ((as)->big_endian) - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - unw_word_t sigcontext_addr; - }; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifndef UNW_REMOTE_ONLY -# if _MIPS_SIM == _ABIN32 -typedef long long mips_reg_t; -# else -typedef long mips_reg_t; -# endif -#endif - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) (intptr_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) (intptr_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -/* FIXME: Implement these for the MIPS FPU. */ -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ -/* ANDROID support update. */ - unw_fpreg_t *addr = (unw_fpreg_t *) (uintptr_t) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_readable ((unw_word_t) (uintptr_t) addr, sizeof(unw_fpreg_t))) - return -1; - - *val = *addr; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ -/* ANDROID support update. */ - unw_fpreg_t *addr = (unw_fpreg_t *) (uintptr_t) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_writable ((unw_word_t) (uintptr_t) addr, sizeof(unw_fpreg_t))) - return -1; - - *addr = val; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ -/* ANDROID support update. */ - mips_reg_t *addr = (mips_reg_t *) (uintptr_t) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_readable ((unw_word_t) (uintptr_t) addr, sizeof(mips_reg_t))) - return -1; - - *val = *addr; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ -/* ANDROID support update. */ - mips_reg_t *addr = (mips_reg_t *) (uintptr_t) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_writable ((unw_word_t) (uintptr_t) addr, sizeof(mips_reg_t))) - return -1; - - *addr = val; - return 0; -/* End of ANDROID update. */ -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -read_s32 (struct dwarf_cursor *c, unw_word_t addr, unw_word_t *val) -{ - int offset = addr & 4; - int ret; - unw_word_t memval; - - ret = (*c->as->acc.access_mem) (c->as, addr - offset, &memval, 0, c->as_arg); - if (ret < 0) - return ret; - - if ((offset != 0) == tdep_big_endian (c->as)) - *val = (int32_t) memval; - else - *val = (int32_t) (memval >> 32); - - return 0; -} - -static inline int -write_s32 (struct dwarf_cursor *c, unw_word_t addr, const unw_word_t *val) -{ - int offset = addr & 4; - int ret; - unw_word_t memval; - - ret = (*c->as->acc.access_mem) (c->as, addr - offset, &memval, 0, c->as_arg); - if (ret < 0) - return ret; - - if ((offset != 0) == tdep_big_endian (c->as)) - memval = (memval & ~0xffffffffLL) | (uint32_t) *val; - else - memval = (memval & 0xffffffffLL) | (uint32_t) (*val << 32); - - return (*c->as->acc.access_mem) (c->as, addr - offset, &memval, 1, c->as_arg); -} - -/* FIXME: Implement these for the MIPS FPU. */ -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else if (c->as->abi == UNW_MIPS_ABI_O32) - return read_s32 (c, DWARF_GET_LOC (loc), val); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else if (c->as->abi == UNW_MIPS_ABI_O32) - return write_s32 (c, DWARF_GET_LOC (loc), &val); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c,rs) do {} while(0) -#define tdep_reuse_frame(c,rs) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (ucontext_t *uc, int reg); -/* ANDROID support update. */ -extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char **path, void *as_arg); -/* End of ANDROID update. */ -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -#endif /* MIPS_LIBUNWIND_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc32/dwarf-config.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc32/dwarf-config.h deleted file mode 100644 index e2676a824..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc32/dwarf-config.h +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* For PPC64, 48 GPRs + 33 FPRs + 33 AltiVec + 1 SPE */ -#define DWARF_NUM_PRESERVED_REGS 115 - -#define DWARF_REGNUM_MAP_LENGTH 115 - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 1 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see X86_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc32/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc32/jmpbuf.h deleted file mode 100644 index 3780d5b5e..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc32/jmpbuf.h +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#define JB_SP 6 -#define JB_RP 7 -#define JB_MASK_SAVED 8 -#define JB_MASK 9 diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc32/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc32/libunwind_i.h deleted file mode 100644 index c375b9ba2..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc32/libunwind_i.h +++ /dev/null @@ -1,321 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef PPC32_LIBUNWIND_I_H -#define PPC32_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf32.h" -/* ANDROID support update. */ -#include "map_info.h" -/* End of ANDROID update. */ -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no ppc32-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space -{ - struct unw_accessors acc; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - int validate; - /* ANDROID support update. */ - struct map_info *map_list; - /* End of ANDROID update. */ -}; - -struct cursor -{ - struct dwarf_cursor dwarf; /* must be first */ - - /* Format of sigcontext structure and address at which it is - stored: */ - enum - { - PPC_SCF_NONE, /* no signal frame encountered */ - PPC_SCF_LINUX_RT_SIGFRAME /* POSIX ucontext_t */ - } - sigcontext_format; - unw_word_t sigcontext_addr; -}; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_IS_FP_LOC(l) 0 -# define DWARF_IS_V_LOC(l) 0 -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_VREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -#else /* !UNW_LOCAL_ONLY */ - -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_LOC_TYPE_V (1 << 2) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_IS_V_LOC(l) (((l).type & DWARF_LOC_TYPE_V) != 0) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) -# define DWARF_VREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_V)) - -#endif /* !UNW_LOCAL_ONLY */ - -static inline int -dwarf_getvr (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t * val) -{ - unw_word_t *valp = (unw_word_t *) val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_V_LOC (loc)); - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 8, valp + 1, 0, c->as_arg); -} - -static inline int -dwarf_putvr (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - unw_word_t *valp = (unw_word_t *) & val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_V_LOC (loc)); - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 8, valp + 1, 1, c->as_arg); -} - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t * val) -{ - unw_word_t *valp = (unw_word_t *) val; - unw_word_t addr; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - return (*c->as->acc.access_mem) (c->as, addr + 0, valp, 0, c->as_arg); - -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - unw_word_t *valp = (unw_word_t *) & val; - unw_word_t addr; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - - return (*c->as->acc.access_mem) (c->as, addr + 0, valp, 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t * val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c,rs) do {} while(0) -#define tdep_reuse_frame(c,rs) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) -#define tdep_get_func_addr UNW_OBJ(get_func_addr) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -extern int tdep_fetch_proc_info_post (struct dwarf_cursor *c, unw_word_t ip, - int need_unwind_info); - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) 1 - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t * di, - unw_proc_info_t * pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (ucontext_t * uc, int reg); -/* ANDROID support update. */ -extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char **path, void *as_arg); -/* End of ANDROID update. */ -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t * valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t * valp, int write); -extern int tdep_get_func_addr (unw_addr_space_t as, unw_word_t addr, - unw_word_t *entry_point); - -#endif /* PPC64_LIBUNWIND_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc64/dwarf-config.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc64/dwarf-config.h deleted file mode 100644 index e2676a824..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc64/dwarf-config.h +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* For PPC64, 48 GPRs + 33 FPRs + 33 AltiVec + 1 SPE */ -#define DWARF_NUM_PRESERVED_REGS 115 - -#define DWARF_REGNUM_MAP_LENGTH 115 - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 1 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see X86_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc64/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc64/jmpbuf.h deleted file mode 100644 index 3780d5b5e..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc64/jmpbuf.h +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#define JB_SP 6 -#define JB_RP 7 -#define JB_MASK_SAVED 8 -#define JB_MASK 9 diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc64/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc64/libunwind_i.h deleted file mode 100644 index cbeb16a08..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-ppc64/libunwind_i.h +++ /dev/null @@ -1,321 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef PPC64_LIBUNWIND_I_H -#define PPC64_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf64.h" -/* ANDROID support update. */ -#include "map_info.h" -/* End of ANDROID update. */ -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no ppc64-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space -{ - struct unw_accessors acc; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - int validate; - /* ANDROID support update. */ - struct map_info *map_list; - /* End of ANDROID update. */ -}; - -struct cursor -{ - struct dwarf_cursor dwarf; /* must be first */ - - /* Format of sigcontext structure and address at which it is - stored: */ - enum - { - PPC_SCF_NONE, /* no signal frame encountered */ - PPC_SCF_LINUX_RT_SIGFRAME /* POSIX ucontext_t */ - } - sigcontext_format; - unw_word_t sigcontext_addr; -}; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_IS_FP_LOC(l) 0 -# define DWARF_IS_V_LOC(l) 0 -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_VREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -#else /* !UNW_LOCAL_ONLY */ - -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_LOC_TYPE_V (1 << 2) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_IS_V_LOC(l) (((l).type & DWARF_LOC_TYPE_V) != 0) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) -# define DWARF_VREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_V)) - -#endif /* !UNW_LOCAL_ONLY */ - -static inline int -dwarf_getvr (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t * val) -{ - unw_word_t *valp = (unw_word_t *) val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_V_LOC (loc)); - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 8, valp + 1, 0, c->as_arg); -} - -static inline int -dwarf_putvr (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - unw_word_t *valp = (unw_word_t *) & val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_V_LOC (loc)); - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 8, valp + 1, 1, c->as_arg); -} - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t * val) -{ - unw_word_t *valp = (unw_word_t *) val; - unw_word_t addr; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - return (*c->as->acc.access_mem) (c->as, addr + 0, valp, 0, c->as_arg); - -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - unw_word_t *valp = (unw_word_t *) & val; - unw_word_t addr; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - - return (*c->as->acc.access_mem) (c->as, addr + 0, valp, 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t * val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c,rs) do {} while(0) -#define tdep_reuse_frame(c,rs) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) -#define tdep_get_func_addr UNW_OBJ(get_func_addr) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -extern int tdep_fetch_proc_info_post (struct dwarf_cursor *c, unw_word_t ip, - int need_unwind_info); - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) 1 - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t * di, - unw_proc_info_t * pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (ucontext_t * uc, int reg); -/* ANDROID support update. */ -extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char **path, void *as_arg); -/* End of ANDROID update. */ -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t * valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t * valp, int write); -extern int tdep_get_func_addr (unw_addr_space_t as, unw_word_t addr, - unw_word_t *entry_point); - -#endif /* PPC64_LIBUNWIND_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-sh/dwarf-config.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-sh/dwarf-config.h deleted file mode 100644 index 2a7116f3a..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-sh/dwarf-config.h +++ /dev/null @@ -1,49 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -#define DWARF_NUM_PRESERVED_REGS 18 - -#define dwarf_to_unw_regnum(reg) (((reg) <= UNW_SH_PR) ? (reg) : 0) - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) ((addr_space)->big_endian) - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-sh/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-sh/jmpbuf.h deleted file mode 100644 index 684a4054c..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-sh/jmpbuf.h +++ /dev/null @@ -1,48 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -/* SH4 glibc jump buffer contents: - * 0. r8 - * 1. r9 - * 2. r10 - * 3. r11 - * 4. r12 - * 5. r13 - * 6. r14 - * 7. r15 - * 8. pr/pc - * 9. gbr - * 10. fpscr - * 11. fr12 - * 12. fr13 - * 13. fr14 - * 14. fr15 - */ - -#define JB_SP 7 -#define JB_RP 8 -#define JB_MASK_SAVED 15 -#define JB_MASK 16 diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-sh/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-sh/libunwind_i.h deleted file mode 100644 index 4a2afd750..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-sh/libunwind_i.h +++ /dev/null @@ -1,299 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef SH_LIBUNWIND_I_H -#define SH_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf32.h" -/* ANDROID support update. */ -#include "map_info.h" -/* End of ANDROID update. */ -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no sh-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - int big_endian; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - /* ANDROID support update. */ - struct map_info *map_list; - /* End of ANDROID update. */ - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - enum - { - SH_SCF_NONE, /* no signal frame */ - SH_SCF_LINUX_SIGFRAME, /* non-RT signal frame */ - SH_SCF_LINUX_RT_SIGFRAME, /* RT signal frame */ - } - sigcontext_format; - unw_word_t sigcontext_addr; - unw_word_t sigcontext_sp; - unw_word_t sigcontext_pc; - }; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ -/* ANDROID support update. */ - unw_fpreg_t *addr = (unw_fpreg_t *) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_readable ((unw_word_t) addr, sizeof(unw_fpreg_t))) - return -1; - - *val = *addr; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ -/* ANDROID support update. */ - unw_fpreg_t *addr = (unw_fpreg_t *) DWARF_GET_LOC (loc); - if (!addr || !map_local_is_writable ((unw_word_t) addr, sizeof(unw_fpreg_t))) - return -1; - - *addr = val; - return 0; -/* End of ANDROID update. */ -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ -/* ANDROID support update. */ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -/* End of ANDROID update. */ -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ -/* ANDROID support update. */ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -/* End of ANDROID update. */ -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c,rs) do {} while(0) -#define tdep_reuse_frame(c,rs) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) ((as)->big_endian) - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg); -/* ANDROID support update. */ -extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char **path, void *as_arg); -/* End of ANDROID update. */ -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -#endif /* SH_LIBUNWIND_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86/dwarf-config.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-x86/dwarf-config.h deleted file mode 100644 index 898ab796a..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86/dwarf-config.h +++ /dev/null @@ -1,52 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* This matches the value used by GCC (see - gcc/config/i386.h:DWARF_FRAME_REGISTERS), which leaves plenty of - room for expansion. */ -#define DWARF_NUM_PRESERVED_REGS 17 - -#define DWARF_REGNUM_MAP_LENGTH 19 - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 0 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see X86_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-x86/jmpbuf.h deleted file mode 100644 index 561495098..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86/jmpbuf.h +++ /dev/null @@ -1,42 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#if defined __linux__ - -#define JB_SP 4 -#define JB_RP 5 -#define JB_MASK_SAVED 6 -#define JB_MASK 7 - -#elif defined __FreeBSD__ - -#define JB_SP 2 -#define JB_RP 0 -#define JB_MASK_SAVED 11 -#define JB_MASK 7 - -#endif diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-x86/libunwind_i.h deleted file mode 100644 index f87bd7130..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86/libunwind_i.h +++ /dev/null @@ -1,302 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef X86_LIBUNWIND_I_H -#define X86_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf32.h" -/* ANDROID support update. */ -#include "map_info.h" -/* End of ANDROID update. */ -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no x86-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - /* ANDROID support update. */ -#if defined(__linux__) - struct map_info *map_list; -#endif - /* End of ANDROID update. */ - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - - /* Format of sigcontext structure and address at which it is - stored: */ - enum - { - X86_SCF_NONE, /* no signal frame encountered */ - X86_SCF_LINUX_SIGFRAME, /* Linux x86 sigcontext */ - X86_SCF_LINUX_RT_SIGFRAME, /* POSIX ucontext_t */ - X86_SCF_FREEBSD_SIGFRAME, /* FreeBSD x86 sigcontext */ - X86_SCF_FREEBSD_SIGFRAME4, /* FreeBSD 4.x x86 sigcontext */ - X86_SCF_FREEBSD_OSIGFRAME, /* FreeBSD pre-4.x x86 sigcontext */ - X86_SCF_FREEBSD_SYSCALL, /* FreeBSD x86 syscall */ - } - sigcontext_format; - unw_word_t sigcontext_addr; - int validate; - ucontext_t *uc; - }; - -static inline ucontext_t * -dwarf_get_uc(const struct dwarf_cursor *cursor) -{ - const struct cursor *c = (struct cursor *) cursor->as_arg; - return c->uc; -} - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr(dwarf_get_uc(c), (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr(dwarf_get_uc(c), (r)), 0)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c,rs) do {} while(0) -#define tdep_reuse_frame(c,rs) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) 0 - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (ucontext_t *uc, int reg); -/* ANDROID support update. */ -extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char **path, void *as_arg); -/* End of ANDROID update. */ -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -#endif /* X86_LIBUNWIND_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86_64/dwarf-config.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-x86_64/dwarf-config.h deleted file mode 100644 index d3cbe7c27..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86_64/dwarf-config.h +++ /dev/null @@ -1,59 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* copy of include/tdep-x86/dwarf-config.h, modified slightly for x86-64 - some consolidation is possible here */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* XXX need to verify if this value is correct */ -#ifdef CONFIG_MSABI_SUPPORT -#define DWARF_NUM_PRESERVED_REGS 33 -#else -#define DWARF_NUM_PRESERVED_REGS 17 -#endif - -#define DWARF_REGNUM_MAP_LENGTH DWARF_NUM_PRESERVED_REGS - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 0 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see X86_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86_64/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-x86_64/jmpbuf.h deleted file mode 100644 index 44fcd69be..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86_64/jmpbuf.h +++ /dev/null @@ -1,43 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#if defined __linux__ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#define JB_SP 6 -#define JB_RP 7 -#define JB_MASK_SAVED 8 -#define JB_MASK 9 - -#elif defined __FreeBSD__ - -#define JB_SP 2 -#define JB_RP 0 -/* Pretend the ip cannot be 0 and mask is always saved */ -#define JB_MASK_SAVED 0 -#define JB_MASK 9 - -#endif diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86_64/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep-x86_64/libunwind_i.h deleted file mode 100644 index 184989e0b..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep-x86_64/libunwind_i.h +++ /dev/null @@ -1,261 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef X86_64_LIBUNWIND_I_H -#define X86_64_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf64.h" -/* ANDROID support update. */ -#include "map_info.h" -/* End of ANDROID update. */ -#include "mempool.h" -#include "dwarf.h" - -typedef enum - { - UNW_X86_64_FRAME_STANDARD = -2, /* regular rbp, rsp +/- offset */ - UNW_X86_64_FRAME_SIGRETURN = -1, /* special sigreturn frame */ - UNW_X86_64_FRAME_OTHER = 0, /* not cacheable (special or unrecognised) */ - UNW_X86_64_FRAME_GUESSED = 1 /* guessed it was regular, but not known */ - } -unw_tdep_frame_type_t; - -typedef struct - { - uint64_t virtual_address; - int64_t frame_type : 2; /* unw_tdep_frame_type_t classification */ - int64_t last_frame : 1; /* non-zero if last frame in chain */ - int64_t cfa_reg_rsp : 1; /* cfa dwarf base register is rsp vs. rbp */ - int64_t cfa_reg_offset : 30; /* cfa is at this offset from base register value */ - int64_t rbp_cfa_offset : 15; /* rbp saved at this offset from cfa (-1 = not saved) */ - int64_t rsp_cfa_offset : 15; /* rsp saved at this offset from cfa (-1 = not saved) */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - /* ANDROID support update. */ - struct map_info *map_list; - /* End of ANDROID update. */ - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - - unw_tdep_frame_t frame_info; /* quick tracing assist info */ - - /* Format of sigcontext structure and address at which it is - stored: */ - enum - { - X86_64_SCF_NONE, /* no signal frame encountered */ - X86_64_SCF_LINUX_RT_SIGFRAME, /* Linux ucontext_t */ - X86_64_SCF_FREEBSD_SIGFRAME, /* FreeBSD signal frame */ - X86_64_SCF_FREEBSD_SYSCALL, /* FreeBSD syscall */ - } - sigcontext_format; - unw_word_t sigcontext_addr; - int validate; - ucontext_t *uc; - }; - -static inline ucontext_t * -dwarf_get_uc(const struct dwarf_cursor *cursor) -{ - const struct cursor *c = (struct cursor *) cursor->as_arg; - return c->uc; -} - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - x86_64_r_uc_addr(dwarf_get_uc(c), (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - x86_64_r_uc_addr(dwarf_get_uc(c), (r)), 0)) -#else /* !UNW_LOCAL_ONLY */ - -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -#endif /* !UNW_LOCAL_ONLY */ - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - abort (); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - abort (); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#define tdep_getcontext_trace UNW_ARCH_OBJ(getcontext_trace) -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init_mem_validate UNW_OBJ(init_mem_validate) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#if __linux__ -# define tdep_fetch_frame UNW_OBJ(fetch_frame) -# define tdep_cache_frame UNW_OBJ(cache_frame) -# define tdep_reuse_frame UNW_OBJ(reuse_frame) -#else -# define tdep_fetch_frame(c,ip,n) do {} while(0) -# define tdep_cache_frame(c,rs) do {} while(0) -# define tdep_reuse_frame(c,rs) do {} while(0) -#endif -#define tdep_stash_frame UNW_OBJ(stash_frame) -#define tdep_trace UNW_OBJ(tdep_trace) -#define x86_64_r_uc_addr UNW_OBJ(r_uc_addr) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) 0 - -extern int tdep_init_done; - -extern void tdep_init (void); -extern void tdep_init_mem_validate (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *x86_64_r_uc_addr (ucontext_t *uc, int reg); -/* ANDROID support update. */ -extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char **path, void *as_arg); -/* End of ANDROID update. */ -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); -#if __linux__ -extern void tdep_fetch_frame (struct dwarf_cursor *c, unw_word_t ip, - int need_unwind_info); -extern void tdep_cache_frame (struct dwarf_cursor *c, - struct dwarf_reg_state *rs); -extern void tdep_reuse_frame (struct dwarf_cursor *c, - struct dwarf_reg_state *rs); -extern void tdep_stash_frame (struct dwarf_cursor *c, - struct dwarf_reg_state *rs); -#endif - -extern int tdep_getcontext_trace (unw_tdep_context_t *); -extern int tdep_trace (unw_cursor_t *cursor, void **addresses, int *n); - -#endif /* X86_64_LIBUNWIND_I_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep/dwarf-config.h b/app/src/main/jni/crash_dump/libunwind/include/tdep/dwarf-config.h deleted file mode 100644 index 5b09fc187..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep/dwarf-config.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Provide a real file - not a symlink - as it would cause multiarch conflicts - when multiple different arch releases are installed simultaneously. */ - -#if defined __aarch64__ -# include "tdep-aarch64/dwarf-config.h" -#elif defined __arm__ -# include "tdep-arm/dwarf-config.h" -#elif defined __hppa__ -# include "tdep-hppa/dwarf-config.h" -#elif defined __ia64__ -# include "tdep-ia64/dwarf-config.h" -#elif defined __mips__ -# include "tdep-mips/dwarf-config.h" -#elif defined __powerpc__ && !defined __powerpc64__ -# include "tdep-ppc32/dwarf-config.h" -#elif defined __powerpc64__ -# include "tdep-ppc64/dwarf-config.h" -#elif defined __sh__ -# include "tdep-sh/dwarf-config.h" -#elif defined __i386__ -# include "tdep-x86/dwarf-config.h" -#elif defined __x86_64__ || defined __amd64__ -# include "tdep-x86_64/dwarf-config.h" -#else -# error "Unsupported arch" -#endif diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/tdep/jmpbuf.h deleted file mode 100644 index 684d0d953..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep/jmpbuf.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Provide a real file - not a symlink - as it would cause multiarch conflicts - when multiple different arch releases are installed simultaneously. */ - -#ifndef UNW_REMOTE_ONLY - -#if defined __aarch64__ -# include "tdep-aarch64/jmpbuf.h" -#if defined __arm__ -# include "tdep-arm/jmpbuf.h" -#elif defined __hppa__ -# include "tdep-hppa/jmpbuf.h" -#elif defined __ia64__ -# include "tdep-ia64/jmpbuf.h" -#elif defined __mips__ -# include "tdep-mips/jmpbuf.h" -#elif defined __powerpc__ && !defined __powerpc64__ -# include "tdep-ppc32/jmpbuf.h" -#elif defined __powerpc64__ -# include "tdep-ppc64/jmpbuf.h" -#elif defined __i386__ -# include "tdep-x86/jmpbuf.h" -#elif defined __x86_64__ -# include "tdep-x86_64/jmpbuf.h" -#else -# error "Unsupported arch" -#endif - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep/libunwind_i.h b/app/src/main/jni/crash_dump/libunwind/include/tdep/libunwind_i.h deleted file mode 100644 index fcca9099c..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep/libunwind_i.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Provide a real file - not a symlink - as it would cause multiarch conflicts - when multiple different arch releases are installed simultaneously. */ - -#ifndef UNW_REMOTE_ONLY - -#if defined __aarch64__ -# include "tdep-aarch64/libunwind_i.h" -#elif defined __arm__ -# include "tdep-arm/libunwind_i.h" -#elif defined __hppa__ -# include "tdep-hppa/libunwind_i.h" -#elif defined __ia64__ -# include "tdep-ia64/libunwind_i.h" -#elif defined __mips__ -# include "tdep-mips/libunwind_i.h" -#elif defined __powerpc__ && !defined __powerpc64__ -# include "tdep-ppc32/libunwind_i.h" -#elif defined __powerpc64__ -# include "tdep-ppc64/libunwind_i.h" -#elif defined __sh__ -# include "tdep-sh/libunwind_i.h" -#elif defined __i386__ -# include "tdep-x86/libunwind_i.h" -#elif defined __x86_64__ -# include "tdep-x86_64/libunwind_i.h" -#else -# error "Unsupported arch" -#endif - - -#else /* UNW_REMOTE_ONLY */ - -# include "tdep-arm/libunwind_i.h" - -#endif /* UNW_REMOTE_ONLY */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/tdep/libunwind_i.h.in b/app/src/main/jni/crash_dump/libunwind/include/tdep/libunwind_i.h.in deleted file mode 100644 index 475f8288a..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/tdep/libunwind_i.h.in +++ /dev/null @@ -1,35 +0,0 @@ -/* Provide a real file - not a symlink - as it would cause multiarch conflicts - when multiple different arch releases are installed simultaneously. */ - -#ifndef UNW_REMOTE_ONLY - -#if defined __aarch64__ -# include "tdep-aarch64/libunwind_i.h" -#elif defined __arm__ -# include "tdep-arm/libunwind_i.h" -#elif defined __hppa__ -# include "tdep-hppa/libunwind_i.h" -#elif defined __ia64__ -# include "tdep-ia64/libunwind_i.h" -#elif defined __mips__ -# include "tdep-mips/libunwind_i.h" -#elif defined __powerpc__ && !defined __powerpc64__ -# include "tdep-ppc32/libunwind_i.h" -#elif defined __powerpc64__ -# include "tdep-ppc64/libunwind_i.h" -#elif defined __sh__ -# include "tdep-sh/libunwind_i.h" -#elif defined __i386__ -# include "tdep-x86/libunwind_i.h" -#elif defined __x86_64__ -# include "tdep-x86_64/libunwind_i.h" -#else -# error "Unsupported arch" -#endif - - -#else /* UNW_REMOTE_ONLY */ - -# include "tdep-@arch@/libunwind_i.h" - -#endif /* UNW_REMOTE_ONLY */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/unwind.h b/app/src/main/jni/crash_dump/libunwind/include/unwind.h deleted file mode 100644 index f8d43d0d0..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/unwind.h +++ /dev/null @@ -1,154 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef _UNWIND_H -#define _UNWIND_H - -/* For uint64_t */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Minimal interface as per C++ ABI draft standard: - - http://www.codesourcery.com/cxx-abi/abi-eh.html */ - -typedef enum - { - _URC_NO_REASON = 0, - _URC_FOREIGN_EXCEPTION_CAUGHT = 1, - _URC_FATAL_PHASE2_ERROR = 2, - _URC_FATAL_PHASE1_ERROR = 3, - _URC_NORMAL_STOP = 4, - _URC_END_OF_STACK = 5, - _URC_HANDLER_FOUND = 6, - _URC_INSTALL_CONTEXT = 7, - _URC_CONTINUE_UNWIND = 8 - } -_Unwind_Reason_Code; - -typedef int _Unwind_Action; - -#define _UA_SEARCH_PHASE 1 -#define _UA_CLEANUP_PHASE 2 -#define _UA_HANDLER_FRAME 4 -#define _UA_FORCE_UNWIND 8 - -struct _Unwind_Context; /* opaque data-structure */ -struct _Unwind_Exception; /* forward-declaration */ - -typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, - struct _Unwind_Exception *); - -typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) (int, _Unwind_Action, - uint64_t, - struct _Unwind_Exception *, - struct _Unwind_Context *, - void *); - -/* The C++ ABI requires exception_class, private_1, and private_2 to - be of type uint64 and the entire structure to be - double-word-aligned. Please note that exception_class stays 64-bit - even on 32-bit machines for gcc compatibility. */ -struct _Unwind_Exception - { - uint64_t exception_class; - _Unwind_Exception_Cleanup_Fn exception_cleanup; - unsigned long private_1; - unsigned long private_2; - } __attribute__((__aligned__)); - -extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *); -extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *, - _Unwind_Stop_Fn, void *); -extern void _Unwind_Resume (struct _Unwind_Exception *); -extern void _Unwind_DeleteException (struct _Unwind_Exception *); -extern unsigned long _Unwind_GetGR (struct _Unwind_Context *, int); -extern void _Unwind_SetGR (struct _Unwind_Context *, int, unsigned long); -extern unsigned long _Unwind_GetIP (struct _Unwind_Context *); -extern unsigned long _Unwind_GetIPInfo (struct _Unwind_Context *, int *); -extern void _Unwind_SetIP (struct _Unwind_Context *, unsigned long); -extern unsigned long _Unwind_GetLanguageSpecificData (struct _Unwind_Context*); -extern unsigned long _Unwind_GetRegionStart (struct _Unwind_Context *); - -#ifdef _GNU_SOURCE - -/* Callback for _Unwind_Backtrace(). The backtrace stops immediately - if the callback returns any value other than _URC_NO_REASON. */ -typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (struct _Unwind_Context *, - void *); - -/* See http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00082.html for why - _UA_END_OF_STACK exists. */ -# define _UA_END_OF_STACK 16 - -/* If the unwind was initiated due to a forced unwind, resume that - operation, else re-raise the exception. This is used by - __cxa_rethrow(). */ -extern _Unwind_Reason_Code - _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *); - -/* See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00154.html for why - _Unwind_GetBSP() exists. */ -extern unsigned long _Unwind_GetBSP (struct _Unwind_Context *); - -/* Return the "canonical frame address" for the given context. - This is used by NPTL... */ -extern unsigned long _Unwind_GetCFA (struct _Unwind_Context *); - -/* Return the base-address for data references. */ -extern unsigned long _Unwind_GetDataRelBase (struct _Unwind_Context *); - -/* Return the base-address for text references. */ -extern unsigned long _Unwind_GetTextRelBase (struct _Unwind_Context *); - -/* Call _Unwind_Trace_Fn once for each stack-frame, without doing any - cleanup. The first frame for which the callback is invoked is the - one for the caller of _Unwind_Backtrace(). _Unwind_Backtrace() - returns _URC_END_OF_STACK when the backtrace stopped due to - reaching the end of the call-chain or _URC_FATAL_PHASE1_ERROR if it - stops for any other reason. */ -extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *); - -/* Find the start-address of the procedure containing the specified IP - or NULL if it cannot be found (e.g., because the function has no - unwind info). Note: there is not necessarily a one-to-one - correspondence between source-level functions and procedures: some - functions don't have unwind-info and others are split into multiple - procedures. */ -extern void *_Unwind_FindEnclosingFunction (void *); - -/* See also Linux Standard Base Spec: - http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/libgcc-s.html */ - -#endif /* _GNU_SOURCE */ - -#ifdef __cplusplus -}; -#endif - -#endif /* _UNWIND_H */ diff --git a/app/src/main/jni/crash_dump/libunwind/include/x86/jmpbuf.h b/app/src/main/jni/crash_dump/libunwind/include/x86/jmpbuf.h deleted file mode 100644 index a0eb072ee..000000000 --- a/app/src/main/jni/crash_dump/libunwind/include/x86/jmpbuf.h +++ /dev/null @@ -1,31 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#define JB_SP 4 -#define JB_RP 5 -#define JB_MASK_SAVED 6 -#define JB_MASK 7