xref: /illumos-gate/usr/src/lib/libdwarf/common/pro_line.h (revision ddb365bfc9e868ad24ccdcb0dc91af18b10df082)
1 /*
2 
3   Copyright (C) 2000,2004 Silicon Graphics, Inc.  All Rights Reserved.
4   Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved.
5   Portions Copyright 2017  David Anderson  All rights reserved.
6 
7   This program is free software; you can redistribute it
8   and/or modify it under the terms of version 2.1 of the
9   GNU Lesser General Public License as published by the Free
10   Software Foundation.
11 
12   This program is distributed in the hope that it would be
13   useful, but WITHOUT ANY WARRANTY; without even the implied
14   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15   PURPOSE.
16 
17   Further, this software is distributed without any warranty
18   that it is free of the rightful claim of any third person
19   regarding infringement or the like.  Any license provided
20   herein, whether implied or otherwise, applies only to this
21   software file.  Patent licenses, if any, provided herein
22   do not apply to combinations of this program with other
23   software, or any other product whatsoever.
24 
25   You should have received a copy of the GNU Lesser General
26   Public License along with this program; if not, write the
27   Free Software Foundation, Inc., 51 Franklin Street - Fifth
28   Floor, Boston MA 02110-1301, USA.
29 
30 */
31 
32 
33 #define DW_LINE_VERSION2   2
34 #define DW_LINE_VERSION3   3
35 #define DW_LINE_VERSION4   4
36 
37 #if defined(__i386) || defined(__x86_64)
38 #define MIN_INST_LENGTH			1
39 #elif defined(__s390__) || defined(__s390x__)
40 /*  Correct value unknown.  This is temporary
41     as we need a better way to set this (in
42     dwarfgen). This at least works for dwarfgen testing
43     at this point, avoids an error. */
44 #define MIN_INST_LENGTH			1
45 #else
46 /*  1 is not necessarily the most efficient (space-wise) for various
47     architectures, but will allow line tables to be generated
48     without error if the input expects the min length to be 1.
49     When using dwarfgen the setting should be that of the
50     output arch, not the host (unless the two essentially match).  */
51 #define MIN_INST_LENGTH			4
52 #endif
53 #define DEFAULT_IS_STMT			false
54 /*  line base and range are temporarily defines.
55     They need to be calculated later. */
56 #define LINE_BASE   -1
57 #define LINE_RANGE   4
58 
59 #define OPCODE_BASE  10 /* DWARF2.  13 in DWARF3, 4, 5  */
60 #define MAX_OPCODE   255
61 
62 
63 
64 /* This struct holds file or include_dir
65    entries for the statement prologue.
66    Defined in pro_line.h */
67 struct Dwarf_P_F_Entry_s {
68     char *dfe_name;
69     Dwarf_P_F_Entry dfe_next;
70 
71     /* DWARF 2,3,4, files only not inc dirs */
72     char *dfe_args;  /* has dir index, time of modification,
73         length in bytes. Encodes as leb128 */
74     int dfe_nbytes; /* number of bytes in args */
75 
76     /*  Dwarf5 Use or not depends on file_name_entry_format
77         actually used.  */
78     unsigned dfe_index;
79     Dwarf_Unsigned dfe_timestamp;
80     unsigned dfe_size;
81     unsigned char dfe_md5[16];
82 
83 };
84 
85 
86 /*
87     Struct holding line number information for each of the producer
88     line entries
89 */
90 struct Dwarf_P_Line_s {
91     /* code address */
92     Dwarf_Addr dpl_address;
93 
94     /* file index, index into file entry */
95     Dwarf_Unsigned dpl_file;
96 
97     /* line number */
98     Dwarf_Unsigned dpl_line;
99 
100     /* column number */
101     Dwarf_Unsigned dpl_column;
102 
103     /* whether its a beginning of a stmt */
104     Dwarf_Ubyte dpl_is_stmt;
105 
106     /* whether its a beginning of basic blk */
107     Dwarf_Ubyte dpl_basic_block;
108 
109     /* used to store opcodes set_address, and end_seq */
110     Dwarf_Ubyte dpl_opc;
111 
112     /*  Used only for relocations.  Has index of symbol relative to
113         which relocation has to be done (the S part in S + A) */
114     Dwarf_Unsigned dpl_r_symidx;
115 
116     Dwarf_P_Line dpl_next;
117 
118     Dwarf_Ubyte    dpl_prologue_end;   /* DWARF3 */
119     Dwarf_Ubyte    dpl_epilogue_begin; /* DWARF3 */
120     Dwarf_Unsigned dpl_isa;            /* DWARF3 */
121     Dwarf_Unsigned dpl_discriminator;  /* DWARF4 */
122 
123 };
124 
125 /*
126     to initialize state machine registers, definition in
127     pro_line.c
128 */
129 void _dwarf_pro_reg_init(Dwarf_P_Debug dbg,Dwarf_P_Line);
130 
131 void _dwarf_init_default_line_header_vals(Dwarf_P_Debug dbg);
132