mirror of
https://github.com/cc65/cc65.git
synced 2024-11-18 15:05:14 +00:00
Output spans to the debug info file.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5152 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
3e6f9a212b
commit
b4967d359f
@ -47,6 +47,7 @@
|
||||
#include "lineinfo.h"
|
||||
#include "scopes.h"
|
||||
#include "segments.h"
|
||||
#include "span.h"
|
||||
|
||||
|
||||
|
||||
@ -102,17 +103,18 @@ void CreateDbgFile (void)
|
||||
/* Output version information */
|
||||
fprintf (F, "version\tmajor=2,minor=0\n");
|
||||
|
||||
/* Output a line with the item numbers so the debug info module is able
|
||||
/* Output a line with the item numbers so the debug info module is able
|
||||
* to preallocate the required memory.
|
||||
*/
|
||||
fprintf (
|
||||
F,
|
||||
"info\tlib=%u,mod=%u,seg=%u,file=%u,scope=%u\n",
|
||||
"info\tlib=%u,file=%u,mod=%u,scope=%u,seg=%u,span=%u\n",
|
||||
FileInfoCount (),
|
||||
LibraryCount (),
|
||||
ObjDataCount (),
|
||||
ScopeCount (),
|
||||
SegmentCount (),
|
||||
FileInfoCount (),
|
||||
ScopeCount ()
|
||||
SpanCount ()
|
||||
);
|
||||
|
||||
/* Assign the ids to the items */
|
||||
@ -133,6 +135,9 @@ void CreateDbgFile (void)
|
||||
/* Output line info */
|
||||
PrintDbgLineInfo (F);
|
||||
|
||||
/* Output spans */
|
||||
PrintDbgSpans (F);
|
||||
|
||||
/* Output symbols */
|
||||
PrintDbgSyms (F);
|
||||
|
||||
|
@ -89,7 +89,7 @@ Scope* ReadScope (FILE* F, ObjData* Obj, unsigned Id)
|
||||
S->LabelId = ReadVar (F);
|
||||
}
|
||||
|
||||
/* Read the segment ranges for this scope */
|
||||
/* Read the spans for this scope */
|
||||
ReadSpans (&S->Spans, F, Obj);
|
||||
|
||||
/* Return the new Scope */
|
||||
@ -120,7 +120,7 @@ unsigned ScopeCount (void)
|
||||
void PrintDbgScopes (FILE* F)
|
||||
/* Output the scopes to a debug info file */
|
||||
{
|
||||
unsigned I, J;
|
||||
unsigned I, J, K;
|
||||
|
||||
/* Print scopes from all modules we have linked into the output file */
|
||||
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||
@ -152,7 +152,7 @@ void PrintDbgScopes (FILE* F)
|
||||
GetObjFileName (O), S->Type);
|
||||
}
|
||||
|
||||
/* Print the size if available */
|
||||
/* Print the size if available */
|
||||
if (S->Size != 0) {
|
||||
fprintf (F, ",size=%lu", S->Size);
|
||||
}
|
||||
@ -164,6 +164,15 @@ void PrintDbgScopes (FILE* F)
|
||||
if (SCOPE_HAS_LABEL (S->Flags)) {
|
||||
fprintf (F, ",sym=%u", O->SymBaseId + S->LabelId);
|
||||
}
|
||||
/* Print the list of spans for this scope */
|
||||
if (CollCount (&S->Spans) > 0) {
|
||||
const Span* SP = CollConstAt (&S->Spans, 0);
|
||||
fprintf (F, ",span=%u", SP->Id);
|
||||
for (K = 1; K < CollCount (&S->Spans); ++K) {
|
||||
SP = CollConstAt (&S->Spans, K);
|
||||
fprintf (F, "+%u", SP->Id);
|
||||
}
|
||||
}
|
||||
|
||||
/* Terminate the output line */
|
||||
fputc ('\n', F);
|
||||
|
@ -36,7 +36,7 @@
|
||||
/* common */
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* ld65 */
|
||||
/* ld65 */
|
||||
#include "fileio.h"
|
||||
#include "objdata.h"
|
||||
#include "segments.h"
|
||||
@ -45,7 +45,18 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* List of all spans */
|
||||
static Collection SpanList = STATIC_COLLECTION_INITIALIZER;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
@ -57,12 +68,16 @@ Span* NewSpan (struct Segment* Seg, unsigned long Offs, unsigned long Size)
|
||||
Span* S = xmalloc (sizeof (*S));
|
||||
|
||||
/* Initialize the fields */
|
||||
S->Id = CollCount (&SpanList);
|
||||
S->Seg = Seg;
|
||||
S->Offs = Offs;
|
||||
S->Size = Size;
|
||||
|
||||
/* Remember this span in the global list */
|
||||
CollAppend (&SpanList, S);
|
||||
|
||||
/* Return the result */
|
||||
return S;
|
||||
return S;
|
||||
}
|
||||
|
||||
|
||||
@ -161,3 +176,29 @@ void AddSpan (Collection* Spans, struct Segment* Seg, unsigned long Offs,
|
||||
|
||||
|
||||
|
||||
unsigned SpanCount (void)
|
||||
/* Return the total number of spans */
|
||||
{
|
||||
return CollCount (&SpanList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PrintDbgSpans (FILE* F)
|
||||
/* Output the spans to a debug info file */
|
||||
{
|
||||
/* Walk over all spans */
|
||||
unsigned I;
|
||||
for (I = 0; I < CollCount (&SpanList); ++I) {
|
||||
|
||||
/* Get this span */
|
||||
const Span* S = CollAtUnchecked (&SpanList, I);
|
||||
|
||||
/* Output the data */
|
||||
fprintf (F, "span\tid=%u,seg=%u,start=%lu,size=%lu\n",
|
||||
S->Id, S->Seg->Id, S->Offs, S->Size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -64,6 +64,7 @@ struct Segment;
|
||||
|
||||
typedef struct Span Span;
|
||||
struct Span {
|
||||
unsigned Id; /* Id of the span */
|
||||
struct Segment* Seg; /* Segment of this span */
|
||||
unsigned long Offs; /* Offset of span within segment */
|
||||
unsigned long Size; /* Size of span */
|
||||
@ -95,6 +96,12 @@ void AddSpan (Collection* Spans, struct Segment* Seg, unsigned long Offs,
|
||||
* possible - merge it with adjacent ones that already exist.
|
||||
*/
|
||||
|
||||
unsigned SpanCount (void);
|
||||
/* Return the total number of spans */
|
||||
|
||||
void PrintDbgSpans (FILE* F);
|
||||
/* Output the spans to a debug info file */
|
||||
|
||||
|
||||
|
||||
/* End of span.h */
|
||||
|
Loading…
Reference in New Issue
Block a user