From: uz Date: Mon, 22 Aug 2011 18:22:45 +0000 (+0000) Subject: Maintain the types as separate indexed items in the debug info file. X-Git-Tag: V2.13.3~199 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=374b106b06ee355613e39ac802a4a2988ee7d95a;p=cc65 Maintain the types as separate indexed items in the debug info file. git-svn-id: svn://svn.cc65.org/cc65/trunk@5263 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ld65/dbgfile.c b/src/ld65/dbgfile.c index 5f56460b5..358849100 100644 --- a/src/ld65/dbgfile.c +++ b/src/ld65/dbgfile.c @@ -47,7 +47,8 @@ #include "lineinfo.h" #include "scopes.h" #include "segments.h" -#include "span.h" +#include "span.h" +#include "tpool.h" @@ -114,13 +115,14 @@ void CreateDbgFile (void) */ fprintf ( F, - "info\tfile=%u,lib=%u,mod=%u,scope=%u,seg=%u,span=%u\n", + "info\tfile=%u,lib=%u,mod=%u,scope=%u,seg=%u,span=%u,type=%u\n", FileInfoCount (), LibraryCount (), ObjDataCount (), ScopeCount (), SegmentCount (), - SpanCount () + SpanCount (), + TypeCount () ); /* Assign the ids to the items */ @@ -143,6 +145,9 @@ void CreateDbgFile (void) /* Output spans */ PrintDbgSpans (F); + + /* Output types */ + PrintDbgTypes (F); /* Output symbols */ PrintDbgSyms (F); diff --git a/src/ld65/main.c b/src/ld65/main.c index 78aab4baf..6a0c09c06 100644 --- a/src/ld65/main.c +++ b/src/ld65/main.c @@ -68,6 +68,7 @@ #include "segments.h" #include "spool.h" #include "tgtcfg.h" +#include "tpool.h" @@ -554,6 +555,9 @@ int main (int argc, char* argv []) /* Initialize the string pool */ InitStrPool (); + /* Initialize the type pool */ + InitTypePool (); + /* Check the parameters */ I = 1; while (I < ArgCount) { diff --git a/src/ld65/objdata.c b/src/ld65/objdata.c index b0a17d0e9..efd4145c3 100644 --- a/src/ld65/objdata.c +++ b/src/ld65/objdata.c @@ -199,7 +199,15 @@ const char* GetObjFileName (const ObjData* O) -struct Section* GetObjSection (ObjData* O, unsigned Id) +const struct StrBuf* GetObjString (const ObjData* Obj, unsigned Id) +/* Get a string from an object file checking for an invalid index */ +{ + return GetStrBuf (MakeGlobalStringId (Obj, Id)); +} + + + +struct Section* GetObjSection (const ObjData* O, unsigned Id) /* Get a section from an object file checking for a valid index */ { if (Id >= CollCount (&O->Sections)) { @@ -211,7 +219,7 @@ struct Section* GetObjSection (ObjData* O, unsigned Id) -struct Import* GetObjImport (ObjData* O, unsigned Id) +struct Import* GetObjImport (const ObjData* O, unsigned Id) /* Get an import from an object file checking for a valid index */ { if (Id >= CollCount (&O->Imports)) { @@ -223,7 +231,7 @@ struct Import* GetObjImport (ObjData* O, unsigned Id) -struct Export* GetObjExport (ObjData* O, unsigned Id) +struct Export* GetObjExport (const ObjData* O, unsigned Id) /* Get an export from an object file checking for a valid index */ { if (Id >= CollCount (&O->Exports)) { @@ -235,7 +243,7 @@ struct Export* GetObjExport (ObjData* O, unsigned Id) -struct Scope* GetObjScope (ObjData* O, unsigned Id) +struct Scope* GetObjScope (const ObjData* O, unsigned Id) /* Get a scope from an object file checking for a valid index */ { if (Id >= CollCount (&O->Scopes)) { diff --git a/src/ld65/objdata.h b/src/ld65/objdata.h index 77d75f064..52a266375 100644 --- a/src/ld65/objdata.h +++ b/src/ld65/objdata.h @@ -57,6 +57,7 @@ struct Import; struct Library; struct Scope; struct Section; +struct StrBuf; /* Values for the Flags field */ #define OBJ_REF 0x0001 /* We have a reference to this file */ @@ -143,16 +144,19 @@ INLINE int ObjHasFiles (const ObjData* O) # define ObjHasFiles(O) ((O) != 0 && CollCount (&(O)->Files) != 0) #endif -struct Section* GetObjSection (ObjData* Obj, unsigned Id); +const struct StrBuf* GetObjString (const ObjData* Obj, unsigned Id); +/* Get a string from an object file checking for an invalid index */ + +struct Section* GetObjSection (const ObjData* Obj, unsigned Id); /* Get a section from an object file checking for a valid index */ -struct Import* GetObjImport (ObjData* Obj, unsigned Id); +struct Import* GetObjImport (const ObjData* Obj, unsigned Id); /* Get an import from an object file checking for a valid index */ -struct Export* GetObjExport (ObjData* Obj, unsigned Id); +struct Export* GetObjExport (const ObjData* Obj, unsigned Id); /* Get an export from an object file checking for a valid index */ -struct Scope* GetObjScope (ObjData* Obj, unsigned Id); +struct Scope* GetObjScope (const ObjData* Obj, unsigned Id); /* Get a scope from an object file checking for a valid index */ unsigned ObjDataCount (void); diff --git a/src/ld65/span.c b/src/ld65/span.c index 877875e00..0ff1e7e1a 100644 --- a/src/ld65/span.c +++ b/src/ld65/span.c @@ -42,7 +42,7 @@ #include "objdata.h" #include "segments.h" #include "span.h" -#include "spool.h" +#include "tpool.h" @@ -87,12 +87,21 @@ static Span* NewSpan (unsigned Id) Span* ReadSpan (FILE* F, ObjData* O, unsigned Id) /* Read a Span from a file and return it */ { + unsigned Type; + /* Create a new Span and initialize it */ Span* S = NewSpan (Id); S->Sec = ReadVar (F); S->Offs = ReadVar (F); S->Size = ReadVar (F); - S->Type = MakeGlobalStringId (O, ReadVar (F)); + + /* Read the type. An id of zero means an empty string (no need to check) */ + Type = ReadVar (F); + if (Type == 0) { + S->Type = INVALID_TYPE_ID; + } else { + S->Type = GetTypeId (GetObjString (O, Type)); + } /* Return the new span */ return S; @@ -193,8 +202,6 @@ void PrintDbgSpans (FILE* F) /* Walk over all spans in this object file */ for (J = 0; J < CollCount (&O->Spans); ++J) { - const StrBuf* Type; - /* Get this span */ const Span* S = CollAtUnchecked (&O->Spans, J); @@ -209,9 +216,8 @@ void PrintDbgSpans (FILE* F) S->Size); /* If we have a type, add it */ - Type = GetStrBuf (S->Type); - if (SB_GetLen (Type) > 0) { - fprintf (F, ",type=\"%s\"", GT_AsString (Type, &SpanType)); + if (S->Type != INVALID_TYPE_ID) { + fprintf (F, ",type=%u", S->Type); } /* Terminate the output line */ diff --git a/src/ld65/tpool.c b/src/ld65/tpool.c index 07b4bb3a3..06957cb5d 100644 --- a/src/ld65/tpool.c +++ b/src/ld65/tpool.c @@ -33,6 +33,9 @@ +/* common */ +#include "gentype.h" + /* ld65 */ #include "tpool.h" @@ -55,16 +58,35 @@ StringPool* TypePool = 0; +void PrintDbgTypes (FILE* F) +/* Output the types to a debug info file */ +{ + StrBuf Type = STATIC_STRBUF_INITIALIZER; + + /* Get the number of strings in the type pool */ + unsigned Count = SP_GetCount (TypePool); + + /* Output all of them */ + unsigned Id; + for (Id = 0; Id < Count; ++Id) { + + /* Output it */ + fprintf (F, "type\tid=%u,val=\"%s\"\n", Id, + GT_AsString (SP_Get (TypePool, Id), &Type)); + + } + + /* Free the memory for the temporary string */ + SB_Done (&Type); +} + + + void InitTypePool (void) /* Initialize the type pool */ { /* Allocate a type pool */ TypePool = NewStringPool (137); - - /* We insert the empty string as first entry here, so it will have id - * zero. - */ - SP_AddStr (TypePool, ""); } diff --git a/src/ld65/tpool.h b/src/ld65/tpool.h index 09a3eae2e..2b1a63dd1 100644 --- a/src/ld65/tpool.h +++ b/src/ld65/tpool.h @@ -38,6 +38,8 @@ +#include + /* common */ #include "strpool.h" @@ -49,8 +51,8 @@ -/* An empty type */ -#define EMPTY_TYPE_ID 0U +/* An invalid type */ +#define INVALID_TYPE_ID (~0U) /* The string pool we're using */ extern StringPool* TypePool; @@ -83,6 +85,19 @@ INLINE const StrBuf* GetType (unsigned Index) # define GetType(Index) SP_Get (TypePool, (Index)) #endif +#if defined(HAVE_INLINE) +INLINE unsigned TypeCount (void) +/* Return the number of types in the pool */ +{ + return SP_GetCount (TypePool); +} +#else +# define TypeCount() SP_GetCount (TypePool) +#endif + +void PrintDbgTypes (FILE* F); +/* Output the types to a debug info file */ + void InitTypePool (void); /* Initialize the type pool */