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:
parent
b064002266
commit
374b106b06
7 changed files with 89 additions and 25 deletions
|
@ -48,6 +48,7 @@
|
||||||
#include "scopes.h"
|
#include "scopes.h"
|
||||||
#include "segments.h"
|
#include "segments.h"
|
||||||
#include "span.h"
|
#include "span.h"
|
||||||
|
#include "tpool.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,13 +115,14 @@ void CreateDbgFile (void)
|
||||||
*/
|
*/
|
||||||
fprintf (
|
fprintf (
|
||||||
F,
|
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 (),
|
FileInfoCount (),
|
||||||
LibraryCount (),
|
LibraryCount (),
|
||||||
ObjDataCount (),
|
ObjDataCount (),
|
||||||
ScopeCount (),
|
ScopeCount (),
|
||||||
SegmentCount (),
|
SegmentCount (),
|
||||||
SpanCount ()
|
SpanCount (),
|
||||||
|
TypeCount ()
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Assign the ids to the items */
|
/* Assign the ids to the items */
|
||||||
|
@ -144,6 +146,9 @@ void CreateDbgFile (void)
|
||||||
/* Output spans */
|
/* Output spans */
|
||||||
PrintDbgSpans (F);
|
PrintDbgSpans (F);
|
||||||
|
|
||||||
|
/* Output types */
|
||||||
|
PrintDbgTypes (F);
|
||||||
|
|
||||||
/* Output symbols */
|
/* Output symbols */
|
||||||
PrintDbgSyms (F);
|
PrintDbgSyms (F);
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
#include "segments.h"
|
#include "segments.h"
|
||||||
#include "spool.h"
|
#include "spool.h"
|
||||||
#include "tgtcfg.h"
|
#include "tgtcfg.h"
|
||||||
|
#include "tpool.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -554,6 +555,9 @@ int main (int argc, char* argv [])
|
||||||
/* Initialize the string pool */
|
/* Initialize the string pool */
|
||||||
InitStrPool ();
|
InitStrPool ();
|
||||||
|
|
||||||
|
/* Initialize the type pool */
|
||||||
|
InitTypePool ();
|
||||||
|
|
||||||
/* Check the parameters */
|
/* Check the parameters */
|
||||||
I = 1;
|
I = 1;
|
||||||
while (I < ArgCount) {
|
while (I < ArgCount) {
|
||||||
|
|
|
@ -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 */
|
/* Get a section from an object file checking for a valid index */
|
||||||
{
|
{
|
||||||
if (Id >= CollCount (&O->Sections)) {
|
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 */
|
/* Get an import from an object file checking for a valid index */
|
||||||
{
|
{
|
||||||
if (Id >= CollCount (&O->Imports)) {
|
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 */
|
/* Get an export from an object file checking for a valid index */
|
||||||
{
|
{
|
||||||
if (Id >= CollCount (&O->Exports)) {
|
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 */
|
/* Get a scope from an object file checking for a valid index */
|
||||||
{
|
{
|
||||||
if (Id >= CollCount (&O->Scopes)) {
|
if (Id >= CollCount (&O->Scopes)) {
|
||||||
|
|
|
@ -57,6 +57,7 @@ struct Import;
|
||||||
struct Library;
|
struct Library;
|
||||||
struct Scope;
|
struct Scope;
|
||||||
struct Section;
|
struct Section;
|
||||||
|
struct StrBuf;
|
||||||
|
|
||||||
/* Values for the Flags field */
|
/* Values for the Flags field */
|
||||||
#define OBJ_REF 0x0001 /* We have a reference to this file */
|
#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)
|
# define ObjHasFiles(O) ((O) != 0 && CollCount (&(O)->Files) != 0)
|
||||||
#endif
|
#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 */
|
/* 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 */
|
/* 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 */
|
/* 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 */
|
/* Get a scope from an object file checking for a valid index */
|
||||||
|
|
||||||
unsigned ObjDataCount (void);
|
unsigned ObjDataCount (void);
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "objdata.h"
|
#include "objdata.h"
|
||||||
#include "segments.h"
|
#include "segments.h"
|
||||||
#include "span.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)
|
Span* ReadSpan (FILE* F, ObjData* O, unsigned Id)
|
||||||
/* Read a Span from a file and return it */
|
/* Read a Span from a file and return it */
|
||||||
{
|
{
|
||||||
|
unsigned Type;
|
||||||
|
|
||||||
/* Create a new Span and initialize it */
|
/* Create a new Span and initialize it */
|
||||||
Span* S = NewSpan (Id);
|
Span* S = NewSpan (Id);
|
||||||
S->Sec = ReadVar (F);
|
S->Sec = ReadVar (F);
|
||||||
S->Offs = ReadVar (F);
|
S->Offs = ReadVar (F);
|
||||||
S->Size = 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 the new span */
|
||||||
return S;
|
return S;
|
||||||
|
@ -193,8 +202,6 @@ void PrintDbgSpans (FILE* F)
|
||||||
/* Walk over all spans in this object file */
|
/* Walk over all spans in this object file */
|
||||||
for (J = 0; J < CollCount (&O->Spans); ++J) {
|
for (J = 0; J < CollCount (&O->Spans); ++J) {
|
||||||
|
|
||||||
const StrBuf* Type;
|
|
||||||
|
|
||||||
/* Get this span */
|
/* Get this span */
|
||||||
const Span* S = CollAtUnchecked (&O->Spans, J);
|
const Span* S = CollAtUnchecked (&O->Spans, J);
|
||||||
|
|
||||||
|
@ -209,9 +216,8 @@ void PrintDbgSpans (FILE* F)
|
||||||
S->Size);
|
S->Size);
|
||||||
|
|
||||||
/* If we have a type, add it */
|
/* If we have a type, add it */
|
||||||
Type = GetStrBuf (S->Type);
|
if (S->Type != INVALID_TYPE_ID) {
|
||||||
if (SB_GetLen (Type) > 0) {
|
fprintf (F, ",type=%u", S->Type);
|
||||||
fprintf (F, ",type=\"%s\"", GT_AsString (Type, &SpanType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the output line */
|
/* Terminate the output line */
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* common */
|
||||||
|
#include "gentype.h"
|
||||||
|
|
||||||
/* ld65 */
|
/* ld65 */
|
||||||
#include "tpool.h"
|
#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)
|
void InitTypePool (void)
|
||||||
/* Initialize the type pool */
|
/* Initialize the type pool */
|
||||||
{
|
{
|
||||||
/* Allocate a type pool */
|
/* Allocate a type pool */
|
||||||
TypePool = NewStringPool (137);
|
TypePool = NewStringPool (137);
|
||||||
|
|
||||||
/* We insert the empty string as first entry here, so it will have id
|
|
||||||
* zero.
|
|
||||||
*/
|
|
||||||
SP_AddStr (TypePool, "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
#include "strpool.h"
|
#include "strpool.h"
|
||||||
|
|
||||||
|
@ -49,8 +51,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* An empty type */
|
/* An invalid type */
|
||||||
#define EMPTY_TYPE_ID 0U
|
#define INVALID_TYPE_ID (~0U)
|
||||||
|
|
||||||
/* The string pool we're using */
|
/* The string pool we're using */
|
||||||
extern StringPool* TypePool;
|
extern StringPool* TypePool;
|
||||||
|
@ -83,6 +85,19 @@ INLINE const StrBuf* GetType (unsigned Index)
|
||||||
# define GetType(Index) SP_Get (TypePool, (Index))
|
# define GetType(Index) SP_Get (TypePool, (Index))
|
||||||
#endif
|
#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);
|
void InitTypePool (void);
|
||||||
/* Initialize the type pool */
|
/* Initialize the type pool */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue