]> git.sur5r.net Git - cc65/commitdiff
Some changes in debug info generation.
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 7 Aug 2010 12:46:12 +0000 (12:46 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 7 Aug 2010 12:46:12 +0000 (12:46 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@4788 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ld65/dbginfo.c
src/ld65/fileinfo.c
src/ld65/fileinfo.h
src/ld65/fragment.c
src/ld65/fragment.h
src/ld65/lineinfo.c
src/ld65/lineinfo.h
src/ld65/segments.c
src/ld65/segments.h

index ddf4320b6763332aceda8982860ef62b27240e3c..98227790b242d6706c9b7378ec8bcaae4053891d 100644 (file)
 #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 */
index 58b5826b16dfee5af601085f9b35cd903a0db6a2..7965d574f6c987a32faf4aab4a8a8317b3b449ba 100644 (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       */
 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;
 }
index 4d2d423ba7a8d1c61e2cfeac0d0ead39508076ed..8ebee797236532c1737e3783e3b3f3d7b7b58b3f 100644 (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       */
 
 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 */
 };
 
 
index c3f902c75a4e32f7d0cdc563dc4363e01fe90c06..3dfbceb91879279a87855da5a7c7565c1564deab 100644 (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;
index 94e40656b1f18637e8c802911cfa5917c3453ffc..24ebc3e196668750539531be9644aca7f8846eda 100644 (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 */
index 2b5eba78f04a62fba4b643f52c1bda5ae50e9d2f..bbdc3548eded866357f57a6f4971e9582dffd8e5 100644 (file)
 
 
 
-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) {
-
-                   /* 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));
 }
 
 
@@ -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 */
index 7ef66d6d42eb18b4eb3ba04c7e24a581cfa2fd9a..f47fa44a9576d0d7549f8c188deb2285b98d5331 100644 (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 */
 };
 
 
index 249ef2817565d867d8bb1602799da24132f76213..9d3627113d235817e74e0d9e29f979c8c30fdc5f 100644 (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");
        }
index aca4bf6ad7f74254226d7a3bfe9fe381842a7f78..6e5f628ed06836fa37edc821363fa0048923649b 100644 (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 */