/* String pool */
DumpObjHeaderSection ("String pool", H.StrPoolOffs, H.StrPoolSize);
+
+ /* Assertions */
+ DumpObjHeaderSection ("Assertions", H.AssertOffs, H.AssertSize);
+
+ /* Scopes */
+ DumpObjHeaderSection ("Scopes", H.ScopeOffs, H.ScopeSize);
}
+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 */
{
/* */
/* */
/* */
-/* (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 */
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 */
/* */
/* */
/* */
-/* (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 */
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
#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 */
-
+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;
if (What & D_LINEINFO) {
DumpObjLineInfo (F, 0);
}
+ if (What & D_SCOPES) {
+ DumpObjScopes (F, 0);
+ }
if (What & D_SEGSIZE) {
DumpObjSegSize (F, 0);
}
{ "--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 },