From: uz Date: Fri, 5 Aug 2011 13:09:13 +0000 (+0000) Subject: Central management of the debug info base ids. X-Git-Tag: V2.13.3~339 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a17d11cba8991e093dc6a9a80ef655a3d8f4079a;p=cc65 Central management of the debug info base ids. git-svn-id: svn://svn.cc65.org/cc65/trunk@5123 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ld65/dbgfile.c b/src/ld65/dbgfile.c index 4aa64c953..a4f8216a4 100644 --- a/src/ld65/dbgfile.c +++ b/src/ld65/dbgfile.c @@ -50,11 +50,43 @@ /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/ +static void AssignBaseIds (void) +/* Assign the base ids for debug info output. Within each module, many of the + * items are addressed by ids which are actually the indices of the items in + * the collections. To make them unique, we must assign a unique base to each + * range. + */ +{ + unsigned I; + + /* Walk over all modules */ + unsigned FileBaseId = 0; + unsigned SymBaseId = 0; + unsigned ScopeBaseId = 0; + for (I = 0; I < CollCount (&ObjDataList); ++I) { + + /* Get this module */ + ObjData* O = CollAt (&ObjDataList, I); + + /* Assign ids */ + O->FileBaseId = FileBaseId; + O->SymBaseId = SymBaseId; + O->ScopeBaseId = ScopeBaseId; + + /* Bump the base ids */ + FileBaseId += CollCount (&O->Files); + SymBaseId += CollCount (&O->DbgSyms); + ScopeBaseId += CollCount (&O->Scopes); + } +} + + + void CreateDbgFile (void) /* Create a debug info file */ { @@ -69,7 +101,10 @@ void CreateDbgFile (void) /* Output version information */ fprintf (F, "version\tmajor=1,minor=2\n"); - /* Output modules */ + /* Assign the base ids to the modules */ + AssignBaseIds (); + + /* Output modules */ for (I = 0; I < CollCount (&ObjDataList); ++I) { /* Get this object file */ @@ -80,7 +115,7 @@ void CreateDbgFile (void) /* Output the module line */ fprintf (F, - "module\tid=%u,name=\"%s\",file=%u", + "mod\tid=%u,name=\"%s\",file=%u", I, GetObjFileName (O), Source->Id); diff --git a/src/ld65/dbgsyms.c b/src/ld65/dbgsyms.c index de17a61d3..090520adf 100644 --- a/src/ld65/dbgsyms.c +++ b/src/ld65/dbgsyms.c @@ -207,10 +207,9 @@ long GetDbgSymVal (const DbgSym* D) void PrintDbgSyms (FILE* F) /* Print the debug symbols in a debug file */ -{ +{ unsigned I, J; - unsigned BaseId = 0; for (I = 0; I < CollCount (&ObjDataList); ++I) { /* Get the object file */ @@ -230,12 +229,12 @@ void PrintDbgSyms (FILE* F) /* Emit the base data for the entry */ fprintf (F, - "sym\tid=%u,name=\"%s\",value=0x%lX,addrsize=%s,type=%s", - BaseId + J, + "sym\tid=%u,name=\"%s\",val=0x%lX,addrsize=%s,type=%s", + O->SymBaseId + J, GetString (S->Name), Val, AddrSizeToStr (S->AddrSize), - SYM_IS_LABEL (S->Type)? "label" : "equate"); + SYM_IS_LABEL (S->Type)? "lab" : "equ"); /* Emit the size only if we know it */ if (S->Size != 0) { @@ -247,24 +246,21 @@ void PrintDbgSyms (FILE* F) */ GetSegExprVal (S->Expr, &D); if (!D.TooComplex && D.Seg != 0) { - fprintf (F, ",segment=%u", D.Seg->Id); + fprintf (F, ",seg=%u", D.Seg->Id); } /* For cheap local symbols, add the owner symbol, for others, * add the owner scope. */ if (SYM_IS_STD (S->Type)) { - fprintf (F, ",scope=%u", S->OwnerId); + fprintf (F, ",scope=%u", O->ScopeBaseId + S->OwnerId); } else { - fprintf (F, ",parent=%u", S->OwnerId); + fprintf (F, ",parent=%u", O->SymBaseId + S->OwnerId); } /* Terminate the output line */ fputc ('\n', F); } - - /* Increment base id */ - BaseId += CollCount (&O->DbgSyms); } } diff --git a/src/ld65/objdata.c b/src/ld65/objdata.c index ce22898c6..e12fd65bb 100644 --- a/src/ld65/objdata.c +++ b/src/ld65/objdata.c @@ -78,6 +78,9 @@ ObjData* NewObjData (void) O->MTime = 0; O->Start = 0; O->Flags = 0; + O->FileBaseId = 0; + O->SymBaseId = 0; + O->ScopeBaseId = 0; O->Files = EmptyCollection; O->Sections = EmptyCollection; O->Exports = EmptyCollection; diff --git a/src/ld65/objdata.h b/src/ld65/objdata.h index bd838cf3d..9cab25092 100644 --- a/src/ld65/objdata.h +++ b/src/ld65/objdata.h @@ -68,6 +68,11 @@ struct ObjData { ObjHeader Header; /* Header of file */ unsigned long Start; /* Start offset of data in library */ unsigned Flags; + + unsigned FileBaseId; /* Debug info base id for files */ + unsigned SymBaseId; /* Debug info base id for symbols */ + unsigned ScopeBaseId; /* Debug info base if for scopes */ + Collection Files; /* List of input files */ Collection Sections; /* List of all sections */ Collection Exports; /* List of all exports */ @@ -136,7 +141,7 @@ INLINE int ObjHasFiles (const ObjData* O) struct Section* GetObjSection (ObjData* Obj, unsigned Id); /* Get a section from an object file checking for a valid index */ -struct Scope* GetObjScope (ObjData* Obj, unsigned Id); +struct Scope* GetObjScope (ObjData* Obj, unsigned Id); /* Get a scope from an object file checking for a valid index */ diff --git a/src/ld65/scopes.c b/src/ld65/scopes.c index 561a555de..a6832f46a 100644 --- a/src/ld65/scopes.c +++ b/src/ld65/scopes.c @@ -100,7 +100,6 @@ void PrintDbgScopes (FILE* F) unsigned I, J; /* Print scopes from all modules we have linked into the output file */ - unsigned BaseId = 0; for (I = 0; I < CollCount (&ObjDataList); ++I) { /* Get the object file */ @@ -111,8 +110,8 @@ void PrintDbgScopes (FILE* F) const Scope* S = CollConstAt (&O->Scopes, J); fprintf (F, - "scope\tid=%u,name=\"%s\",module=%u,type=%u", - BaseId + S->Id, + "scope\tid=%u,name=\"%s\",mod=%u,type=%u", + O->ScopeBaseId + S->Id, GetString (S->Name), I, S->Type); @@ -123,15 +122,12 @@ void PrintDbgScopes (FILE* F) } /* Print parent if available */ if (S->Id != S->ParentId) { - fprintf (F, ",parent=%u", BaseId + S->ParentId); + fprintf (F, ",parent=%u", O->ScopeBaseId + S->ParentId); } /* Terminate the output line */ fputc ('\n', F); } - - /* Increment scope base id */ - BaseId += CollCount (&O->Scopes); } } diff --git a/src/ld65/segments.c b/src/ld65/segments.c index 518288eea..75a2427b0 100644 --- a/src/ld65/segments.c +++ b/src/ld65/segments.c @@ -641,19 +641,19 @@ void PrintDbgSegments (FILE* F) /* Print the segment data */ fprintf (F, - "segment\tid=%u,name=\"%s\",start=0x%06lX,size=0x%04lX,addrsize=%s,type=%s", + "seg\tid=%u,name=\"%s\",start=0x%06lX,size=0x%04lX,addrsize=%s,type=%s", S->Id, GetString (S->Name), S->PC, S->Size, AddrSizeToStr (S->AddrSize), S->ReadOnly? "ro" : "rw"); if (S->OutputName) { - fprintf (F, ",outputname=\"%s\",outputoffs=%lu", + fprintf (F, ",oname=\"%s\",ooffs=%lu", S->OutputName, S->OutputOffs); } fputc ('\n', F); /* Follow the linked list */ S = S->List; - } + } }