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;
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));
{
unsigned I, J;
+ unsigned BaseId = 0;
for (I = 0; I < CollCount (&ObjDataList); ++I) {
/* Get the object file */
/* 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),
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);
}
}
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 */
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);
-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 */
{
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 */
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 */
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 */
#endif
-
+