Fox scopes that have a label (= .PROC), write the label to the debug

information.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5130 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2011-08-07 18:46:56 +00:00
parent c19491035b
commit af8fbf8d62
4 changed files with 29 additions and 19 deletions

View file

@ -807,12 +807,12 @@ static void CreateObjFile (void)
/* Write the export list */ /* Write the export list */
WriteExports (); WriteExports ();
/* Write the scopes if requested */
WriteScopes ();
/* Write debug symbols if requested */ /* Write debug symbols if requested */
WriteDbgSyms (); WriteDbgSyms ();
/* Write the scopes if requested */
WriteScopes ();
/* Write line infos if requested */ /* Write line infos if requested */
WriteLineInfos (); WriteLineInfos ();

View file

@ -817,7 +817,7 @@ static void DoEnd (void)
static void DoEndProc (void) static void DoEndProc (void)
/* Leave a lexical level */ /* Leave a lexical level */
{ {
if (CurrentScope->Type != SCOPE_SCOPE || CurrentScope->OwnerSym == 0) { if (CurrentScope->Type != SCOPE_SCOPE || CurrentScope->Label == 0) {
/* No local scope */ /* No local scope */
ErrorSkip ("No open .PROC"); ErrorSkip ("No open .PROC");
} else { } else {
@ -830,7 +830,7 @@ static void DoEndProc (void)
static void DoEndScope (void) static void DoEndScope (void)
/* Leave a lexical level */ /* Leave a lexical level */
{ {
if (CurrentScope->Type != SCOPE_SCOPE || CurrentScope->OwnerSym != 0) { if (CurrentScope->Type != SCOPE_SCOPE || CurrentScope->Label != 0) {
/* No local scope */ /* No local scope */
ErrorSkip ("No open .SCOPE"); ErrorSkip ("No open .SCOPE");
} else { } else {

View file

@ -116,7 +116,7 @@ static SymTable* NewSymTable (SymTable* Parent, const StrBuf* Name)
S->Left = 0; S->Left = 0;
S->Right = 0; S->Right = 0;
S->Childs = 0; S->Childs = 0;
S->OwnerSym = 0; S->Label = 0;
S->Spans = AUTO_COLLECTION_INITIALIZER; S->Spans = AUTO_COLLECTION_INITIALIZER;
S->Id = ScopeCount++; S->Id = ScopeCount++;
S->Flags = ST_NONE; S->Flags = ST_NONE;
@ -184,7 +184,7 @@ static SymTable* NewSymTable (SymTable* Parent, const StrBuf* Name)
void SymEnterLevel (const StrBuf* ScopeName, unsigned char Type, void SymEnterLevel (const StrBuf* ScopeName, unsigned char Type,
unsigned char AddrSize, SymEntry* OwnerSym) unsigned char AddrSize, SymEntry* ScopeLabel)
/* Enter a new lexical level */ /* Enter a new lexical level */
{ {
/* Map a default address size to something real */ /* Map a default address size to something real */
@ -214,7 +214,7 @@ void SymEnterLevel (const StrBuf* ScopeName, unsigned char Type,
CurrentScope->Flags |= ST_DEFINED; CurrentScope->Flags |= ST_DEFINED;
CurrentScope->AddrSize = AddrSize; CurrentScope->AddrSize = AddrSize;
CurrentScope->Type = Type; CurrentScope->Type = Type;
CurrentScope->OwnerSym = OwnerSym; CurrentScope->Label = ScopeLabel;
/* If this is a scope that allows to emit data into segments, add spans /* If this is a scope that allows to emit data into segments, add spans
* for all currently existing segments. Doing this for just a few scope * for all currently existing segments. Doing this for just a few scope
@ -246,8 +246,8 @@ void SymLeaveLevel (void)
const Span* S = CollAtUnchecked (&CurrentScope->Spans, 0); const Span* S = CollAtUnchecked (&CurrentScope->Spans, 0);
unsigned long Size = GetSpanSize (S); unsigned long Size = GetSpanSize (S);
DefSizeOfScope (CurrentScope, Size); DefSizeOfScope (CurrentScope, Size);
if (CurrentScope->OwnerSym) { if (CurrentScope->Label) {
DefSizeOfSymbol (CurrentScope->OwnerSym, Size); DefSizeOfSymbol (CurrentScope->Label, Size);
} }
} }
@ -914,6 +914,11 @@ void WriteScopes (void)
Flags |= SCOPE_SIZE; Flags |= SCOPE_SIZE;
} }
/* Check if the scope has a label */
if (S->Label) {
Flags |= SCOPE_LABELED;
}
/* Scope must be defined */ /* Scope must be defined */
CHECK (S->Type != SCOPE_UNDEF); CHECK (S->Type != SCOPE_UNDEF);
@ -941,6 +946,11 @@ void WriteScopes (void)
ObjWriteVar (Size); ObjWriteVar (Size);
} }
/* If the scope has a label, write its id to the file */
if (SCOPE_HAS_LABEL (Flags)) {
ObjWriteVar (S->Label->DebugSymId);
}
/* Spans for this scope */ /* Spans for this scope */
WriteSpans (&S->Spans); WriteSpans (&S->Spans);

View file

@ -67,7 +67,7 @@ struct SymTable {
SymTable* Right; /* Pointer to greater entry */ SymTable* Right; /* Pointer to greater entry */
SymTable* Parent; /* Link to enclosing scope if any */ SymTable* Parent; /* Link to enclosing scope if any */
SymTable* Childs; /* Pointer to child scopes */ SymTable* Childs; /* Pointer to child scopes */
SymEntry* OwnerSym; /* Symbol that "owns" the scope */ SymEntry* Label; /* Scope label */
Collection Spans; /* Spans for this scope */ Collection Spans; /* Spans for this scope */
unsigned Id; /* Scope id */ unsigned Id; /* Scope id */
unsigned short Flags; /* Symbol table flags */ unsigned short Flags; /* Symbol table flags */