mirror of
https://github.com/cc65/cc65.git
synced 2024-11-19 06:31:31 +00:00
Allow to dump scope information.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5092 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
359e119a6b
commit
4ad597ff39
@ -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 */
|
||||
{
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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? */
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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 },
|
||||
|
Loading…
Reference in New Issue
Block a user