/* Output version information */
fprintf (F, "version\tmajor=2,minor=0\n");
+ /* Output a line with the item numbers so the debug info module is able
+ * to preallocate the required memory.
+ */
+ fprintf (
+ F,
+ "info\tlib=%u,mod=%u,seg=%u,file=%u,scope=%u\n",
+ LibraryCount (),
+ ObjDataCount (),
+ SegmentCount (),
+ FileInfoCount (),
+ ScopeCount ()
+ );
+
/* Assign the ids to the items */
AssignIds ();
+unsigned FileInfoCount (void)
+/* Return the total number of file infos */
+{
+ return CollCount (&FileInfos);
+}
+
+
+
void AssignFileInfoIds (void)
/* Remove unused file infos and assign the ids to the remaining ones */
{
FileInfo* ReadFileInfo (FILE* F, ObjData* O);
/* Read a file info from a file and return it */
+unsigned FileInfoCount (void);
+/* Return the total number of file infos */
+
void AssignFileInfoIds (void);
/* Assign the ids to the file infos */
static Collection OpenLibs = STATIC_COLLECTION_INITIALIZER;
/* List of used libraries */
-static Collection Libraries = STATIC_COLLECTION_INITIALIZER;
+static Collection LibraryList = STATIC_COLLECTION_INITIALIZER;
/* Flag for library grouping */
static int Grouping = 0;
*/
if (CollCount (&L->Modules) > 0) {
CloseLibrary (L);
- L->Id = CollCount (&Libraries);
- CollAppend (&Libraries, L);
+ L->Id = CollCount (&LibraryList);
+ CollAppend (&LibraryList, L);
} else {
/* Delete the library */
FreeLibrary (L);
+unsigned LibraryCount (void)
+/* Return the total number of libraries */
+{
+ return CollCount (&LibraryList);
+}
+
+
+
void PrintDbgLibraries (FILE* F)
/* Output the libraries to a debug info file */
{
unsigned I;
/* Output information about all libraries */
- for (I = 0; I < CollCount (&Libraries); ++I) {
+ for (I = 0; I < CollCount (&LibraryList); ++I) {
/* Get the library */
- const Library* L = CollAtUnchecked (&Libraries, I);
+ const Library* L = CollAtUnchecked (&LibraryList, I);
/* Output the info */
fprintf (F, "library\tid=%u,name=\"%s\"\n", L->Id, GetString (L->Name));
unsigned GetLibId (const struct Library* L);
/* Get the id of a library file. */
+unsigned LibraryCount (void);
+/* Return the total number of libraries */
+
void PrintDbgLibraries (FILE* F);
/* Output the libraries to a debug info file */
+unsigned ObjDataCount (void)
+/* Return the total number of modules */
+{
+ return CollCount (&ObjDataList);
+}
+
+
+
void PrintDbgModules (FILE* F)
/* Output the modules to a debug info file */
{
struct Scope* GetObjScope (ObjData* Obj, unsigned Id);
/* Get a scope from an object file checking for a valid index */
+unsigned ObjDataCount (void);
+/* Return the total number of modules */
+
void PrintDbgModules (FILE* F);
/* Output the modules to a debug info file */
+unsigned ScopeCount (void)
+/* Return the total number of scopes */
+{
+
+ /* Count scopes from all modules we have linked into the output file */
+ unsigned I;
+ unsigned Count = 0;
+ for (I = 0; I < CollCount (&ObjDataList); ++I) {
+ /* Get the object file */
+ const ObjData* O = CollAtUnchecked (&ObjDataList, I);
+
+ /* Account for the scopes in this file */
+ Count += CollCount (&O->Scopes);
+ }
+ return Count;
+}
+
+
+
void PrintDbgScopes (FILE* F)
/* Output the scopes to a debug info file */
{
if (SCOPE_HAS_LABEL (S->Flags)) {
fprintf (F, ",sym=%u", O->SymBaseId + S->LabelId);
}
-
+
/* Terminate the output line */
fputc ('\n', F);
}
ObjData* Obj; /* Object file that contains the scope */
unsigned ParentId; /* Id of parent scope */
unsigned LabelId; /* Id of the scope label if any */
- unsigned LexicalLevel; /* Lexical level */
+ unsigned LexicalLevel; /* Lexical level */
unsigned Flags;
unsigned Type; /* Type of scope */
unsigned Name; /* Name of scope */
Scope* ReadScope (FILE* F, ObjData* Obj, unsigned Id);
/* Read a scope from a file, insert and return it */
+unsigned ScopeCount (void);
+/* Return the total number of scopes */
+
void PrintDbgScopes (FILE* F);
/* Output the scopes to a debug info file */
unsigned I;
unsigned long Count;
unsigned char* Data;
-
+
for (I = 0; I < CollCount (&SegmentList); ++I) {
const Segment* Seg = CollConstAt (&SegmentList, I);
Section* S = Seg->SecRoot;
+unsigned SegmentCount (void)
+/* Return the total number of segments */
+{
+ return CollCount (&SegmentList);
+}
+
+
+
static int CmpSegStart (const void* K1, const void* K2)
/* Compare function for qsort */
{
void PrintDbgSegments (FILE* F)
/* Output the segments to the debug file */
-{
+{
/* Walk over all segments */
unsigned I;
for (I = 0; I < CollCount (&SegmentList); ++I) {
* called (see description of SegWriteFunc above).
*/
+unsigned SegmentCount (void);
+/* Return the total number of segments */
+
void PrintSegmentMap (FILE* F);
/* Print a segment map to the given file */