Central management of the debug info base ids.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5123 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -55,6 +55,38 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
void CreateDbgFile (void)
|
||||||
/* Create a debug info file */
|
/* Create a debug info file */
|
||||||
{
|
{
|
||||||
@@ -69,6 +101,9 @@ void CreateDbgFile (void)
|
|||||||
/* Output version information */
|
/* Output version information */
|
||||||
fprintf (F, "version\tmajor=1,minor=2\n");
|
fprintf (F, "version\tmajor=1,minor=2\n");
|
||||||
|
|
||||||
|
/* Assign the base ids to the modules */
|
||||||
|
AssignBaseIds ();
|
||||||
|
|
||||||
/* Output modules */
|
/* Output modules */
|
||||||
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||||
|
|
||||||
@@ -80,7 +115,7 @@ void CreateDbgFile (void)
|
|||||||
|
|
||||||
/* Output the module line */
|
/* Output the module line */
|
||||||
fprintf (F,
|
fprintf (F,
|
||||||
"module\tid=%u,name=\"%s\",file=%u",
|
"mod\tid=%u,name=\"%s\",file=%u",
|
||||||
I,
|
I,
|
||||||
GetObjFileName (O),
|
GetObjFileName (O),
|
||||||
Source->Id);
|
Source->Id);
|
||||||
|
|||||||
@@ -210,7 +210,6 @@ void PrintDbgSyms (FILE* F)
|
|||||||
{
|
{
|
||||||
unsigned I, J;
|
unsigned I, J;
|
||||||
|
|
||||||
unsigned BaseId = 0;
|
|
||||||
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||||
|
|
||||||
/* Get the object file */
|
/* Get the object file */
|
||||||
@@ -230,12 +229,12 @@ void PrintDbgSyms (FILE* F)
|
|||||||
|
|
||||||
/* Emit the base data for the entry */
|
/* Emit the base data for the entry */
|
||||||
fprintf (F,
|
fprintf (F,
|
||||||
"sym\tid=%u,name=\"%s\",value=0x%lX,addrsize=%s,type=%s",
|
"sym\tid=%u,name=\"%s\",val=0x%lX,addrsize=%s,type=%s",
|
||||||
BaseId + J,
|
O->SymBaseId + J,
|
||||||
GetString (S->Name),
|
GetString (S->Name),
|
||||||
Val,
|
Val,
|
||||||
AddrSizeToStr (S->AddrSize),
|
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 */
|
/* Emit the size only if we know it */
|
||||||
if (S->Size != 0) {
|
if (S->Size != 0) {
|
||||||
@@ -247,24 +246,21 @@ void PrintDbgSyms (FILE* F)
|
|||||||
*/
|
*/
|
||||||
GetSegExprVal (S->Expr, &D);
|
GetSegExprVal (S->Expr, &D);
|
||||||
if (!D.TooComplex && D.Seg != 0) {
|
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,
|
/* For cheap local symbols, add the owner symbol, for others,
|
||||||
* add the owner scope.
|
* add the owner scope.
|
||||||
*/
|
*/
|
||||||
if (SYM_IS_STD (S->Type)) {
|
if (SYM_IS_STD (S->Type)) {
|
||||||
fprintf (F, ",scope=%u", S->OwnerId);
|
fprintf (F, ",scope=%u", O->ScopeBaseId + S->OwnerId);
|
||||||
} else {
|
} else {
|
||||||
fprintf (F, ",parent=%u", S->OwnerId);
|
fprintf (F, ",parent=%u", O->SymBaseId + S->OwnerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the output line */
|
/* Terminate the output line */
|
||||||
fputc ('\n', F);
|
fputc ('\n', F);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increment base id */
|
|
||||||
BaseId += CollCount (&O->DbgSyms);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ ObjData* NewObjData (void)
|
|||||||
O->MTime = 0;
|
O->MTime = 0;
|
||||||
O->Start = 0;
|
O->Start = 0;
|
||||||
O->Flags = 0;
|
O->Flags = 0;
|
||||||
|
O->FileBaseId = 0;
|
||||||
|
O->SymBaseId = 0;
|
||||||
|
O->ScopeBaseId = 0;
|
||||||
O->Files = EmptyCollection;
|
O->Files = EmptyCollection;
|
||||||
O->Sections = EmptyCollection;
|
O->Sections = EmptyCollection;
|
||||||
O->Exports = EmptyCollection;
|
O->Exports = EmptyCollection;
|
||||||
|
|||||||
@@ -68,6 +68,11 @@ struct ObjData {
|
|||||||
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 SymBaseId; /* Debug info base id for symbols */
|
||||||
|
unsigned ScopeBaseId; /* Debug info base if for scopes */
|
||||||
|
|
||||||
Collection Files; /* List of input files */
|
Collection Files; /* List of input files */
|
||||||
Collection Sections; /* List of all sections */
|
Collection Sections; /* List of all sections */
|
||||||
Collection Exports; /* List of all exports */
|
Collection Exports; /* List of all exports */
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ void PrintDbgScopes (FILE* F)
|
|||||||
unsigned I, J;
|
unsigned I, J;
|
||||||
|
|
||||||
/* Print scopes from all modules we have linked into the output file */
|
/* Print scopes from all modules we have linked into the output file */
|
||||||
unsigned BaseId = 0;
|
|
||||||
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||||
|
|
||||||
/* Get the object file */
|
/* Get the object file */
|
||||||
@@ -111,8 +110,8 @@ void PrintDbgScopes (FILE* F)
|
|||||||
const Scope* S = CollConstAt (&O->Scopes, J);
|
const Scope* S = CollConstAt (&O->Scopes, J);
|
||||||
|
|
||||||
fprintf (F,
|
fprintf (F,
|
||||||
"scope\tid=%u,name=\"%s\",module=%u,type=%u",
|
"scope\tid=%u,name=\"%s\",mod=%u,type=%u",
|
||||||
BaseId + S->Id,
|
O->ScopeBaseId + S->Id,
|
||||||
GetString (S->Name),
|
GetString (S->Name),
|
||||||
I,
|
I,
|
||||||
S->Type);
|
S->Type);
|
||||||
@@ -123,15 +122,12 @@ void PrintDbgScopes (FILE* F)
|
|||||||
}
|
}
|
||||||
/* Print parent if available */
|
/* Print parent if available */
|
||||||
if (S->Id != S->ParentId) {
|
if (S->Id != S->ParentId) {
|
||||||
fprintf (F, ",parent=%u", BaseId + S->ParentId);
|
fprintf (F, ",parent=%u", O->ScopeBaseId + S->ParentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the output line */
|
/* Terminate the output line */
|
||||||
fputc ('\n', F);
|
fputc ('\n', F);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increment scope base id */
|
|
||||||
BaseId += CollCount (&O->Scopes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -641,12 +641,12 @@ void PrintDbgSegments (FILE* F)
|
|||||||
|
|
||||||
/* Print the segment data */
|
/* Print the segment data */
|
||||||
fprintf (F,
|
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,
|
S->Id, GetString (S->Name), S->PC, S->Size,
|
||||||
AddrSizeToStr (S->AddrSize),
|
AddrSizeToStr (S->AddrSize),
|
||||||
S->ReadOnly? "ro" : "rw");
|
S->ReadOnly? "ro" : "rw");
|
||||||
if (S->OutputName) {
|
if (S->OutputName) {
|
||||||
fprintf (F, ",outputname=\"%s\",outputoffs=%lu",
|
fprintf (F, ",oname=\"%s\",ooffs=%lu",
|
||||||
S->OutputName, S->OutputOffs);
|
S->OutputName, S->OutputOffs);
|
||||||
}
|
}
|
||||||
fputc ('\n', F);
|
fputc ('\n', F);
|
||||||
|
|||||||
Reference in New Issue
Block a user