mirror of
https://github.com/cc65/cc65.git
synced 2025-01-13 09:31:53 +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:
parent
1dbb84bcee
commit
8c39874daa
@ -37,12 +37,13 @@
|
|||||||
#include "dbginfo.h"
|
#include "dbginfo.h"
|
||||||
#include "fileinfo.h"
|
#include "fileinfo.h"
|
||||||
#include "lineinfo.h"
|
#include "lineinfo.h"
|
||||||
|
#include "segments.h"
|
||||||
#include "spool.h"
|
#include "spool.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Code */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
@ -55,8 +56,9 @@ void PrintDbgInfo (ObjData* O, FILE* F)
|
|||||||
/* Output the files section */
|
/* Output the files section */
|
||||||
for (I = 0; I < CollCount (&O->Files); ++I) {
|
for (I = 0; I < CollCount (&O->Files); ++I) {
|
||||||
const FileInfo* FI = CollConstAt (&O->Files, I);
|
const FileInfo* FI = CollConstAt (&O->Files, I);
|
||||||
fprintf (F, "file\t\"%s\",size=%lu,mtime=0x%08lX\n",
|
fprintf (F,
|
||||||
GetString (FI->Name), FI->Size, FI->MTime);
|
"file\tid=%u,name=\"%s\",size=%lu,mtime=0x%08lX\n",
|
||||||
|
FI->Id, GetString (FI->Name), FI->Size, FI->MTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output the line infos */
|
/* Output the line infos */
|
||||||
@ -76,10 +78,9 @@ void PrintDbgInfo (ObjData* O, FILE* F)
|
|||||||
|
|
||||||
/* Print it */
|
/* Print it */
|
||||||
fprintf (F,
|
fprintf (F,
|
||||||
"line\t\"%s\",line=%lu,range=0x%06lX-0x%06lX",
|
"line\tfile=%u,line=%lu,segment=%u,range=0x%06lX-0x%06lX",
|
||||||
GetString (LI->File->Name),
|
LI->File->Id, LI->Pos.Line, R->Seg->Id,
|
||||||
LI->Pos.Line,
|
R->Offs, R->Offs + R->Size - 1);
|
||||||
R->Offs, R->Offs + R->Size - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the line */
|
/* Terminate the line */
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2001 Ullrich von Bassewitz */
|
/* (C) 2001-2010, Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -51,9 +51,15 @@
|
|||||||
static FileInfo* NewFileInfo (void)
|
static FileInfo* NewFileInfo (void)
|
||||||
/* Allocate and initialize a new FileInfo struct and return it */
|
/* 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 */
|
/* Allocate memory */
|
||||||
FileInfo* FI = xmalloc (sizeof (FileInfo));
|
FileInfo* FI = xmalloc (sizeof (FileInfo));
|
||||||
|
|
||||||
|
/* Initialize stuff */
|
||||||
|
FI->Id = Id++;
|
||||||
|
|
||||||
/* Return the new struct */
|
/* Return the new struct */
|
||||||
return FI;
|
return FI;
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2001 Ullrich von Bassewitz */
|
/* (C) 2001-2010, Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -57,9 +57,10 @@
|
|||||||
|
|
||||||
typedef struct FileInfo FileInfo;
|
typedef struct FileInfo FileInfo;
|
||||||
struct FileInfo {
|
struct FileInfo {
|
||||||
unsigned Name; /* File name index */
|
unsigned Name; /* File name index */
|
||||||
unsigned long MTime; /* Time of last modification */
|
unsigned long MTime; /* Time of last modification */
|
||||||
unsigned long Size; /* Size of the file */
|
unsigned long Size; /* Size of the file */
|
||||||
|
unsigned Id; /* Id of file for debug info */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ Fragment* NewFragment (unsigned char Type, unsigned Size, Section* S)
|
|||||||
/* Initialize the data */
|
/* Initialize the data */
|
||||||
F->Next = 0;
|
F->Next = 0;
|
||||||
F->Obj = 0;
|
F->Obj = 0;
|
||||||
|
F->Sec = S;
|
||||||
F->Size = Size;
|
F->Size = Size;
|
||||||
F->Expr = 0;
|
F->Expr = 0;
|
||||||
F->LineInfos = EmptyCollection;
|
F->LineInfos = EmptyCollection;
|
||||||
|
@ -67,6 +67,7 @@ typedef struct Fragment Fragment;
|
|||||||
struct Fragment {
|
struct Fragment {
|
||||||
Fragment* Next; /* Next fragment in list */
|
Fragment* Next; /* Next fragment in list */
|
||||||
struct ObjData* Obj; /* Source of fragment */
|
struct ObjData* Obj; /* Source of fragment */
|
||||||
|
struct Section* Sec; /* Section for this fragment */
|
||||||
unsigned Size; /* Size of data/expression */
|
unsigned Size; /* Size of data/expression */
|
||||||
struct ExprNode* Expr; /* Expression if FRAG_EXPR */
|
struct ExprNode* Expr; /* Expression if FRAG_EXPR */
|
||||||
Collection LineInfos; /* Line info for this fragment */
|
Collection LineInfos; /* Line info for this fragment */
|
||||||
|
@ -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 */
|
/* Create and return a new CodeRange struct */
|
||||||
{
|
{
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
CodeRange* R = xmalloc (sizeof (CodeRange));
|
CodeRange* R = xmalloc (sizeof (CodeRange));
|
||||||
|
|
||||||
/* Initialize the fields */
|
/* Initialize the fields */
|
||||||
|
R->Seg = Seg;
|
||||||
R->Offs = Offs;
|
R->Offs = Offs;
|
||||||
R->Size = Size;
|
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 */
|
/* Add a range of code to this line */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
@ -117,34 +119,35 @@ static void AddCodeRange (LineInfo* LI, unsigned long Offs, unsigned long Size)
|
|||||||
*/
|
*/
|
||||||
for (I = 0; I < CollCount (CodeRanges); ++I) {
|
for (I = 0; I < CollCount (CodeRanges); ++I) {
|
||||||
CodeRange* R = CollAtUnchecked (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 */
|
/* Got the insert position */
|
||||||
if (Offs + Size == R->Offs) {
|
if (Offs + Size == R->Offs) {
|
||||||
/* Merge the two */
|
/* Merge the two */
|
||||||
R->Offs = Offs;
|
R->Offs = Offs;
|
||||||
R->Size += Size;
|
R->Size += Size;
|
||||||
} else {
|
} else {
|
||||||
/* Insert a new entry */
|
/* Insert a new entry */
|
||||||
CollInsert (CodeRanges, NewCodeRange (Offs, Size), I);
|
CollInsert (CodeRanges, NewCodeRange (Seg, Offs, Size), I);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Done */
|
/* Done */
|
||||||
return;
|
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. */
|
/* Done */
|
||||||
R->Size += Size;
|
return;
|
||||||
|
}
|
||||||
/* Done */
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We must append an entry */
|
/* 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 */
|
/* Add the range for this fragment to all line infos */
|
||||||
for (I = 0; I < CollCount (&Frag->LineInfos); ++I) {
|
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 */
|
/* Update the offset */
|
||||||
|
@ -65,18 +65,19 @@ struct Segment;
|
|||||||
|
|
||||||
typedef struct CodeRange CodeRange;
|
typedef struct CodeRange CodeRange;
|
||||||
struct CodeRange {
|
struct CodeRange {
|
||||||
unsigned long Offs;
|
struct Segment* Seg; /* Segment of this code range */
|
||||||
unsigned long Size;
|
unsigned long Offs; /* Offset of code range */
|
||||||
|
unsigned long Size; /* Size of code range */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct LineInfo LineInfo;
|
typedef struct LineInfo LineInfo;
|
||||||
struct LineInfo {
|
struct LineInfo {
|
||||||
struct FileInfo* File; /* File struct for this line */
|
struct FileInfo* File; /* File struct for this line */
|
||||||
FilePos Pos; /* File position */
|
FilePos Pos; /* File position */
|
||||||
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 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +103,12 @@ static Segment* NewSegment (unsigned Name, unsigned char AddrSize)
|
|||||||
S->Relocatable = 0;
|
S->Relocatable = 0;
|
||||||
S->Dumped = 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;
|
S->List = SegRoot;
|
||||||
SegRoot = S;
|
SegRoot = S;
|
||||||
++SegCount;
|
++SegCount;
|
||||||
@ -656,8 +661,9 @@ void PrintDbgSegments (FILE* F)
|
|||||||
if (S->Size > 0) {
|
if (S->Size > 0) {
|
||||||
|
|
||||||
/* Print the segment data */
|
/* Print the segment data */
|
||||||
fprintf (F, "segment\t\"%s\",start=0x%06lX,size=0x%04lX,addrsize=%s,type=%s\n",
|
fprintf (F,
|
||||||
GetString (S->Name), S->PC, S->Size,
|
"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),
|
AddrSizeToStr (S->AddrSize),
|
||||||
S->ReadOnly? "ro" : "rw");
|
S->ReadOnly? "ro" : "rw");
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
/* (C) 1998-2010, Ullrich von Bassewitz */
|
||||||
/* Römerstraße 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -55,6 +55,7 @@
|
|||||||
typedef struct Segment Segment;
|
typedef struct Segment Segment;
|
||||||
struct Segment {
|
struct Segment {
|
||||||
unsigned Name; /* Name index of the segment */
|
unsigned Name; /* Name index of the segment */
|
||||||
|
unsigned Id; /* Segment id for debug info */
|
||||||
Segment* Next; /* Hash list */
|
Segment* Next; /* Hash list */
|
||||||
Segment* List; /* List of all segments */
|
Segment* List; /* List of all segments */
|
||||||
struct Section* SecRoot; /* Section list */
|
struct Section* SecRoot; /* Section list */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user