mirror of
https://github.com/cc65/cc65.git
synced 2025-01-27 09:33:42 +00:00
Output library information to the debug file.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5127 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
b418fdf985
commit
af3a5e6e15
@ -43,6 +43,7 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "fileinfo.h"
|
#include "fileinfo.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "library.h"
|
||||||
#include "lineinfo.h"
|
#include "lineinfo.h"
|
||||||
#include "scopes.h"
|
#include "scopes.h"
|
||||||
#include "segments.h"
|
#include "segments.h"
|
||||||
@ -104,7 +105,10 @@ void CreateDbgFile (void)
|
|||||||
/* Assign the base ids to the modules */
|
/* Assign the base ids to the modules */
|
||||||
AssignBaseIds ();
|
AssignBaseIds ();
|
||||||
|
|
||||||
/* Output modules */
|
/* Output libraries */
|
||||||
|
PrintDbgLibraries (F);
|
||||||
|
|
||||||
|
/* Output modules */
|
||||||
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||||
|
|
||||||
/* Get this object file */
|
/* Get this object file */
|
||||||
@ -121,11 +125,8 @@ void CreateDbgFile (void)
|
|||||||
Source->Id);
|
Source->Id);
|
||||||
|
|
||||||
/* Add library if any */
|
/* Add library if any */
|
||||||
if (O->LibName != INVALID_STRING_ID) {
|
if (O->Lib != 0) {
|
||||||
fprintf (F,
|
fprintf (F, ",lib=%u", GetLibId (O->Lib));
|
||||||
",lib=\"%s\",mtime=0x%08lX",
|
|
||||||
GetString (O->LibName),
|
|
||||||
O->MTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the output line */
|
/* Terminate the output line */
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
/* Library data structure */
|
/* Library data structure */
|
||||||
typedef struct Library Library;
|
typedef struct Library Library;
|
||||||
struct Library {
|
struct Library {
|
||||||
|
unsigned Id; /* Id of library */
|
||||||
unsigned Name; /* String id of the name */
|
unsigned Name; /* String id of the name */
|
||||||
FILE* F; /* Open file stream */
|
FILE* F; /* Open file stream */
|
||||||
LibHeader Header; /* Library header */
|
LibHeader Header; /* Library header */
|
||||||
@ -74,6 +75,9 @@ struct Library {
|
|||||||
/* List of open libraries */
|
/* List of open libraries */
|
||||||
static Collection OpenLibs = STATIC_COLLECTION_INITIALIZER;
|
static Collection OpenLibs = STATIC_COLLECTION_INITIALIZER;
|
||||||
|
|
||||||
|
/* List of used libraries */
|
||||||
|
static Collection Libraries = STATIC_COLLECTION_INITIALIZER;
|
||||||
|
|
||||||
/* Flag for library grouping */
|
/* Flag for library grouping */
|
||||||
static int Grouping = 0;
|
static int Grouping = 0;
|
||||||
|
|
||||||
@ -92,6 +96,7 @@ static Library* NewLibrary (FILE* F, const char* Name)
|
|||||||
Library* L = xmalloc (sizeof (*L));
|
Library* L = xmalloc (sizeof (*L));
|
||||||
|
|
||||||
/* Initialize the fields */
|
/* Initialize the fields */
|
||||||
|
L->Id = ~0U;
|
||||||
L->Name = GetStringId (Name);
|
L->Name = GetStringId (Name);
|
||||||
L->F = F;
|
L->F = F;
|
||||||
L->Modules = EmptyCollection;
|
L->Modules = EmptyCollection;
|
||||||
@ -102,13 +107,23 @@ static Library* NewLibrary (FILE* F, const char* Name)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void FreeLibrary (Library* L)
|
static void CloseLibrary (Library* L)
|
||||||
/* Free a library structure */
|
/* Close a library file and remove the list of modules */
|
||||||
{
|
{
|
||||||
/* Close the library file */
|
/* Close the library file */
|
||||||
if (fclose (L->F) != 0) {
|
if (fclose (L->F) != 0) {
|
||||||
Error ("Error closing `%s': %s", GetString (L->Name), strerror (errno));
|
Error ("Error closing `%s': %s", GetString (L->Name), strerror (errno));
|
||||||
}
|
}
|
||||||
|
L->F = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void FreeLibrary (Library* L)
|
||||||
|
/* Free a library structure */
|
||||||
|
{
|
||||||
|
/* Close the library */
|
||||||
|
CloseLibrary (L);
|
||||||
|
|
||||||
/* Free the module index */
|
/* Free the module index */
|
||||||
DoneCollection (&L->Modules);
|
DoneCollection (&L->Modules);
|
||||||
@ -196,7 +211,7 @@ static ObjData* ReadIndexEntry (Library* L)
|
|||||||
ObjData* O = NewObjData ();
|
ObjData* O = NewObjData ();
|
||||||
|
|
||||||
/* Remember from which library this module is */
|
/* Remember from which library this module is */
|
||||||
O->LibName = L->Name;
|
O->Lib = L;
|
||||||
|
|
||||||
/* Module name */
|
/* Module name */
|
||||||
O->Name = ReadStr (L->F);
|
O->Name = ReadStr (L->F);
|
||||||
@ -365,7 +380,8 @@ static void LibResolve (void)
|
|||||||
/* Walk over all modules in this library and add the files list and
|
/* Walk over all modules in this library and add the files list and
|
||||||
* sections for all referenced modules.
|
* sections for all referenced modules.
|
||||||
*/
|
*/
|
||||||
for (J = 0; J < CollCount (&L->Modules); ++J) {
|
J = 0;
|
||||||
|
while (J < CollCount (&L->Modules)) {
|
||||||
|
|
||||||
/* Get the object data */
|
/* Get the object data */
|
||||||
ObjData* O = CollAtUnchecked (&L->Modules, J);
|
ObjData* O = CollAtUnchecked (&L->Modules, J);
|
||||||
@ -398,16 +414,30 @@ static void LibResolve (void)
|
|||||||
/* Insert the object into the list of all used object files */
|
/* Insert the object into the list of all used object files */
|
||||||
InsertObjData (O);
|
InsertObjData (O);
|
||||||
|
|
||||||
|
/* Process next object file in library */
|
||||||
|
++J;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* Unreferenced object file, remove it */
|
/* Unreferenced object file, remove it */
|
||||||
FreeObjData (O);
|
FreeObjData (O);
|
||||||
|
CollDelete (&L->Modules, J);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the file and delete the library data */
|
/* If we have referenced modules in this library, assign it an id
|
||||||
FreeLibrary (L);
|
* (which is the index in the library collection) and keep it.
|
||||||
|
*/
|
||||||
|
if (CollCount (&L->Modules) > 0) {
|
||||||
|
CloseLibrary (L);
|
||||||
|
L->Id = CollCount (&Libraries);
|
||||||
|
CollAppend (&Libraries, L);
|
||||||
|
} else {
|
||||||
|
/* Delete the library */
|
||||||
|
FreeLibrary (L);
|
||||||
|
CollDelete (&OpenLibs, I);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We're done with all open libraries, clear the OpenLibs collection */
|
/* We're done with all open libraries, clear the OpenLibs collection */
|
||||||
@ -480,3 +510,37 @@ void LibCheckGroup (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char* GetLibFileName (const Library* L)
|
||||||
|
/* Get the name of a library */
|
||||||
|
{
|
||||||
|
return GetString (L->Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned GetLibId (const Library* L)
|
||||||
|
/* Get the id of a library file. */
|
||||||
|
{
|
||||||
|
return L->Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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) {
|
||||||
|
/* Get the library */
|
||||||
|
const Library* L = CollAtUnchecked (&Libraries, I);
|
||||||
|
|
||||||
|
/* Output the info */
|
||||||
|
fprintf (F, "library\tid=%u,name=\"%s\"\n", L->Id, GetString (L->Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2005 Ullrich von Bassewitz */
|
/* (C) 1998-2011, Ullrich von Bassewitz */
|
||||||
/* Römerstraße 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -39,7 +39,18 @@
|
|||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Opaque structure */
|
||||||
|
struct Library;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Code */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
@ -64,6 +75,15 @@ void LibEndGroup (void);
|
|||||||
void LibCheckGroup (void);
|
void LibCheckGroup (void);
|
||||||
/* Check if there are open library groups */
|
/* Check if there are open library groups */
|
||||||
|
|
||||||
|
const char* GetLibFileName (const struct Library* L);
|
||||||
|
/* Get the name of a library */
|
||||||
|
|
||||||
|
unsigned GetLibId (const struct Library* L);
|
||||||
|
/* Get the id of a library file. */
|
||||||
|
|
||||||
|
void PrintDbgLibraries (FILE* F);
|
||||||
|
/* Output the libraries to a debug info file */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of library.h */
|
/* End of library.h */
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "exports.h"
|
#include "exports.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "library.h"
|
||||||
#include "mapfile.h"
|
#include "mapfile.h"
|
||||||
#include "objdata.h"
|
#include "objdata.h"
|
||||||
#include "segments.h"
|
#include "segments.h"
|
||||||
@ -80,9 +81,9 @@ void CreateMapFile (int ShortMap)
|
|||||||
const ObjData* O = CollConstAt (&ObjDataList, I);
|
const ObjData* O = CollConstAt (&ObjDataList, I);
|
||||||
|
|
||||||
/* Output the data */
|
/* Output the data */
|
||||||
if (O->LibName != INVALID_STRING_ID) {
|
if (O->Lib) {
|
||||||
/* The file is from a library */
|
/* The file is from a library */
|
||||||
fprintf (F, "%s(%s):\n", GetString (O->LibName), GetObjFileName (O));
|
fprintf (F, "%s(%s):\n", GetLibFileName (O->Lib), GetObjFileName (O));
|
||||||
} else {
|
} else {
|
||||||
fprintf (F, "%s:\n", GetObjFileName (O));
|
fprintf (F, "%s:\n", GetObjFileName (O));
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ ObjData* NewObjData (void)
|
|||||||
/* Initialize the data */
|
/* Initialize the data */
|
||||||
O->Next = 0;
|
O->Next = 0;
|
||||||
O->Name = INVALID_STRING_ID;
|
O->Name = INVALID_STRING_ID;
|
||||||
O->LibName = INVALID_STRING_ID;
|
O->Lib = 0;
|
||||||
O->MTime = 0;
|
O->MTime = 0;
|
||||||
O->Start = 0;
|
O->Start = 0;
|
||||||
O->Flags = 0;
|
O->Flags = 0;
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Forwards */
|
/* Forwards */
|
||||||
|
struct Library;
|
||||||
struct Scope;
|
struct Scope;
|
||||||
struct Section;
|
struct Section;
|
||||||
|
|
||||||
@ -63,11 +64,11 @@ typedef struct ObjData ObjData;
|
|||||||
struct ObjData {
|
struct ObjData {
|
||||||
ObjData* Next; /* Linked list of all objects */
|
ObjData* Next; /* Linked list of all objects */
|
||||||
unsigned Name; /* Module name */
|
unsigned Name; /* Module name */
|
||||||
unsigned LibName; /* Name of library */
|
struct Library* Lib; /* Library where module comes from */
|
||||||
unsigned long MTime; /* Time of last modification */
|
unsigned long MTime; /* Time of last modification */
|
||||||
ObjHeader Header; /* Header of file */
|
ObjHeader Header; /* Header of file */
|
||||||
unsigned long Start; /* Start offset of data in library */
|
unsigned long Start; /* Start offset of data in library */
|
||||||
unsigned Flags;
|
unsigned Flags;
|
||||||
|
|
||||||
unsigned FileBaseId; /* Debug info base id for files */
|
unsigned FileBaseId; /* Debug info base id for files */
|
||||||
unsigned SymBaseId; /* Debug info base id for symbols */
|
unsigned SymBaseId; /* Debug info base id for symbols */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user