Added line infos

git-svn-id: svn://svn.cc65.org/cc65/trunk@748 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2001-05-23 19:03:40 +00:00
parent ea2cf602b0
commit bfbedfa54b
26 changed files with 451 additions and 77 deletions

View File

@@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 2000-2001 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@@ -191,6 +191,9 @@ static unsigned SkipFragment (FILE* F)
/* Skip the file position of the fragment */
ReadFilePos (F, &Pos);
/* Skip the additional line info */
(void) ReadVar (F);
/* Return the size */
return Size;
}
@@ -388,7 +391,7 @@ void DumpObjFiles (FILE* F, unsigned long Offset)
/* Read the header */
ReadObjHeader (F, &H);
/* Seek to the start of the options */
/* Seek to the start of the source files */
FileSeek (F, Offset + H.FileOffs);
/* Output a header */
@@ -436,7 +439,7 @@ void DumpObjSegments (FILE* F, unsigned long Offset)
/* Read the header */
ReadObjHeader (F, &H);
/* Seek to the start of the options */
/* Seek to the start of the segments */
FileSeek (F, Offset + H.SegOffs);
/* Output a header */
@@ -511,7 +514,7 @@ void DumpObjImports (FILE* F, unsigned long Offset)
/* Read the header */
ReadObjHeader (F, &H);
/* Seek to the start of the options */
/* Seek to the start of the imports */
FileSeek (F, Offset + H.ImportOffs);
/* Output a header */
@@ -567,7 +570,7 @@ void DumpObjExports (FILE* F, unsigned long Offset)
/* Read the header */
ReadObjHeader (F, &H);
/* Seek to the start of the options */
/* Seek to the start of the exports */
FileSeek (F, Offset + H.ExportOffs);
/* Output a header */
@@ -633,7 +636,7 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
/* Read the header */
ReadObjHeader (F, &H);
/* Seek to the start of the options */
/* Seek to the start of the debug syms */
FileSeek (F, Offset + H.DbgSymOffs);
/* Output a header */
@@ -691,4 +694,54 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
void DumpObjLineInfo (FILE* F, unsigned long Offset)
/* Dump the line info from an object file */
{
ObjHeader H;
unsigned Count;
unsigned I;
/* Seek to the header position */
FileSeek (F, Offset);
/* Read the header */
ReadObjHeader (F, &H);
/* Seek to the start of line infos */
FileSeek (F, Offset + H.LineInfoOffs);
/* Output a header */
printf (" Line info:\n");
/* Check if the object file was compiled with debug info */
if ((H.Flags & OBJ_FLAGS_DBGINFO) == 0) {
/* Print that there no line infos and bail out */
printf (" Count:%27u\n", 0);
return;
}
/* Read the number of line infos and print it */
Count = ReadVar (F);
printf (" Count:%27u\n", Count);
/* Read and print all line infos */
for (I = 0; I < Count; ++I) {
FilePos Pos;
/* Read one line info */
ReadFilePos (F, &Pos);
/* Print the header */
printf (" Index:%27u\n", I);
/* Print the data */
printf (" Line:%26lu\n", Pos.Line);
printf (" Col:%27u\n", Pos.Col);
printf (" Name:%26u\n", Pos.Name);
}
}

View File

@@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 2000-2001 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@@ -69,6 +69,9 @@ void DumpObjExports (FILE* F, unsigned long Offset);
void DumpObjDbgSyms (FILE* F, unsigned long Offset);
/* Dump the debug symbols from an object file */
void DumpObjLineInfo (FILE* F, unsigned long Offset);
/* Dump the line infos from an object file */
/* End of dump.h */

View File

@@ -183,7 +183,7 @@ void* ReadData (FILE* F, void* Data, unsigned Size)
if (Size > 0) {
if (fread (Data, 1, Size, F) != Size) {
Error ("Read error (file corrupt?)");
}
}
}
return Data;
}
@@ -209,6 +209,8 @@ void ReadObjHeader (FILE* F, ObjHeader* H)
H->ExportSize = Read32 (F);
H->DbgSymOffs = Read32 (F);
H->DbgSymSize = Read32 (F);
H->LineInfoOffs = Read32 (F);
H->LineInfoSize = Read32 (F);
}

View File

@@ -51,6 +51,7 @@
#define D_IMPORTS 0x0010U /* Dump imported symbols */
#define D_EXPORTS 0x0020U /* Dump exported symbols */
#define D_DBGSYMS 0x0040U /* Dump debug symbols */
#define D_LINEINFO 0x0080U /* Dump line infos */
#define D_ALL 0xFFFFU /* Dump anything */

View File

@@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 2000 Ullrich von Bassewitz */
/* (C) 2000-2001 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@@ -83,6 +83,7 @@ static void Usage (void)
" --dump-files\t\tDump the source files\n"
" --dump-header\t\tDump the object file header\n"
" --dump-imports\tDump imported symbols\n"
" --dump-lineinfo\tDump line information\n"
" --dump-options\tDump object file options\n"
" --dump-segments\tDump the segments in the file\n"
" --help\t\tHelp (this text)\n"
@@ -140,6 +141,14 @@ static void OptDumpImports (const char* Opt, const char* Arg)
static void OptDumpLineInfo (const char* Opt, const char* Arg)
/* Dump the line infos */
{
What |= D_LINEINFO;
}
static void OptDumpOptions (const char* Opt, const char* Arg)
/* Dump the object file options */
{
@@ -227,6 +236,9 @@ static void DumpFile (const char* Name)
if (What & D_DBGSYMS) {
DumpObjDbgSyms (F, 0);
}
if (What & D_LINEINFO) {
DumpObjLineInfo (F, 0);
}
}
/* Close the file */
@@ -246,6 +258,7 @@ int main (int argc, char* argv [])
{ "--dump-files", 0, OptDumpFiles },
{ "--dump-header", 0, OptDumpHeader },
{ "--dump-imports", 0, OptDumpImports },
{ "--dump-lineinfo", 0, OptDumpLineInfo },
{ "--dump-options", 0, OptDumpOptions },
{ "--dump-segments", 0, OptDumpSegments },
{ "--help", 0, OptHelp },