]> git.saurik.com Git - apple/ld64.git/blame - src/ld/debugline.h
ld64-97.14.tar.gz
[apple/ld64.git] / src / ld / debugline.h
CommitLineData
d696c285
A
1/*
2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23#include <stdint.h>
24#include <stddef.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/* Information about a line.
31 DIRECTORY is to be ignored if FILENAME is absolute.
32 PC will be relative to the file the debug_line section is in. */
33struct line_info
34{
35 uint64_t file;
36 int64_t line;
37 uint64_t col;
38 uint64_t pc;
39 int end_of_sequence;
40};
41
42/* Opaque status structure for the line readers. */
43struct line_reader_data;
44
45/* Create a line_reader_data, given address and size of the debug_line section.
46 SIZE may be (size_t)-1 if unknown, although this suppresses checking
47 for an incorrectly large size in the debug_line section.
48 LITTLE_ENDIAN is set if the debug_line section is for a little-endian
49 machine.
50 Returns NULL on error. */
51struct line_reader_data * line_open (const uint8_t * debug_line,
52 size_t debug_line_size,
53 int little_endian);
54
55/* The STOP parameter to line_next is one of line_stop_{file,line,col},
56 perhaps ORed with line_stop_pc; or line_stop_atend, or line_stop_always. */
57enum line_stop_constants {
58 line_stop_atend = 0, /* Stop only at the end of a sequence. */
59 line_stop_file = 1, /* Stop if DIRECTORY or FILENAME change. */
60 line_stop_line = 2, /* Stop if LINE, DIRECTORY, or FILENAME change. */
61 line_stop_col = 3, /* Stop if COL, LINE, DIRECTORY, or FILENAME change. */
62 line_stop_pos_mask = 3,
63 line_stop_pc = 4, /* Stop if PC changes. */
64 line_stop_always = 8 /* Stop always. */
65};
66
67/* Either return FALSE on an error, in which case the line_reader_data
68 may be invalid and should be passed immediately to line_free; or
69 fill RESULT with the first 'interesting' line, as determined by STOP.
70 The last line data in a sequence is always considered 'interesting'. */
71int line_next (struct line_reader_data * lnd,
72 struct line_info * result,
73 enum line_stop_constants stop);
74
75/* Find the region (START->pc through END->pc) in the debug_line
76 information which contains PC. This routine starts searching at
77 the current position (which is returned as END), and will go all
78 the way around the debug_line information. It will return false if
79 an error occurs or if there is no matching region; these may be
80 distinguished by looking at START->end_of_sequence, which will be
81 false on error and true if there was no matching region.
82 You could write this routine using line_next, but this version
83 will be slightly more efficient, and of course more convenient. */
84
85int line_find_addr (struct line_reader_data * lnd,
86 struct line_info * start,
87 struct line_info * end,
88 uint64_t pc);
89
90/* Return TRUE if there is more line data to be fetched.
91 If line_next has not been called or it has been called but did not
92 set END_OF_SEQUENCE, you can assume there is more line data,
93 but it's safe to call this routine anyway. */
94int line_at_eof (struct line_reader_data * lnd);
95
96/* Return the pathname of the file in S, or NULL on error.
97 The result will have been allocated with malloc. */
98char * line_file (struct line_reader_data *lnd, uint64_t file);
99
100/* Reset the line_reader_data: go back to the beginning. */
101void line_reset (struct line_reader_data * lnd);
102
103/* Free a line_reader_data structure. */
104void line_free (struct line_reader_data * lnd);
105
106#ifdef __cplusplus
107}
108#endif
109