From: uz Date: Wed, 10 Aug 2011 21:17:45 +0000 (+0000) Subject: Started to add spans. X-Git-Tag: V2.13.3~314 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d8feaf2e54d90582450165695fdc4438bf0b4bfc;p=cc65 Started to add spans. git-svn-id: svn://svn.cc65.org/cc65/trunk@5148 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/dbginfo/dbginfo.c b/src/dbginfo/dbginfo.c index 6d6a25abb..41698f28c 100644 --- a/src/dbginfo/dbginfo.c +++ b/src/dbginfo/dbginfo.c @@ -149,6 +149,7 @@ typedef enum { 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 */ @@ -180,6 +181,7 @@ struct DbgInfo { 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 */ @@ -220,6 +222,7 @@ typedef struct LineInfo LineInfo; 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 */ @@ -296,12 +299,23 @@ struct ScopeInfo { 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 */ @@ -1598,6 +1612,53 @@ static int CompareSegInfoByName (const void* L, const void* R) +/*****************************************************************************/ +/* 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 */ /*****************************************************************************/ @@ -1709,6 +1770,7 @@ static DbgInfo* NewDbgInfo (void) CollInit (&Info->ModInfoById); CollInit (&Info->ScopeInfoById); CollInit (&Info->SegInfoById); + CollInit (&Info->SpanInfoById); CollInit (&Info->SymInfoById); CollInit (&Info->FileInfoByName); @@ -1749,6 +1811,9 @@ static void FreeDbgInfo (DbgInfo* Info) 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)); } @@ -1760,6 +1825,7 @@ static void FreeDbgInfo (DbgInfo* Info) CollDone (&Info->ModInfoById); CollDone (&Info->ScopeInfoById); CollDone (&Info->SegInfoById); + CollDone (&Info->SpanInfoById); CollDone (&Info->SymInfoById); /* Free the memory used by the other collections */ @@ -1783,7 +1849,7 @@ static void FreeDbgInfo (DbgInfo* Info) /*****************************************************************************/ - + static void ParseError (InputData* D, cc65_error_severity Type, const char* Msg, ...) /* Call the user supplied parse error function */ { @@ -1940,6 +2006,7 @@ static void NextToken (InputData* D) { "scope", TOK_SCOPE }, { "seg", TOK_SEGMENT }, { "size", TOK_SIZE }, + { "span", TOK_SPAN }, { "start", TOK_START }, { "struct", TOK_STRUCT }, { "sym", TOK_SYM }, diff --git a/src/dbginfo/dbginfo.h b/src/dbginfo/dbginfo.h index 68c580a8f..04f4d7f68 100644 --- a/src/dbginfo/dbginfo.h +++ b/src/dbginfo/dbginfo.h @@ -242,6 +242,44 @@ void cc65_free_moduleinfo (cc65_dbginfo handle, cc65_moduleinfo* info); +/*****************************************************************************/ +/* 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 */ /*****************************************************************************/ @@ -305,7 +343,7 @@ struct cc65_segmentdata { 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 */ };