3 symopen, symclose, findhdr, indexsym, lookupsym, findsym,
4 findexsym, flookupsym, ffindsym,
5 lookuplsym, indexlsym, findlsym,
6 symoff, pc2file, file2pc, line2pc, fnbound, fileline,
7 pc2line \- symbol table access functions
15 .ta \w'\fBxxxxxxxx'u +\w'\fBxxxxxx'u
17 int symopen(Fhdr *hdr)
19 void symclose(Fhdr *hdr)
21 Fhdr *findhdr(char *name)
23 extern Fhdr* fhdrlist;
26 int indexsym(uint n, Symbol *s)
28 int lookupsym(char *fn, char *var, Symbol *s)
30 int findsym(Loc loc, uint class, Symbol *s)
33 int findexsym(Fhdr *hdr, uint n, Symbol *s)
35 Symbol *flookupsym(Fhdr *hdr, char *name)
37 Symbol *ffindsym(Fhdr *hdr, Loc loc, uint class)
40 int indexlsym(Symbol *s1, uint n, Symbol *s2)
42 int lookuplsym(Symbol *s1, char *name, Symbol *s2)
44 int findlsym(Symbol *s1, Loc loc, Symbol *s2)
47 int symoff(char *a, uint n, ulong addr, uint class)
50 int pc2file(ulong pc, char *file, uint n, ulong *line)
52 int pc2line(ulong pc, ulong *line)
54 int fileline(ulong pc, char *buf, uint n)
56 int file2pc(char *file, ulong line, ulong *pc)
58 int line2pc(ulong basepc, ulong line, ulong *pc)
60 int fnbound(ulong pc, ulong bounds[2])
62 These functions provide machine-independent access to the
63 symbol table of an executable file or executing process.
68 describe additional library functions for
69 accessing executable files and executing processes.
78 to initialize in-memory structures used to access the symbol
79 tables contained in the file.
82 The rest of the functions described here access a composite
83 symbol table made up of all currently open tables.
85 The set of all currently open
87 is maintained as a linked list starting at
93 searches the currently open
95 for one whose file name ends with the path
111 typedef struct Symbol Symbol;
124 describes a symbol table entry.
127 field contains the offset of the symbol within its
128 address space: global variables relative to the beginning
129 of the data segment, text beyond the start of the text
130 segment, and automatic variables and parameters relative
131 to the stack frame. The
133 field contains the type of the symbol:
140 static text segment symbol
146 static data segment symbol
152 static bss segment symbol
155 automatic (local) variable symbol
158 function parameter symbol
167 field assigns the symbol to a general class;
173 are the most popular.
176 stores information for the
180 The symbols are ordered by increasing address.
185 structure with symbol table information. Global variables
186 and functions are represented by a single name; local variables
187 and parameters are uniquely specified by a function and
188 variable name pair. Arguments
193 name of a function and variable, respectively.
195 are non-zero, the symbol table is searched for a parameter
196 or automatic variable. If only
199 zero, the text symbol table is searched for function
203 is zero, the global variable table
208 returns the symbol table entry of type
212 The selected symbol is a global variable or function with
213 address nearest to and less than or equal to
217 searches only the global variable symbol table; class
219 limits the search to the text symbol table.
222 searches the text table first, then the global table.
233 but operate only on the symbols from
238 return pointers to data stored in the
240 which must not be modified or freed.
251 but operate on the smaller symbol table of parameters and
252 variables local to the function represented by symbol
256 writes symbol information for the
258 local symbol of function
262 Function parameters appear first in the ordering, followed by local symbols.
265 writes symbol information for the symbol named
273 searches for a symbol local to the function
275 whose location is exactly
277 writing its symbol information to
280 is almost always an indirection through a frame pointer register;
281 the details vary from architecture to architecture.
284 converts a location to a symbol reference.
285 The string containing that reference is of the form
286 `name+offset', where `name' is the name of the
287 nearest symbol with an address less than or equal to the
288 target address, and `offset' is the hexadecimal offset beyond
289 that symbol. If `offset' is zero, only the name of the
291 If no symbol is found within 4096 bytes of the address, the address
292 is formatted as a hexadecimal address.
294 is the address of a buffer of
296 bytes to receive the formatted string.
298 is the address to be converted.
300 is the type code of the search space:
306 returns the length of the formatted string contained in
310 searches the symbol table to find the file and line number
311 corresponding to the instruction at program counter
314 is the address of a buffer of
316 bytes to receive the file name.
318 receives the line number.
323 but neglects to return information about the source file.
328 but returns the file and line number in the
336 performs the opposite mapping:
339 a text address associated with
346 is similar: it converts a line number to an
347 instruction address, storing it in
349 Since a line number does not uniquely identify an
350 instruction (e.g., every source file has line 1),
352 specifies a text address from which
354 Usually this is the address of the first function in the
358 returns the start and end addresses of the function containing
359 the text address supplied as the first argument.
360 The second argument is an array of two unsigned longs;
362 places the bounding addresses of the function in the
363 first and second elements of this array.
364 The start address is the address of the first instruction of the function;
365 the end address is the first address beyond the end of the target function.
367 All functions return 0 on success and \-1 on error.
368 When an error occurs, a message describing it is stored
369 in the system error buffer where it is available via
372 .B /usr/local/plan9/src/libmach