TOK_SCOPE, /* SCOPE keyword */
TOK_SEGMENT, /* SEGMENT keyword */
TOK_SIZE, /* SIZE keyword */
+ TOK_SPAN, /* SPAN keyword */
TOK_START, /* START keyword */
TOK_STRUCT, /* STRUCT keyword */
TOK_SYM, /* SYM keyword */
Collection ModInfoById; /* Module infos sorted by id */
Collection ScopeInfoById; /* Scope infos sorted by id */
Collection SegInfoById; /* Segment infos sorted by id */
+ Collection SpanInfoById; /* Span infos sorted by id */
Collection SymInfoById; /* Symbol infos sorted by id */
/* Collections with other sort criteria */
typedef struct ModInfo ModInfo;
typedef struct ScopeInfo ScopeInfo;
typedef struct SegInfo SegInfo;
+typedef struct SpanInfo SpanInfo;
typedef struct SymInfo SymInfo;
/* Internally used file info struct */
struct SegInfo {
unsigned Id; /* Id of segment */
cc65_addr Start; /* Start address of segment */
- cc65_addr Size; /* Size of segment */
+ cc65_size Size; /* Size of segment */
char* OutputName; /* Name of output file */
unsigned long OutputOffs; /* Offset in output file */
char Name[1]; /* Name of segment */
};
+/* Internally used span info struct */
+struct SpanInfo {
+ unsigned Id; /* Id of span */
+ cc65_addr Offs; /* Start offset of span */
+ cc65_size Size; /* Size of span */
+ union {
+ unsigned Id; /* Id of segment */
+ SegInfo* Info; /* Pointer to segment */
+ } Seg;
+};
+
/* Internally used symbol info struct */
struct SymInfo {
unsigned Id; /* Id of symbol */
+/*****************************************************************************/
+/* Span info */
+/*****************************************************************************/
+
+
+
+static SpanInfo* NewSpanInfo (void)
+/* Create a new SpanInfo struct, intialize and return it */
+{
+ /* Allocate memory and return it */
+ return xmalloc (sizeof (SpanInfo));
+}
+
+
+
+static void FreeSpanInfo (SpanInfo* S)
+/* Free a SpanInfo struct */
+{
+ xfree (S);
+}
+
+
+
+static cc65_spaninfo* new_cc65_spaninfo (unsigned Count)
+/* Allocate and return a cc65_spaninfo struct that is able to hold Count
+ * entries. Initialize the count field of the returned struct.
+ */
+{
+ cc65_spaninfo* S = xmalloc (sizeof (*S) - sizeof (S->data[0]) +
+ Count * sizeof (S->data[0]));
+ S->count = Count;
+ return S;
+}
+
+
+
+static void CopySpanInfo (cc65_spandata* D, const SpanInfo* S)
+/* Copy data from a SpanInfo struct to a cc65_spandata struct */
+{
+ D->span_id = S->Id;
+ D->span_offs = S->Offs;
+ D->span_size = S->Size;
+ D->segment_id = S->Seg.Info->Id;
+}
+
+
+
/*****************************************************************************/
/* Symbol info */
/*****************************************************************************/
CollInit (&Info->ModInfoById);
CollInit (&Info->ScopeInfoById);
CollInit (&Info->SegInfoById);
+ CollInit (&Info->SpanInfoById);
CollInit (&Info->SymInfoById);
CollInit (&Info->FileInfoByName);
for (I = 0; I < CollCount (&Info->SegInfoById); ++I) {
FreeSegInfo (CollAt (&Info->SegInfoById, I));
}
+ for (I = 0; I < CollCount (&Info->SpanInfoById); ++I) {
+ FreeSpanInfo (CollAt (&Info->SpanInfoById, I));
+ }
for (I = 0; I < CollCount (&Info->SymInfoById); ++I) {
FreeSymInfo (CollAt (&Info->SymInfoById, I));
}
CollDone (&Info->ModInfoById);
CollDone (&Info->ScopeInfoById);
CollDone (&Info->SegInfoById);
+ CollDone (&Info->SpanInfoById);
CollDone (&Info->SymInfoById);
/* Free the memory used by the other collections */
/*****************************************************************************/
-
+
static void ParseError (InputData* D, cc65_error_severity Type, const char* Msg, ...)
/* Call the user supplied parse error function */
{
{ "scope", TOK_SCOPE },
{ "seg", TOK_SEGMENT },
{ "size", TOK_SIZE },
+ { "span", TOK_SPAN },
{ "start", TOK_START },
{ "struct", TOK_STRUCT },
{ "sym", TOK_SYM },
+/*****************************************************************************/
+/* Spans */
+/*****************************************************************************/
+
+
+
+/* Span information */
+typedef struct cc65_spandata cc65_spandata;
+struct cc65_spandata {
+ unsigned span_id; /* The internal span id */
+ cc65_addr span_offs; /* Offset of the span in the segment */
+ cc65_size span_size; /* Size of the span */
+ unsigned segment_id; /* Id of the segment */
+};
+
+typedef struct cc65_spaninfo cc65_spaninfo;
+struct cc65_spaninfo {
+ unsigned count; /* Number of data sets that follow */
+ cc65_spandata data[1]; /* Data sets, number is dynamic */
+};
+
+
+
+cc65_spaninfo* cc65_get_spanlist (cc65_dbginfo handle);
+/* Return a list of all spans */
+
+cc65_spaninfo* cc65_spaninfo_byid (cc65_dbginfo handle, unsigned id);
+/* Return information about a span with a specific id. The function
+ * returns NULL if the id is invalid (no such span) and otherwise a
+ * cc65_spaninfo structure with one entry that contains the requested
+ * span information.
+ */
+
+void cc65_free_spaninfo (cc65_dbginfo handle, cc65_spaninfo* info);
+/* Free a span info record */
+
+
+
/*****************************************************************************/
/* Source files */
/*****************************************************************************/
unsigned segment_id; /* The internal segment id */
const char* segment_name; /* Name of the segment */
cc65_addr segment_start; /* Start address of segment */
- cc65_addr segment_size; /* Size of segment */
+ cc65_size segment_size; /* Size of segment */
const char* output_name; /* Output file this seg was written to */
unsigned long output_offs; /* Offset of this seg in output file */
};