/* ld65 */
#include "dbgfile.h"
-#include "dbginfo.h"
#include "dbgsyms.h"
#include "error.h"
+#include "fileinfo.h"
#include "global.h"
+#include "lineinfo.h"
+#include "scopes.h"
#include "segments.h"
void CreateDbgFile (void)
/* Create a debug info file */
{
- unsigned I;
-
/* Open the debug info file */
FILE* F = fopen (DbgFileName, "w");
if (F == 0) {
/* Output version information */
fprintf (F, "version\tmajor=1,minor=2\n");
- /* Clear the debug sym table (used to detect duplicates) */
- ClearDbgSymTable ();
-
/* Output the segment info */
PrintDbgSegments (F);
- /* Print line infos from all modules we have linked into the output file */
- for (I = 0; I < CollCount (&ObjDataList); ++I) {
+ /* Output files */
+ PrintDbgFileInfo (F);
- /* Get the object file */
- ObjData* O = CollAtUnchecked (&ObjDataList, I);
+ /* Output line info */
+ PrintDbgLineInfo (F);
- /* Output debug info */
- PrintDbgInfo (O, F);
- PrintDbgSyms (O, F);
- }
+ /* Output symbols */
+ PrintDbgSyms (F);
+
+ /* Output scopes */
+ PrintDbgScopes (F);
/* Close the file */
if (fclose (F) != 0) {
+++ /dev/null
-/*****************************************************************************/
-/* */
-/* 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);
-
- }
- }
-}
-
-
-
+++ /dev/null
-/*****************************************************************************/
-/* */
-/* 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
-
-
-
-
-
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
-void PrintDbgSyms (ObjData* O, FILE* F)
+void PrintDbgSyms (FILE* F)
/* Print the debug symbols in a debug file */
{
- unsigned I;
+ unsigned I, J;
- /* Walk through all debug symbols in this module */
- for (I = 0; I < CollCount (&O->DbgSyms); ++I) {
+ for (I = 0; I < CollCount (&ObjDataList); ++I) {
- long Val;
+ /* Get the object file */
+ const ObjData* O = CollAtUnchecked (&ObjDataList, I);
- /* Get the next debug symbol */
- DbgSym* S = CollAt (&O->DbgSyms, I);
+ /* Walk through all debug symbols in this module */
+ for (J = 0; J < CollCount (&O->DbgSyms); ++J) {
- /* Get the symbol value */
- Val = GetDbgSymVal (S);
+ long Val;
+ SegExprDesc D;
- /* 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) {
+ /* Get the next debug symbol */
+ const DbgSym* S = CollConstAt (&O->DbgSyms, J);
- SegExprDesc D;
+ /* Get the symbol value */
+ Val = GetDbgSymVal (S);
- /* Emit the base data for the entry */
- fprintf (F,
+ /* Emit the base data for the entry */
+ fprintf (F,
"sym\tname=\"%s\",value=0x%lX,addrsize=%s,type=%s",
GetString (S->Name),
Val,
/* Terminate the output line */
fputc ('\n', F);
-
- /* Insert the symbol into the table */
- InsertDbgSym (S, Val);
- }
+ }
}
}
* or debug labels the first time.
*/
-void PrintDbgSyms (ObjData* O, FILE* F);
+void PrintDbgSyms (FILE* F);
/* Print the debug symbols in a debug file */
void PrintDbgSymLabels (ObjData* O, FILE* F);
/* */
/* fileinfo.c */
/* */
-/* sOURCE FILE INFO STRUCTURE */
+/* Source file info structure */
/* */
/* */
/* */
/* ld65 */
#include "fileio.h"
#include "fileinfo.h"
+#include "objdata.h"
+#include "spool.h"
FileInfo* FI = xmalloc (sizeof (FileInfo));
/* Initialize stuff */
- FI->Id = Id++;
+ FI->Id = Id++;
FI->Dumped = 0;
/* Return the new struct */
+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;
+ }
+ }
+ }
+}
+
+
+
FileInfo* ReadFileInfo (FILE* F, ObjData* O);
/* 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 */
+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);
+
+ }
+ }
+ }
+}
+
+
GetSourceLine ((const LineInfo*) CollConstAt ((LineInfos), 0))
#endif
+void PrintDbgLineInfo (FILE* F);
+/* Output the line infos to a debug info file */
+
/* End of lineinfo.h */
condes.o \
config.o \
dbgfile.o \
- dbginfo.o \
dbgsyms.o \
error.o \
exports.o \
condes.obj \
config.obj \
dbgfile.obj \
- dbginfo.obj \
dbgsyms.obj \
error.obj \
exports.obj \
CollGrow (&O->Scopes, ScopeCount);
for (I = 0; I < ScopeCount; ++I) {
CollAppend (&O->Scopes, ReadScope (F, O, I));
- }
+ }
}
#include "fileio.h"
#include "scopes.h"
#include "span.h"
+#include "spool.h"
+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);
+ }
+}
+
+
+