1132bfccd21960e462352175f8553a5bdce8a210cnjn 2132bfccd21960e462352175f8553a5bdce8a210cnjn/*--------------------------------------------------------------------*/ 3132bfccd21960e462352175f8553a5bdce8a210cnjn/*--- Assertions and panics. m_libcassert.c ---*/ 4132bfccd21960e462352175f8553a5bdce8a210cnjn/*--------------------------------------------------------------------*/ 5132bfccd21960e462352175f8553a5bdce8a210cnjn 6132bfccd21960e462352175f8553a5bdce8a210cnjn/* 7132bfccd21960e462352175f8553a5bdce8a210cnjn This file is part of Valgrind, a dynamic binary instrumentation 8132bfccd21960e462352175f8553a5bdce8a210cnjn framework. 9132bfccd21960e462352175f8553a5bdce8a210cnjn 10b3a1e4bffbdbbf38304f216af405009868f43628sewardj Copyright (C) 2000-2015 Julian Seward 11132bfccd21960e462352175f8553a5bdce8a210cnjn jseward@acm.org 12132bfccd21960e462352175f8553a5bdce8a210cnjn 13132bfccd21960e462352175f8553a5bdce8a210cnjn This program is free software; you can redistribute it and/or 14132bfccd21960e462352175f8553a5bdce8a210cnjn modify it under the terms of the GNU General Public License as 15132bfccd21960e462352175f8553a5bdce8a210cnjn published by the Free Software Foundation; either version 2 of the 16132bfccd21960e462352175f8553a5bdce8a210cnjn License, or (at your option) any later version. 17132bfccd21960e462352175f8553a5bdce8a210cnjn 18132bfccd21960e462352175f8553a5bdce8a210cnjn This program is distributed in the hope that it will be useful, but 19132bfccd21960e462352175f8553a5bdce8a210cnjn WITHOUT ANY WARRANTY; without even the implied warranty of 20132bfccd21960e462352175f8553a5bdce8a210cnjn MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21132bfccd21960e462352175f8553a5bdce8a210cnjn General Public License for more details. 22132bfccd21960e462352175f8553a5bdce8a210cnjn 23132bfccd21960e462352175f8553a5bdce8a210cnjn You should have received a copy of the GNU General Public License 24132bfccd21960e462352175f8553a5bdce8a210cnjn along with this program; if not, write to the Free Software 25132bfccd21960e462352175f8553a5bdce8a210cnjn Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 26132bfccd21960e462352175f8553a5bdce8a210cnjn 02111-1307, USA. 27132bfccd21960e462352175f8553a5bdce8a210cnjn 28132bfccd21960e462352175f8553a5bdce8a210cnjn The GNU General Public License is contained in the file COPYING. 29132bfccd21960e462352175f8553a5bdce8a210cnjn*/ 30132bfccd21960e462352175f8553a5bdce8a210cnjn 31c7561b931e249acf3768ead77638545b0ccaa8f1njn#include "pub_core_basics.h" 324cfea4f9480393ed6799db463b2e0fb8865a1a2fsewardj#include "pub_core_vki.h" 33745fc459ce4ce9264d8844bf1ab695d235a4ce01sewardj#include "pub_core_vkiscnums.h" 3449b45ba90382fd313e40555559f5f5aaa23033b4njn#include "pub_core_threadstate.h" 35180a7500bf2464d5b16cddb5618b91fb3f095998philippe#include "pub_core_gdbserver.h" 364f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe#include "pub_core_aspacemgr.h" 37132bfccd21960e462352175f8553a5bdce8a210cnjn#include "pub_core_libcbase.h" 38132bfccd21960e462352175f8553a5bdce8a210cnjn#include "pub_core_libcassert.h" 39132bfccd21960e462352175f8553a5bdce8a210cnjn#include "pub_core_libcprint.h" 4049b45ba90382fd313e40555559f5f5aaa23033b4njn#include "pub_core_libcproc.h" // For VG_(gettid)() 4138a74d2cc4670e3eb559adff51a376cd6ec98005philippe#include "pub_core_machine.h" 4238a74d2cc4670e3eb559adff51a376cd6ec98005philippe#include "pub_core_stacks.h" 4349b45ba90382fd313e40555559f5f5aaa23033b4njn#include "pub_core_stacktrace.h" 449abd608244d8123868d027f616fa928156615d5anjn#include "pub_core_syscall.h" 45e070c20d9f3e651f478bba6bdb6fc34aa1f9514dnjn#include "pub_core_tooliface.h" // For VG_(details).{name,bug_reports_to} 46f349d55d40891b890d0da268cfb9f092af0fc8f4sewardj#include "pub_core_options.h" // For VG_(clo_xml) 47132bfccd21960e462352175f8553a5bdce8a210cnjn 48132bfccd21960e462352175f8553a5bdce8a210cnjn/* --------------------------------------------------------------------- 49132bfccd21960e462352175f8553a5bdce8a210cnjn Assertery. 50132bfccd21960e462352175f8553a5bdce8a210cnjn ------------------------------------------------------------------ */ 51132bfccd21960e462352175f8553a5bdce8a210cnjn 528eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#if defined(VGP_x86_linux) || defined(VGP_x86_darwin) \ 538eb8bab992e3998c33770b0cdb16059a8b918a06sewardj || defined(VGP_x86_solaris) 5459570ffbe31930ab4d678754daaeec0715117a3dsewardj# define GET_STARTREGS(srP) \ 5559570ffbe31930ab4d678754daaeec0715117a3dsewardj { UInt eip, esp, ebp; \ 5659570ffbe31930ab4d678754daaeec0715117a3dsewardj __asm__ __volatile__( \ 5759570ffbe31930ab4d678754daaeec0715117a3dsewardj "call 0f;" \ 5859570ffbe31930ab4d678754daaeec0715117a3dsewardj "0: popl %0;" \ 5959570ffbe31930ab4d678754daaeec0715117a3dsewardj "movl %%esp, %1;" \ 6059570ffbe31930ab4d678754daaeec0715117a3dsewardj "movl %%ebp, %2;" \ 6159570ffbe31930ab4d678754daaeec0715117a3dsewardj : "=r" (eip), "=r" (esp), "=r" (ebp) \ 6259570ffbe31930ab4d678754daaeec0715117a3dsewardj : /* reads none */ \ 6359570ffbe31930ab4d678754daaeec0715117a3dsewardj : "memory" \ 6459570ffbe31930ab4d678754daaeec0715117a3dsewardj ); \ 6559570ffbe31930ab4d678754daaeec0715117a3dsewardj (srP)->r_pc = (ULong)eip; \ 6659570ffbe31930ab4d678754daaeec0715117a3dsewardj (srP)->r_sp = (ULong)esp; \ 6759570ffbe31930ab4d678754daaeec0715117a3dsewardj (srP)->misc.X86.r_ebp = ebp; \ 6859570ffbe31930ab4d678754daaeec0715117a3dsewardj } 698eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#elif defined(VGP_amd64_linux) || defined(VGP_amd64_darwin) \ 708eb8bab992e3998c33770b0cdb16059a8b918a06sewardj || defined(VGP_amd64_solaris) 7159570ffbe31930ab4d678754daaeec0715117a3dsewardj# define GET_STARTREGS(srP) \ 7259570ffbe31930ab4d678754daaeec0715117a3dsewardj { ULong rip, rsp, rbp; \ 7359570ffbe31930ab4d678754daaeec0715117a3dsewardj __asm__ __volatile__( \ 7459570ffbe31930ab4d678754daaeec0715117a3dsewardj "leaq 0(%%rip), %0;" \ 7559570ffbe31930ab4d678754daaeec0715117a3dsewardj "movq %%rsp, %1;" \ 7659570ffbe31930ab4d678754daaeec0715117a3dsewardj "movq %%rbp, %2;" \ 7759570ffbe31930ab4d678754daaeec0715117a3dsewardj : "=r" (rip), "=r" (rsp), "=r" (rbp) \ 7859570ffbe31930ab4d678754daaeec0715117a3dsewardj : /* reads none */ \ 7959570ffbe31930ab4d678754daaeec0715117a3dsewardj : "memory" \ 8059570ffbe31930ab4d678754daaeec0715117a3dsewardj ); \ 8159570ffbe31930ab4d678754daaeec0715117a3dsewardj (srP)->r_pc = rip; \ 8259570ffbe31930ab4d678754daaeec0715117a3dsewardj (srP)->r_sp = rsp; \ 8359570ffbe31930ab4d678754daaeec0715117a3dsewardj (srP)->misc.AMD64.r_rbp = rbp; \ 8459570ffbe31930ab4d678754daaeec0715117a3dsewardj } 856e9de463ef677f093e9f24f126e1b11c28cf59fdsewardj#elif defined(VGP_ppc32_linux) 8659570ffbe31930ab4d678754daaeec0715117a3dsewardj# define GET_STARTREGS(srP) \ 8759570ffbe31930ab4d678754daaeec0715117a3dsewardj { UInt cia, r1, lr; \ 8859570ffbe31930ab4d678754daaeec0715117a3dsewardj __asm__ __volatile__( \ 8959570ffbe31930ab4d678754daaeec0715117a3dsewardj "mflr 0;" /* r0 = lr */ \ 907f3c1f251860f760950fcbd5c8da91ed4ed35f52florian "bl 0f;" /* lr = pc */ \ 917f3c1f251860f760950fcbd5c8da91ed4ed35f52florian "0:\n" \ 9259570ffbe31930ab4d678754daaeec0715117a3dsewardj "mflr %0;" /* %0 = pc */ \ 9359570ffbe31930ab4d678754daaeec0715117a3dsewardj "mtlr 0;" /* restore lr */ \ 9459570ffbe31930ab4d678754daaeec0715117a3dsewardj "mr %1,1;" /* %1 = r1 */ \ 9559570ffbe31930ab4d678754daaeec0715117a3dsewardj "mr %2,0;" /* %2 = lr */ \ 9659570ffbe31930ab4d678754daaeec0715117a3dsewardj : "=r" (cia), "=r" (r1), "=r" (lr) \ 9759570ffbe31930ab4d678754daaeec0715117a3dsewardj : /* reads none */ \ 9859570ffbe31930ab4d678754daaeec0715117a3dsewardj : "r0" /* trashed */ \ 9959570ffbe31930ab4d678754daaeec0715117a3dsewardj ); \ 100f5f1e12bd89408917c1ffeb22ec23a1fd11b7a23sewardj (srP)->r_pc = (ULong)cia; \ 101f5f1e12bd89408917c1ffeb22ec23a1fd11b7a23sewardj (srP)->r_sp = (ULong)r1; \ 102f5f1e12bd89408917c1ffeb22ec23a1fd11b7a23sewardj (srP)->misc.PPC32.r_lr = lr; \ 10359570ffbe31930ab4d678754daaeec0715117a3dsewardj } 104cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) 10559570ffbe31930ab4d678754daaeec0715117a3dsewardj# define GET_STARTREGS(srP) \ 10659570ffbe31930ab4d678754daaeec0715117a3dsewardj { ULong cia, r1, lr; \ 10759570ffbe31930ab4d678754daaeec0715117a3dsewardj __asm__ __volatile__( \ 10859570ffbe31930ab4d678754daaeec0715117a3dsewardj "mflr 0;" /* r0 = lr */ \ 1097f3c1f251860f760950fcbd5c8da91ed4ed35f52florian "bl 0f;" /* lr = pc */ \ 1107f3c1f251860f760950fcbd5c8da91ed4ed35f52florian "0:\n" \ 11159570ffbe31930ab4d678754daaeec0715117a3dsewardj "mflr %0;" /* %0 = pc */ \ 11259570ffbe31930ab4d678754daaeec0715117a3dsewardj "mtlr 0;" /* restore lr */ \ 11359570ffbe31930ab4d678754daaeec0715117a3dsewardj "mr %1,1;" /* %1 = r1 */ \ 11459570ffbe31930ab4d678754daaeec0715117a3dsewardj "mr %2,0;" /* %2 = lr */ \ 11559570ffbe31930ab4d678754daaeec0715117a3dsewardj : "=r" (cia), "=r" (r1), "=r" (lr) \ 11659570ffbe31930ab4d678754daaeec0715117a3dsewardj : /* reads none */ \ 11759570ffbe31930ab4d678754daaeec0715117a3dsewardj : "r0" /* trashed */ \ 11859570ffbe31930ab4d678754daaeec0715117a3dsewardj ); \ 119f5f1e12bd89408917c1ffeb22ec23a1fd11b7a23sewardj (srP)->r_pc = cia; \ 120f5f1e12bd89408917c1ffeb22ec23a1fd11b7a23sewardj (srP)->r_sp = r1; \ 121f5f1e12bd89408917c1ffeb22ec23a1fd11b7a23sewardj (srP)->misc.PPC64.r_lr = lr; \ 12259570ffbe31930ab4d678754daaeec0715117a3dsewardj } 12359570ffbe31930ab4d678754daaeec0715117a3dsewardj#elif defined(VGP_arm_linux) 12459570ffbe31930ab4d678754daaeec0715117a3dsewardj# define GET_STARTREGS(srP) \ 125fa5ce5616a17e79828fbc79f30b02b5085151e3csewardj { UInt block[6]; \ 12659570ffbe31930ab4d678754daaeec0715117a3dsewardj __asm__ __volatile__( \ 12759570ffbe31930ab4d678754daaeec0715117a3dsewardj "str r15, [%0, #+0];" \ 12859570ffbe31930ab4d678754daaeec0715117a3dsewardj "str r14, [%0, #+4];" \ 12959570ffbe31930ab4d678754daaeec0715117a3dsewardj "str r13, [%0, #+8];" \ 13059570ffbe31930ab4d678754daaeec0715117a3dsewardj "str r12, [%0, #+12];" \ 13159570ffbe31930ab4d678754daaeec0715117a3dsewardj "str r11, [%0, #+16];" \ 132fa5ce5616a17e79828fbc79f30b02b5085151e3csewardj "str r7, [%0, #+20];" \ 13359570ffbe31930ab4d678754daaeec0715117a3dsewardj : /* out */ \ 13459570ffbe31930ab4d678754daaeec0715117a3dsewardj : /* in */ "r"(&block[0]) \ 13559570ffbe31930ab4d678754daaeec0715117a3dsewardj : /* trash */ "memory" \ 13659570ffbe31930ab4d678754daaeec0715117a3dsewardj ); \ 13759570ffbe31930ab4d678754daaeec0715117a3dsewardj (srP)->r_pc = block[0] - 8; \ 138d474ab25fa26da6adf1f1fd4199379887eb377f6sewardj (srP)->misc.ARM.r14 = block[1]; \ 139d474ab25fa26da6adf1f1fd4199379887eb377f6sewardj (srP)->r_sp = block[2]; \ 14059570ffbe31930ab4d678754daaeec0715117a3dsewardj (srP)->misc.ARM.r12 = block[3]; \ 14159570ffbe31930ab4d678754daaeec0715117a3dsewardj (srP)->misc.ARM.r11 = block[4]; \ 142fa5ce5616a17e79828fbc79f30b02b5085151e3csewardj (srP)->misc.ARM.r7 = block[5]; \ 14359570ffbe31930ab4d678754daaeec0715117a3dsewardj } 144f0c1250e324f6684757c6a15545366447ef1d64fsewardj#elif defined(VGP_arm64_linux) 145f0c1250e324f6684757c6a15545366447ef1d64fsewardj# define GET_STARTREGS(srP) \ 146f0c1250e324f6684757c6a15545366447ef1d64fsewardj { ULong block[4]; \ 147f0c1250e324f6684757c6a15545366447ef1d64fsewardj __asm__ __volatile__( \ 148f0c1250e324f6684757c6a15545366447ef1d64fsewardj "adr x19, 0;" \ 149f0c1250e324f6684757c6a15545366447ef1d64fsewardj "str x19, [%0, #+0];" /* pc */ \ 150f0c1250e324f6684757c6a15545366447ef1d64fsewardj "mov x19, sp;" \ 151f0c1250e324f6684757c6a15545366447ef1d64fsewardj "str x19, [%0, #+8];" /* sp */ \ 152f0c1250e324f6684757c6a15545366447ef1d64fsewardj "str x29, [%0, #+16];" /* fp */ \ 153f0c1250e324f6684757c6a15545366447ef1d64fsewardj "str x30, [%0, #+24];" /* lr */ \ 154f0c1250e324f6684757c6a15545366447ef1d64fsewardj : /* out */ \ 155f0c1250e324f6684757c6a15545366447ef1d64fsewardj : /* in */ "r"(&block[0]) \ 156f0c1250e324f6684757c6a15545366447ef1d64fsewardj : /* trash */ "memory","x19" \ 157f0c1250e324f6684757c6a15545366447ef1d64fsewardj ); \ 158f0c1250e324f6684757c6a15545366447ef1d64fsewardj (srP)->r_pc = block[0]; \ 159f0c1250e324f6684757c6a15545366447ef1d64fsewardj (srP)->r_sp = block[1]; \ 160f0c1250e324f6684757c6a15545366447ef1d64fsewardj (srP)->misc.ARM64.x29 = block[2]; \ 161f0c1250e324f6684757c6a15545366447ef1d64fsewardj (srP)->misc.ARM64.x30 = block[3]; \ 162f0c1250e324f6684757c6a15545366447ef1d64fsewardj } 163b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#elif defined(VGP_s390x_linux) 164b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj# define GET_STARTREGS(srP) \ 165b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj { ULong ia, sp, fp, lr; \ 166b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj __asm__ __volatile__( \ 167b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj "bras %0,0f;" \ 168b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj "0: lgr %1,15;" \ 169b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj "lgr %2,11;" \ 170b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj "lgr %3,14;" \ 171b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj : "=r" (ia), "=r" (sp),"=r" (fp),"=r" (lr) \ 172b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj /* no read & clobber */ \ 173b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj ); \ 174b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj (srP)->r_pc = ia; \ 175b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj (srP)->r_sp = sp; \ 176b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj (srP)->misc.S390X.r_fp = fp; \ 177b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj (srP)->misc.S390X.r_lr = lr; \ 178b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj } 1795db15403e889d4db339b342bc2a824ef0bfaa654sewardj#elif defined(VGP_mips32_linux) 1805db15403e889d4db339b342bc2a824ef0bfaa654sewardj# define GET_STARTREGS(srP) \ 1815db15403e889d4db339b342bc2a824ef0bfaa654sewardj { UInt pc, sp, fp, ra, gp; \ 1825db15403e889d4db339b342bc2a824ef0bfaa654sewardj asm("move $8, $31;" /* t0 = ra */ \ 1837f3c1f251860f760950fcbd5c8da91ed4ed35f52florian "bal 0f;" /* ra = pc */ \ 1847f3c1f251860f760950fcbd5c8da91ed4ed35f52florian "0:\n" \ 1855db15403e889d4db339b342bc2a824ef0bfaa654sewardj "move %0, $31;" \ 1865db15403e889d4db339b342bc2a824ef0bfaa654sewardj "move $31, $8;" /* restore lr */ \ 1875db15403e889d4db339b342bc2a824ef0bfaa654sewardj "move %1, $29;" \ 1885db15403e889d4db339b342bc2a824ef0bfaa654sewardj "move %2, $30;" \ 1895db15403e889d4db339b342bc2a824ef0bfaa654sewardj "move %3, $31;" \ 1905db15403e889d4db339b342bc2a824ef0bfaa654sewardj "move %4, $28;" \ 1915db15403e889d4db339b342bc2a824ef0bfaa654sewardj : "=r" (pc), \ 1925db15403e889d4db339b342bc2a824ef0bfaa654sewardj "=r" (sp), \ 1935db15403e889d4db339b342bc2a824ef0bfaa654sewardj "=r" (fp), \ 1945db15403e889d4db339b342bc2a824ef0bfaa654sewardj "=r" (ra), \ 1955db15403e889d4db339b342bc2a824ef0bfaa654sewardj "=r" (gp) \ 1965db15403e889d4db339b342bc2a824ef0bfaa654sewardj : /* reads none */ \ 1975db15403e889d4db339b342bc2a824ef0bfaa654sewardj : "$8" /* trashed */ ); \ 1985db15403e889d4db339b342bc2a824ef0bfaa654sewardj (srP)->r_pc = (ULong)pc - 8; \ 1995db15403e889d4db339b342bc2a824ef0bfaa654sewardj (srP)->r_sp = (ULong)sp; \ 2005db15403e889d4db339b342bc2a824ef0bfaa654sewardj (srP)->misc.MIPS32.r30 = (ULong)fp; \ 2015db15403e889d4db339b342bc2a824ef0bfaa654sewardj (srP)->misc.MIPS32.r31 = (ULong)ra; \ 2025db15403e889d4db339b342bc2a824ef0bfaa654sewardj (srP)->misc.MIPS32.r28 = (ULong)gp; \ 2035db15403e889d4db339b342bc2a824ef0bfaa654sewardj } 2044df0bfc0614379192c780c944415dc420d9cfe8epetarj#elif defined(VGP_mips64_linux) 2054df0bfc0614379192c780c944415dc420d9cfe8epetarj# define GET_STARTREGS(srP) \ 2067f3c1f251860f760950fcbd5c8da91ed4ed35f52florian { ULong pc, sp, fp, ra, gp; \ 2074df0bfc0614379192c780c944415dc420d9cfe8epetarj asm("move $8, $31;" /* t0 = ra */ \ 2087f3c1f251860f760950fcbd5c8da91ed4ed35f52florian "bal 0f;" /* ra = pc */ \ 2097f3c1f251860f760950fcbd5c8da91ed4ed35f52florian "0:\n" \ 2104df0bfc0614379192c780c944415dc420d9cfe8epetarj "move %0, $31;" \ 2114df0bfc0614379192c780c944415dc420d9cfe8epetarj "move $31, $8;" /* restore lr */ \ 2124df0bfc0614379192c780c944415dc420d9cfe8epetarj "move %1, $29;" \ 2134df0bfc0614379192c780c944415dc420d9cfe8epetarj "move %2, $30;" \ 2144df0bfc0614379192c780c944415dc420d9cfe8epetarj "move %3, $31;" \ 2154df0bfc0614379192c780c944415dc420d9cfe8epetarj "move %4, $28;" \ 2164df0bfc0614379192c780c944415dc420d9cfe8epetarj : "=r" (pc), \ 2174df0bfc0614379192c780c944415dc420d9cfe8epetarj "=r" (sp), \ 2184df0bfc0614379192c780c944415dc420d9cfe8epetarj "=r" (fp), \ 2194df0bfc0614379192c780c944415dc420d9cfe8epetarj "=r" (ra), \ 2204df0bfc0614379192c780c944415dc420d9cfe8epetarj "=r" (gp) \ 2214df0bfc0614379192c780c944415dc420d9cfe8epetarj : /* reads none */ \ 2224df0bfc0614379192c780c944415dc420d9cfe8epetarj : "$8" /* trashed */ ); \ 2234df0bfc0614379192c780c944415dc420d9cfe8epetarj (srP)->r_pc = (ULong)pc - 8; \ 2244df0bfc0614379192c780c944415dc420d9cfe8epetarj (srP)->r_sp = (ULong)sp; \ 2254df0bfc0614379192c780c944415dc420d9cfe8epetarj (srP)->misc.MIPS64.r30 = (ULong)fp; \ 2264df0bfc0614379192c780c944415dc420d9cfe8epetarj (srP)->misc.MIPS64.r31 = (ULong)ra; \ 2274df0bfc0614379192c780c944415dc420d9cfe8epetarj (srP)->misc.MIPS64.r28 = (ULong)gp; \ 2284df0bfc0614379192c780c944415dc420d9cfe8epetarj } 229112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#elif defined(VGP_tilegx_linux) 230112711afefcfcd43680c7c4aa8d38ef180e8811esewardj# define GET_STARTREGS(srP) \ 23162cee7a76f79da8ffd0c3d018e18699147391249zliu { ULong pc, sp, fp, ra; \ 232112711afefcfcd43680c7c4aa8d38ef180e8811esewardj __asm__ __volatile__( \ 233112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "move r8, lr \n" \ 234112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "jal 0f \n" \ 235112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "0:\n" \ 236112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "move %0, lr \n" \ 237112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "move lr, r8 \n" /* put old lr back*/ \ 238112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "move %1, sp \n" \ 239112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "move %2, r52 \n" \ 240112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "move %3, lr \n" \ 241112711afefcfcd43680c7c4aa8d38ef180e8811esewardj : "=r" (pc), \ 242112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "=r" (sp), \ 243112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "=r" (fp), \ 244112711afefcfcd43680c7c4aa8d38ef180e8811esewardj "=r" (ra) \ 245112711afefcfcd43680c7c4aa8d38ef180e8811esewardj : /* reads none */ \ 246112711afefcfcd43680c7c4aa8d38ef180e8811esewardj : "%r8" /* trashed */ ); \ 247112711afefcfcd43680c7c4aa8d38ef180e8811esewardj (srP)->r_pc = (ULong)pc - 8; \ 248112711afefcfcd43680c7c4aa8d38ef180e8811esewardj (srP)->r_sp = (ULong)sp; \ 249112711afefcfcd43680c7c4aa8d38ef180e8811esewardj (srP)->misc.TILEGX.r52 = (ULong)fp; \ 250112711afefcfcd43680c7c4aa8d38ef180e8811esewardj (srP)->misc.TILEGX.r55 = (ULong)ra; \ 251112711afefcfcd43680c7c4aa8d38ef180e8811esewardj } 2529450d245afa7cd6e49f2734c2a621047df0d01ecnjn#else 2539450d245afa7cd6e49f2734c2a621047df0d01ecnjn# error Unknown platform 2549450d245afa7cd6e49f2734c2a621047df0d01ecnjn#endif 2559450d245afa7cd6e49f2734c2a621047df0d01ecnjn 2569450d245afa7cd6e49f2734c2a621047df0d01ecnjn#define BACKTRACE_DEPTH 100 // nice and deep! 2573161e808ce76595c60447d041715a3ece1f9665dnjn 258180a7500bf2464d5b16cddb5618b91fb3f095998philippe__attribute__ ((__noreturn__)) 259180a7500bf2464d5b16cddb5618b91fb3f095998philippestatic void exit_wrk( Int status, Bool gdbserver_call_allowed) 260f39e9a36dca9642668a66c6b054f81c88650bcb9njn{ 261180a7500bf2464d5b16cddb5618b91fb3f095998philippe static Bool exit_called = False; 262180a7500bf2464d5b16cddb5618b91fb3f095998philippe // avoid recursive exit during gdbserver call. 263180a7500bf2464d5b16cddb5618b91fb3f095998philippe 264180a7500bf2464d5b16cddb5618b91fb3f095998philippe if (gdbserver_call_allowed && !exit_called) { 265180a7500bf2464d5b16cddb5618b91fb3f095998philippe const ThreadId atid = 1; // Arbitrary tid used to call/terminate gdbsrv. 266180a7500bf2464d5b16cddb5618b91fb3f095998philippe exit_called = True; 267180a7500bf2464d5b16cddb5618b91fb3f095998philippe if (status != 0 && VG_(gdbserver_stop_at) (VgdbStopAt_ValgrindAbExit)) { 268180a7500bf2464d5b16cddb5618b91fb3f095998philippe if (VG_(gdbserver_init_done)()) { 269180a7500bf2464d5b16cddb5618b91fb3f095998philippe VG_(umsg)("(action at valgrind abnormal exit) vgdb me ... \n"); 270180a7500bf2464d5b16cddb5618b91fb3f095998philippe VG_(gdbserver) (atid); 271180a7500bf2464d5b16cddb5618b91fb3f095998philippe } else { 272180a7500bf2464d5b16cddb5618b91fb3f095998philippe VG_(umsg)("(action at valgrind abnormal exit) " 273180a7500bf2464d5b16cddb5618b91fb3f095998philippe "Early valgrind exit : vgdb not yet usable\n"); 274180a7500bf2464d5b16cddb5618b91fb3f095998philippe } 275180a7500bf2464d5b16cddb5618b91fb3f095998philippe } 276180a7500bf2464d5b16cddb5618b91fb3f095998philippe if (VG_(gdbserver_init_done)()) { 277180a7500bf2464d5b16cddb5618b91fb3f095998philippe // Always terminate the gdbserver when Valgrind exits, so as 278180a7500bf2464d5b16cddb5618b91fb3f095998philippe // to e.g. cleanup the FIFOs. 279180a7500bf2464d5b16cddb5618b91fb3f095998philippe VG_(gdbserver_exit) (atid, 280180a7500bf2464d5b16cddb5618b91fb3f095998philippe status == 0 ? VgSrc_ExitProcess : VgSrc_FatalSig); 281180a7500bf2464d5b16cddb5618b91fb3f095998philippe } 282180a7500bf2464d5b16cddb5618b91fb3f095998philippe } 283180a7500bf2464d5b16cddb5618b91fb3f095998philippe exit_called = True; 284180a7500bf2464d5b16cddb5618b91fb3f095998philippe 285421c26e30de64ccf441ec398c1f8beda7afbb47cflorian VG_(exit_now) (status); 286421c26e30de64ccf441ec398c1f8beda7afbb47cflorian} 287421c26e30de64ccf441ec398c1f8beda7afbb47cflorian 288421c26e30de64ccf441ec398c1f8beda7afbb47cflorian/* Call the appropriate system call and nothing else. This function should 289421c26e30de64ccf441ec398c1f8beda7afbb47cflorian be called in places where the dependencies of VG_(exit) need to be 290421c26e30de64ccf441ec398c1f8beda7afbb47cflorian avoided. */ 291421c26e30de64ccf441ec398c1f8beda7afbb47cflorian__attribute__ ((__noreturn__)) 292421c26e30de64ccf441ec398c1f8beda7afbb47cflorianvoid VG_(exit_now)( Int status ) 293421c26e30de64ccf441ec398c1f8beda7afbb47cflorian{ 2945b6b8faafbfa52635d444dd58b107d3a4081c86cnjn#if defined(VGO_linux) 295f39e9a36dca9642668a66c6b054f81c88650bcb9njn (void)VG_(do_syscall1)(__NR_exit_group, status ); 2968eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#elif defined(VGO_darwin) || defined(VGO_solaris) 297f39e9a36dca9642668a66c6b054f81c88650bcb9njn (void)VG_(do_syscall1)(__NR_exit, status ); 2985b6b8faafbfa52635d444dd58b107d3a4081c86cnjn#else 2995b6b8faafbfa52635d444dd58b107d3a4081c86cnjn# error Unknown OS 3005b6b8faafbfa52635d444dd58b107d3a4081c86cnjn#endif 301f39e9a36dca9642668a66c6b054f81c88650bcb9njn /*NOTREACHED*/ 3024eeb0e50fd10c08a396c6d3c53f296287a47d9c3njn // We really shouldn't reach here. Just in case we do, use some very crude 3034eeb0e50fd10c08a396c6d3c53f296287a47d9c3njn // methods to force abort 3044eeb0e50fd10c08a396c6d3c53f296287a47d9c3njn __builtin_trap(); 3054eeb0e50fd10c08a396c6d3c53f296287a47d9c3njn *(volatile Int*)0 = 'x'; 306f39e9a36dca9642668a66c6b054f81c88650bcb9njn} 307f39e9a36dca9642668a66c6b054f81c88650bcb9njn 308180a7500bf2464d5b16cddb5618b91fb3f095998philippe/* Pull down the entire world */ 309180a7500bf2464d5b16cddb5618b91fb3f095998philippevoid VG_(exit)( Int status ) 310180a7500bf2464d5b16cddb5618b91fb3f095998philippe{ 311180a7500bf2464d5b16cddb5618b91fb3f095998philippe exit_wrk (status, True); 312180a7500bf2464d5b16cddb5618b91fb3f095998philippe} 313180a7500bf2464d5b16cddb5618b91fb3f095998philippe 314180a7500bf2464d5b16cddb5618b91fb3f095998philippe/* Pull down the entire world */ 315180a7500bf2464d5b16cddb5618b91fb3f095998philippevoid VG_(client_exit)( Int status ) 316180a7500bf2464d5b16cddb5618b91fb3f095998philippe{ 317180a7500bf2464d5b16cddb5618b91fb3f095998philippe exit_wrk (status, False); 318180a7500bf2464d5b16cddb5618b91fb3f095998philippe} 319180a7500bf2464d5b16cddb5618b91fb3f095998philippe 320180a7500bf2464d5b16cddb5618b91fb3f095998philippe 321c7561b931e249acf3768ead77638545b0ccaa8f1njn// Print the scheduler status. 3224f6f336badda2171d6e842cca3de63b53f4c9f0bphilippestatic void show_sched_status_wrk ( Bool host_stacktrace, 32338a74d2cc4670e3eb559adff51a376cd6ec98005philippe Bool stack_usage, 3244f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe Bool exited_threads, 325518850bf0da07ed3e2244e307268ae0fd80e93a8florian const UnwindStartRegs* startRegsIN) 32649b45ba90382fd313e40555559f5f5aaa23033b4njn{ 32749b45ba90382fd313e40555559f5f5aaa23033b4njn Int i; 3284f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe if (host_stacktrace) { 3294f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe const Bool save_clo_xml = VG_(clo_xml); 3304f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe Addr stacktop; 3314f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe Addr ips[BACKTRACE_DEPTH]; 3324f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe Int n_ips; 3334f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe ThreadState *tst 3344f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe = VG_(get_ThreadState)( VG_(lwpid_to_vgtid)( VG_(gettid)() ) ); 3354f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe 3364f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe // If necessary, fake up an ExeContext which is of our actual real CPU 3374f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe // state. Could cause problems if we got the panic/exception within the 3384f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe // execontext/stack dump/symtab code. But it's better than nothing. 3394f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe UnwindStartRegs startRegs; 3404f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe VG_(memset)(&startRegs, 0, sizeof(startRegs)); 3414f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe 3424f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe if (startRegsIN == NULL) { 3434f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe GET_STARTREGS(&startRegs); 3444f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe } else { 3454f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe startRegs = *startRegsIN; 3464f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe } 3474f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe 3484f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe stacktop = tst->os_state.valgrind_stack_init_SP; 3494f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe 3504f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe n_ips = 3514f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe VG_(get_StackTrace_wrk)( 3524f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe 0/*tid is unknown*/, 3534f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe ips, BACKTRACE_DEPTH, 3544f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe NULL/*array to dump SP values in*/, 3554f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe NULL/*array to dump FP values in*/, 3564f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe &startRegs, stacktop 3574f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe ); 3584f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe VG_(printf)("\nhost stacktrace:\n"); 3594f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe VG_(clo_xml) = False; 3604f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe VG_(pp_StackTrace) (ips, n_ips); 3614f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe VG_(clo_xml) = save_clo_xml; 3624f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe } 3634f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe 36449b45ba90382fd313e40555559f5f5aaa23033b4njn VG_(printf)("\nsched status:\n"); 365a5e06c36bf9d93461bc8c4351e960888020ea1c4florian VG_(printf)(" running_tid=%u\n", VG_(get_running_tid)()); 36649b45ba90382fd313e40555559f5f5aaa23033b4njn for (i = 1; i < VG_N_THREADS; i++) { 3674f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe VgStack* stack 3684f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe = (VgStack*)VG_(threads)[i].os_state.valgrind_stack_base; 3694f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe /* If a thread slot was never used (yet), valgrind_stack_base is 0. 3704f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe If a thread slot is used by a thread or was used by a thread which 3714f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe has exited, then valgrind_stack_base points to the stack base. */ 3724f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe if (VG_(threads)[i].status == VgTs_Empty 3734f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe && (!exited_threads || stack == 0)) continue; 374026fe8634d7a56b101bb8e43a6666b2f0d00d38dphilippe VG_(printf)("\nThread %d: status = %s (lwpid %d)\n", i, 375026fe8634d7a56b101bb8e43a6666b2f0d00d38dphilippe VG_(name_of_ThreadStatus)(VG_(threads)[i].status), 376026fe8634d7a56b101bb8e43a6666b2f0d00d38dphilippe VG_(threads)[i].os_state.lwpid); 3774f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe if (VG_(threads)[i].status != VgTs_Empty) 3784f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe VG_(get_and_pp_StackTrace)( i, BACKTRACE_DEPTH ); 37938a74d2cc4670e3eb559adff51a376cd6ec98005philippe if (stack_usage && VG_(threads)[i].client_stack_highest_byte != 0 ) { 38038a74d2cc4670e3eb559adff51a376cd6ec98005philippe Addr start, end; 38138a74d2cc4670e3eb559adff51a376cd6ec98005philippe 38238a74d2cc4670e3eb559adff51a376cd6ec98005philippe start = end = 0; 38338a74d2cc4670e3eb559adff51a376cd6ec98005philippe VG_(stack_limits)(VG_(threads)[i].client_stack_highest_byte, 38438a74d2cc4670e3eb559adff51a376cd6ec98005philippe &start, &end); 38538a74d2cc4670e3eb559adff51a376cd6ec98005philippe if (start != end) 38638a74d2cc4670e3eb559adff51a376cd6ec98005philippe VG_(printf)("client stack range: [%p %p] client SP: %p\n", 38738a74d2cc4670e3eb559adff51a376cd6ec98005philippe (void*)start, (void*)end, (void*)VG_(get_SP)(i)); 38838a74d2cc4670e3eb559adff51a376cd6ec98005philippe else 38938a74d2cc4670e3eb559adff51a376cd6ec98005philippe VG_(printf)("client stack range: ???????\n"); 39038a74d2cc4670e3eb559adff51a376cd6ec98005philippe } 39138a74d2cc4670e3eb559adff51a376cd6ec98005philippe if (stack_usage && stack != 0) 392a5e06c36bf9d93461bc8c4351e960888020ea1c4florian VG_(printf)("valgrind stack top usage: %lu of %lu\n", 393d0720e4a624bdfe7ce2494d690e7a88f986b93c1philippe VG_(clo_valgrind_stacksize) 394026fe8634d7a56b101bb8e43a6666b2f0d00d38dphilippe - VG_(am_get_VgStack_unused_szB) 395026fe8634d7a56b101bb8e43a6666b2f0d00d38dphilippe (stack, VG_(clo_valgrind_stacksize)), 396d0720e4a624bdfe7ce2494d690e7a88f986b93c1philippe (SizeT) VG_(clo_valgrind_stacksize)); 39749b45ba90382fd313e40555559f5f5aaa23033b4njn } 39849b45ba90382fd313e40555559f5f5aaa23033b4njn VG_(printf)("\n"); 39949b45ba90382fd313e40555559f5f5aaa23033b4njn} 400c7561b931e249acf3768ead77638545b0ccaa8f1njn 4014f6f336badda2171d6e842cca3de63b53f4c9f0bphilippevoid VG_(show_sched_status) ( Bool host_stacktrace, 40238a74d2cc4670e3eb559adff51a376cd6ec98005philippe Bool stack_usage, 4034f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe Bool exited_threads) 4044f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe{ 4054f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe show_sched_status_wrk (host_stacktrace, 40638a74d2cc4670e3eb559adff51a376cd6ec98005philippe stack_usage, 4074f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe exited_threads, 4084f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe NULL); 4094f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe} 4104f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe 411132bfccd21960e462352175f8553a5bdce8a210cnjn__attribute__ ((noreturn)) 412bbd9a21ca8518fc34cd7b6254a61d72f82495120florianstatic void report_and_quit ( const HChar* report, 413518850bf0da07ed3e2244e307268ae0fd80e93a8florian const UnwindStartRegs* startRegsIN ) 414132bfccd21960e462352175f8553a5bdce8a210cnjn{ 4154f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe show_sched_status_wrk (True, // host_stacktrace 41638a74d2cc4670e3eb559adff51a376cd6ec98005philippe False, // stack_usage 4174f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe False, // exited_threads 4184f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe startRegsIN); 419b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn VG_(printf)( 420b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "\n" 421b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "Note: see also the FAQ in the source distribution.\n" 422b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "It contains workarounds to several common problems.\n" 423b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "In particular, if Valgrind aborted or crashed after\n" 424b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "identifying problems in your program, there's a good chance\n" 425b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "that fixing those problems will prevent Valgrind aborting or\n" 426b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "crashing, especially if it happened in m_mallocfree.c.\n" 427b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "\n" 428b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "If that doesn't help, please report this bug to: %s\n\n" 429b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "In the bug report, send all the above text, the valgrind\n" 430b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn "version, and what OS and version you are using. Thanks.\n\n", 431b8329f0ce649067dc5d9d74f8392c6a0ab8d2d40njn report); 432132bfccd21960e462352175f8553a5bdce8a210cnjn VG_(exit)(1); 433132bfccd21960e462352175f8553a5bdce8a210cnjn} 434132bfccd21960e462352175f8553a5bdce8a210cnjn 435bbd9a21ca8518fc34cd7b6254a61d72f82495120florianvoid VG_(assert_fail) ( Bool isCore, const HChar* expr, const HChar* file, 436bbd9a21ca8518fc34cd7b6254a61d72f82495120florian Int line, const HChar* fn, const HChar* format, ... ) 437132bfccd21960e462352175f8553a5bdce8a210cnjn{ 43874054f4eac95d1ff81274b9d08be662494210134florian va_list vargs, vargs_copy; 439bbd9a21ca8518fc34cd7b6254a61d72f82495120florian const HChar* component; 440bbd9a21ca8518fc34cd7b6254a61d72f82495120florian const HChar* bugs_to; 4415869dedfc08dd385b3672b51becbb713f5c8931aflorian UInt written; 442132bfccd21960e462352175f8553a5bdce8a210cnjn 443132bfccd21960e462352175f8553a5bdce8a210cnjn static Bool entered = False; 444132bfccd21960e462352175f8553a5bdce8a210cnjn if (entered) 445745fc459ce4ce9264d8844bf1ab695d235a4ce01sewardj VG_(exit)(2); 446132bfccd21960e462352175f8553a5bdce8a210cnjn entered = True; 447132bfccd21960e462352175f8553a5bdce8a210cnjn 448132bfccd21960e462352175f8553a5bdce8a210cnjn if (isCore) { 449132bfccd21960e462352175f8553a5bdce8a210cnjn component = "valgrind"; 450132bfccd21960e462352175f8553a5bdce8a210cnjn bugs_to = VG_BUGS_TO; 451132bfccd21960e462352175f8553a5bdce8a210cnjn } else { 452132bfccd21960e462352175f8553a5bdce8a210cnjn component = VG_(details).name; 453132bfccd21960e462352175f8553a5bdce8a210cnjn bugs_to = VG_(details).bug_reports_to; 454132bfccd21960e462352175f8553a5bdce8a210cnjn } 455132bfccd21960e462352175f8553a5bdce8a210cnjn 456f349d55d40891b890d0da268cfb9f092af0fc8f4sewardj if (VG_(clo_xml)) 457738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(printf_xml)("</valgrindoutput>\n"); 458f349d55d40891b890d0da268cfb9f092af0fc8f4sewardj 459132bfccd21960e462352175f8553a5bdce8a210cnjn // Treat vg_assert2(0, "foo") specially, as a panicky abort 460132bfccd21960e462352175f8553a5bdce8a210cnjn if (VG_STREQ(expr, "0")) { 461132bfccd21960e462352175f8553a5bdce8a210cnjn VG_(printf)("\n%s: %s:%d (%s): the 'impossible' happened.\n", 4628a7b41b41b46c0aa7bd4b6678b82285437e7f08cnjn component, file, line, fn ); 463132bfccd21960e462352175f8553a5bdce8a210cnjn } else { 464132bfccd21960e462352175f8553a5bdce8a210cnjn VG_(printf)("\n%s: %s:%d (%s): Assertion '%s' failed.\n", 465132bfccd21960e462352175f8553a5bdce8a210cnjn component, file, line, fn, expr ); 466132bfccd21960e462352175f8553a5bdce8a210cnjn } 46774054f4eac95d1ff81274b9d08be662494210134florian 46874054f4eac95d1ff81274b9d08be662494210134florian /* Check whether anything will be written */ 46974054f4eac95d1ff81274b9d08be662494210134florian HChar buf[5]; 47074054f4eac95d1ff81274b9d08be662494210134florian va_start(vargs, format); 47174054f4eac95d1ff81274b9d08be662494210134florian va_copy(vargs_copy, vargs); 47274054f4eac95d1ff81274b9d08be662494210134florian written = VG_(vsnprintf) ( buf, sizeof(buf), format, vargs ); 47374054f4eac95d1ff81274b9d08be662494210134florian va_end(vargs); 47474054f4eac95d1ff81274b9d08be662494210134florian 47574054f4eac95d1ff81274b9d08be662494210134florian if (written > 0) { 47674054f4eac95d1ff81274b9d08be662494210134florian VG_(printf)("%s: ", component); 47774054f4eac95d1ff81274b9d08be662494210134florian VG_(vprintf)(format, vargs_copy); 47874054f4eac95d1ff81274b9d08be662494210134florian VG_(printf)("\n"); 47974054f4eac95d1ff81274b9d08be662494210134florian } 480132bfccd21960e462352175f8553a5bdce8a210cnjn 48159570ffbe31930ab4d678754daaeec0715117a3dsewardj report_and_quit(bugs_to, NULL); 482132bfccd21960e462352175f8553a5bdce8a210cnjn} 483132bfccd21960e462352175f8553a5bdce8a210cnjn 484132bfccd21960e462352175f8553a5bdce8a210cnjn__attribute__ ((noreturn)) 485bbd9a21ca8518fc34cd7b6254a61d72f82495120florianstatic void panic ( const HChar* name, const HChar* report, const HChar* str, 486518850bf0da07ed3e2244e307268ae0fd80e93a8florian const UnwindStartRegs* startRegs ) 487132bfccd21960e462352175f8553a5bdce8a210cnjn{ 488f349d55d40891b890d0da268cfb9f092af0fc8f4sewardj if (VG_(clo_xml)) 489738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(printf_xml)("</valgrindoutput>\n"); 490132bfccd21960e462352175f8553a5bdce8a210cnjn VG_(printf)("\n%s: the 'impossible' happened:\n %s\n", name, str); 49159570ffbe31930ab4d678754daaeec0715117a3dsewardj report_and_quit(report, startRegs); 492132bfccd21960e462352175f8553a5bdce8a210cnjn} 493132bfccd21960e462352175f8553a5bdce8a210cnjn 494518850bf0da07ed3e2244e307268ae0fd80e93a8florianvoid VG_(core_panic_at) ( const HChar* str, const UnwindStartRegs* startRegs ) 495132bfccd21960e462352175f8553a5bdce8a210cnjn{ 49659570ffbe31930ab4d678754daaeec0715117a3dsewardj panic("valgrind", VG_BUGS_TO, str, startRegs); 497132bfccd21960e462352175f8553a5bdce8a210cnjn} 498132bfccd21960e462352175f8553a5bdce8a210cnjn 499bbd9a21ca8518fc34cd7b6254a61d72f82495120florianvoid VG_(core_panic) ( const HChar* str ) 500132bfccd21960e462352175f8553a5bdce8a210cnjn{ 50159570ffbe31930ab4d678754daaeec0715117a3dsewardj VG_(core_panic_at)(str, NULL); 502132bfccd21960e462352175f8553a5bdce8a210cnjn} 503132bfccd21960e462352175f8553a5bdce8a210cnjn 504bbd9a21ca8518fc34cd7b6254a61d72f82495120florianvoid VG_(tool_panic) ( const HChar* str ) 505132bfccd21960e462352175f8553a5bdce8a210cnjn{ 50659570ffbe31930ab4d678754daaeec0715117a3dsewardj panic(VG_(details).name, VG_(details).bug_reports_to, str, NULL); 507132bfccd21960e462352175f8553a5bdce8a210cnjn} 508132bfccd21960e462352175f8553a5bdce8a210cnjn 50949b45ba90382fd313e40555559f5f5aaa23033b4njn/* Print some helpful-ish text about unimplemented things, and give up. */ 5108eb8bab992e3998c33770b0cdb16059a8b918a06sewardjvoid VG_(unimplemented) ( const HChar* format, ... ) 511132bfccd21960e462352175f8553a5bdce8a210cnjn{ 5128eb8bab992e3998c33770b0cdb16059a8b918a06sewardj va_list vargs; 5138eb8bab992e3998c33770b0cdb16059a8b918a06sewardj HChar msg[256]; 5148eb8bab992e3998c33770b0cdb16059a8b918a06sewardj 5158eb8bab992e3998c33770b0cdb16059a8b918a06sewardj va_start(vargs, format); 5168eb8bab992e3998c33770b0cdb16059a8b918a06sewardj VG_(vsnprintf)(msg, sizeof(msg), format, vargs); 5178eb8bab992e3998c33770b0cdb16059a8b918a06sewardj va_end(vargs); 5188eb8bab992e3998c33770b0cdb16059a8b918a06sewardj 519f349d55d40891b890d0da268cfb9f092af0fc8f4sewardj if (VG_(clo_xml)) 520738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(printf_xml)("</valgrindoutput>\n"); 521738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)("\n"); 522738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)("Valgrind detected that your program requires\n"); 523738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)("the following unimplemented functionality:\n"); 524738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)(" %s\n", msg); 525738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)("This may be because the functionality is hard to implement,\n"); 526738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)("or because no reasonable program would behave this way,\n"); 527738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)("or because nobody has yet needed it. " 528738856f99eea33d86ce91dcb1d6cd5b151e307casewardj "In any case, let us know at\n"); 529738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)("%s and/or try to work around the problem, if you can.\n", 530738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_BUGS_TO); 531738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)("\n"); 532738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)("Valgrind has to exit now. Sorry. Bye!\n"); 533738856f99eea33d86ce91dcb1d6cd5b151e307casewardj VG_(umsg)("\n"); 5344f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe VG_(show_sched_status)(False, // host_stacktrace 53538a74d2cc4670e3eb559adff51a376cd6ec98005philippe False, // stack_usage 5364f6f336badda2171d6e842cca3de63b53f4c9f0bphilippe False); // exited_threads 537132bfccd21960e462352175f8553a5bdce8a210cnjn VG_(exit)(1); 538132bfccd21960e462352175f8553a5bdce8a210cnjn} 539132bfccd21960e462352175f8553a5bdce8a210cnjn 540132bfccd21960e462352175f8553a5bdce8a210cnjn/*--------------------------------------------------------------------*/ 541132bfccd21960e462352175f8553a5bdce8a210cnjn/*--- end ---*/ 542132bfccd21960e462352175f8553a5bdce8a210cnjn/*--------------------------------------------------------------------*/ 543