1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-31 11:32:00 +00:00

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
This commit is contained in:
uz 2011-08-22 18:22:45 +00:00
parent b064002266
commit 374b106b06
7 changed files with 89 additions and 25 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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)) {

View File

@ -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);

View File

@ -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 */

View File

@ -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, "");
}

View File

@ -38,6 +38,8 @@
#include <stdio.h>
/* 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 */