From dd3a841b1a4c565697af394761c24b743dff150a Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 31 Jul 2011 13:28:54 +0000 Subject: [PATCH] Add the parent scope/symbol to the debug symbol attributes. git-svn-id: svn://svn.cc65.org/cc65/trunk@5094 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/symtab.c | 9 +++++++++ src/ld65/dbgsyms.c | 4 ++++ src/ld65/dbgsyms.h | 8 ++++++++ src/od65/dump.c | 2 ++ 4 files changed, 23 insertions(+) diff --git a/src/ca65/symtab.c b/src/ca65/symtab.c index 8ba04c1f7..70fcdf42e 100644 --- a/src/ca65/symtab.c +++ b/src/ca65/symtab.c @@ -849,6 +849,15 @@ void WriteDbgSyms (void) /* Write the address size */ ObjWrite8 (S->AddrSize); + /* Write the id of the parent. For normal symbols, this is a + * scope (symbol table), for cheap locals, it's a symbol. + */ + if (SYM_IS_STD (ExprMask)) { + ObjWriteVar (S->Sym.Tab->Id); + } else { + ObjWriteVar (S->Sym.Entry->DebugSymId); + } + /* Write the name */ ObjWriteVar (S->Name); diff --git a/src/ld65/dbgsyms.c b/src/ld65/dbgsyms.c index 7ce767c4e..a9c6ede28 100644 --- a/src/ld65/dbgsyms.c +++ b/src/ld65/dbgsyms.c @@ -85,6 +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->Name = 0; D->Type = Type; D->AddrSize = AddrSize; @@ -151,6 +152,9 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* O) /* Create a new debug symbol */ DbgSym* D = NewDbgSym (Type, AddrSize, O); + /* Read the id of the owner scope/symbol */ + D->Parent.Id = ReadVar (F); + /* Read and assign the name */ D->Name = MakeGlobalStringId (O, ReadVar (F)); diff --git a/src/ld65/dbgsyms.h b/src/ld65/dbgsyms.h index d18ac7ff5..e1b0aef23 100644 --- a/src/ld65/dbgsyms.h +++ b/src/ld65/dbgsyms.h @@ -55,6 +55,9 @@ +/* Forwards */ +struct Scope; + /* Debug symbol structure */ typedef struct DbgSym DbgSym; struct DbgSym { @@ -64,6 +67,11 @@ 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 Name; /* Name */ unsigned char Type; /* Type of symbol */ unsigned char AddrSize; /* Address size of symbol */ diff --git a/src/od65/dump.c b/src/od65/dump.c index b5b3f2a83..e08818cb8 100644 --- a/src/od65/dump.c +++ b/src/od65/dump.c @@ -663,6 +663,7 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset) /* Read the data for one symbol */ unsigned Type = ReadVar (F); unsigned char AddrSize = Read8 (F); + unsigned long Owner = ReadVar (F); const char* Name = GetString (&StrPool, ReadVar (F)); unsigned Len = strlen (Name); if (SYM_IS_CONST (Type)) { @@ -684,6 +685,7 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset) printf (" Type:%22s0x%02X (%s)\n", "", Type, GetExportFlags (Type, 0)); printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize, AddrSizeToStr (AddrSize)); + printf (" Owner:%25lu\n", Owner); printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name); if (SYM_IS_CONST (Type)) { printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value); -- 2.39.5