Collection SegInfoById; /* Segment infos sorted by id */
Collection FileInfoByName; /* File infos sorted by name */
Collection FileInfoById; /* File infos sorted by id */
+ Collection LineInfoByAddr; /* Line information sorted by address */
};
/* Input tokens */
cc65_errorfunc Error; /* Function called in case of errors */
unsigned MajorVersion; /* Major version number */
unsigned MinorVersion; /* Minor version number */
- Collection LineInfos; /* Line information */
DbgInfo* Info; /* Pointer to debug info */
};
static void FreeSegInfo (SegInfo* S)
/* Free a SegInfo struct */
{
+ xfree (S->OutputName);
xfree (S);
}
InitCollection (&Info->SegInfoById);
InitCollection (&Info->FileInfoByName);
InitCollection (&Info->FileInfoById);
+ InitCollection (&Info->LineInfoByAddr);
/* Return it */
return Info;
DoneCollection (&Info->FileInfoByName);
DoneCollection (&Info->FileInfoById);
+ /* Free line info */
+ DoneCollection (&Info->LineInfoByAddr);
+
/* Free the structure itself */
xfree (Info);
}
/* Create the line info and remember it */
L = NewLineInfo (File, Segment, Line, Start, End);
- CollAppend (&D->LineInfos, L);
+ CollAppend (&D->Info->LineInfoByAddr, L);
ErrorExit:
/* Entry point in case of errors */
/* Postprocess line infos */
{
/* Get pointers to the collections */
- Collection* LineInfos = &D->LineInfos;
+ Collection* LineInfos = &D->Info->LineInfoByAddr;
Collection* FileInfos = &D->Info->FileInfoByName;
/* Walk over the line infos and replace the id numbers of file and segment
F->Start = ((const LineInfo*) CollFirst (&F->LineInfoByAddr))->Start;
F->End = ((const LineInfo*) CollLast (&F->LineInfoByAddr))->End;
}
-
}
+
+ /* Sort the collection with all line infos by address */
+ CollSort (LineInfos, CompareLineInfoByAddr);
}
0, /* Function called in case of errors */
0, /* Major version number */
0, /* Minor version number */
- COLLECTION_INITIALIZER, /* Line information */
0, /* Pointer to debug info */
};
D.FileName = FileName;
if (D.Errors > 0) {
/* Free allocated stuff */
unsigned I;
- for (I = 0; I < CollCount (&D.LineInfos); ++I) {
- FreeLineInfo (CollAt (&D.LineInfos, I));
+ for (I = 0; I < CollCount (&D.Info->LineInfoByAddr); ++I) {
+ FreeLineInfo (CollAt (&D.Info->LineInfoByAddr, I));
}
- DoneCollection (&D.LineInfos);
+ DoneCollection (&D.Info->LineInfoByAddr);
FreeDbgInfo (D.Info);
return 0;
}
ProcessFileInfo (&D);
ProcessLineInfo (&D);
- /* Free the collection that contained the line info */
- DoneCollection (&D.LineInfos);
-
/* Return the debug info struct that was created */
return D.Info;
}