]> git.sur5r.net Git - cc65/blob - src/dbginfo/dbginfo.h
First working version with complete API for line information.
[cc65] / src / dbginfo / dbginfo.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 dbginfo.h                                 */
4 /*                                                                           */
5 /*                         cc65 debug info handling                          */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2010,      Ullrich von Bassewitz                                      */
10 /*                Roemerstrasse 52                                           */
11 /*                D-70794 Filderstadt                                        */
12 /* EMail:         uz@cc65.org                                                */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef DBGINFO_H
37 #define DBGINFO_H
38
39
40
41 /*****************************************************************************/
42 /*                                   Data                                    */
43 /*****************************************************************************/
44
45
46
47 /* Data types used for addresses and line numbers. Change to "unsigned long"
48  * if you ever want to run the code on a 16-bit machine.
49  */
50 typedef unsigned cc65_line;             /* Used to store line numbers */
51 typedef unsigned cc65_addr;             /* Use to store (65xx) addresses */
52
53 /* Pointer to an opaque data structure containing information from the debug
54  * info file. Actually a handle to the data in the file.
55  */
56 typedef void* cc65_dbginfo;
57
58 /* ### Parseerror */
59 typedef enum cc65_error_severity cc65_error_severity;
60 enum cc65_error_severity {
61     CC65_WARNING,
62     CC65_ERROR,
63 };
64
65 /* Warnings/errors in cc65_read_dbginfo are passed via this struct */
66 typedef struct cc65_parseerror cc65_parseerror;
67 struct cc65_parseerror {
68     cc65_error_severity type;           /* Type of error */
69     const char*         name;           /* Name of input file */
70     cc65_line           line;           /* Error line */
71     unsigned            column;         /* Error column */
72     char                errormsg[1];    /* Error message */
73 };
74
75 /* Function that is called in case of parse errors */
76 typedef void (*cc65_errorfunc) (const struct cc65_parseerror*);
77
78 /* Line information */
79 typedef struct cc65_lineinfo cc65_lineinfo;
80 struct cc65_lineinfo {
81     unsigned            count;          /* Count of data sets that follow */
82     struct {
83         const char*     name;           /* Name of the file */
84         unsigned long   size;           /* Size of file */
85         unsigned long   mtime;          /* Modification time */
86         cc65_line       line;           /* Line number */
87         cc65_addr       start;          /* Start address for this line */
88         cc65_addr       end;            /* End address for this line */
89     }                   data[1];
90 };
91
92
93
94 /*****************************************************************************/
95 /*                                   Code                                    */
96 /*****************************************************************************/
97
98
99
100 cc65_dbginfo cc65_read_dbginfo (const char* filename, cc65_errorfunc errorfunc);
101 /* Parse the debug info file with the given name. On success, the function
102  * will return a pointer to an opaque cc65_dbginfo structure, that must be
103  * passed to the other functions in this module to retrieve information.
104  * errorfunc is called in case of warnings and errors. If the file cannot be
105  * read successfully, NULL is returned.
106  */
107
108 void cc65_free_dbginfo (cc65_dbginfo Handle);
109 /* Free debug information read from a file */
110
111 cc65_lineinfo* cc65_get_lineinfo (cc65_dbginfo handle, unsigned long addr);
112 /* Return line information for the given address. The function returns NULL
113  * if no line information was found.
114  */
115
116 void cc65_free_lineinfo (cc65_dbginfo handle, cc65_lineinfo* info);
117 /* Free line info returned by cc65_get_lineinfo() */
118
119
120
121 /* End of dbginfo.h */
122
123 #endif
124
125
126
127