#include "dbginfo.h"
#include "fileinfo.h"
#include "lineinfo.h"
+#include "segments.h"
#include "spool.h"
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
/* 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 */
/* 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 */
/* */
/* */
/* */
-/* (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 */
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;
}
/* */
/* */
/* */
-/* (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 */
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 */
};
/* Initialize the data */
F->Next = 0;
F->Obj = 0;
+ F->Sec = S;
F->Size = Size;
F->Expr = 0;
F->LineInfos = EmptyCollection;
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 */
-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;
-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;
*/
for (I = 0; I < CollCount (CodeRanges); ++I) {
CodeRange* R = CollAtUnchecked (CodeRanges, I);
- 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);
- }
-
- /* Done */
- return;
-
- } else if (R->Offs + R->Size == Offs) {
-
- /* This is the regular case. Merge the two. */
- R->Size += Size;
-
- /* Done */
- return;
-
- }
+ /* 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 (Seg, Offs, Size), I);
+ }
+
+ /* Done */
+ return;
+
+ } else if (R->Offs + R->Size == Offs) {
+ /* This is the regular case. Merge the two. */
+ R->Size += Size;
+
+ /* Done */
+ return;
+ }
+ }
}
/* We must append an entry */
- CollAppend (CodeRanges, NewCodeRange (Offs, Size));
+ CollAppend (CodeRanges, NewCodeRange (Seg, Offs, Size));
}
/* 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 */
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 */
};
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;
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");
}
/* */
/* */
/* */
-/* (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 */
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 */