Rearrange debug info output. Add scopes to the debug info.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5117 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -39,10 +39,12 @@
|
|||||||
|
|
||||||
/* ld65 */
|
/* ld65 */
|
||||||
#include "dbgfile.h"
|
#include "dbgfile.h"
|
||||||
#include "dbginfo.h"
|
|
||||||
#include "dbgsyms.h"
|
#include "dbgsyms.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fileinfo.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "lineinfo.h"
|
||||||
|
#include "scopes.h"
|
||||||
#include "segments.h"
|
#include "segments.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -56,8 +58,6 @@
|
|||||||
void CreateDbgFile (void)
|
void CreateDbgFile (void)
|
||||||
/* Create a debug info file */
|
/* Create a debug info file */
|
||||||
{
|
{
|
||||||
unsigned I;
|
|
||||||
|
|
||||||
/* Open the debug info file */
|
/* Open the debug info file */
|
||||||
FILE* F = fopen (DbgFileName, "w");
|
FILE* F = fopen (DbgFileName, "w");
|
||||||
if (F == 0) {
|
if (F == 0) {
|
||||||
@@ -67,22 +67,20 @@ void CreateDbgFile (void)
|
|||||||
/* Output version information */
|
/* Output version information */
|
||||||
fprintf (F, "version\tmajor=1,minor=2\n");
|
fprintf (F, "version\tmajor=1,minor=2\n");
|
||||||
|
|
||||||
/* Clear the debug sym table (used to detect duplicates) */
|
|
||||||
ClearDbgSymTable ();
|
|
||||||
|
|
||||||
/* Output the segment info */
|
/* Output the segment info */
|
||||||
PrintDbgSegments (F);
|
PrintDbgSegments (F);
|
||||||
|
|
||||||
/* Print line infos from all modules we have linked into the output file */
|
/* Output files */
|
||||||
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
PrintDbgFileInfo (F);
|
||||||
|
|
||||||
/* Get the object file */
|
/* Output line info */
|
||||||
ObjData* O = CollAtUnchecked (&ObjDataList, I);
|
PrintDbgLineInfo (F);
|
||||||
|
|
||||||
/* Output debug info */
|
/* Output symbols */
|
||||||
PrintDbgInfo (O, F);
|
PrintDbgSyms (F);
|
||||||
PrintDbgSyms (O, F);
|
|
||||||
}
|
/* Output scopes */
|
||||||
|
PrintDbgScopes (F);
|
||||||
|
|
||||||
/* Close the file */
|
/* Close the file */
|
||||||
if (fclose (F) != 0) {
|
if (fclose (F) != 0) {
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
/*****************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* dbginfo.c */
|
|
||||||
/* */
|
|
||||||
/* Debug info handling for the ld65 linker */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* (C) 2001-2011, Ullrich von Bassewitz */
|
|
||||||
/* Roemerstrasse 52 */
|
|
||||||
/* D-70794 Filderstadt */
|
|
||||||
/* EMail: uz@cc65.org */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
|
||||||
/* warranty. In no event will the authors be held liable for any damages */
|
|
||||||
/* arising from the use of this software. */
|
|
||||||
/* */
|
|
||||||
/* Permission is granted to anyone to use this software for any purpose, */
|
|
||||||
/* including commercial applications, and to alter it and redistribute it */
|
|
||||||
/* freely, subject to the following restrictions: */
|
|
||||||
/* */
|
|
||||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
||||||
/* claim that you wrote the original software. If you use this software */
|
|
||||||
/* in a product, an acknowledgment in the product documentation would be */
|
|
||||||
/* appreciated but is not required. */
|
|
||||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
||||||
/* be misrepresented as being the original software. */
|
|
||||||
/* 3. This notice may not be removed or altered from any source */
|
|
||||||
/* distribution. */
|
|
||||||
/* */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* common */
|
|
||||||
#include "lidefs.h"
|
|
||||||
|
|
||||||
/* ld65 */
|
|
||||||
#include "dbginfo.h"
|
|
||||||
#include "fileinfo.h"
|
|
||||||
#include "lineinfo.h"
|
|
||||||
#include "segments.h"
|
|
||||||
#include "spool.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Code */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PrintDbgInfo (ObjData* O, FILE* F)
|
|
||||||
/* Print the debug info into a file */
|
|
||||||
{
|
|
||||||
unsigned I, J;
|
|
||||||
|
|
||||||
/* Output the files section */
|
|
||||||
for (I = 0; I < CollCount (&O->Files); ++I) {
|
|
||||||
FileInfo* FI = CollAt (&O->Files, I);
|
|
||||||
if (!FI->Dumped) {
|
|
||||||
fprintf (F,
|
|
||||||
"file\tid=%u,name=\"%s\",size=%lu,mtime=0x%08lX\n",
|
|
||||||
FI->Id, GetString (FI->Name), FI->Size, FI->MTime);
|
|
||||||
FI->Dumped = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Output the line infos */
|
|
||||||
for (I = 0; I < CollCount (&O->LineInfos); ++I) {
|
|
||||||
|
|
||||||
/* Get this line info */
|
|
||||||
const LineInfo* LI = CollConstAt (&O->LineInfos, I);
|
|
||||||
|
|
||||||
/* Get the line info type and count */
|
|
||||||
unsigned Type = LI_GET_TYPE (LI->Type);
|
|
||||||
unsigned Count = LI_GET_COUNT (LI->Type);
|
|
||||||
|
|
||||||
/* Get a pointer to the spans */
|
|
||||||
const Collection* Spans = &LI->Spans;
|
|
||||||
|
|
||||||
/* Spans */
|
|
||||||
for (J = 0; J < CollCount (Spans); ++J) {
|
|
||||||
|
|
||||||
/* Get this code range */
|
|
||||||
const Span* S = CollConstAt (Spans, J);
|
|
||||||
|
|
||||||
/* Print it */
|
|
||||||
fprintf (F,
|
|
||||||
"line\tfile=%u,line=%lu,segment=%u,range=0x%lX-0x%lX",
|
|
||||||
LI->File->Id, GetSourceLine (LI), S->Seg->Id,
|
|
||||||
S->Offs, S->Offs + S->Size - 1);
|
|
||||||
|
|
||||||
/* Print type if not LI_TYPE_ASM and count if not zero */
|
|
||||||
if (Type != LI_TYPE_ASM) {
|
|
||||||
fprintf (F, ",type=%u", Type);
|
|
||||||
}
|
|
||||||
if (Count != 0) {
|
|
||||||
fprintf (F, ",count=%u", Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Terminate line */
|
|
||||||
fputc ('\n', F);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
/*****************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* dbginfo.h */
|
|
||||||
/* */
|
|
||||||
/* Debug info handling for the ld65 linker */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* (C) 2001 Ullrich von Bassewitz */
|
|
||||||
/* Wacholderweg 14 */
|
|
||||||
/* D-70597 Stuttgart */
|
|
||||||
/* EMail: uz@cc65.org */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
|
||||||
/* warranty. In no event will the authors be held liable for any damages */
|
|
||||||
/* arising from the use of this software. */
|
|
||||||
/* */
|
|
||||||
/* Permission is granted to anyone to use this software for any purpose, */
|
|
||||||
/* including commercial applications, and to alter it and redistribute it */
|
|
||||||
/* freely, subject to the following restrictions: */
|
|
||||||
/* */
|
|
||||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
||||||
/* claim that you wrote the original software. If you use this software */
|
|
||||||
/* in a product, an acknowledgment in the product documentation would be */
|
|
||||||
/* appreciated but is not required. */
|
|
||||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
||||||
/* be misrepresented as being the original software. */
|
|
||||||
/* 3. This notice may not be removed or altered from any source */
|
|
||||||
/* distribution. */
|
|
||||||
/* */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef DBGINFO_H
|
|
||||||
#define DBGINFO_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* ld65 */
|
|
||||||
#include "objdata.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Code */
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PrintDbgInfo (ObjData* O, FILE* F);
|
|
||||||
/* Print the debug info into a file */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of dbginfo.h */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -205,30 +205,28 @@ long GetDbgSymVal (const DbgSym* D)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PrintDbgSyms (ObjData* O, FILE* F)
|
void PrintDbgSyms (FILE* F)
|
||||||
/* Print the debug symbols in a debug file */
|
/* Print the debug symbols in a debug file */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I, J;
|
||||||
|
|
||||||
|
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||||
|
|
||||||
|
/* Get the object file */
|
||||||
|
const ObjData* O = CollAtUnchecked (&ObjDataList, I);
|
||||||
|
|
||||||
/* Walk through all debug symbols in this module */
|
/* Walk through all debug symbols in this module */
|
||||||
for (I = 0; I < CollCount (&O->DbgSyms); ++I) {
|
for (J = 0; J < CollCount (&O->DbgSyms); ++J) {
|
||||||
|
|
||||||
long Val;
|
long Val;
|
||||||
|
SegExprDesc D;
|
||||||
|
|
||||||
/* Get the next debug symbol */
|
/* Get the next debug symbol */
|
||||||
DbgSym* S = CollAt (&O->DbgSyms, I);
|
const DbgSym* S = CollConstAt (&O->DbgSyms, J);
|
||||||
|
|
||||||
/* Get the symbol value */
|
/* Get the symbol value */
|
||||||
Val = GetDbgSymVal (S);
|
Val = GetDbgSymVal (S);
|
||||||
|
|
||||||
/* Lookup this symbol in the table. If it is found in the table, it was
|
|
||||||
* already written to the file, so don't emit it twice. If it is not in
|
|
||||||
* the table, insert and output it.
|
|
||||||
*/
|
|
||||||
if (GetDbgSym (S, Val) == 0) {
|
|
||||||
|
|
||||||
SegExprDesc D;
|
|
||||||
|
|
||||||
/* Emit the base data for the entry */
|
/* Emit the base data for the entry */
|
||||||
fprintf (F,
|
fprintf (F,
|
||||||
"sym\tname=\"%s\",value=0x%lX,addrsize=%s,type=%s",
|
"sym\tname=\"%s\",value=0x%lX,addrsize=%s,type=%s",
|
||||||
@@ -252,9 +250,6 @@ void PrintDbgSyms (ObjData* O, FILE* F)
|
|||||||
|
|
||||||
/* Terminate the output line */
|
/* Terminate the output line */
|
||||||
fputc ('\n', F);
|
fputc ('\n', F);
|
||||||
|
|
||||||
/* Insert the symbol into the table */
|
|
||||||
InsertDbgSym (S, Val);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ void ClearDbgSymTable (void);
|
|||||||
* or debug labels the first time.
|
* or debug labels the first time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void PrintDbgSyms (ObjData* O, FILE* F);
|
void PrintDbgSyms (FILE* F);
|
||||||
/* Print the debug symbols in a debug file */
|
/* Print the debug symbols in a debug file */
|
||||||
|
|
||||||
void PrintDbgSymLabels (ObjData* O, FILE* F);
|
void PrintDbgSymLabels (ObjData* O, FILE* F);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* fileinfo.c */
|
/* fileinfo.c */
|
||||||
/* */
|
/* */
|
||||||
/* sOURCE FILE INFO STRUCTURE */
|
/* Source file info structure */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -40,6 +40,8 @@
|
|||||||
/* ld65 */
|
/* ld65 */
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "fileinfo.h"
|
#include "fileinfo.h"
|
||||||
|
#include "objdata.h"
|
||||||
|
#include "spool.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -180,3 +182,29 @@ FileInfo* ReadFileInfo (FILE* F, ObjData* O)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PrintDbgFileInfo (FILE* F)
|
||||||
|
/* Output the file info to a debug info file */
|
||||||
|
{
|
||||||
|
unsigned I, J;
|
||||||
|
|
||||||
|
/* Print file infos from all modules we have linked into the output file */
|
||||||
|
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||||
|
|
||||||
|
/* Get the object file */
|
||||||
|
ObjData* O = CollAtUnchecked (&ObjDataList, I);
|
||||||
|
|
||||||
|
/* Output the files section */
|
||||||
|
for (J = 0; J < CollCount (&O->Files); ++J) {
|
||||||
|
FileInfo* FI = CollAt (&O->Files, J);
|
||||||
|
if (!FI->Dumped) {
|
||||||
|
fprintf (F,
|
||||||
|
"file\tid=%u,name=\"%s\",size=%lu,mtime=0x%08lX\n",
|
||||||
|
FI->Id, GetString (FI->Name), FI->Size, FI->MTime);
|
||||||
|
FI->Dumped = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ struct FileInfo {
|
|||||||
FileInfo* ReadFileInfo (FILE* F, ObjData* O);
|
FileInfo* ReadFileInfo (FILE* F, ObjData* O);
|
||||||
/* Read a file info from a file and return it */
|
/* Read a file info from a file and return it */
|
||||||
|
|
||||||
|
void PrintDbgFileInfo (FILE* F);
|
||||||
|
/* Output the file info to a debug info file */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of fileinfo.h */
|
/* End of fileinfo.h */
|
||||||
|
|||||||
@@ -204,4 +204,57 @@ void RelocLineInfo (Segment* S)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PrintDbgLineInfo (FILE* F)
|
||||||
|
/* Output the line infos to a debug info file */
|
||||||
|
{
|
||||||
|
unsigned I, J, K;
|
||||||
|
|
||||||
|
/* Print line infos from all modules we have linked into the output file */
|
||||||
|
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||||
|
|
||||||
|
/* Get the object file */
|
||||||
|
const ObjData* O = CollAtUnchecked (&ObjDataList, I);
|
||||||
|
|
||||||
|
/* Output the line infos */
|
||||||
|
for (J = 0; J < CollCount (&O->LineInfos); ++J) {
|
||||||
|
|
||||||
|
/* Get this line info */
|
||||||
|
const LineInfo* LI = CollConstAt (&O->LineInfos, J);
|
||||||
|
|
||||||
|
/* Get the line info type and count */
|
||||||
|
unsigned Type = LI_GET_TYPE (LI->Type);
|
||||||
|
unsigned Count = LI_GET_COUNT (LI->Type);
|
||||||
|
|
||||||
|
/* Get a pointer to the spans */
|
||||||
|
const Collection* Spans = &LI->Spans;
|
||||||
|
|
||||||
|
/* Spans */
|
||||||
|
for (K = 0; K < CollCount (Spans); ++K) {
|
||||||
|
|
||||||
|
/* Get this code range */
|
||||||
|
const Span* S = CollConstAt (Spans, K);
|
||||||
|
|
||||||
|
/* Print it */
|
||||||
|
fprintf (F,
|
||||||
|
"line\tfile=%u,line=%lu,segment=%u,range=0x%lX-0x%lX",
|
||||||
|
LI->File->Id, GetSourceLine (LI), S->Seg->Id,
|
||||||
|
S->Offs, S->Offs + S->Size - 1);
|
||||||
|
|
||||||
|
/* Print type if not LI_TYPE_ASM and count if not zero */
|
||||||
|
if (Type != LI_TYPE_ASM) {
|
||||||
|
fprintf (F, ",type=%u", Type);
|
||||||
|
}
|
||||||
|
if (Count != 0) {
|
||||||
|
fprintf (F, ",count=%u", Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate line */
|
||||||
|
fputc ('\n', F);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,9 @@ INLINE unsigned long GetSourceLineFromList (const Collection* LineInfos)
|
|||||||
GetSourceLine ((const LineInfo*) CollConstAt ((LineInfos), 0))
|
GetSourceLine ((const LineInfo*) CollConstAt ((LineInfos), 0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void PrintDbgLineInfo (FILE* F);
|
||||||
|
/* Output the line infos to a debug info file */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of lineinfo.h */
|
/* End of lineinfo.h */
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ OBJS = asserts.o \
|
|||||||
condes.o \
|
condes.o \
|
||||||
config.o \
|
config.o \
|
||||||
dbgfile.o \
|
dbgfile.o \
|
||||||
dbginfo.o \
|
|
||||||
dbgsyms.o \
|
dbgsyms.o \
|
||||||
error.o \
|
error.o \
|
||||||
exports.o \
|
exports.o \
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ OBJS = asserts.obj \
|
|||||||
condes.obj \
|
condes.obj \
|
||||||
config.obj \
|
config.obj \
|
||||||
dbgfile.obj \
|
dbgfile.obj \
|
||||||
dbginfo.obj \
|
|
||||||
dbgsyms.obj \
|
dbgsyms.obj \
|
||||||
error.obj \
|
error.obj \
|
||||||
exports.obj \
|
exports.obj \
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "scopes.h"
|
#include "scopes.h"
|
||||||
#include "span.h"
|
#include "span.h"
|
||||||
|
#include "spool.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -116,3 +117,45 @@ void ResolveScopes (ObjData* Obj)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PrintDbgScopes (FILE* F)
|
||||||
|
/* Output the scopes to a debug info file */
|
||||||
|
{
|
||||||
|
unsigned I, J;
|
||||||
|
|
||||||
|
/* Print scopes from all modules we have linked into the output file */
|
||||||
|
unsigned BaseId = 0;
|
||||||
|
for (I = 0; I < CollCount (&ObjDataList); ++I) {
|
||||||
|
|
||||||
|
/* Get the object file */
|
||||||
|
ObjData* O = CollAtUnchecked (&ObjDataList, I);
|
||||||
|
|
||||||
|
/* Output the scopes for this object file */
|
||||||
|
for (J = 0; J < CollCount (&O->Scopes); ++J) {
|
||||||
|
const Scope* S = CollConstAt (&O->Scopes, J);
|
||||||
|
|
||||||
|
fprintf (F,
|
||||||
|
"scope\tid=%u,name=\"%s\",type=%u",
|
||||||
|
BaseId + S->Id,
|
||||||
|
GetString (S->Name),
|
||||||
|
S->Type);
|
||||||
|
|
||||||
|
/* Print the size if available */
|
||||||
|
if (S->Size != 0) {
|
||||||
|
fprintf (F, ",size=%lu", S->Size);
|
||||||
|
}
|
||||||
|
/* Print parent if available */
|
||||||
|
if (S->Parent.Scope) {
|
||||||
|
fprintf (F, ",parent=%u", BaseId + S->Parent.Scope->Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the output line */
|
||||||
|
fputc ('\n', F);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Increment scope base id */
|
||||||
|
BaseId += CollCount (&O->Scopes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user