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

@@ -58,6 +58,9 @@ void DbgInfoFile (void)
unsigned long Size;
unsigned long MTime;
/* Parameters are separated by a comma */
ConsumeComma ();
/* Name */
if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED);
@@ -90,6 +93,17 @@ void DbgInfoLine (void)
unsigned Index;
long LineNum;
/* If a parameters follow, this is actual line info. If no parameters
* follow, the last line info is terminated.
*/
if (Tok == TOK_SEP) {
ClearLineInfo ();
return;
}
/* Parameters are separated by a comma */
ConsumeComma ();
/* The name of the file follows */
if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED);

View File

@@ -48,6 +48,7 @@
#include "xmalloc.h"
/* ca65 */
#include "objfile.h"
#include "lineinfo.h"
@@ -128,6 +129,14 @@ void GenLineInfo (unsigned FileIndex, unsigned long LineNum)
void ClearLineInfo (void)
/* Clear the current line info */
{
CurLineInfo = 0;
}
void MakeLineInfoIndex (void)
/* Walk over the line info list and make an index of all entries ignoring
* those with a usage count of zero.
@@ -145,3 +154,37 @@ void MakeLineInfoIndex (void)
void WriteLineInfo (void)
/* Write a list of all line infos to the object file. */
{
LineInfo* LI;
/* Tell the object file module that we're about to write line infos */
ObjStartLineInfos ();
/* Check if debug info is requested */
if (DbgSyms) {
/* Write the line info count to the list */
ObjWriteVar (LineInfoValid);
/* Walk through list and write all line infos that have references */
LI = LineInfoRoot;
while (LI) {
if (LI->Usage) {
/* Write the source file position */
ObjWritePos (&LI->Pos);
}
LI = LI->Next;
}
} else {
/* No line infos */
ObjWriteVar (0);
}
}

View File

@@ -51,6 +51,9 @@
/* common */
#include "filepos.h"
/* ca65 */
#include "global.h"
/*****************************************************************************/
@@ -95,6 +98,17 @@ LineInfo* UseLineInfo (LineInfo* LI);
void GenLineInfo (unsigned FileIndex, unsigned long LineNum);
/* Generate a new line info */
void ClearLineInfo (void);
/* Clear the current line info */
void MakeLineInfoIndex (void);
/* Walk over the line info list and make an index of all entries ignoring
* those with a usage count of zero.
*/
void WriteLineInfo (void);
/* Write a list of all line infos to the object file. */
/* End of lineinfo.h */

View File

@@ -56,6 +56,7 @@
#include "incpath.h"
#include "instr.h"
#include "istack.h"
#include "lineinfo.h"
#include "listing.h"
#include "macro.h"
#include "nexttok.h"
@@ -480,6 +481,9 @@ static void CreateObjFile (void)
/* Write debug symbols if requested */
WriteDbgSyms ();
/* Write line infos if requested */
WriteLineInfo ();
/* Write an updated header and close the file */
ObjClose ();
}
@@ -636,6 +640,9 @@ int main (int argc, char* argv [])
SegCheck ();
}
/* If we didn't have an errors, index the line infos */
MakeLineInfoIndex ();
/* Dump the data */
if (Verbosity >= 2) {
SymDump (stdout);

View File

@@ -460,6 +460,7 @@ static void WriteOneSeg (Segment* Seg)
Fragment* Frag;
Fragment* F;
unsigned long Size;
unsigned LineInfoIndex;
/* Write the segment name followed by the byte count in this segment */
ObjWriteStr (Seg->Name);
@@ -534,6 +535,12 @@ static void WriteOneSeg (Segment* Seg)
/* Write the file position of this fragment */
ObjWritePos (&Frag->Pos);
/* Write extra line info for this fragment. Zero is considered
* "no line info", so add one to the value.
*/
LineInfoIndex = Frag->LI? Frag->LI->Index + 1 : 0;
ObjWriteVar (LineInfoIndex);
/* Next fragment */
Frag = Frag->Next;
}

View File

@@ -113,12 +113,14 @@ static void ObjWriteHeader (void)
ObjWrite32 (Header.ExportSize);
ObjWrite32 (Header.DbgSymOffs);
ObjWrite32 (Header.DbgSymSize);
ObjWrite32 (Header.LineInfoOffs);
ObjWrite32 (Header.LineInfoSize);
}
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -241,7 +243,7 @@ void ObjWriteStr (const char* S)
*/
ObjWriteVar (Len);
ObjWriteData (S, Len);
}
}
@@ -370,6 +372,7 @@ void ObjEndDbgSyms (void)
void ObjStartLineInfos (void)
/* Mark the start of the line info section */
{
Header.LineInfoOffs = ftell (F);
}
@@ -377,6 +380,7 @@ void ObjStartLineInfos (void)
void ObjEndLineInfos (void)
/* Mark the end of the line info section */
{
Header.LineInfoSize = ftell (F) - Header.LineInfoOffs;
}

View File

@@ -482,9 +482,6 @@ static void DoDbg (void)
/* Skip the subkey */
NextTok ();
/* Parameters are separated by a comma */
ConsumeComma ();
/* Check the key and dispatch to a handler */
switch (Key) {
case 0: DbgInfoFile (); break;