#include "lineinfo.h"
#include "scopes.h"
#include "segments.h"
-#include "span.h"
+#include "span.h"
+#include "tpool.h"
*/
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 */
/* Output spans */
PrintDbgSpans (F);
+
+ /* Output types */
+ PrintDbgTypes (F);
/* Output symbols */
PrintDbgSyms (F);
#include "segments.h"
#include "spool.h"
#include "tgtcfg.h"
+#include "tpool.h"
/* Initialize the string pool */
InitStrPool ();
+ /* Initialize the type pool */
+ InitTypePool ();
+
/* Check the parameters */
I = 1;
while (I < ArgCount) {
-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)) {
-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)) {
-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)) {
-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)) {
struct Library;
struct Scope;
struct Section;
+struct StrBuf;
/* Values for the Flags field */
#define OBJ_REF 0x0001 /* We have a reference to this file */
# 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);
#include "objdata.h"
#include "segments.h"
#include "span.h"
-#include "spool.h"
+#include "tpool.h"
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;
/* 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);
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 */
+/* common */
+#include "gentype.h"
+
/* ld65 */
#include "tpool.h"
+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, "");
}
+#include <stdio.h>
+
/* common */
#include "strpool.h"
-/* 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;
# 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 */