1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-29 17:56:21 +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:
uz 2011-08-11 17:11:45 +00:00
parent 3e6f9a212b
commit b4967d359f
4 changed files with 72 additions and 10 deletions

View File

@ -47,6 +47,7 @@
#include "lineinfo.h" #include "lineinfo.h"
#include "scopes.h" #include "scopes.h"
#include "segments.h" #include "segments.h"
#include "span.h"
@ -107,12 +108,13 @@ void CreateDbgFile (void)
*/ */
fprintf ( fprintf (
F, 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 (), LibraryCount (),
ObjDataCount (), ObjDataCount (),
ScopeCount (),
SegmentCount (), SegmentCount (),
FileInfoCount (), SpanCount ()
ScopeCount ()
); );
/* Assign the ids to the items */ /* Assign the ids to the items */
@ -133,6 +135,9 @@ void CreateDbgFile (void)
/* Output line info */ /* Output line info */
PrintDbgLineInfo (F); PrintDbgLineInfo (F);
/* Output spans */
PrintDbgSpans (F);
/* Output symbols */ /* Output symbols */
PrintDbgSyms (F); PrintDbgSyms (F);

View File

@ -89,7 +89,7 @@ Scope* ReadScope (FILE* F, ObjData* Obj, unsigned Id)
S->LabelId = ReadVar (F); S->LabelId = ReadVar (F);
} }
/* Read the segment ranges for this scope */ /* Read the spans for this scope */
ReadSpans (&S->Spans, F, Obj); ReadSpans (&S->Spans, F, Obj);
/* Return the new Scope */ /* Return the new Scope */
@ -120,7 +120,7 @@ unsigned ScopeCount (void)
void PrintDbgScopes (FILE* F) void PrintDbgScopes (FILE* F)
/* Output the scopes to a debug info file */ /* 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 */ /* Print scopes from all modules we have linked into the output file */
for (I = 0; I < CollCount (&ObjDataList); ++I) { for (I = 0; I < CollCount (&ObjDataList); ++I) {
@ -164,6 +164,15 @@ void PrintDbgScopes (FILE* F)
if (SCOPE_HAS_LABEL (S->Flags)) { if (SCOPE_HAS_LABEL (S->Flags)) {
fprintf (F, ",sym=%u", O->SymBaseId + S->LabelId); 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 */ /* Terminate the output line */
fputc ('\n', F); fputc ('\n', F);

View File

@ -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)); Span* S = xmalloc (sizeof (*S));
/* Initialize the fields */ /* Initialize the fields */
S->Id = CollCount (&SpanList);
S->Seg = Seg; S->Seg = Seg;
S->Offs = Offs; S->Offs = Offs;
S->Size = Size; S->Size = Size;
/* Remember this span in the global list */
CollAppend (&SpanList, S);
/* Return the result */ /* 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);
}
}

View File

@ -64,6 +64,7 @@ struct Segment;
typedef struct Span Span; typedef struct Span Span;
struct Span { struct Span {
unsigned Id; /* Id of the span */
struct Segment* Seg; /* Segment of this span */ struct Segment* Seg; /* Segment of this span */
unsigned long Offs; /* Offset of span within segment */ unsigned long Offs; /* Offset of span within segment */
unsigned long Size; /* Size of span */ 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. * 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 */ /* End of span.h */