/
symtab.h
172 lines (139 loc) · 5.34 KB
/
symtab.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at
* http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at src/CDDL.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
* Copyright (c) 2004-2005 PathScale, Inc. All rights reserved.
* Use is subject to license terms.
file: symtab.h
created on: Fri Aug 13 11:02:33 PDT 2004
author: David Allison <dallison@pathscale.com>
*/
#ifndef symtab_h_included
#define symtab_h_included
#include "dbg_dwarf.h"
#include "dwf_info.h"
#include "file_info.h"
#include "pstream.h"
#include "gen_loc.h"
// imported classes
class Process ;
class Frame ;
class Architecture ;
class EvalContext ;
//
// alias object (holds aliases of symbol names)
//
struct cstring_less {
bool operator() (const char *s1, const char *s2) {
return strcmp (s1,s2) < 0 ;
}
} ;
class AliasManager {
public:
AliasManager() ;
~AliasManager() ;
void lock() ;
void unlock() ;
void add_alias (const char *name, const char *alias) ;
const char *find_alias(const char *alias) ;
void list_aliases() ;
void complete (std::string name, std::vector<std::string> &result) ;
private:
//typedef __gnu_cxx::hash_map<const char *, const char *, cstring_equal_to> AliasMap ;
typedef std::map<const char *, const char *, cstring_less> AliasMap ;
AliasMap aliases ;
} ;
class SymbolTable ;
class Symbol {
public:
Symbol(std::string name, DIE * die) ;
~Symbol() ;
std::string name ;
DIE * die ;
} ;
// the symbol table provides a number of indexes to allow quick searches
// of the data.
// XXX: describe the indexes here
class SymbolTable: public DwInfo {
public:
SymbolTable(Architecture *arch, ELF * elf, std::istream & stream, AliasManager *aliases, PStream *os = NULL, bool reporterror = false) ;
~SymbolTable() ;
Location find_address (Address addr, bool guess) ;
LineInfo * get_line_info (Address address) ;
void list_functions (EvalContext &context) ;
void list_variables (EvalContext &context) ;
void list_source_files (PStream &os, uint width) ;
void delete_temp_dies() ;
void keep_temp_dies (std::vector<DIE*> &buffer) ;
void keep_temp_die (DIE *die) ;
DIE * new_int() ;
DIE * new_boolean() ;
DIE * new_scalar_type (std::string name, int encoding, int size = 0) ;
DIE * new_pointer_type (DIE * to) ;
DIE * new_const_type (DIE * to) ;
DIE * new_volatile_type (DIE * to) ;
DIE * new_array_type (DIE * to) ;
DIE * new_subrange_type (int lb, int ub) ;
DIE * new_subrange_type () ;
DIE * new_string_type (int len) ;
DIE * new_subroutine_type () ;
DIE * new_formal_parameter (DIE *type) ;
DIE * find_symbol (std::string name, bool search_alias=true) ;
DIE * find_scope (std::string name) ;
DIE * find_struct (std::string name) ;
Address skip_preamble (Address addr) ;
bool at_first_line (FunctionLocation *func, Address addr) ;
bool is_at_function_start (Address addr) ; // is the address at the start of a function?
bool find_function (std::string name, int offset, std::string &filename, int &lineno) ; // find filename:lineno for function+offset
Address find_line (std::string filename, int line) ;
std::string find_alias (std::string name) ;
void enumerate_functions (std::string name, std::vector<std::string> &result) ;
DwCUnit *find_compilation_unit (std::string name) ;
void complete_function (std::string name, std::vector<std::string> &result) ;
Architecture *arch ;
File *find_file (std::string name) ;
protected:
private:
void read(PStream *os, bool reporterror) ;
void wait() ; // wait for symbol table to become ready
FunctionLocation * find_function_by_address (Address addr) ;
typedef std::map<std::string, Symbol *> SymbolMap ;
typedef std::vector<LineInfo*> LineInfoVec ;
// for looking up file:line we need a mapping of filename vs array of lines, sorted by linenum
typedef std::map<std::string, LineInfoVec*> FileMap ;
SymbolMap functions ;
SymbolMap variables ;
SymbolMap structs ;
FileMap files ;
LineInfoVec lineaddresses ; // vector of LineInfo, sorted on address
Map_Range<Address,FunctionLocation*> funcmap;
std::vector<Address> function_start_addresses ; // add function start addresses
DwCUnit * debugger_cu ;
AliasManager *aliases ;
void do_cxx_alias();
void do_f90_alias();
void register_subprogram (std::string name, DIE *die) ;
void register_symbol (std::string name, DIE *die) ;
void register_struct (std::string name, DIE *die) ;
typedef std::multimap<std::string, const char*> BaseMap ;
BaseMap cpp_basenames ;
public:
//DirectoryTable &dirlist ;
} ;
extern std::string demangle(const std::string &func);
#endif