Handle file position information for fragments differently: Instead of

handling them separately (which has historic reasons), generate real line info
information. This means that line info for the assembler source will be part
of the debug info file.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4774 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2010-07-30 22:44:09 +00:00
parent f308a3c4d1
commit 23b867b7a4
6 changed files with 124 additions and 57 deletions

View File

@@ -203,6 +203,7 @@ Section* ReadSection (FILE* F, ObjData* O)
unsigned FragCount;
Segment* S;
Section* Sec;
LineInfo* LI;
/* Read the segment data */
(void) Read32 (F); /* File size of data */
@@ -231,9 +232,11 @@ Section* ReadSection (FILE* F, ObjData* O)
}
/* Start reading fragments from the file and insert them into the section . */
LI = 0;
while (FragCount--) {
Fragment* Frag;
FilePos Pos;
unsigned LineInfoIndex;
/* Read the fragment type */
@@ -270,24 +273,41 @@ Section* ReadSection (FILE* F, ObjData* O)
}
/* Read the file position of the fragment */
ReadFilePos (F, &Frag->Pos);
ReadFilePos (F, &Pos);
/* Generate a LineInfo for this fragment. First check if this fragment
* was generated by the same line than that before. If not, generate
* a new LineInfo.
*/
if (LI == 0 || LI->Pos.Line != Pos.Line || LI->Pos.Col != Pos.Col ||
LI->Pos.Name != Pos.Name) {
/* We don't have a previous line info or this one is different */
LI = NewLineInfo (O, &Pos);
CollAppend (&O->LineInfos, LI);
}
AddLineInfo (Frag, LI);
/* Read the additional line info and resolve it */
LineInfoIndex = ReadVar (F);
if (LineInfoIndex) {
--LineInfoIndex;
if (LineInfoIndex >= CollCount (&O->LineInfos)) {
/* The line info index was written by the assembler and must
* therefore be part of the line infos read from the object file.
* To make sure this is true, don't compare against the count
* of line infos in the collection (which grows) but against the
* count initialized when reading from the file.
*/
if (LineInfoIndex >= O->LineInfoCount) {
Internal ("In module `%s', file `%s', line %lu: Invalid line "
"info with index %u (max count %u)",
GetObjFileName (O),
GetSourceFileName (O, Frag->Pos.Name),
Frag->Pos.Line, LineInfoIndex,
CollCount (&O->LineInfos));
"info with index %u (max count %u)",
GetObjFileName (O),
GetFragmentSourceName (Frag),
GetFragmentSourceLine (Frag),
LineInfoIndex,
O->LineInfoCount);
}
/* Point from the fragment to the line info... */
Frag->LI = CollAt (&O->LineInfos, LineInfoIndex);
/* ...and back from the line info to the fragment */
CollAppend (&Frag->LI->Fragments, Frag);
/* Add line info to the fragment */
AddLineInfo (Frag, CollAt (&O->LineInfos, LineInfoIndex));
}
/* Remember the module we had this fragment from */
@@ -499,20 +519,20 @@ void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data)
case SEG_EXPR_RANGE_ERROR:
Error ("Range error in module `%s', line %lu",
GetSourceFileName (Frag->Obj, Frag->Pos.Name),
Frag->Pos.Line);
GetFragmentSourceName (Frag),
GetFragmentSourceLine (Frag));
break;
case SEG_EXPR_TOO_COMPLEX:
Error ("Expression too complex in module `%s', line %lu",
GetSourceFileName (Frag->Obj, Frag->Pos.Name),
Frag->Pos.Line);
GetFragmentSourceName (Frag),
GetFragmentSourceLine (Frag));
break;
case SEG_EXPR_INVALID:
Error ("Invalid expression in module `%s', line %lu",
GetSourceFileName (Frag->Obj, Frag->Pos.Name),
Frag->Pos.Line);
GetFragmentSourceName (Frag),
GetFragmentSourceLine (Frag));
break;
default: