149d3bc91SRichard Lowe /* 249d3bc91SRichard Lowe 307dc1947SRichard Lowe Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved. 407dc1947SRichard Lowe Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved. 5*4d9fdb46SRobert Mustacchi Portions Copyright 2017 David Anderson All rights reserved. 6*4d9fdb46SRobert Mustacchi 7*4d9fdb46SRobert Mustacchi This program is free software; you can redistribute it 8*4d9fdb46SRobert Mustacchi and/or modify it under the terms of version 2.1 of the 9*4d9fdb46SRobert Mustacchi GNU Lesser General Public License as published by the Free 10*4d9fdb46SRobert Mustacchi Software Foundation. 11*4d9fdb46SRobert Mustacchi 12*4d9fdb46SRobert Mustacchi This program is distributed in the hope that it would be 13*4d9fdb46SRobert Mustacchi useful, but WITHOUT ANY WARRANTY; without even the implied 14*4d9fdb46SRobert Mustacchi warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15*4d9fdb46SRobert Mustacchi PURPOSE. 16*4d9fdb46SRobert Mustacchi 17*4d9fdb46SRobert Mustacchi Further, this software is distributed without any warranty 18*4d9fdb46SRobert Mustacchi that it is free of the rightful claim of any third person 19*4d9fdb46SRobert Mustacchi regarding infringement or the like. Any license provided 20*4d9fdb46SRobert Mustacchi herein, whether implied or otherwise, applies only to this 21*4d9fdb46SRobert Mustacchi software file. Patent licenses, if any, provided herein 22*4d9fdb46SRobert Mustacchi do not apply to combinations of this program with other 23*4d9fdb46SRobert Mustacchi software, or any other product whatsoever. 24*4d9fdb46SRobert Mustacchi 25*4d9fdb46SRobert Mustacchi You should have received a copy of the GNU Lesser General 26*4d9fdb46SRobert Mustacchi Public License along with this program; if not, write the 27*4d9fdb46SRobert Mustacchi Free Software Foundation, Inc., 51 Franklin Street - Fifth 28*4d9fdb46SRobert Mustacchi Floor, Boston MA 02110-1301, USA. 2949d3bc91SRichard Lowe 3049d3bc91SRichard Lowe */ 3149d3bc91SRichard Lowe 3249d3bc91SRichard Lowe 33*4d9fdb46SRobert Mustacchi #define DW_LINE_VERSION2 2 34*4d9fdb46SRobert Mustacchi #define DW_LINE_VERSION3 3 35*4d9fdb46SRobert Mustacchi #define DW_LINE_VERSION4 4 3649d3bc91SRichard Lowe 37*4d9fdb46SRobert Mustacchi #if defined(__i386) || defined(__x86_64) 38*4d9fdb46SRobert Mustacchi #define MIN_INST_LENGTH 1 39*4d9fdb46SRobert Mustacchi #elif defined(__s390__) || defined(__s390x__) 40*4d9fdb46SRobert Mustacchi /* Correct value unknown. This is temporary 41*4d9fdb46SRobert Mustacchi as we need a better way to set this (in 42*4d9fdb46SRobert Mustacchi dwarfgen). This at least works for dwarfgen testing 43*4d9fdb46SRobert Mustacchi at this point, avoids an error. */ 4407dc1947SRichard Lowe #define MIN_INST_LENGTH 1 4507dc1947SRichard Lowe #else 46*4d9fdb46SRobert Mustacchi /* 1 is not necessarily the most efficient (space-wise) for various 47*4d9fdb46SRobert Mustacchi architectures, but will allow line tables to be generated 48*4d9fdb46SRobert Mustacchi without error if the input expects the min length to be 1. 49*4d9fdb46SRobert Mustacchi When using dwarfgen the setting should be that of the 50*4d9fdb46SRobert Mustacchi output arch, not the host (unless the two essentially match). */ 5149d3bc91SRichard Lowe #define MIN_INST_LENGTH 4 5207dc1947SRichard Lowe #endif 5349d3bc91SRichard Lowe #define DEFAULT_IS_STMT false 54*4d9fdb46SRobert Mustacchi /* line base and range are temporarily defines. 55*4d9fdb46SRobert Mustacchi They need to be calculated later. */ 56*4d9fdb46SRobert Mustacchi #define LINE_BASE -1 57*4d9fdb46SRobert Mustacchi #define LINE_RANGE 4 5849d3bc91SRichard Lowe 59*4d9fdb46SRobert Mustacchi #define OPCODE_BASE 10 /* DWARF2. 13 in DWARF3, 4, 5 */ 60*4d9fdb46SRobert Mustacchi #define MAX_OPCODE 255 6149d3bc91SRichard Lowe 6249d3bc91SRichard Lowe 6349d3bc91SRichard Lowe 64*4d9fdb46SRobert Mustacchi /* This struct holds file or include_dir 65*4d9fdb46SRobert Mustacchi entries for the statement prologue. 66*4d9fdb46SRobert Mustacchi Defined in pro_line.h */ 6749d3bc91SRichard Lowe struct Dwarf_P_F_Entry_s { 6849d3bc91SRichard Lowe char *dfe_name; 6949d3bc91SRichard Lowe Dwarf_P_F_Entry dfe_next; 70*4d9fdb46SRobert Mustacchi 71*4d9fdb46SRobert Mustacchi /* DWARF 2,3,4, files only not inc dirs */ 72*4d9fdb46SRobert Mustacchi char *dfe_args; /* has dir index, time of modification, 73*4d9fdb46SRobert Mustacchi length in bytes. Encodes as leb128 */ 74*4d9fdb46SRobert Mustacchi int dfe_nbytes; /* number of bytes in args */ 75*4d9fdb46SRobert Mustacchi 76*4d9fdb46SRobert Mustacchi /* Dwarf5 Use or not depends on file_name_entry_format 77*4d9fdb46SRobert Mustacchi actually used. */ 78*4d9fdb46SRobert Mustacchi unsigned dfe_index; 79*4d9fdb46SRobert Mustacchi Dwarf_Unsigned dfe_timestamp; 80*4d9fdb46SRobert Mustacchi unsigned dfe_size; 81*4d9fdb46SRobert Mustacchi unsigned char dfe_md5[16]; 82*4d9fdb46SRobert Mustacchi 8349d3bc91SRichard Lowe }; 8449d3bc91SRichard Lowe 8549d3bc91SRichard Lowe 8649d3bc91SRichard Lowe /* 87*4d9fdb46SRobert Mustacchi Struct holding line number information for each of the producer 88*4d9fdb46SRobert Mustacchi line entries 8949d3bc91SRichard Lowe */ 9049d3bc91SRichard Lowe struct Dwarf_P_Line_s { 9149d3bc91SRichard Lowe /* code address */ 9249d3bc91SRichard Lowe Dwarf_Addr dpl_address; 9349d3bc91SRichard Lowe 9449d3bc91SRichard Lowe /* file index, index into file entry */ 95*4d9fdb46SRobert Mustacchi Dwarf_Unsigned dpl_file; 9649d3bc91SRichard Lowe 9749d3bc91SRichard Lowe /* line number */ 98*4d9fdb46SRobert Mustacchi Dwarf_Unsigned dpl_line; 9949d3bc91SRichard Lowe 10049d3bc91SRichard Lowe /* column number */ 101*4d9fdb46SRobert Mustacchi Dwarf_Unsigned dpl_column; 10249d3bc91SRichard Lowe 10349d3bc91SRichard Lowe /* whether its a beginning of a stmt */ 10449d3bc91SRichard Lowe Dwarf_Ubyte dpl_is_stmt; 10549d3bc91SRichard Lowe 10649d3bc91SRichard Lowe /* whether its a beginning of basic blk */ 10749d3bc91SRichard Lowe Dwarf_Ubyte dpl_basic_block; 10849d3bc91SRichard Lowe 10949d3bc91SRichard Lowe /* used to store opcodes set_address, and end_seq */ 11049d3bc91SRichard Lowe Dwarf_Ubyte dpl_opc; 11149d3bc91SRichard Lowe 112*4d9fdb46SRobert Mustacchi /* Used only for relocations. Has index of symbol relative to 113*4d9fdb46SRobert Mustacchi which relocation has to be done (the S part in S + A) */ 11449d3bc91SRichard Lowe Dwarf_Unsigned dpl_r_symidx; 11549d3bc91SRichard Lowe 11649d3bc91SRichard Lowe Dwarf_P_Line dpl_next; 117*4d9fdb46SRobert Mustacchi 118*4d9fdb46SRobert Mustacchi Dwarf_Ubyte dpl_prologue_end; /* DWARF3 */ 119*4d9fdb46SRobert Mustacchi Dwarf_Ubyte dpl_epilogue_begin; /* DWARF3 */ 120*4d9fdb46SRobert Mustacchi Dwarf_Unsigned dpl_isa; /* DWARF3 */ 121*4d9fdb46SRobert Mustacchi Dwarf_Unsigned dpl_discriminator; /* DWARF4 */ 122*4d9fdb46SRobert Mustacchi 12349d3bc91SRichard Lowe }; 12449d3bc91SRichard Lowe 125*4d9fdb46SRobert Mustacchi /* 126*4d9fdb46SRobert Mustacchi to initialize state machine registers, definition in 127*4d9fdb46SRobert Mustacchi pro_line.c 12849d3bc91SRichard Lowe */ 129*4d9fdb46SRobert Mustacchi void _dwarf_pro_reg_init(Dwarf_P_Debug dbg,Dwarf_P_Line); 130*4d9fdb46SRobert Mustacchi 131*4d9fdb46SRobert Mustacchi void _dwarf_init_default_line_header_vals(Dwarf_P_Debug dbg); 132