1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 02:29:52 +00:00

Some changes in debug info generation.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4788 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2010-08-07 12:46:12 +00:00
parent 1dbb84bcee
commit 8c39874daa
9 changed files with 76 additions and 55 deletions

View File

@ -37,12 +37,13 @@
#include "dbginfo.h"
#include "fileinfo.h"
#include "lineinfo.h"
#include "segments.h"
#include "spool.h"
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@ -55,8 +56,9 @@ void PrintDbgInfo (ObjData* O, FILE* F)
/* Output the files section */
for (I = 0; I < CollCount (&O->Files); ++I) {
const FileInfo* FI = CollConstAt (&O->Files, I);
fprintf (F, "file\t\"%s\",size=%lu,mtime=0x%08lX\n",
GetString (FI->Name), FI->Size, FI->MTime);
fprintf (F,
"file\tid=%u,name=\"%s\",size=%lu,mtime=0x%08lX\n",
FI->Id, GetString (FI->Name), FI->Size, FI->MTime);
}
/* Output the line infos */
@ -76,10 +78,9 @@ void PrintDbgInfo (ObjData* O, FILE* F)
/* Print it */
fprintf (F,
"line\t\"%s\",line=%lu,range=0x%06lX-0x%06lX",
GetString (LI->File->Name),
LI->Pos.Line,
R->Offs, R->Offs + R->Size - 1);
"line\tfile=%u,line=%lu,segment=%u,range=0x%06lX-0x%06lX",
LI->File->Id, LI->Pos.Line, R->Seg->Id,
R->Offs, R->Offs + R->Size - 1);
}
/* Terminate the line */

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 2001 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@cc65.org */
/* (C) 2001-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -51,9 +51,15 @@
static FileInfo* NewFileInfo (void)
/* Allocate and initialize a new FileInfo struct and return it */
{
/* We will assign file info ids in increasing order of creation */
static unsigned Id = 0;
/* Allocate memory */
FileInfo* FI = xmalloc (sizeof (FileInfo));
/* Initialize stuff */
FI->Id = Id++;
/* Return the new struct */
return FI;
}

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 2001 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@cc65.org */
/* (C) 2001-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -57,9 +57,10 @@
typedef struct FileInfo FileInfo;
struct FileInfo {
unsigned Name; /* File name index */
unsigned long MTime; /* Time of last modification */
unsigned long Size; /* Size of the file */
unsigned Name; /* File name index */
unsigned long MTime; /* Time of last modification */
unsigned long Size; /* Size of the file */
unsigned Id; /* Id of file for debug info */
};

View File

@ -71,6 +71,7 @@ Fragment* NewFragment (unsigned char Type, unsigned Size, Section* S)
/* Initialize the data */
F->Next = 0;
F->Obj = 0;
F->Sec = S;
F->Size = Size;
F->Expr = 0;
F->LineInfos = EmptyCollection;

View File

