From ea2cf602b0961d149b140ccb963500b3ed81c2f5 Mon Sep 17 00:00:00 2001 From: cuz Date: Wed, 23 May 2001 08:51:48 +0000 Subject: [PATCH] Working on source line information git-svn-id: svn://svn.cc65.org/cc65/trunk@747 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/fragment.c | 4 ++-- src/ca65/fragment.h | 23 +++++++++++++++++------ src/ca65/lineinfo.c | 26 +++++++++++++++++++------- src/ca65/lineinfo.h | 20 +++++++++++++++++--- src/ca65/objcode.c | 6 ++++-- src/ca65/objcode.h | 4 ++-- src/ca65/objfile.c | 20 +++++++++++++++++--- src/ca65/objfile.h | 12 +++++++++--- 8 files changed, 87 insertions(+), 28 deletions(-) diff --git a/src/ca65/fragment.c b/src/ca65/fragment.c index 2d269be21..bd0e70493 100644 --- a/src/ca65/fragment.c +++ b/src/ca65/fragment.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2000 Ullrich von Bassewitz */ +/* (C) 1998-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 */ diff --git a/src/ca65/fragment.h b/src/ca65/fragment.h index e160462b4..c9ea5742b 100644 --- a/src/ca65/fragment.h +++ b/src/ca65/fragment.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2000 Ullrich von Bassewitz */ +/* (C) 1998-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 */ @@ -45,17 +45,28 @@ /*****************************************************************************/ -/* struct Fragment */ +/* Forwards */ /*****************************************************************************/ -typedef struct Fragment_ Fragment; -struct Fragment_ { +struct LineInfo; + + + +/*****************************************************************************/ +/* struct Fragment */ +/*****************************************************************************/ + + + +typedef struct Fragment Fragment; +struct Fragment { Fragment* List; /* List of all fragments */ Fragment* Next; /* Fragment list in one segment */ Fragment* LineList; /* List of fragments for one src line */ FilePos Pos; /* File position for this fragment */ + struct LineInfo* LI; /* Extra line info */ unsigned short Len; /* Length for this fragment */ unsigned char Type; /* Fragment type */ union { @@ -77,4 +88,4 @@ extern Fragment* FragLast; - + diff --git a/src/ca65/lineinfo.c b/src/ca65/lineinfo.c index be70fd7ef..5634c5a9b 100644 --- a/src/ca65/lineinfo.c +++ b/src/ca65/lineinfo.c @@ -33,6 +33,16 @@ +/* Note: The line infos kept here are additional line infos supplied by the + * ".dbg line" command. The native line infos are always kept in the fragments + * itself (because one fragment always originates from one line). The + * additional line infos (which may not exist if none are supplied in the + * source) may have several fragments attached (as is the case with sources + * generated by the C compiler). + */ + + + /* common */ #include "coll.h" #include "xmalloc.h" @@ -72,11 +82,12 @@ static LineInfo* NewLineInfo (unsigned FileIndex, unsigned long LineNum) LineInfo* LI = xmalloc (sizeof (LineInfo)); /* Initialize the fields */ - LI->Next = 0; - LI->Usage = 0; - LI->LineNum = LineNum; - LI->FileIndex = FileIndex; - LI->Index = 0; /* Currently invalid */ + LI->Next = 0; + LI->Usage = 0; + LI->Index = 0; /* Currently invalid */ + LI->Pos.Line = LineNum; + LI->Pos.Col = 0; + LI->Pos.Name = FileIndex; /* Insert this structure into the line info list */ if (LineInfoLast == 0) { @@ -100,8 +111,9 @@ LineInfo* UseLineInfo (LineInfo* LI) * function will gracefully accept NULL pointers and do nothing in this case. */ { - CHECK (LI != 0); - ++LI->Usage; + if (LI) { + ++LI->Usage; + } return LI; } diff --git a/src/ca65/lineinfo.h b/src/ca65/lineinfo.h index 4b266799a..f00843b82 100644 --- a/src/ca65/lineinfo.h +++ b/src/ca65/lineinfo.h @@ -33,11 +33,26 @@ +/* Note: The line infos kept here are additional line infos supplied by the + * ".dbg line" command. The native line infos are always kept in the fragments + * itself (because one fragment always originates from one line). The + * additional line infos (which may not exist if none are supplied in the + * source) may have several fragments attached (as is the case with sources + * generated by the C compiler). + */ + + + #ifndef LINEINFO_H #define LINEINFO_H +/* common */ +#include "filepos.h" + + + /*****************************************************************************/ /* Data */ /*****************************************************************************/ @@ -51,15 +66,14 @@ typedef struct LineInfo LineInfo; struct LineInfo { LineInfo* Next; /* Pointer to next info in list */ unsigned Usage; /* Usage counter */ - unsigned long LineNum; /* Line number */ - unsigned FileIndex; /* Index of input file */ unsigned Index; /* Index */ + FilePos Pos; /* File position */ }; /* Linked list of all line infos */ extern LineInfo* LineInfoRoot; extern LineInfo* LineInfoLast; -extern unsigned LineInfoCount; +extern unsigned LineInfoCount; extern unsigned LineInfoValid; /* Valid, that is, used entries */ /* Global pointer to last line info or NULL if not active */ diff --git a/src/ca65/objcode.c b/src/ca65/objcode.c index da6d3e3bb..81d16420e 100644 --- a/src/ca65/objcode.c +++ b/src/ca65/objcode.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2000 Ullrich von Bassewitz */ +/* (C) 1998-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 */ @@ -46,6 +46,7 @@ #include "error.h" #include "fragment.h" #include "global.h" +#include "lineinfo.h" #include "listing.h" #include "objfile.h" #include "scanner.h" @@ -598,6 +599,7 @@ static Fragment* NewFragment (unsigned char Type, unsigned short Len) F->Next = 0; F->LineList = 0; F->Pos = CurPos; + F->LI = UseLineInfo (CurLineInfo); F->Len = Len; F->Type = Type; diff --git a/src/ca65/objcode.h b/src/ca65/objcode.h index 83c7720c9..0dc3744ab 100644 --- a/src/ca65/objcode.h +++ b/src/ca65/objcode.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2000 Ullrich von Bassewitz */ +/* (C) 1998-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 */ diff --git a/src/ca65/objfile.c b/src/ca65/objfile.c index 30f6c2c87..cd5c49622 100644 --- a/src/ca65/objfile.c +++ b/src/ca65/objfile.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2000 Ullrich von Bassewitz */ +/* (C) 1998-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 */ @@ -266,7 +266,7 @@ void ObjWritePos (const FilePos* Pos) ObjWriteVar (0); } else { ObjWriteVar (Pos->Name - 1); - } + } } @@ -367,3 +367,17 @@ void ObjEndDbgSyms (void) +void ObjStartLineInfos (void) +/* Mark the start of the line info section */ +{ +} + + + +void ObjEndLineInfos (void) +/* Mark the end of the line info section */ +{ +} + + + diff --git a/src/ca65/objfile.h b/src/ca65/objfile.h index cf726e81d..07ba44c4a 100644 --- a/src/ca65/objfile.h +++ b/src/ca65/objfile.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2000 Ullrich von Bassewitz */ +/* (C) 1998-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 */ @@ -66,7 +66,7 @@ void ObjWrite24 (unsigned long V); void ObjWrite32 (unsigned long V); /* Write a 32 bit value to the file */ - + void ObjWriteVar (unsigned long V); /* Write a variable sized value to the file in special encoding */ @@ -115,6 +115,12 @@ void ObjStartDbgSyms (void); void ObjEndDbgSyms (void); /* Mark the end of the debug symbol section */ +void ObjStartLineInfos (void); +/* Mark the start of the line info section */ + +void ObjEndLineInfos (void); +/* Mark the end of the line info section */ + /* End of objfile.h */ -- 2.39.5