1 /* Copyright (C) 2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
30 template <class ITEM
> class Vector
;
31 template <class ITEM
> class DbeArray
;
32 template <typename Key_t
, typename Value_t
> class DefaultMap
;
34 typedef uint64_t ULEB128
;
35 typedef int64_t SLEB128
;
36 typedef unsigned short Dwarf_Half
;
37 typedef unsigned char Dwarf_Small
;
38 typedef uint64_t Dwarf_Off
;
39 typedef uint64_t Dwarf_Addr
;
40 typedef uint64_t Dwarf_Unsigned
;
41 typedef int64_t Dwarf_Die
;
42 typedef int32_t Dwarf_Debug
;
43 typedef int32_t Dwarf_Attribute
;
49 DwrSec (unsigned char *_data
, uint64_t _size
, bool _need_swap_endian
, bool _addr32
);
50 DwrSec (DwrSec
*secp
, uint64_t _offset
);
52 unsigned char Get_8 ();
53 unsigned short Get_16 ();
58 uint64_t GetADDR_32 ();
59 uint64_t GetADDR_64 ();
61 uint64_t ReadLength ();
62 SLEB128
GetSLEB128 ();
63 ULEB128
GetULEB128 ();
64 char *GetString (uint64_t *lenp
);
65 char *GetData (uint64_t len
);
66 void dump (char *msg
);
71 return (uint32_t) GetULEB128 ();
75 inRange (uint64_t left
, uint64_t right
)
77 return (offset
>= left
) && (offset
< right
);
86 bool need_swap_endian
;
91 bool bounds_violation (uint64_t sz
);
97 DwrFileName (char *_fname
);
121 DwrInlinedSubr (int64_t _abstract_origin
, uint64_t _low_pc
, uint64_t _high_pc
,
122 int _file
, int _line
, int _level
);
124 int64_t abstract_origin
;
135 DwrLineRegs (DwrSec
*_secp
, char *dirName
);
137 char *getPath (int fn
);
138 Vector
<DwrLine
*> *get_lines ();
141 Vector
<DwrFileName
*> *file_names
;
144 void DoExtendedOpcode ();
145 void DoStandardOpcode (int opcode
);
146 void DoSpecialOpcode (int opcode
);
159 uint64_t op_index_register
;
160 Dwarf_Small maximum_operations_per_instruction
;
161 Dwarf_Small minimum_instruction_length
;
162 Dwarf_Small default_is_stmt
;
163 Dwarf_Small line_range
;
164 Dwarf_Small opcode_base
;
165 signed char line_base
;
169 Vector
<DwrLine
*> *lines
;
170 Vector
<char *> *include_directories
;
171 Dwarf_Small
*standard_opcode_length
;
172 DwrSec
*debug_lineSec
;
173 uint64_t header_length
;
174 uint64_t opcode_start
;
177 typedef struct Dwr_Attr
182 unsigned char *block
;
186 uint64_t len
; // length of u.str
191 typedef struct Dwr_Tag
194 Dwr_Attr
*get_attr (Dwarf_Half attr
);
197 DbeArray
<Dwr_Attr
> *abbrevAtForm
;
218 typedef struct DwrLocation
226 typedef struct DwrAbbrevTable
246 Function
*fortranMAIN
;
248 DwrInlinedSubr
*inlinedSubr
;
249 DefaultMap
<int64_t, Dwr_type
*> *dwr_types
;
252 Dwr_type
*get_dwr_type (int64_t cu_die_offset
);
253 Dwr_type
*put_dwr_type (int64_t cu_die_offset
, int tag
);
254 Dwr_type
*put_dwr_type (Dwr_Tag
*dwrTag
);
260 DwrCU (Dwarf
*_dwarf
);
262 Module
*parse_cu_header (LoadObject
*lo
);
263 void parseChild (Dwarf_cnt
*ctx
);
264 void read_hwcprof_info (Dwarf_cnt
*ctx
);
265 void map_dwarf_lines (Module
*mod
);
266 int set_die (Dwarf_Die die
);
267 DwrLineRegs
*get_dwrLineReg ();
269 static char *at2str (int tag
);
270 static char *form2str (int tag
);
271 static char *tag2str (int tag
);
273 uint64_t cu_header_offset
;
275 uint64_t next_cu_offset
;
276 Vector
<DwrInlinedSubr
*> *dwrInlinedSubrs
;
277 Vector
<SourceFile
*> *srcFiles
;
282 void build_abbrevTable (DwrSec
*debug_abbrevSec
, uint64_t stmt_list_offset
);
283 Function
*append_Function (Dwarf_cnt
*ctx
);
284 void parse_inlined_subroutine (Dwarf_cnt
*ctx
);
285 uint64_t get_low_pc ();
286 uint64_t get_high_pc (uint64_t low_pc
);
287 DwrLocation
*dwr_get_location (DwrSec
*secp
, DwrLocation
*lp
);
288 int read_data_attr (Dwarf_Half attr
, int64_t *retVal
);
289 int read_ref_attr (Dwarf_Half attr
, int64_t *retVal
);
290 char *get_linkage_name ();
291 char *Dwarf_string (Dwarf_Half attr
);
292 int64_t Dwarf_data (Dwarf_Half attr
);
293 int64_t Dwarf_ref (Dwarf_Half attr
);
294 DwrSec
*Dwarf_block (Dwarf_Half attr
);
295 Dwarf_Addr
Dwarf_addr (Dwarf_Half attr
);
296 Dwarf_Addr
Dwarf_location (Dwarf_Attribute attr
);
297 Sp_lang_code
Dwarf_lang ();
300 DwrSec
*debug_infoSec
;
301 uint64_t debug_abbrev_offset
;
302 uint64_t stmt_list_offset
; // offset in .debug_line section (DW_AT_stmt_list)
303 char *comp_dir
; // compilation directory (DW_AT_comp_dir)
306 Dwarf_Small address_size
;
308 DwrLineRegs
*dwrLineReg
;
309 DbeArray
<DwrAbbrevTable
> *abbrevTable
;
310 DbeArray
<Dwr_Attr
> *abbrevAtForm
;
313 #endif /* _DWARFLIB_H_ */