@ -67,6 +67,7 @@ typedef struct Fragment Fragment;
struct Fragment {
Fragment* Next; /* Next fragment in list */
struct ObjData* Obj; /* Source of fragment */
struct Section* Sec; /* Section for this fragment */
unsigned Size; /* Size of data/expression */
struct ExprNode* Expr; /* Expression if FRAG_EXPR */
Collection LineInfos; /* Line info for this fragment */

View File

@ -52,13 +52,14 @@
static CodeRange* NewCodeRange (unsigned long Offs, unsigned long Size)
static CodeRange* NewCodeRange (Segment* Seg, unsigned long Offs, unsigned long Size)
/* Create and return a new CodeRange struct */
{
/* Allocate memory */
CodeRange* R = xmalloc (sizeof (CodeRange));
/* Initialize the fields */
R->Seg = Seg;
R->Offs = Offs;
R->Size = Size;
@ -102,7 +103,8 @@ LineInfo* ReadLineInfo (FILE* F, ObjData* O)
static void AddCodeRange (LineInfo* LI, unsigned long Offs, unsigned long Size)
static void AddCodeRange (LineInfo* LI, Segment* Seg, unsigned long Offs,
unsigned long Size)
/* Add a range of code to this line */
{
unsigned I;
@ -117,34 +119,35 @@ static void AddCodeRange (LineInfo* LI, unsigned long Offs, unsigned long Size)
*/
for (I = 0; I < CollCount (CodeRanges); ++I) {
CodeRange* R = CollAtUnchecked (CodeRanges, I);
if (Offs < R->Offs) {
/* Must be same segment */
if (R->Seg == Seg) {
if (Offs < R->Offs) {
/* Got the insert position */
if (Offs + Size == R->Offs) {
/* Merge the two */
R->Offs = Offs;
R->Size += Size;
} else {
/* Insert a new entry */
CollInsert (CodeRanges, NewCodeRange (Offs, Size), I);
}
/* Got the insert position */
if (Offs + Size == R->Offs) {
/* Merge the two */
R->Offs = Offs;
R->Size += Size;
} else {
/* Insert a new entry */
CollInsert (CodeRanges, NewCodeRange (Seg, Offs, Size), I);
}
/* Done */
return;
/* Done */
return;
} else if (R->Offs + R->Size == Offs) {
} else if (R->Offs + R->Size == Offs) {
/* This is the regular case. Merge the two. */
R->Size += Size;
/* This is the regular case. Merge the two. */
R->Size += Size;
/* Done */
return;
}
/* Done */
return;
}
}
}
/* We must append an entry */
CollAppend (CodeRanges, NewCodeRange (Offs, Size));
CollAppend (CodeRanges, NewCodeRange (Seg, Offs, Size));
}
@ -170,7 +173,7 @@ void RelocLineInfo (Segment* S)
/* Add the range for this fragment to all line infos */
for (I = 0; I < CollCount (&Frag->LineInfos); ++I) {
AddCodeRange (CollAt (&Frag->LineInfos, I), Offs, Frag->Size);
AddCodeRange (CollAt (&Frag->LineInfos, I), S, Offs, Frag->Size);
}
/* Update the offset */

View File

@ -65,18 +65,19 @@ struct Segment;
typedef struct CodeRange CodeRange;
struct CodeRange {
unsigned long Offs;
unsigned long Size;
struct Segment* Seg; /* Segment of this code range */
unsigned long Offs; /* Offset of code range */
unsigned long Size; /* Size of code range */
};
typedef struct LineInfo LineInfo;
struct LineInfo {
struct FileInfo* File; /* File struct for this line */
FilePos Pos; /* File position */
Collection Fragments; /* Fragments for this line */
Collection CodeRanges; /* Code ranges for this line */
struct FileInfo* File; /* File struct for this line */
FilePos Pos; /* File position */
Collection Fragments; /* Fragments for this line */
Collection CodeRanges; /* Code ranges for this line */
};

View File

@ -103,7 +103,12 @@ static Segment* NewSegment (unsigned Name, unsigned char AddrSize)
S->Relocatable = 0;
S->Dumped = 0;
/* Insert the segment into the segment list */
/* Insert the segment into the segment list and assign the segment id */
if (SegRoot == 0) {
S->Id = 0;
} else {
S->Id = SegRoot->Id + 1;
}
S->List = SegRoot;
SegRoot = S;
++SegCount;
@ -656,8 +661,9 @@ void PrintDbgSegments (FILE* F)
if (S->Size > 0) {
/* Print the segment data */
fprintf (F, "segment\t\"%s\",start=0x%06lX,size=0x%04lX,addrsize=%s,type=%s\n",
GetString (S->Name), S->PC, S->Size,
fprintf (F,
"segment\tid=%u,name=\"%s\",start=0x%06lX,size=0x%04lX,addrsize=%s,type=%s\n",
S->Id, GetString (S->Name), S->PC, S->Size,
AddrSizeToStr (S->AddrSize),
S->ReadOnly? "ro" : "rw");
}

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998-2003 Ullrich von Bassewitz */
/* Römerstraße 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* (C) 1998-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -55,6 +55,7 @@
typedef struct Segment Segment;
struct Segment {
unsigned Name; /* Name index of the segment */
unsigned Id; /* Segment id for debug info */
Segment* Next; /* Hash list */
Segment* List; /* List of all segments */
struct Section* SecRoot; /* Section list */