/*****************************************************************************/
-/* 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 */
{
/* 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 */
/* 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);
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 */
/* 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) {
*/
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);
}
}
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;
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 */
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 */
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 */
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);
}
/* 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);
}
}
/* 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;
- }
+ }
}