1 /* 2 * %CopyrightBegin% 3 * 4 * Copyright Ericsson AB 2004-2012. All Rights Reserved. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 * %CopyrightEnd% 19 */ 20 #ifndef _ERL_DEBUG_H_ 21 #define _ERL_DEBUG_H_ 22 #ifdef DEBUG 23 24 #include "erl_term.h" 25 26 /* Heap areas will be filled with this value when they are deallocated 27 * after a garbage collection. This value used to be 0xff, but that is 28 * an immediate and might not crash the system if it is encountered. 29 * The value is now 0x01, the cons of death. 30 */ 31 #define DEBUG_BAD_BYTE 0x01 32 #define DEBUG_BAD_WORD 0x01010101 33 34 /* 35 * VERBOSE. Use the -v option to enable the different categories. 36 */ 37 #define VERBOSE(flag, format) (flag & verbose ? erts_printf format : 0) 38 39 #define DEBUG_DEFAULT 0x0000 /* No flags are set per default */ 40 #define DEBUG_SYSTEM 0x0001 /* Misc system info at startup and end */ 41 #define DEBUG_PRIVATE_GC 0x0002 /* GC of private heaps */ 42 #define DEBUG_ALLOCATION 0x0004 /* HAlloc. To find holes in the heap */ 43 #define DEBUG_MESSAGES 0x0008 /* Message passing */ 44 #define DEBUG_THREADS 0x0010 /* Thread-related stuff */ 45 #define DEBUG_PROCESSES 0x0020 /* Process creation and removal */ 46 #define DEBUG_MEMORY 0x0040 /* Display results of memory checks */ 47 #define DEBUG_SHCOPY 0x0080 /* Sharing-preserving copying of terms */ 48 49 extern Uint32 verbose; 50 51 void upp(byte*, size_t); 52 void pat(Eterm); 53 void pinfo(void); 54 void pp(Process*); 55 void ppi(Eterm); 56 void pba(Process*, int); 57 void td(Eterm); 58 void ps(Process*, Eterm*); 59 60 #undef ERTS_OFFHEAP_DEBUG 61 #define ERTS_OFFHEAP_DEBUG 62 63 #else /* Non-debug mode */ 64 65 #define VERBOSE(flag,format) 66 67 #endif /* DEBUG */ 68 69 #ifdef ERTS_OFFHEAP_DEBUG 70 #define ERTS_CHK_OFFHEAP(P) erts_check_off_heap((P)) 71 #define ERTS_CHK_OFFHEAP2(P, HT) erts_check_off_heap2((P), (HT)) 72 void erts_check_off_heap(Process *); 73 void erts_check_off_heap2(Process *, Eterm *); 74 #else 75 #define ERTS_CHK_OFFHEAP(P) 76 #define ERTS_CHK_OFFHEAP2(P, HT) 77 #endif 78 79 /* 80 * These functions can be handy when developing, and perhaps useful 81 * even outside debugging. 82 */ 83 extern void erts_check_off_heap(Process *p); 84 extern void erts_check_stack(Process *p); 85 extern void erts_check_heap(Process *p); 86 extern void erts_check_memory(Process *p, Eterm *start, Eterm *end); 87 extern void verify_process(Process *p); 88 extern void print_tagged_memory(Eterm *start, Eterm *end); 89 extern void print_untagged_memory(Eterm *start, Eterm *end); 90 extern void print_memory(Process *p); 91 extern void print_memory_info(Process *p); 92 #endif /* _ERL_DEBUG_H_ */ 93