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;
59 typedef enum cc65_error_severity cc65_error_severity;
60 enum cc65_error_severity {
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 */
75 /* Function that is called in case of parse errors */
76 typedef void (*cc65_errorfunc) (const struct cc65_parseerror*);
78 /* Line information */
79 typedef struct cc65_lineinfo cc65_lineinfo;
80 struct cc65_lineinfo {
81 unsigned count; /* Count of data sets that follow */
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 */
94 /*****************************************************************************/
96 /*****************************************************************************/
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.
108 void cc65_free_dbginfo (cc65_dbginfo Handle);
109 /* Free debug information read from a file */
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.
116 void cc65_free_lineinfo (cc65_dbginfo handle, cc65_lineinfo* info);
117 /* Free line info returned by cc65_get_lineinfo() */
121 /* End of dbginfo.h */