Added line infos
git-svn-id: svn://svn.cc65.org/cc65/trunk@748 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -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 */
|
||||
@@ -60,6 +60,7 @@ Fragment* NewFragment (unsigned char Type, unsigned long Size, Section* S)
|
||||
F->Size = Size;
|
||||
F->Expr = 0;
|
||||
InitFilePos (&F->Pos);
|
||||
F->LI = 0;
|
||||
F->Type = Type;
|
||||
|
||||
/* Insert the code fragment into the section */
|
||||
|
||||
@@ -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 */
|
||||
@@ -57,6 +57,7 @@ struct Fragment {
|
||||
unsigned long Size; /* Size of data/expression */
|
||||
struct ExprNode* Expr; /* Expression if FRAG_EXPR */
|
||||
FilePos Pos; /* File position in source */
|
||||
struct LineInfo* LI; /* Additional line info */
|
||||
unsigned char Type; /* Type of fragment */
|
||||
unsigned char LitBuf [1]; /* Dynamically alloc'ed literal buffer */
|
||||
};
|
||||
|
||||
81
src/ld65/lineinfo.c
Normal file
81
src/ld65/lineinfo.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* lineinfo.h */
|
||||
/* */
|
||||
/* Source file line info structure */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (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. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* common */
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* ld65 */
|
||||
#include "fileio.h"
|
||||
#include "lineinfo.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
static LineInfo* NewLineInfo (void)
|
||||
/* Create and return a new LineInfo struct */
|
||||
{
|
||||
/* Allocate memory */
|
||||
LineInfo* LI = xmalloc (sizeof (LineInfo));
|
||||
|
||||
/* Initialize the fields */
|
||||
InitFilePos (&LI->Pos);
|
||||
InitCollection (&LI->Fragments);
|
||||
|
||||
/* Return the new struct */
|
||||
return LI;
|
||||
}
|
||||
|
||||
|
||||
|
||||
LineInfo* ReadLineInfo (FILE* F, ObjData* O)
|
||||
/* Read a line info from a file and return it */
|
||||
{
|
||||
/* Allocate a new LineInfo struct and initialize it */
|
||||
LineInfo* LI = NewLineInfo ();
|
||||
|
||||
/* Read the file position */
|
||||
ReadFilePos (F, &LI->Pos);
|
||||
|
||||
/* Return the new LineInfo */
|
||||
return LI;
|
||||
}
|
||||
|
||||
|
||||
|
||||
79
src/ld65/lineinfo.h
Normal file
79
src/ld65/lineinfo.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* lineinfo.h */
|
||||
/* */
|
||||
/* Source file line info structure */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (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 LINEINFO_H
|
||||
#define LINEINFO_H
|
||||
|
||||
|
||||
|
||||
/* common */
|
||||
#include "coll.h"
|
||||
#include "filepos.h"
|
||||
|
||||
/* ld65 */
|
||||
#include "objdata.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
typedef struct LineInfo LineInfo;
|
||||
struct LineInfo {
|
||||
FilePos Pos; /* File position */
|
||||
Collection Fragments; /* Fragments for this line */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
LineInfo* ReadLineInfo (FILE* F, ObjData* O);
|
||||
/* Read a line info from a file and return it */
|
||||
|
||||
|
||||
|
||||
/* End of lineinfo.h */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ OBJS = bin.o \
|
||||
fragment.o \
|
||||
global.o \
|
||||
library.o \
|
||||
lineinfo.o \
|
||||
main.o \
|
||||
mapfile.o \
|
||||
o65.o \
|
||||
|
||||
@@ -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 */
|
||||
@@ -83,6 +83,8 @@ ObjData* NewObjData (void)
|
||||
O->Imports = 0;
|
||||
O->DbgSymCount = 0;
|
||||
O->DbgSyms = 0;
|
||||
O->LineInfoCount = 0;
|
||||
O->LineInfos = 0;
|
||||
|
||||
/* Link it into the list */
|
||||
if (ObjLast) {
|
||||
@@ -108,7 +110,8 @@ void FreeObjData (ObjData* O)
|
||||
xfree (O->Name);
|
||||
xfree (O->Imports);
|
||||
xfree (O->Exports);
|
||||
xfree (O->DbgSyms);
|
||||
xfree (O->DbgSyms);
|
||||
xfree (O->LineInfos);
|
||||
xfree (O);
|
||||
}
|
||||
|
||||
@@ -143,7 +146,7 @@ const char* GetSourceFileName (const ObjData* O, unsigned Index)
|
||||
/* Return the name */
|
||||
return O->Files[Index];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@@ -74,6 +74,8 @@ struct ObjData {
|
||||
struct Import** Imports; /* List of all imports */
|
||||
unsigned DbgSymCount; /* Count of debug symbols */
|
||||
struct DbgSym** DbgSyms; /* List of debug symbols */
|
||||
unsigned LineInfoCount; /* Count of additional line infos */
|
||||
struct LineInfo** LineInfos; /* List of additional line infos */
|
||||
};
|
||||
|
||||
|
||||
@@ -104,7 +106,7 @@ const char* GetObjFileName (const ObjData* O);
|
||||
|
||||
const char* GetSourceFileName (const ObjData* O, unsigned Index);
|
||||
/* Get the name of the source file with the given index. If O is NULL, return
|
||||
* "[linker generated]" as the file name.
|
||||
* "[linker generated]" as the file name.
|
||||
*/
|
||||
|
||||
|
||||
@@ -116,3 +118,4 @@ const char* GetSourceFileName (const ObjData* O, unsigned Index);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "error.h"
|
||||
#include "exports.h"
|
||||
#include "fileio.h"
|
||||
#include "lineinfo.h"
|
||||
#include "objdata.h"
|
||||
#include "segments.h"
|
||||
#include "objfile.h"
|
||||
@@ -86,19 +87,21 @@ static void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name)
|
||||
if (H->Version != OBJ_VERSION) {
|
||||
Error ("Object file `%s' has wrong version", Name);
|
||||
}
|
||||
H->Flags = Read16 (Obj);
|
||||
H->OptionOffs = Read32 (Obj);
|
||||
H->OptionSize = Read32 (Obj);
|
||||
H->FileOffs = Read32 (Obj);
|
||||
H->FileSize = Read32 (Obj);
|
||||
H->SegOffs = Read32 (Obj);
|
||||
H->SegSize = Read32 (Obj);
|
||||
H->ImportOffs = Read32 (Obj);
|
||||
H->ImportSize = Read32 (Obj);
|
||||
H->ExportOffs = Read32 (Obj);
|
||||
H->ExportSize = Read32 (Obj);
|
||||
H->DbgSymOffs = Read32 (Obj);
|
||||
H->DbgSymSize = Read32 (Obj);
|
||||
H->Flags = Read16 (Obj);
|
||||
H->OptionOffs = Read32 (Obj);
|
||||
H->OptionSize = Read32 (Obj);
|
||||
H->FileOffs = Read32 (Obj);
|
||||
H->FileSize = Read32 (Obj);
|
||||
H->SegOffs = Read32 (Obj);
|
||||
H->SegSize = Read32 (Obj);
|
||||
H->ImportOffs = Read32 (Obj);
|
||||
H->ImportSize = Read32 (Obj);
|
||||
H->ExportOffs = Read32 (Obj);
|
||||
H->ExportSize = Read32 (Obj);
|
||||
H->DbgSymOffs = Read32 (Obj);
|
||||
H->DbgSymSize = Read32 (Obj);
|
||||
H->LineInfoOffs = Read32 (Obj);
|
||||
H->LineInfoSize = Read32 (Obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +158,7 @@ void ObjReadDbgSyms (FILE* F, ObjData* O)
|
||||
/* Read the debug symbols from a file at the current position */
|
||||
{
|
||||
unsigned I;
|
||||
|
||||
|
||||
O->DbgSymCount = ReadVar (F);
|
||||
O->DbgSyms = xmalloc (O->DbgSymCount * sizeof (DbgSym*));
|
||||
for (I = 0; I < O->DbgSymCount; ++I) {
|
||||
@@ -165,6 +168,20 @@ void ObjReadDbgSyms (FILE* F, ObjData* O)
|
||||
|
||||
|
||||
|
||||
void ObjReadLineInfos (FILE* F, ObjData* O)
|
||||
/* Read the line infos from a file at the current position */
|
||||
{
|
||||
unsigned I;
|
||||
|
||||
O->LineInfoCount = ReadVar (F);
|
||||
O->LineInfos = xmalloc (O->LineInfoCount * sizeof (LineInfo*));
|
||||
for (I = 0; I < O->LineInfoCount; ++I) {
|
||||
O->LineInfos[I] = ReadLineInfo (F, O);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ObjReadSections (FILE* F, ObjData* O)
|
||||
/* Read the section data from a file at the current position */
|
||||
{
|
||||
@@ -211,6 +228,10 @@ void ObjAdd (FILE* Obj, const char* Name)
|
||||
fseek (Obj, O->Header.DbgSymOffs, SEEK_SET);
|
||||
ObjReadDbgSyms (Obj, O);
|
||||
|
||||
/* Read the line infos from the object file */
|
||||
fseek (Obj, O->Header.LineInfoOffs, SEEK_SET);
|
||||
ObjReadLineInfos (Obj, O);
|
||||
|
||||
/* Read the segment list from the object file. This must be last, since
|
||||
* the expressions stored in the code may reference segments or imported
|
||||
* symbols.
|
||||
|
||||
@@ -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 */
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "fileio.h"
|
||||
#include "fragment.h"
|
||||
#include "global.h"
|
||||
#include "lineinfo.h"
|
||||
#include "segments.h"
|
||||
|
||||
|
||||
@@ -253,6 +254,7 @@ Section* ReadSection (FILE* F, ObjData* O)
|
||||
while (Size) {
|
||||
|
||||
Fragment* Frag;
|
||||
unsigned LineInfoIndex;
|
||||
|
||||
/* Read the fragment type */
|
||||
unsigned char Type = Read8 (F);
|
||||
@@ -299,13 +301,24 @@ Section* ReadSection (FILE* F, ObjData* O)
|
||||
case FRAG_SEXPR:
|
||||
/* An expression */
|
||||
Frag->Expr = ReadExpr (F, O);
|
||||
break;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/* Read the file position of the fragment */
|
||||
ReadFilePos (F, &Frag->Pos);
|
||||
|
||||
/* Read the additional line info and resolve it */
|
||||
LineInfoIndex = ReadVar (F);
|
||||
if (LineInfoIndex) {
|
||||
--LineInfoIndex;
|
||||
CHECK (LineInfoIndex < O->LineInfoCount);
|
||||
/* Point from the fragment to the line info... */
|
||||
Frag->LI = O->LineInfos[LineInfoIndex];
|
||||
/* ...and back from the line info to the fragment */
|
||||
CollAppend (&Frag->LI->Fragments, Frag);
|
||||
}
|
||||
|
||||
/* Remember the module we had this fragment from */
|
||||
Frag->Obj = O;
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user