From: uz Date: Sun, 7 Aug 2011 18:46:56 +0000 (+0000) Subject: Fox scopes that have a label (= .PROC), write the label to the debug X-Git-Tag: V2.13.3~332 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=af8fbf8d627e994ffdf5e5636f23dc36b4ee418b;p=cc65 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 --- diff --git a/src/ca65/main.c b/src/ca65/main.c index f41ddb683..30f22da14 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -807,12 +807,12 @@ static void CreateObjFile (void) /* Write the export list */ WriteExports (); - /* Write the scopes if requested */ - WriteScopes (); - /* Write debug symbols if requested */ WriteDbgSyms (); + /* Write the scopes if requested */ + WriteScopes (); + /* Write line infos if requested */ WriteLineInfos (); diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index 81e5273ce..3a2e391d3 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -817,7 +817,7 @@ static void DoEnd (void) static void DoEndProc (void) /* Leave a lexical level */ { - if (CurrentScope->Type != SCOPE_SCOPE || CurrentScope->OwnerSym == 0) { + if (CurrentScope->Type != SCOPE_SCOPE || CurrentScope->Label == 0) { /* No local scope */ ErrorSkip ("No open .PROC"); } else { @@ -830,7 +830,7 @@ static void DoEndProc (void) static void DoEndScope (void) /* Leave a lexical level */ { - if (CurrentScope->Type != SCOPE_SCOPE || CurrentScope->OwnerSym != 0) { + if (CurrentScope->Type != SCOPE_SCOPE || CurrentScope->Label != 0) { /* No local scope */ ErrorSkip ("No open .SCOPE"); } else { diff --git a/src/ca65/symtab.c b/src/ca65/symtab.c index fb48de223..3b83b8167 100644 --- a/src/ca65/symtab.c +++ b/src/ca65/symtab.c @@ -116,7 +116,7 @@ static SymTable* NewSymTable (SymTable* Parent, const StrBuf* Name) S->Left = 0; S->Right = 0; S->Childs = 0; - S->OwnerSym = 0; + S->Label = 0; S->Spans = AUTO_COLLECTION_INITIALIZER; S->Id = ScopeCount++; S->Flags = ST_NONE; @@ -184,7 +184,7 @@ static SymTable* NewSymTable (SymTable* Parent, const StrBuf* Name) void SymEnterLevel (const StrBuf* ScopeName, unsigned char Type, - unsigned char AddrSize, SymEntry* OwnerSym) + unsigned char AddrSize, SymEntry* ScopeLabel) /* Enter a new lexical level */ { /* Map a default address size to something real */ @@ -214,12 +214,12 @@ void SymEnterLevel (const StrBuf* ScopeName, unsigned char Type, CurrentScope->Flags |= ST_DEFINED; CurrentScope->AddrSize = AddrSize; CurrentScope->Type = Type; - CurrentScope->OwnerSym = OwnerSym; + CurrentScope->Label = ScopeLabel; /* 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 - * types is not really necessary but an optimization, because it does not - * allocate memory for useless data (unhandled types here don't occupy + * for all currently existing segments. Doing this for just a few scope + * types is not really necessary but an optimization, because it does not + * allocate memory for useless data (unhandled types here don't occupy * space in any segment). */ if (CurrentScope->Type <= SCOPE_HAS_DATA) { @@ -232,23 +232,23 @@ void SymEnterLevel (const StrBuf* ScopeName, unsigned char Type, void SymLeaveLevel (void) /* Leave the current lexical level */ { - /* Close the spans. We don't care about the scope type here, since types + /* Close the spans. We don't care about the scope type here, since types * without spans will just have an empty list. */ CloseSpans (&CurrentScope->Spans); - /* If we have spans, the first one is the segment that was active, when the - * scope was opened. Set the size of the scope to the number of data bytes - * emitted into this segment. If we have an owner symbol set the size of + /* If we have spans, the first one is the segment that was active, when the + * scope was opened. Set the size of the scope to the number of data bytes + * emitted into this segment. If we have an owner symbol set the size of * this symbol, too. */ if (CollCount (&CurrentScope->Spans) > 0) { const Span* S = CollAtUnchecked (&CurrentScope->Spans, 0); unsigned long Size = GetSpanSize (S); DefSizeOfScope (CurrentScope, Size); - if (CurrentScope->OwnerSym) { - DefSizeOfSymbol (CurrentScope->OwnerSym, Size); - } + if (CurrentScope->Label) { + DefSizeOfSymbol (CurrentScope->Label, Size); + } } /* Leave the scope */ @@ -914,6 +914,11 @@ void WriteScopes (void) Flags |= SCOPE_SIZE; } + /* Check if the scope has a label */ + if (S->Label) { + Flags |= SCOPE_LABELED; + } + /* Scope must be defined */ CHECK (S->Type != SCOPE_UNDEF); @@ -941,6 +946,11 @@ void WriteScopes (void) 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 */ WriteSpans (&S->Spans); diff --git a/src/ca65/symtab.h b/src/ca65/symtab.h index eef258703..ea7e66515 100644 --- a/src/ca65/symtab.h +++ b/src/ca65/symtab.h @@ -67,7 +67,7 @@ struct SymTable { SymTable* Right; /* Pointer to greater entry */ SymTable* Parent; /* Link to enclosing scope if any */ SymTable* Childs; /* Pointer to child scopes */ - SymEntry* OwnerSym; /* Symbol that "owns" the scope */ + SymEntry* Label; /* Scope label */ Collection Spans; /* Spans for this scope */ unsigned Id; /* Scope id */ unsigned short Flags; /* Symbol table flags */