diff --git a/src/od65/dump.c b/src/od65/dump.c index de9fa3c39..b5b3f2a83 100644 --- a/src/od65/dump.c +++ b/src/od65/dump.c @@ -285,6 +285,12 @@ void DumpObjHeader (FILE* F, unsigned long Offset) /* String pool */ DumpObjHeaderSection ("String pool", H.StrPoolOffs, H.StrPoolSize); + + /* Assertions */ + DumpObjHeaderSection ("Assertions", H.AssertOffs, H.AssertSize); + + /* Scopes */ + DumpObjHeaderSection ("Scopes", H.ScopeOffs, H.ScopeSize); } @@ -754,6 +760,81 @@ void DumpObjLineInfo (FILE* F, unsigned long Offset) +void DumpObjScopes (FILE* F, unsigned long Offset) +/* Dump the scopes from an object file */ +{ + ObjHeader H; + Collection StrPool = AUTO_COLLECTION_INITIALIZER; + unsigned Count; + unsigned I; + + /* Seek to the header position and read the header */ + FileSetPos (F, Offset); + ReadObjHeader (F, &H); + + /* Seek to the start of the string pool and read it */ + FileSetPos (F, Offset + H.StrPoolOffs); + ReadStrPool (F, &StrPool); + + /* Seek to the start of scopes */ + FileSetPos (F, Offset + H.ScopeOffs); + + /* Output a header */ + printf (" Scopes:\n"); + + /* Check if the object file was compiled with debug info */ + if ((H.Flags & OBJ_FLAGS_DBGINFO) == 0) { + /* Print that there no scopes and bail out */ + printf (" Count:%27u\n", 0); + return; + } + + /* Read the number of scopes and print it */ + Count = ReadVar (F); + printf (" Count:%27u\n", Count); + + /* Read and print all scopes */ + for (I = 0; I < Count; ++I) { + + const char* Name; + unsigned Len; + unsigned SegCount; + unsigned J; + + /* Print the header */ + printf (" Index:%27u\n", I); + + /* Print the data */ + printf (" Id:%28lu\n", ReadVar (F)); + printf (" Parent id:%21lu\n", ReadVar (F)); + printf (" Lexical level:%17lu\n", ReadVar (F)); + printf (" Flags:%25lu\n", ReadVar (F)); + printf (" Type:%26lu\n", ReadVar (F)); + + /* Resolve and print the name */ + Name = GetString (&StrPool, ReadVar (F)); + Len = strlen (Name); + printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name); + + /* Segment ranges */ + SegCount = ReadVar (F); + printf (" Segment ranges:\n"); + printf (" Count:%23u\n", SegCount); + + for (J = 0; J < SegCount; ++J) { + printf (" Index:%23u\n", J); + printf (" Segment:%19lu\n", ReadVar (F)); + printf (" Start:%13s0x%06lX\n", "", ReadVar (F)); + printf (" End:%15s0x%06lX\n", "", ReadVar (F)); + } + } + + /* Destroy the string pool */ + DestroyStrPool (&StrPool); +} + + + void DumpObjSegSize (FILE* F, unsigned long Offset) /* Dump the sizes of the segment in the object file */ { diff --git a/src/od65/dump.h b/src/od65/dump.h index 43d96a7e1..23971fe83 100644 --- a/src/od65/dump.h +++ b/src/od65/dump.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000-2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@cc65.org */ +/* (C) 2000-2011, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -72,6 +72,9 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset); void DumpObjLineInfo (FILE* F, unsigned long Offset); /* Dump the line infos from an object file */ +void DumpObjScopes (FILE* F, unsigned long Offset); +/* Dump the scopes from an object file */ + void DumpObjSegSize (FILE* F, unsigned long Offset); /* Dump the sizes of the segment in the object file */ diff --git a/src/od65/global.h b/src/od65/global.h index 09eab2c11..7cc531f6e 100644 --- a/src/od65/global.h +++ b/src/od65/global.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000-2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2000-2011, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -39,7 +39,7 @@ /*****************************************************************************/ -/* Data */ +/* Data */ /*****************************************************************************/ @@ -52,7 +52,8 @@ #define D_EXPORTS 0x0020U /* Dump exported symbols */ #define D_DBGSYMS 0x0040U /* Dump debug symbols */ #define D_LINEINFO 0x0080U /* Dump line infos */ -#define D_SEGSIZE 0x0100U /* Dump segment sizes */ +#define D_SCOPES 0x0100U /* Dump scopes */ +#define D_SEGSIZE 0x0200U /* Dump segment sizes */ #define D_ALL 0xFFFFU /* Dump anything */ @@ -67,4 +68,3 @@ extern unsigned What; /* What should get dumped? */ - diff --git a/src/od65/main.c b/src/od65/main.c index aa046634f..a637b7651 100644 --- a/src/od65/main.c +++ b/src/od65/main.c @@ -168,8 +168,17 @@ static void OptDumpOptions (const char* Opt attribute ((unused)), +static void OptDumpScopes (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Dump the scopes in the object file */ +{ + What |= D_SCOPES; +} + + + static void OptDumpSegments (const char* Opt attribute ((unused)), - const char* Arg attribute ((unused))) + const char* Arg attribute ((unused))) /* Dump the segments in the object file */ { What |= D_SEGMENTS; @@ -262,6 +271,9 @@ static void DumpFile (const char* Name) if (What & D_LINEINFO) { DumpObjLineInfo (F, 0); } + if (What & D_SCOPES) { + DumpObjScopes (F, 0); + } if (What & D_SEGSIZE) { DumpObjSegSize (F, 0); } @@ -286,6 +298,7 @@ int main (int argc, char* argv []) { "--dump-imports", 0, OptDumpImports }, { "--dump-lineinfo", 0, OptDumpLineInfo }, { "--dump-options", 0, OptDumpOptions }, + { "--dump-scopes", 0, OptDumpScopes }, { "--dump-segments", 0, OptDumpSegments }, { "--dump-segsize", 0, OptDumpSegSize }, { "--help", 0, OptHelp },