mirror of
https://github.com/cc65/cc65.git
synced 2025-08-08 06:25:17 +00:00
Many changes. Map spans instead of line infos into the address space. Quite
some API changes. The test program is almost useless and has to be replaced. git-svn-id: svn://svn.cc65.org/cc65/trunk@5177 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -64,8 +64,8 @@ typedef unsigned cc65_size; /* Used to store (65xx) sizes */
|
|||||||
/* A structure that is used to store a list of ids */
|
/* A structure that is used to store a list of ids */
|
||||||
typedef struct cc65_idlist cc65_idlist;
|
typedef struct cc65_idlist cc65_idlist;
|
||||||
struct cc65_idlist {
|
struct cc65_idlist {
|
||||||
unsigned count; /* Number of elements */
|
unsigned count; /* Number of elements */
|
||||||
unsigned ids[1]; /* List of ids, number is dynamic */
|
unsigned* ids; /* List of ids, number is dynamic */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ typedef void (*cc65_errorfunc) (const struct cc65_parseerror*);
|
|||||||
/* Pointer to an opaque data structure containing information from the debug
|
/* Pointer to an opaque data structure containing information from the debug
|
||||||
* info file. Actually a handle to the data in the file.
|
* info file. Actually a handle to the data in the file.
|
||||||
*/
|
*/
|
||||||
typedef void* cc65_dbginfo;
|
typedef const void* cc65_dbginfo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -136,17 +136,17 @@ struct cc65_libraryinfo {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cc65_libraryinfo* cc65_get_librarylist (cc65_dbginfo handle);
|
const cc65_libraryinfo* cc65_get_librarylist (cc65_dbginfo handle);
|
||||||
/* Return a list of all libraries */
|
/* Return a list of all libraries */
|
||||||
|
|
||||||
cc65_libraryinfo* cc65_libraryinfo_byid (cc65_dbginfo handle, unsigned id);
|
const cc65_libraryinfo* cc65_libraryinfo_byid (cc65_dbginfo handle, unsigned id);
|
||||||
/* Return information about a library with a specific id. The function
|
/* Return information about a library with a specific id. The function
|
||||||
* returns NULL if the id is invalid (no such library) and otherwise a
|
* returns NULL if the id is invalid (no such library) and otherwise a
|
||||||
* cc65_libraryinfo structure with one entry that contains the requested
|
* cc65_libraryinfo structure with one entry that contains the requested
|
||||||
* library information.
|
* library information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cc65_free_libraryinfo (cc65_dbginfo handle, cc65_libraryinfo* info);
|
void cc65_free_libraryinfo (cc65_dbginfo handle, const cc65_libraryinfo* info);
|
||||||
/* Free a library info record */
|
/* Free a library info record */
|
||||||
|
|
||||||
|
|
||||||
@@ -164,27 +164,15 @@ typedef enum {
|
|||||||
CC65_LINE_MACRO, /* Macro expansion */
|
CC65_LINE_MACRO, /* Macro expansion */
|
||||||
} cc65_line_type;
|
} cc65_line_type;
|
||||||
|
|
||||||
/* Line information.
|
/* Line information */
|
||||||
* Notes:
|
|
||||||
* - line_end is inclusive
|
|
||||||
* - output_name may be NULL if the data wasn't written to the output file
|
|
||||||
* (example: bss segment)
|
|
||||||
* - output_offs is invalid if there is no output_name, and may not be of
|
|
||||||
* much use in case of a relocatable output file
|
|
||||||
*/
|
|
||||||
typedef struct cc65_linedata cc65_linedata;
|
typedef struct cc65_linedata cc65_linedata;
|
||||||
struct cc65_linedata {
|
struct cc65_linedata {
|
||||||
unsigned line_id; /* Internal id of this record */
|
unsigned line_id; /* Internal id of this record */
|
||||||
cc65_addr line_start; /* Start address for this line */
|
unsigned source_id; /* Id of the source file */
|
||||||
cc65_addr line_end; /* End address for this line */
|
|
||||||
const char* source_name; /* Name of the file */
|
|
||||||
unsigned long source_size; /* Size of file */
|
|
||||||
unsigned long source_mtime; /* Modification time */
|
|
||||||
cc65_line source_line; /* Line number */
|
cc65_line source_line; /* Line number */
|
||||||
const char* output_name; /* Output file */
|
|
||||||
unsigned long output_offs; /* Offset in output file */
|
|
||||||
cc65_line_type line_type; /* Type of line */
|
cc65_line_type line_type; /* Type of line */
|
||||||
unsigned count; /* Nesting counter for macros */
|
unsigned count; /* Nesting counter for macros */
|
||||||
|
cc65_idlist span_list; /* List of spans for this line */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct cc65_lineinfo cc65_lineinfo;
|
typedef struct cc65_lineinfo cc65_lineinfo;
|
||||||
@@ -195,18 +183,14 @@ struct cc65_lineinfo {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cc65_lineinfo* cc65_lineinfo_byaddr (cc65_dbginfo handle, unsigned long addr);
|
const cc65_lineinfo* cc65_lineinfo_byline (cc65_dbginfo handle,
|
||||||
/* Return line information for the given address. The function returns NULL
|
unsigned source_id,
|
||||||
* if no line information was found.
|
cc65_line line);
|
||||||
|
/* Return line information for a source file/line number combination. The
|
||||||
|
* function returns NULL if no line information was found.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cc65_lineinfo* cc65_lineinfo_byname (cc65_dbginfo handle, const char* filename,
|
void cc65_free_lineinfo (cc65_dbginfo handle, const cc65_lineinfo* info);
|
||||||
cc65_line line);
|
|
||||||
/* Return line information for a file/line number combination. The function
|
|
||||||
* returns NULL if no line information was found.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void cc65_free_lineinfo (cc65_dbginfo handle, cc65_lineinfo* info);
|
|
||||||
/* Free line info returned by one of the other functions */
|
/* Free line info returned by one of the other functions */
|
||||||
|
|
||||||
|
|
||||||
@@ -235,17 +219,17 @@ struct cc65_moduleinfo {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cc65_moduleinfo* cc65_get_modulelist (cc65_dbginfo handle);
|
const cc65_moduleinfo* cc65_get_modulelist (cc65_dbginfo handle);
|
||||||
/* Return a list of all modules */
|
/* Return a list of all modules */
|
||||||
|
|
||||||
cc65_moduleinfo* cc65_moduleinfo_byid (cc65_dbginfo handle, unsigned id);
|
const cc65_moduleinfo* cc65_moduleinfo_byid (cc65_dbginfo handle, unsigned id);
|
||||||
/* Return information about a module with a specific id. The function
|
/* Return information about a module with a specific id. The function
|
||||||
* returns NULL if the id is invalid (no such module) and otherwise a
|
* returns NULL if the id is invalid (no such module) and otherwise a
|
||||||
* cc65_moduleinfo structure with one entry that contains the requested
|
* cc65_moduleinfo structure with one entry that contains the requested
|
||||||
* module information.
|
* module information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cc65_free_moduleinfo (cc65_dbginfo handle, cc65_moduleinfo* info);
|
void cc65_free_moduleinfo (cc65_dbginfo handle, const cc65_moduleinfo* info);
|
||||||
/* Free a module info record */
|
/* Free a module info record */
|
||||||
|
|
||||||
|
|
||||||
@@ -260,8 +244,8 @@ void cc65_free_moduleinfo (cc65_dbginfo handle, cc65_moduleinfo* info);
|
|||||||
typedef struct cc65_spandata cc65_spandata;
|
typedef struct cc65_spandata cc65_spandata;
|
||||||
struct cc65_spandata {
|
struct cc65_spandata {
|
||||||
unsigned span_id; /* The internal span id */
|
unsigned span_id; /* The internal span id */
|
||||||
cc65_addr span_offs; /* Offset of the span in the segment */
|
cc65_addr span_start; /* Start of the span */
|
||||||
cc65_size span_size; /* Size of the span */
|
cc65_addr span_end; /* End of the span (inclusive!) */
|
||||||
unsigned segment_id; /* Id of the segment */
|
unsigned segment_id; /* Id of the segment */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -273,17 +257,23 @@ struct cc65_spaninfo {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cc65_spaninfo* cc65_get_spanlist (cc65_dbginfo handle);
|
const cc65_spaninfo* cc65_get_spanlist (cc65_dbginfo handle);
|
||||||
/* Return a list of all spans */
|
/* Return a list of all spans. BEWARE: Large! */
|
||||||
|
|
||||||
cc65_spaninfo* cc65_spaninfo_byid (cc65_dbginfo handle, unsigned id);
|
const cc65_spaninfo* cc65_spaninfo_byid (cc65_dbginfo handle, unsigned id);
|
||||||
/* Return information about a span with a specific id. The function
|
/* Return information about a span with a specific id. The function
|
||||||
* returns NULL if the id is invalid (no such span) and otherwise a
|
* returns NULL if the id is invalid (no such span) and otherwise a
|
||||||
* cc65_spaninfo structure with one entry that contains the requested
|
* cc65_spaninfo structure with one entry that contains the requested
|
||||||
* span information.
|
* span information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cc65_free_spaninfo (cc65_dbginfo handle, cc65_spaninfo* info);
|
const cc65_spaninfo* cc65_spaninfo_byaddr (cc65_dbginfo handle,
|
||||||
|
unsigned long addr);
|
||||||
|
/* Return span information for the given address. The function returns NULL
|
||||||
|
* if no spans were found for this address.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void cc65_free_spaninfo (cc65_dbginfo handle, const cc65_spaninfo* info);
|
||||||
/* Free a span info record */
|
/* Free a span info record */
|
||||||
|
|
||||||
|
|
||||||
@@ -311,24 +301,24 @@ struct cc65_sourceinfo {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cc65_sourceinfo* cc65_get_sourcelist (cc65_dbginfo handle);
|
const cc65_sourceinfo* cc65_get_sourcelist (cc65_dbginfo handle);
|
||||||
/* Return a list of all source files */
|
/* Return a list of all source files */
|
||||||
|
|
||||||
cc65_sourceinfo* cc65_sourceinfo_byid (cc65_dbginfo handle, unsigned id);
|
const cc65_sourceinfo* cc65_sourceinfo_byid (cc65_dbginfo handle, unsigned id);
|
||||||
/* Return information about a source file with a specific id. The function
|
/* Return information about a source file with a specific id. The function
|
||||||
* returns NULL if the id is invalid (no such source file) and otherwise a
|
* returns NULL if the id is invalid (no such source file) and otherwise a
|
||||||
* cc65_sourceinfo structure with one entry that contains the requested
|
* cc65_sourceinfo structure with one entry that contains the requested
|
||||||
* source file information.
|
* source file information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cc65_sourceinfo* cc65_sourceinfo_bymodule (cc65_dbginfo handle,
|
const cc65_sourceinfo* cc65_sourceinfo_bymodule (cc65_dbginfo handle,
|
||||||
unsigned module_id);
|
unsigned module_id);
|
||||||
/* Return information about the source files used to build a module. The
|
/* Return information about the source files used to build a module. The
|
||||||
* function returns NULL if the module id is invalid (no such module) and
|
* function returns NULL if the module id is invalid (no such module) and
|
||||||
* otherwise a cc65_sourceinfo structure with one entry per source file.
|
* otherwise a cc65_sourceinfo structure with one entry per source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cc65_free_sourceinfo (cc65_dbginfo handle, cc65_sourceinfo* info);
|
void cc65_free_sourceinfo (cc65_dbginfo handle, const cc65_sourceinfo* info);
|
||||||
/* Free a source info record */
|
/* Free a source info record */
|
||||||
|
|
||||||
|
|
||||||
@@ -364,16 +354,16 @@ struct cc65_segmentinfo {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cc65_segmentinfo* cc65_get_segmentlist (cc65_dbginfo handle);
|
const cc65_segmentinfo* cc65_get_segmentlist (cc65_dbginfo handle);
|
||||||
/* Return a list of all segments referenced in the debug information */
|
/* Return a list of all segments referenced in the debug information */
|
||||||
|
|
||||||
cc65_segmentinfo* cc65_segmentinfo_byid (cc65_dbginfo handle, unsigned id);
|
const cc65_segmentinfo* cc65_segmentinfo_byid (cc65_dbginfo handle, unsigned id);
|
||||||
/* Return information about a segment with a specific id. The function returns
|
/* Return information about a segment with a specific id. The function returns
|
||||||
* NULL if the id is invalid (no such segment) and otherwise a cc65_segmentinfo
|
* NULL if the id is invalid (no such segment) and otherwise a cc65_segmentinfo
|
||||||
* structure with one entry that contains the requested segment information.
|
* structure with one entry that contains the requested segment information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cc65_free_segmentinfo (cc65_dbginfo handle, cc65_segmentinfo* info);
|
void cc65_free_segmentinfo (cc65_dbginfo handle, const cc65_segmentinfo* info);
|
||||||
/* Free a segment info record */
|
/* Free a segment info record */
|
||||||
|
|
||||||
|
|
||||||
@@ -413,24 +403,24 @@ struct cc65_symbolinfo {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cc65_symbolinfo* cc65_symbol_byid (cc65_dbginfo handle, unsigned id);
|
const cc65_symbolinfo* cc65_symbol_byid (cc65_dbginfo handle, unsigned id);
|
||||||
/* Return the symbol with a given id. The function returns NULL if no symbol
|
/* Return the symbol with a given id. The function returns NULL if no symbol
|
||||||
* with this id was found.
|
* with this id was found.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cc65_symbolinfo* cc65_symbol_byname (cc65_dbginfo handle, const char* name);
|
const cc65_symbolinfo* cc65_symbol_byname (cc65_dbginfo handle, const char* name);
|
||||||
/* Return a list of symbols with a given name. The function returns NULL if
|
/* Return a list of symbols with a given name. The function returns NULL if
|
||||||
* no symbol with this name was found.
|
* no symbol with this name was found.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cc65_symbolinfo* cc65_symbol_inrange (cc65_dbginfo handle,
|
const cc65_symbolinfo* cc65_symbol_inrange (cc65_dbginfo handle,
|
||||||
cc65_addr start, cc65_addr end);
|
cc65_addr start, cc65_addr end);
|
||||||
/* Return a list of labels in the given range. end is inclusive. The function
|
/* Return a list of labels in the given range. end is inclusive. The function
|
||||||
* return NULL if no symbols within the given range are found. Non label
|
* return NULL if no symbols within the given range are found. Non label
|
||||||
* symbols are ignored and not returned.
|
* symbols are ignored and not returned.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cc65_free_symbolinfo (cc65_dbginfo Handle, cc65_symbolinfo* Info);
|
void cc65_free_symbolinfo (cc65_dbginfo Handle, const cc65_symbolinfo* Info);
|
||||||
/* Free a symbol info record */
|
/* Free a symbol info record */
|
||||||
|
|
||||||
|
|
||||||
@@ -469,17 +459,17 @@ struct cc65_scopeinfo {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cc65_scopeinfo* cc65_scope_byid (cc65_dbginfo handle, unsigned id);
|
const cc65_scopeinfo* cc65_scope_byid (cc65_dbginfo handle, unsigned id);
|
||||||
/* Return the scope with a given id. The function returns NULL if no scope
|
/* Return the scope with a given id. The function returns NULL if no scope
|
||||||
* with this id was found.
|
* with this id was found.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cc65_scopeinfo* cc65_scope_bymodule (cc65_dbginfo handle, unsigned module_id);
|
const cc65_scopeinfo* cc65_scope_bymodule (cc65_dbginfo handle, unsigned module_id);
|
||||||
/* Return the list of scopes for one module. The function returns NULL if no
|
/* Return the list of scopes for one module. The function returns NULL if no
|
||||||
* scope with the given id was found.
|
* scope with the given id was found.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cc65_free_scopeinfo (cc65_dbginfo Handle, cc65_scopeinfo* Info);
|
void cc65_free_scopeinfo (cc65_dbginfo Handle, const cc65_scopeinfo* Info);
|
||||||
/* Free a scope info record */
|
/* Free a scope info record */
|
||||||
|
|
||||||
|
|
||||||
|
@@ -91,10 +91,7 @@ static void PrintSegmentData (const cc65_segmentdata* D)
|
|||||||
static void PrintLineData (const cc65_linedata* D)
|
static void PrintLineData (const cc65_linedata* D)
|
||||||
/* Print the data for one source line */
|
/* Print the data for one source line */
|
||||||
{
|
{
|
||||||
printf (" %s(%lu)", D->source_name, (unsigned long) D->source_line);
|
printf (" file %u", D->source_id);
|
||||||
if (D->output_name) {
|
|
||||||
printf (" [%s($%06lX)]", D->output_name, D->output_offs);
|
|
||||||
}
|
|
||||||
switch (D->line_type) {
|
switch (D->line_type) {
|
||||||
case CC65_LINE_ASM:
|
case CC65_LINE_ASM:
|
||||||
printf (": Assembler source");
|
printf (": Assembler source");
|
||||||
@@ -119,7 +116,7 @@ static void PrintSymbolData (const cc65_symboldata* D)
|
|||||||
{
|
{
|
||||||
char Segment[256] = { 0 }; /* Needs dynamic alloc ### */
|
char Segment[256] = { 0 }; /* Needs dynamic alloc ### */
|
||||||
if (D->segment_id != CC65_INV_ID) {
|
if (D->segment_id != CC65_INV_ID) {
|
||||||
cc65_segmentinfo* I = cc65_segmentinfo_byid (Info, D->segment_id);
|
const cc65_segmentinfo* I = cc65_segmentinfo_byid (Info, D->segment_id);
|
||||||
if (I && I->count == 1) {
|
if (I && I->count == 1) {
|
||||||
sprintf (Segment, "segment=%s,", I->data[0].segment_name);
|
sprintf (Segment, "segment=%s,", I->data[0].segment_name);
|
||||||
cc65_free_segmentinfo (Info, I);
|
cc65_free_segmentinfo (Info, I);
|
||||||
@@ -136,7 +133,7 @@ static void PrintSymbolData (const cc65_symboldata* D)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void PrintSourceInfo (cc65_sourceinfo* Sources)
|
static void PrintSourceInfo (const cc65_sourceinfo* Sources)
|
||||||
/* Output the list of source files */
|
/* Output the list of source files */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
@@ -149,7 +146,7 @@ static void PrintSourceInfo (cc65_sourceinfo* Sources)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void PrintSegmentInfo (cc65_segmentinfo* Segments)
|
static void PrintSegmentInfo (const cc65_segmentinfo* Segments)
|
||||||
/* Output the list of segments */
|
/* Output the list of segments */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
@@ -190,12 +187,12 @@ static void PrintSymbolInfo (const cc65_symbolinfo* Symbols)
|
|||||||
|
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
const char* Input;
|
const char* Input;
|
||||||
cc65_sourceinfo* Sources;
|
const cc65_sourceinfo* Sources;
|
||||||
cc65_segmentinfo* Segments;
|
const cc65_segmentinfo* Segments;
|
||||||
cc65_lineinfo* Lines;
|
const cc65_lineinfo* Lines;
|
||||||
cc65_symbolinfo* Symbols;
|
const cc65_symbolinfo* Symbols;
|
||||||
cc65_addr Addr;
|
cc65_addr Addr;
|
||||||
|
|
||||||
|
|
||||||
/* Input file is argument */
|
/* Input file is argument */
|
||||||
@@ -224,6 +221,7 @@ int main (int argc, char** argv)
|
|||||||
PrintSegmentInfo (Segments);
|
PrintSegmentInfo (Segments);
|
||||||
cc65_free_segmentinfo (Info, Segments);
|
cc65_free_segmentinfo (Info, Segments);
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* Check one line */
|
/* Check one line */
|
||||||
printf ("Requesting line info for crt0.s(59):\n");
|
printf ("Requesting line info for crt0.s(59):\n");
|
||||||
Lines = cc65_lineinfo_byname (Info, "crt0.s", 59);
|
Lines = cc65_lineinfo_byname (Info, "crt0.s", 59);
|
||||||
@@ -246,7 +244,7 @@ int main (int argc, char** argv)
|
|||||||
cc65_free_lineinfo (Info, Lines);
|
cc65_free_lineinfo (Info, Lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* Check for address of main */
|
/* Check for address of main */
|
||||||
printf ("Requesting address of _main:\n");
|
printf ("Requesting address of _main:\n");
|
||||||
Symbols = cc65_symbol_byname (Info, "_main");
|
Symbols = cc65_symbol_byname (Info, "_main");
|
||||||
|
@@ -12,7 +12,7 @@ EXE = dbgtest
|
|||||||
|
|
||||||
#
|
#
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -g -O2 -Wall -W
|
CFLAGS = -g -Wall -W
|
||||||
EBIND = emxbind
|
EBIND = emxbind
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user