mirror of
https://github.com/cc65/cc65.git
synced 2025-02-04 13:32:54 +00:00
More work on scope suport.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5119 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
d1efe1af90
commit
3593eb2869
@ -85,7 +85,7 @@ static DbgSym* NewDbgSym (unsigned char Type, unsigned char AddrSize, ObjData* O
|
||||
D->LineInfos = EmptyCollection;
|
||||
D->Expr = 0;
|
||||
D->Size = 0;
|
||||
D->Parent.Id = ~0UL;
|
||||
D->OwnerId = ~0U;
|
||||
D->Name = 0;
|
||||
D->Type = Type;
|
||||
D->AddrSize = AddrSize;
|
||||
@ -153,7 +153,7 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* O)
|
||||
DbgSym* D = NewDbgSym (Type, AddrSize, O);
|
||||
|
||||
/* Read the id of the owner scope/symbol */
|
||||
D->Parent.Id = ReadVar (F);
|
||||
D->OwnerId = ReadVar (F);
|
||||
|
||||
/* Read and assign the name */
|
||||
D->Name = MakeGlobalStringId (O, ReadVar (F));
|
||||
@ -210,6 +210,7 @@ void PrintDbgSyms (FILE* F)
|
||||
{
|
||||
unsigned I, J;
|
||||
|
||||
unsigned BaseId = 0;
|
||||
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||
|
||||
/* Get the object file */
|
||||
@ -229,7 +230,8 @@ void PrintDbgSyms (FILE* F)
|
||||
|
||||
/* Emit the base data for the entry */
|
||||
fprintf (F,
|
||||
"sym\tname=\"%s\",value=0x%lX,addrsize=%s,type=%s",
|
||||
"sym\tid=%u,name=\"%s\",value=0x%lX,addrsize=%s,type=%s",
|
||||
BaseId + J,
|
||||
GetString (S->Name),
|
||||
Val,
|
||||
AddrSizeToStr (S->AddrSize),
|
||||
@ -248,9 +250,21 @@ void PrintDbgSyms (FILE* F)
|
||||
fprintf (F, ",segment=%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);
|
||||
} else {
|
||||
fprintf (F, ",parent=%u", S->OwnerId);
|
||||
}
|
||||
|
||||
/* Terminate the output line */
|
||||
fputc ('\n', F);
|
||||
}
|
||||
|
||||
/* Increment base id */
|
||||
BaseId += CollCount (&O->DbgSyms);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,11 +67,7 @@ struct DbgSym {
|
||||
Collection LineInfos; /* Line infos of definition */
|
||||
ExprNode* Expr; /* Expression (0 if not def'd) */
|
||||
unsigned long Size; /* Symbol size if any */
|
||||
union {
|
||||
unsigned long Id; /* Id of parent while not resolved */
|
||||
struct Scope* Scope; /* Parent scope */
|
||||
struct DbgSym* Sym; /* Parent symbol for cheap locals */
|
||||
} Parent;
|
||||
unsigned OwnerId; /* Id of parent/owner */
|
||||
unsigned Name; /* Name */
|
||||
unsigned char Type; /* Type of symbol */
|
||||
unsigned char AddrSize; /* Address size of symbol */
|
||||
|
@ -76,7 +76,7 @@ Scope* ReadScope (FILE* F, ObjData* Obj, unsigned Id)
|
||||
Scope* S = NewScope (Obj, Id);
|
||||
|
||||
/* Read the data from file */
|
||||
S->Parent.Id = ReadVar (F);
|
||||
S->ParentId = ReadVar (F);
|
||||
S->LexicalLevel = ReadVar (F);
|
||||
S->Flags = ReadVar (F);
|
||||
S->Type = ReadVar (F);
|
||||
@ -94,29 +94,6 @@ Scope* ReadScope (FILE* F, ObjData* Obj, unsigned Id)
|
||||
|
||||
|
||||
|
||||
void ResolveScopes (ObjData* Obj)
|
||||
/* Resolve a scope list. */
|
||||
{
|
||||
unsigned I;
|
||||
|
||||
/* Walk over the list and resolve the parent ids. */
|
||||
for (I = 0; I < CollCount (&Obj->Scopes); ++I) {
|
||||
|
||||
/* Get the scope */
|
||||
Scope* S = CollAtUnchecked (&Obj->Scopes, I);
|
||||
|
||||
/* Resolve the parent id. The root scope doesn't have a parent */
|
||||
if (S->Id == 0) {
|
||||
/* Root scope */
|
||||
S->Parent.Scope = 0;
|
||||
} else {
|
||||
S->Parent.Scope = GetObjScope (Obj, S->Parent.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PrintDbgScopes (FILE* F)
|
||||
/* Output the scopes to a debug info file */
|
||||
{
|
||||
@ -144,8 +121,8 @@ void PrintDbgScopes (FILE* F)
|
||||
fprintf (F, ",size=%lu", S->Size);
|
||||
}
|
||||
/* Print parent if available */
|
||||
if (S->Parent.Scope) {
|
||||
fprintf (F, ",parent=%u", BaseId + S->Parent.Scope->Id);
|
||||
if (S->Id != S->ParentId) {
|
||||
fprintf (F, ",parent=%u", BaseId + S->ParentId);
|
||||
}
|
||||
|
||||
/* Terminate the output line */
|
||||
|
@ -60,10 +60,7 @@ typedef struct Scope Scope;
|
||||
struct Scope {
|
||||
unsigned Id; /* Id of scope */
|
||||
ObjData* Obj; /* Object file that exports the name */
|
||||
union {
|
||||
unsigned Id; /* Id of parent scope */
|
||||
Scope* Scope; /* Pointer to parent scope */
|
||||
} Parent;
|
||||
unsigned ParentId; /* Id of parent scope */
|
||||
unsigned LexicalLevel; /* Lexical level */
|
||||
unsigned Flags;
|
||||
unsigned Type; /* Type of scope */
|
||||
@ -83,8 +80,8 @@ struct Scope {
|
||||
Scope* ReadScope (FILE* F, ObjData* Obj, unsigned Id);
|
||||
/* Read a scope from a file, insert and return it */
|
||||
|
||||
void ResolveScopes (ObjData* Obj);
|
||||
/* Resolve a scope list. */
|
||||
void PrintDbgScopes (FILE* F);
|
||||
/* Output the scopes to a debug info file */
|
||||
|
||||
|
||||
|
||||
@ -93,4 +90,4 @@ void ResolveScopes (ObjData* Obj);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user