1 /*****************************************************************************/
5 /* cc65 debug info handling */
9 /* (C) 2010, Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
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. */
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: */
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 */
32 /*****************************************************************************/
41 /*****************************************************************************/
43 /*****************************************************************************/
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.
50 typedef unsigned cc65_line; /* Used to store line numbers */
51 typedef unsigned cc65_addr; /* Use to store (65xx) addresses */
53 /* Pointer to an opaque data structure containing information from the debug
54 * info file. Actually a handle to the data in the file.
56 typedef void* cc65_dbginfo;
58 /* Severity for cc65_parseerror */
62 } cc65_error_severity;
64 /* Warnings/errors in cc65_read_dbginfo are passed via this struct */
65 typedef struct cc65_parseerror cc65_parseerror;
66 struct cc65_parseerror {
67 cc65_error_severity type; /* Type of error */
68 const char* name; /* Name of input file */
69 cc65_line line; /* Error line */
70 unsigned column; /* Error column */
71 char errormsg[1]; /* Error message */
74 /* Function that is called in case of parse errors */
75 typedef void (*cc65_errorfunc) (const struct cc65_parseerror*);
77 /* Line information */
78 typedef struct cc65_lineinfo cc65_lineinfo;
79 struct cc65_lineinfo {
80 unsigned count; /* Number of data sets that follow */
82 const char* name; /* Name of the file */
83 unsigned long size; /* Size of file */
84 unsigned long mtime; /* Modification time */
85 cc65_line line; /* Line number */
86 cc65_addr start; /* Start address for this line */
87 cc65_addr end; /* End address for this line */
91 /* A list of files with some information */
92 typedef struct cc65_filelist cc65_filelist;
93 struct cc65_filelist {
94 unsigned count; /* Number of data sets that follow */
96 const char* name; /* Name of the file */
97 unsigned long size; /* Size of file */
98 unsigned long mtime; /* Modification time */
104 /* A list of segments with some information */
105 typedef struct cc65_segmentlist cc65_segmentlist;
106 struct cc65_segmentlist {
107 unsigned count; /* Number of data sets that follow */
109 const char* name; /* Name of the file */
110 cc65_addr start; /* Start address of segment */
111 cc65_addr end; /* End address of segment */
117 /*****************************************************************************/
119 /*****************************************************************************/
123 cc65_dbginfo cc65_read_dbginfo (const char* filename, cc65_errorfunc errorfunc);
124 /* Parse the debug info file with the given name. On success, the function
125 * will return a pointer to an opaque cc65_dbginfo structure, that must be
126 * passed to the other functions in this module to retrieve information.
127 * errorfunc is called in case of warnings and errors. If the file cannot be
128 * read successfully, NULL is returned.
131 void cc65_free_dbginfo (cc65_dbginfo Handle);
132 /* Free debug information read from a file */
134 cc65_lineinfo* cc65_lineinfo_byaddr (cc65_dbginfo handle, unsigned long addr);
135 /* Return line information for the given address. The function returns NULL
136 * if no line information was found.
139 cc65_lineinfo* cc65_lineinfo_byname (cc65_dbginfo handle, const char* filename,
141 /* Return line information for a file/line number combination. The function
142 * returns NULL if no line information was found.
145 void cc65_free_lineinfo (cc65_dbginfo handle, cc65_lineinfo* info);
146 /* Free line info returned by one of the other functions */
148 cc65_filelist* cc65_get_filelist (cc65_dbginfo handle);
149 /* Return a list of all files referenced in the debug information */
151 void cc65_free_filelist (cc65_dbginfo handle, cc65_filelist* list);
152 /* free a file list returned by cc65_get_filelist() */
154 cc65_segmentlist* cc65_get_segmentlist (cc65_dbginfo handle);
155 /* Return a list of all segments referenced in the debug information */
157 void cc65_free_segmentlist (cc65_dbginfo handle, cc65_segmentlist* list);
158 /* Free a file list returned by cc65_get_filelist() */
162 /* End of dbginfo.h */