Pass type of line info through the object files.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4957 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -126,15 +126,15 @@ void InitLineInfo (void)
|
|||||||
* generated without any input file open.
|
* generated without any input file open.
|
||||||
*/
|
*/
|
||||||
UsedSlots = 2;
|
UsedSlots = 2;
|
||||||
CurLineInfo[LI_SLOT_ASM].Type = LI_TYPE_ASM;
|
CurLineInfo[LI_SLOT_ASM].Type = LI_TYPE_ASM; /* Count = 0 */
|
||||||
CurLineInfo[LI_SLOT_ASM].Info = NewLineInfo (LI_TYPE_ASM, &DefaultPos);
|
CurLineInfo[LI_SLOT_ASM].Info = NewLineInfo (LI_TYPE_ASM, &DefaultPos);
|
||||||
CurLineInfo[LI_SLOT_EXT].Type = LI_TYPE_EXT;
|
CurLineInfo[LI_SLOT_EXT].Type = LI_TYPE_EXT; /* Count = 0 */
|
||||||
CurLineInfo[LI_SLOT_EXT].Info = 0;
|
CurLineInfo[LI_SLOT_EXT].Info = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned AllocLineInfoSlot (unsigned Type)
|
unsigned AllocLineInfoSlot (unsigned Type, unsigned Count)
|
||||||
/* Allocate a line info slot of the given type and return the slot index */
|
/* Allocate a line info slot of the given type and return the slot index */
|
||||||
{
|
{
|
||||||
/* Grow the array if necessary */
|
/* Grow the array if necessary */
|
||||||
@@ -148,7 +148,7 @@ unsigned AllocLineInfoSlot (unsigned Type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Array is now big enough, add the new data */
|
/* Array is now big enough, add the new data */
|
||||||
CurLineInfo[UsedSlots].Type = Type;
|
CurLineInfo[UsedSlots].Type = LI_MAKE_TYPE(Type, Count);
|
||||||
CurLineInfo[UsedSlots].Info = 0;
|
CurLineInfo[UsedSlots].Info = 0;
|
||||||
|
|
||||||
/* Increment the count and return the index of the new slot */
|
/* Increment the count and return the index of the new slot */
|
||||||
@@ -349,6 +349,10 @@ void WriteLineInfos (void)
|
|||||||
for (I = 0; I < UsedLineInfoCount; ++I) {
|
for (I = 0; I < UsedLineInfoCount; ++I) {
|
||||||
/* Get a pointer to this line info */
|
/* Get a pointer to this line info */
|
||||||
LineInfo* LI = CollAt (&LineInfoColl, I);
|
LineInfo* LI = CollAt (&LineInfoColl, I);
|
||||||
|
|
||||||
|
/* Write the type and count of the line info */
|
||||||
|
ObjWriteVar (LI->Type);
|
||||||
|
|
||||||
/* Write the source file position */
|
/* Write the source file position */
|
||||||
ObjWritePos (&LI->Pos);
|
ObjWritePos (&LI->Pos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
/* common */
|
/* common */
|
||||||
#include "coll.h"
|
#include "coll.h"
|
||||||
#include "filepos.h"
|
#include "filepos.h"
|
||||||
|
#include "lidefs.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -59,18 +60,6 @@ enum {
|
|||||||
LI_SLOT_EXT = 1, /* Externally supplied line info */
|
LI_SLOT_EXT = 1, /* Externally supplied line info */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Types of line infos. The low byte may be used for some sort of depth
|
|
||||||
* counter.
|
|
||||||
*/
|
|
||||||
enum {
|
|
||||||
LI_MASK_COUNT = 0x00FF, /* Mask to extract the count */
|
|
||||||
|
|
||||||
LI_TYPE_ASM = 0x0100, /* Normal assembler source */
|
|
||||||
LI_TYPE_EXT = 0x0200, /* Externally supplied line info */
|
|
||||||
LI_TYPE_MACRO = 0x0300, /* Macro expansion */
|
|
||||||
LI_MASK_TYPE = 0x7F00, /* Mask to extract the type */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The LineInfo structure is shared between several fragments, so we need a
|
/* The LineInfo structure is shared between several fragments, so we need a
|
||||||
* reference counter.
|
* reference counter.
|
||||||
*/
|
*/
|
||||||
@@ -93,7 +82,7 @@ struct LineInfo {
|
|||||||
void InitLineInfo (void);
|
void InitLineInfo (void);
|
||||||
/* Initialize the line infos */
|
/* Initialize the line infos */
|
||||||
|
|
||||||
unsigned AllocLineInfoSlot (unsigned Type);
|
unsigned AllocLineInfoSlot (unsigned Type, unsigned Count);
|
||||||
/* Allocate a line info slot of the given type and return the slot index */
|
/* Allocate a line info slot of the given type and return the slot index */
|
||||||
|
|
||||||
void FreeLineInfoSlot (unsigned Slot);
|
void FreeLineInfoSlot (unsigned Slot);
|
||||||
@@ -137,10 +126,10 @@ INLINE const FilePos* GetSourcePos (const LineInfo* LI)
|
|||||||
INLINE unsigned GetLineInfoType (const LineInfo* LI)
|
INLINE unsigned GetLineInfoType (const LineInfo* LI)
|
||||||
/* Return the type of a line info */
|
/* Return the type of a line info */
|
||||||
{
|
{
|
||||||
return (LI->Type & LI_MASK_TYPE);
|
return LI_GET_TYPE (LI->Type);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define GetLineInfoType(LI) ((LI)->Type & LI_MASK_TYPE)
|
# define GetLineInfoType(LI) LI_GET_TYPE ((LI)->Type)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void WriteLineInfo (const Collection* LineInfos);
|
void WriteLineInfo (const Collection* LineInfos);
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ static MacExp* NewMacExp (Macro* M)
|
|||||||
for (I = 0; I < M->ParamCount; ++I) {
|
for (I = 0; I < M->ParamCount; ++I) {
|
||||||
E->Params[I] = 0;
|
E->Params[I] = 0;
|
||||||
}
|
}
|
||||||
E->LISlot = AllocLineInfoSlot (LI_TYPE_MACRO | MacExpansions);
|
E->LISlot = AllocLineInfoSlot (LI_TYPE_MACRO, MacExpansions);
|
||||||
|
|
||||||
/* One macro expansion more */
|
/* One macro expansion more */
|
||||||
++MacExpansions;
|
++MacExpansions;
|
||||||
|
|||||||
@@ -33,6 +33,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* common */
|
||||||
|
#include "lidefs.h"
|
||||||
|
|
||||||
/* ld65 */
|
/* ld65 */
|
||||||
#include "dbginfo.h"
|
#include "dbginfo.h"
|
||||||
#include "fileinfo.h"
|
#include "fileinfo.h"
|
||||||
@@ -67,6 +70,10 @@ void PrintDbgInfo (ObjData* O, FILE* F)
|
|||||||
/* Get this line info */
|
/* Get this line info */
|
||||||
const LineInfo* LI = CollConstAt (&O->LineInfos, I);
|
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 code ranges */
|
/* Get a pointer to the code ranges */
|
||||||
const Collection* CodeRanges = &LI->CodeRanges;
|
const Collection* CodeRanges = &LI->CodeRanges;
|
||||||
|
|
||||||
@@ -78,9 +85,21 @@ void PrintDbgInfo (ObjData* O, FILE* F)
|
|||||||
|
|
||||||
/* Print it */
|
/* Print it */
|
||||||
fprintf (F,
|
fprintf (F,
|
||||||
"line\tfile=%u,line=%lu,segment=%u,range=0x%06lX-0x%06lX\n",
|
"line\tfile=%u,line=%lu,segment=%u,range=0x%06lX-0x%06lX",
|
||||||
LI->File->Id, GetSourceLine (LI), R->Seg->Id,
|
LI->File->Id, GetSourceLine (LI), R->Seg->Id,
|
||||||
R->Offs, R->Offs + R->Size - 1);
|
R->Offs, R->Offs + R->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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
|
#include "lidefs.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
|
||||||
/* ld65 */
|
/* ld65 */
|
||||||
@@ -78,10 +79,11 @@ static LineInfo* NewLineInfo (void)
|
|||||||
LineInfo* LI = xmalloc (sizeof (LineInfo));
|
LineInfo* LI = xmalloc (sizeof (LineInfo));
|
||||||
|
|
||||||
/* Initialize the fields */
|
/* Initialize the fields */
|
||||||
|
LI->File = 0;
|
||||||
|
LI->Type = LI_TYPE_ASM;
|
||||||
LI->Pos.Name = INVALID_STRING_ID;
|
LI->Pos.Name = INVALID_STRING_ID;
|
||||||
LI->Pos.Line = 0;
|
LI->Pos.Line = 0;
|
||||||
LI->Pos.Col = 0;
|
LI->Pos.Col = 0;
|
||||||
LI->File = 0;
|
|
||||||
LI->Fragments = EmptyCollection;
|
LI->Fragments = EmptyCollection;
|
||||||
LI->CodeRanges = EmptyCollection;
|
LI->CodeRanges = EmptyCollection;
|
||||||
|
|
||||||
@@ -92,7 +94,7 @@ static LineInfo* NewLineInfo (void)
|
|||||||
|
|
||||||
|
|
||||||
LineInfo* GenLineInfo (const FilePos* Pos)
|
LineInfo* GenLineInfo (const FilePos* Pos)
|
||||||
/* Generate a new (internally used) line info with the given information */
|
/* Generate a new (internally used) line info with the given information */
|
||||||
{
|
{
|
||||||
/* Create a new LineInfo struct */
|
/* Create a new LineInfo struct */
|
||||||
LineInfo* LI = NewLineInfo ();
|
LineInfo* LI = NewLineInfo ();
|
||||||
@@ -113,6 +115,7 @@ LineInfo* ReadLineInfo (FILE* F, ObjData* O)
|
|||||||
LineInfo* LI = NewLineInfo ();
|
LineInfo* LI = NewLineInfo ();
|
||||||
|
|
||||||
/* Read/fill the fields in the new LineInfo */
|
/* Read/fill the fields in the new LineInfo */
|
||||||
|
LI->Type = ReadVar (F);
|
||||||
LI->Pos.Line = ReadVar (F);
|
LI->Pos.Line = ReadVar (F);
|
||||||
LI->Pos.Col = ReadVar (F);
|
LI->Pos.Col = ReadVar (F);
|
||||||
LI->File = CollAt (&O->Files, ReadVar (F));
|
LI->File = CollAt (&O->Files, ReadVar (F));
|
||||||
@@ -242,5 +245,4 @@ void RelocLineInfo (Segment* S)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ struct CodeRange {
|
|||||||
typedef struct LineInfo LineInfo;
|
typedef struct LineInfo LineInfo;
|
||||||
struct LineInfo {
|
struct LineInfo {
|
||||||
struct FileInfo* File; /* File struct for this line if any */
|
struct FileInfo* File; /* File struct for this line if any */
|
||||||
|
unsigned Type; /* Type of line info */
|
||||||
FilePos Pos; /* Position in file */
|
FilePos Pos; /* Position in file */
|
||||||
Collection Fragments; /* Fragments for this line */
|
Collection Fragments; /* Fragments for this line */
|
||||||
Collection CodeRanges; /* Code ranges for this line */
|
Collection CodeRanges; /* Code ranges for this line */
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
#include "coll.h"
|
#include "coll.h"
|
||||||
#include "exprdefs.h"
|
#include "exprdefs.h"
|
||||||
#include "filepos.h"
|
#include "filepos.h"
|
||||||
|
#include "lidefs.h"
|
||||||
#include "objdefs.h"
|
#include "objdefs.h"
|
||||||
#include "optdefs.h"
|
#include "optdefs.h"
|
||||||
#include "segdefs.h"
|
#include "segdefs.h"
|
||||||
@@ -714,14 +715,20 @@ void DumpObjLineInfo (FILE* F, unsigned long Offset)
|
|||||||
/* Read and print all line infos */
|
/* Read and print all line infos */
|
||||||
for (I = 0; I < Count; ++I) {
|
for (I = 0; I < Count; ++I) {
|
||||||
|
|
||||||
/* Read one line info */
|
|
||||||
FilePos Pos;
|
FilePos Pos;
|
||||||
|
|
||||||
|
/* Type of line info */
|
||||||
|
unsigned Type = ReadVar (F);
|
||||||
|
|
||||||
|
/* File position of line info */
|
||||||
ReadFilePos (F, &Pos);
|
ReadFilePos (F, &Pos);
|
||||||
|
|
||||||
/* Print the header */
|
/* Print the header */
|
||||||
printf (" Index:%27u\n", I);
|
printf (" Index:%27u\n", I);
|
||||||
|
|
||||||
/* Print the data */
|
/* Print the data */
|
||||||
|
printf (" Type:%26u\n", LI_GET_TYPE (Type));
|
||||||
|
printf (" Count:%25u\n", LI_GET_COUNT (Type));
|
||||||
printf (" Line:%26lu\n", Pos.Line);
|
printf (" Line:%26lu\n", Pos.Line);
|
||||||
printf (" Col:%27u\n", Pos.Col);
|
printf (" Col:%27u\n", Pos.Col);
|
||||||
printf (" Name:%26u\n", Pos.Name);
|
printf (" Name:%26u\n", Pos.Name);
|
||||||
|
|||||||
Reference in New Issue
Block a user