17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 55aefb655Srie * Common Development and Distribution License (the "License"). 65aefb655Srie * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 215aefb655Srie 227c478bd9Sstevel@tonic-gate /* 2320272c2eSAli Bahrami * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _DEBUG_DOT_H 287c478bd9Sstevel@tonic-gate #define _DEBUG_DOT_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <debug.h> 317c478bd9Sstevel@tonic-gate #include <conv.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * Debugging is enabled by various tokens (see debug.c) that result in an 395aefb655Srie * internal bit mask (d_class) being initialized. Each debugging function is 407c478bd9Sstevel@tonic-gate * appropriate for one or more of the classes specified by the bit mask. Each 417c478bd9Sstevel@tonic-gate * debugging function validates whether it is appropriate for the present 427c478bd9Sstevel@tonic-gate * classes before printing anything. 437c478bd9Sstevel@tonic-gate */ 445aefb655Srie #define DBG_NOTCLASS(c) !(dbg_desc->d_class & (c)) 457c478bd9Sstevel@tonic-gate 465aefb655Srie #define DBG_C_ARGS 0x00000001 47e23c41c9SAli Bahrami #define DBG_C_AUDITING 0x00000002 48e23c41c9SAli Bahrami #define DBG_C_BASIC 0x00000004 49e23c41c9SAli Bahrami #define DBG_C_BINDINGS 0x00000008 50e23c41c9SAli Bahrami #define DBG_C_CAP 0x00000010 51e23c41c9SAli Bahrami #define DBG_C_DEMANGLE 0x00000020 52e23c41c9SAli Bahrami #define DBG_C_ENTRY 0x00000040 53e23c41c9SAli Bahrami #define DBG_C_FILES 0x00000080 54e23c41c9SAli Bahrami #define DBG_C_GOT 0x00000100 55e23c41c9SAli Bahrami #define DBG_C_INIT 0x00000200 56e23c41c9SAli Bahrami #define DBG_C_LIBS 0x00000400 57e23c41c9SAli Bahrami #define DBG_C_MAP 0x00000800 58e23c41c9SAli Bahrami #define DBG_C_MOVE 0x00001000 59e23c41c9SAli Bahrami #define DBG_C_RELOC 0x00002000 60e23c41c9SAli Bahrami #define DBG_C_SECTIONS 0x00004000 61e23c41c9SAli Bahrami #define DBG_C_SEGMENTS 0x00008000 62e23c41c9SAli Bahrami #define DBG_C_STATS 0x00010000 63e23c41c9SAli Bahrami #define DBG_C_STRTAB 0x00020000 64e23c41c9SAli Bahrami #define DBG_C_SUPPORT 0x00040000 65e23c41c9SAli Bahrami #define DBG_C_SYMBOLS 0x00080000 66e23c41c9SAli Bahrami #define DBG_C_TLS 0x00100000 675aefb655Srie #define DBG_C_UNUSED 0x00200000 68e23c41c9SAli Bahrami #define DBG_C_VERSIONS 0x00400000 69*98c080d5SRod Evans #define DBG_C_DL 0x00800000 70e23c41c9SAli Bahrami 717c478bd9Sstevel@tonic-gate 725aefb655Srie #define DBG_C_ALL 0xffffffff 737c478bd9Sstevel@tonic-gate 745aefb655Srie typedef struct { 757c478bd9Sstevel@tonic-gate const char *o_name; /* command line argument name */ 765aefb655Srie uint_t o_class; /* associated class for this name */ 775aefb655Srie uint_t o_extra; /* associated extra for this name */ 785aefb655Srie } DBG_options; 797c478bd9Sstevel@tonic-gate 805aefb655Srie #define AL_CNT_DEBUG 4 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* 835aefb655Srie * Some Dbg_*() format strings differ depending on whether they are used for 845aefb655Srie * 32-bit or 64-bit values. 857c478bd9Sstevel@tonic-gate */ 865aefb655Srie #if defined(_ELF64) 875aefb655Srie 885aefb655Srie #define MSG_EDATA_TITLE MSG_EDATA_TITLE_64 895aefb655Srie #define MSG_EDATA_ENTRY MSG_EDATA_ENTRY_64 905aefb655Srie 915aefb655Srie #else 925aefb655Srie 935aefb655Srie #define MSG_EDATA_TITLE MSG_EDATA_TITLE_32 945aefb655Srie #define MSG_EDATA_ENTRY MSG_EDATA_ENTRY_32 955aefb655Srie 967c478bd9Sstevel@tonic-gate #endif 975aefb655Srie 985aefb655Srie /* 995aefb655Srie * Some Elf_*() format strings differ depending on whether they are used for 1005aefb655Srie * 32-bit or 64-bit values. 1015aefb655Srie */ 1025aefb655Srie #if defined(_ELF64) 1035aefb655Srie 104*98c080d5SRod Evans #define MSG_DL_IPHDR_ADDR MSG_DL_IPHDR_ADDR_64 105*98c080d5SRod Evans #define MSG_DL_IPHDR_PHDR MSG_DL_IPHDR_PHDR_64 10620272c2eSAli Bahrami 1075aefb655Srie #define MSG_GOT_TITLE MSG_GOT_TITLE_64 1085aefb655Srie #define MSG_GOT_ENTRY_RE MSG_GOT_ENTRY_RE_64 1095aefb655Srie #define MSG_GOT_ENTRY_NR MSG_GOT_ENTRY_NR_64 110d326b23bSrie #define MSG_GOT_COLUMNS1 MSG_GOT_COLUMNS1_64 111d326b23bSrie #define MSG_GOT_COLUMNS2 MSG_GOT_COLUMNS2_64 112d326b23bSrie #define MSG_GOT_FORMAT1 MSG_GOT_FORMAT1_64 113d326b23bSrie #define MSG_GOT_FORMAT2 MSG_GOT_FORMAT2_64 1145aefb655Srie 1155aefb655Srie #define MSG_PHD_VADDR MSG_PHD_VADDR_64 1165aefb655Srie #define MSG_PHD_PADDR MSG_PHD_PADDR_64 1175aefb655Srie #define MSG_PHD_FILESZ MSG_PHD_FILESZ_64 1185aefb655Srie #define MSG_PHD_OFFSET MSG_PHD_OFFSET_64 1195aefb655Srie 1205aefb655Srie #define MSG_REL_EFSA_TITLE MSG_REL_EFSA_TITLE_64 1215aefb655Srie #define MSG_REL_EFLA_TITLE MSG_REL_EFLA_TITLE_64 1225aefb655Srie #define MSG_REL_EFSN_TITLE MSG_REL_EFSN_TITLE_64 1235aefb655Srie #define MSG_REL_EFLN_TITLE MSG_REL_EFLN_TITLE_64 1245aefb655Srie #define MSG_REL_EFSA_ENTRY MSG_REL_EFSA_ENTRY_64 1255aefb655Srie #define MSG_REL_EFLA_ENTRY MSG_REL_EFLA_ENTRY_64 1265aefb655Srie #define MSG_REL_EFSN_ENTRY MSG_REL_EFSN_ENTRY_64 1275aefb655Srie #define MSG_REL_EFLN_ENTRY MSG_REL_EFLN_ENTRY_64 1285aefb655Srie #define MSG_REL_RT_APLREG MSG_REL_RT_APLREG_64 1295aefb655Srie #define MSG_REL_RT_APLVAL MSG_REL_RT_APLVAL_64 1305aefb655Srie #define MSG_REL_RTA_TITLE MSG_REL_RTA_TITLE_64 1315aefb655Srie #define MSG_REL_RTN_TITLE MSG_REL_RTN_TITLE_64 1325aefb655Srie #define MSG_REL_RTV_TITLE MSG_REL_RTV_TITLE_64 1335aefb655Srie #define MSG_REL_RTA_ENTRY MSG_REL_RTA_ENTRY_64 1345aefb655Srie #define MSG_REL_RTN_ENTRY MSG_REL_RTN_ENTRY_64 1355aefb655Srie #define MSG_REL_LDSA_TITLE MSG_REL_LDSA_TITLE_64 1365aefb655Srie #define MSG_REL_LDSN_TITLE MSG_REL_LDSN_TITLE_64 1375aefb655Srie #define MSG_REL_LDSA_ENTRY MSG_REL_LDSA_ENTRY_64 1385aefb655Srie #define MSG_REL_LDSN_ENTRY MSG_REL_LDSN_ENTRY_64 139635216b6SRod Evans #define MSG_REL_LDSV_TITLE MSG_REL_LDSV_TITLE_64 140635216b6SRod Evans #define MSG_REL_LDSV_ENTRY MSG_REL_LDSV_ENTRY_64 1415aefb655Srie #define MSG_REL_LDLA_TITLE MSG_REL_LDLA_TITLE_64 1425aefb655Srie #define MSG_REL_LDLN_TITLE MSG_REL_LDLN_TITLE_64 1435aefb655Srie #define MSG_REL_LDLA_ENTRY MSG_REL_LDLA_ENTRY_64 1445aefb655Srie #define MSG_REL_LDLN_ENTRY MSG_REL_LDLN_ENTRY_64 145635216b6SRod Evans #define MSG_REL_LDLV_TITLE MSG_REL_LDLV_TITLE_64 146635216b6SRod Evans #define MSG_REL_LDLV_ENTRY MSG_REL_LDLV_ENTRY_64 1475aefb655Srie 1485aefb655Srie #define MSG_SHD_ADDR MSG_SHD_ADDR_64 1495aefb655Srie #define MSG_SHD_SIZE MSG_SHD_SIZE_64 1505aefb655Srie #define MSG_SHD_OFFSET MSG_SHD_OFFSET_64 151d579eb63Sab196087 #define MSG_SHD_OFFSET_ENT MSG_SHD_OFFSET_ENT_64 1525aefb655Srie #define MSG_SHD_ALIGN MSG_SHD_ALIGN_64 1535aefb655Srie #define MSG_SHD_LINK MSG_SHD_LINK_64 1545aefb655Srie 1555aefb655Srie #define MSG_SYM_EFS_ENTRY MSG_SYM_EFS_ENTRY_64 1565aefb655Srie #define MSG_SYM_EFL_ENTRY MSG_SYM_EFL_ENTRY_64 1575aefb655Srie #define MSG_SYM_EFS_TITLE MSG_SYM_EFS_TITLE_64 1585aefb655Srie #define MSG_SYM_EFL_TITLE MSG_SYM_EFL_TITLE_64 1595aefb655Srie #define MSG_SYM_LDS_TITLE MSG_SYM_LDS_TITLE_64 1605aefb655Srie #define MSG_SYM_LDL_TITLE MSG_SYM_LDL_TITLE_64 1615aefb655Srie 1625aefb655Srie #else 1635aefb655Srie 164*98c080d5SRod Evans #define MSG_DL_IPHDR_ADDR MSG_DL_IPHDR_ADDR_32 165*98c080d5SRod Evans #define MSG_DL_IPHDR_PHDR MSG_DL_IPHDR_PHDR_32 16620272c2eSAli Bahrami 1675aefb655Srie #define MSG_GOT_TITLE MSG_GOT_TITLE_32 1685aefb655Srie #define MSG_GOT_ENTRY_RE MSG_GOT_ENTRY_RE_32 1695aefb655Srie #define MSG_GOT_ENTRY_NR MSG_GOT_ENTRY_NR_32 170d326b23bSrie #define MSG_GOT_COLUMNS1 MSG_GOT_COLUMNS1_32 171d326b23bSrie #define MSG_GOT_COLUMNS2 MSG_GOT_COLUMNS2_32 172d326b23bSrie #define MSG_GOT_FORMAT1 MSG_GOT_FORMAT1_32 173d326b23bSrie #define MSG_GOT_FORMAT2 MSG_GOT_FORMAT2_32 1745aefb655Srie 1755aefb655Srie #define MSG_PHD_VADDR MSG_PHD_VADDR_32 1765aefb655Srie #define MSG_PHD_PADDR MSG_PHD_PADDR_32 1775aefb655Srie #define MSG_PHD_FILESZ MSG_PHD_FILESZ_32 1785aefb655Srie #define MSG_PHD_OFFSET MSG_PHD_OFFSET_32 1795aefb655Srie 1805aefb655Srie #define MSG_REL_EFSA_TITLE MSG_REL_EFSA_TITLE_32 1815aefb655Srie #define MSG_REL_EFLA_TITLE MSG_REL_EFLA_TITLE_32 1825aefb655Srie #define MSG_REL_EFSN_TITLE MSG_REL_EFSN_TITLE_32 1835aefb655Srie #define MSG_REL_EFLN_TITLE MSG_REL_EFLN_TITLE_32 1845aefb655Srie #define MSG_REL_EFSA_ENTRY MSG_REL_EFSA_ENTRY_32 1855aefb655Srie #define MSG_REL_EFLA_ENTRY MSG_REL_EFLA_ENTRY_32 1865aefb655Srie #define MSG_REL_EFSN_ENTRY MSG_REL_EFSN_ENTRY_32 1875aefb655Srie #define MSG_REL_EFLN_ENTRY MSG_REL_EFLN_ENTRY_32 1885aefb655Srie #define MSG_REL_RT_APLREG MSG_REL_RT_APLREG_32 1895aefb655Srie #define MSG_REL_RT_APLVAL MSG_REL_RT_APLVAL_32 1905aefb655Srie #define MSG_REL_RTA_TITLE MSG_REL_RTA_TITLE_32 1915aefb655Srie #define MSG_REL_RTN_TITLE MSG_REL_RTN_TITLE_32 1925aefb655Srie #define MSG_REL_RTV_TITLE MSG_REL_RTV_TITLE_32 1935aefb655Srie #define MSG_REL_RTA_ENTRY MSG_REL_RTA_ENTRY_32 1945aefb655Srie #define MSG_REL_RTN_ENTRY MSG_REL_RTN_ENTRY_32 1955aefb655Srie #define MSG_REL_LDSA_TITLE MSG_REL_LDSA_TITLE_32 1965aefb655Srie #define MSG_REL_LDSN_TITLE MSG_REL_LDSN_TITLE_32 1975aefb655Srie #define MSG_REL_LDSA_ENTRY MSG_REL_LDSA_ENTRY_32 1985aefb655Srie #define MSG_REL_LDSN_ENTRY MSG_REL_LDSN_ENTRY_32 199635216b6SRod Evans #define MSG_REL_LDSV_TITLE MSG_REL_LDSV_TITLE_32 200635216b6SRod Evans #define MSG_REL_LDSV_ENTRY MSG_REL_LDSV_ENTRY_32 2015aefb655Srie #define MSG_REL_LDLA_TITLE MSG_REL_LDLA_TITLE_32 2025aefb655Srie #define MSG_REL_LDLN_TITLE MSG_REL_LDLN_TITLE_32 2035aefb655Srie #define MSG_REL_LDLA_ENTRY MSG_REL_LDLA_ENTRY_32 2045aefb655Srie #define MSG_REL_LDLN_ENTRY MSG_REL_LDLN_ENTRY_32 205635216b6SRod Evans #define MSG_REL_LDLV_TITLE MSG_REL_LDLV_TITLE_32 206635216b6SRod Evans #define MSG_REL_LDLV_ENTRY MSG_REL_LDLV_ENTRY_32 2075aefb655Srie 2085aefb655Srie #define MSG_SHD_ADDR MSG_SHD_ADDR_32 2095aefb655Srie #define MSG_SHD_SIZE MSG_SHD_SIZE_32 2105aefb655Srie #define MSG_SHD_OFFSET MSG_SHD_OFFSET_32 211d579eb63Sab196087 #define MSG_SHD_OFFSET_ENT MSG_SHD_OFFSET_ENT_32 2125aefb655Srie #define MSG_SHD_ALIGN MSG_SHD_ALIGN_32 2135aefb655Srie #define MSG_SHD_LINK MSG_SHD_LINK_32 2145aefb655Srie 2155aefb655Srie #define MSG_SYM_EFS_ENTRY MSG_SYM_EFS_ENTRY_32 2165aefb655Srie #define MSG_SYM_EFL_ENTRY MSG_SYM_EFL_ENTRY_32 2175aefb655Srie #define MSG_SYM_EFS_TITLE MSG_SYM_EFS_TITLE_32 2185aefb655Srie #define MSG_SYM_EFL_TITLE MSG_SYM_EFL_TITLE_32 2195aefb655Srie #define MSG_SYM_LDS_TITLE MSG_SYM_LDS_TITLE_32 2205aefb655Srie #define MSG_SYM_LDL_TITLE MSG_SYM_LDL_TITLE_32 2215aefb655Srie 2225aefb655Srie #endif 2235aefb655Srie 2245aefb655Srie #define INDEX_STR_SIZE 10 2257c478bd9Sstevel@tonic-gate 226e23c41c9SAli Bahrami /* 227e23c41c9SAli Bahrami * Buffer used by dbg_isec_name() to format input section 228e23c41c9SAli Bahrami * names. The size was selected to satisfy two opposing 229e23c41c9SAli Bahrami * constraints: 230e23c41c9SAli Bahrami * - To be large enough to handle the largest C++ mangled name. 231e23c41c9SAli Bahrami * Although we can malloc buffers, we don't want that to happen. 232e23c41c9SAli Bahrami * - To be small enough on the thread stack to not cause problems. 233e23c41c9SAli Bahrami */ 234e23c41c9SAli Bahrami typedef char dbg_isec_name_buf_t[INDEX_STR_SIZE + 2048]; 235e23c41c9SAli Bahrami 236e23c41c9SAli Bahrami #if defined(_ELF64) 237e23c41c9SAli Bahrami #define dbg_fmt_isec_name dbg64_fmt_isec_name 238e23c41c9SAli Bahrami #define dbg_fmt_isec_name2 dbg64_fmt_isec_name2 239e23c41c9SAli Bahrami #else 240e23c41c9SAli Bahrami #define dbg_fmt_isec_name dbg32_fmt_isec_name 241e23c41c9SAli Bahrami #define dbg_fmt_isec_name2 dbg32_fmt_isec_name2 242e23c41c9SAli Bahrami #endif 243e23c41c9SAli Bahrami extern const char *dbg_fmt_isec_name(Is_desc *, dbg_isec_name_buf_t, 244e23c41c9SAli Bahrami char **); 245e23c41c9SAli Bahrami extern const char *dbg_fmt_isec_name2(const char *, Word, 246e23c41c9SAli Bahrami dbg_isec_name_buf_t, char **); 247e23c41c9SAli Bahrami 2487c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2497c478bd9Sstevel@tonic-gate } 2507c478bd9Sstevel@tonic-gate #endif 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate #endif /* _DEBUG_DOT_H */ 253