]> git.sur5r.net Git - cc65/commitdiff
Working on source line information
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 23 May 2001 08:51:48 +0000 (08:51 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 23 May 2001 08:51:48 +0000 (08:51 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@747 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ca65/fragment.c
src/ca65/fragment.h
src/ca65/lineinfo.c
src/ca65/lineinfo.h
src/ca65/objcode.c
src/ca65/objcode.h
src/ca65/objfile.c
src/ca65/objfile.h

index 2d269be2101a0530e40fa554f0f6e5ec5430fba2..bd0e704933d53c7daf04db8c1a05b1cacbf5c369 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/* (C) 1998-2001 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
index e160462b419de0b990ba1e23ba96a904372fdf36..c9ea5742b9df5221a95f5c0617564e78a416a912 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/* (C) 1998-2001 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 
 /*****************************************************************************/
-/*                             struct Fragment                              */
+/*                                Forwards                                  */
 /*****************************************************************************/
 
 
 
-typedef struct Fragment_ Fragment;
-struct Fragment_ {
+struct LineInfo;
+
+
+
+/*****************************************************************************/
+/*                             struct Fragment                              */
+/*****************************************************************************/
+
+
+
+typedef struct Fragment Fragment;
+struct Fragment {
     Fragment*          List;           /* List of all fragments */
     Fragment*                  Next;           /* Fragment list in one segment */
     Fragment*          LineList;       /* List of fragments for one src line */
     FilePos                    Pos;            /* File position for this fragment */
+    struct LineInfo*    LI;             /* Extra line info */
     unsigned short     Len;            /* Length for this fragment */
     unsigned char      Type;           /* Fragment type */
     union {
@@ -77,4 +88,4 @@ extern Fragment* FragLast;
 
 
 
-         
+
index be70fd7ef650e949d4d33d7a5e8e1ed2e041b477..5634c5a9b41143ce9fb6ca94ccb8807254e6ce76 100644 (file)
 
 
 
+/* Note: The line infos kept here are additional line infos supplied by the
+ * ".dbg line" command. The native line infos are always kept in the fragments
+ * itself (because one fragment always originates from one line). The
+ * additional line infos (which may not exist if none are supplied in the
+ * source) may have several fragments attached (as is the case with sources
+ * generated by the C compiler).
+ */
+
+
+
 /* common */
 #include "coll.h"
 #include "xmalloc.h"
@@ -72,11 +82,12 @@ static LineInfo* NewLineInfo (unsigned FileIndex, unsigned long LineNum)
     LineInfo* LI = xmalloc (sizeof (LineInfo));
 
     /* Initialize the fields */
-    LI->Next      = 0;
-    LI->Usage     = 0;
-    LI->LineNum   = LineNum;
-    LI->FileIndex = FileIndex;
-    LI->Index     = 0;           /* Currently invalid */
+    LI->Next     = 0;
+    LI->Usage    = 0;
+    LI->Index    = 0;           /* Currently invalid */
+    LI->Pos.Line = LineNum;
+    LI->Pos.Col  = 0;
+    LI->Pos.Name = FileIndex;
 
     /* Insert this structure into the line info list */
     if (LineInfoLast == 0) {
@@ -100,8 +111,9 @@ LineInfo* UseLineInfo (LineInfo* LI)
  * function will gracefully accept NULL pointers and do nothing in this case.
  */
 {
-    CHECK (LI != 0);
-    ++LI->Usage;
+    if (LI) {
+       ++LI->Usage;
+    }
     return LI;
 }
 
index 4b266799a5814430d6de576c61b959af45faa90a..f00843b82cc4a0ad48a156d3af487fb05ead4c1a 100644 (file)
 
 
 
+/* Note: The line infos kept here are additional line infos supplied by the
+ * ".dbg line" command. The native line infos are always kept in the fragments
+ * itself (because one fragment always originates from one line). The
+ * additional line infos (which may not exist if none are supplied in the
+ * source) may have several fragments attached (as is the case with sources
+ * generated by the C compiler).
+ */
+
+
+
 #ifndef LINEINFO_H
 #define LINEINFO_H
 
 
 
+/* common */
+#include "filepos.h"
+
+
+
 /*****************************************************************************/
 /*                                  Data                                    */
 /*****************************************************************************/
@@ -51,15 +66,14 @@ typedef struct LineInfo LineInfo;
 struct LineInfo {
     LineInfo*       Next;                 /* Pointer to next info in list */
     unsigned               Usage;                /* Usage counter */
-    unsigned long   LineNum;              /* Line number */
-    unsigned        FileIndex;            /* Index of input file */
     unsigned        Index;                /* Index */
+    FilePos         Pos;                  /* File position */
 };
 
 /* Linked list of all line infos */
 extern LineInfo* LineInfoRoot;
 extern LineInfo* LineInfoLast;
-extern unsigned  LineInfoCount;          
+extern unsigned  LineInfoCount;
 extern unsigned  LineInfoValid;           /* Valid, that is, used entries */
 
 /* Global pointer to last line info or NULL if not active */
index da6d3e3bbbb3b82455be1a5d71001214f43eade8..81d16420e444595e93631f0b9f611a83338914b4 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/* (C) 1998-2001 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -46,6 +46,7 @@
 #include "error.h"
 #include "fragment.h"
 #include "global.h"
+#include "lineinfo.h"
 #include "listing.h"
 #include "objfile.h"
 #include "scanner.h"
@@ -598,6 +599,7 @@ static Fragment* NewFragment (unsigned char Type, unsigned short Len)
     F->Next    = 0;
     F->LineList = 0;
     F->Pos     = CurPos;
+    F->LI       = UseLineInfo (CurLineInfo);
     F->Len     = Len;
     F->Type    = Type;
 
index 83c7720c9ca4775187f6ec8c31d29bcc662f7464..0dc3744abb9c45f504fccabaf2b00660873ca198 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/* (C) 1998-2001 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
index 30f6c2c8795a3e0a8f69e78acb120466d65efe86..cd5c496228ec775483f59b442baba33eca930c5d 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/* (C) 1998-2001 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -266,7 +266,7 @@ void ObjWritePos (const FilePos* Pos)
        ObjWriteVar (0);
     } else {
         ObjWriteVar (Pos->Name - 1);
-    }             
+    }
 }
 
 
@@ -367,3 +367,17 @@ void ObjEndDbgSyms (void)
 
 
 
+void ObjStartLineInfos (void)
+/* Mark the start of the line info section */
+{
+}
+
+
+
+void ObjEndLineInfos (void)
+/* Mark the end of the line info section */
+{
+}
+
+
+
index cf726e81db527714c71b62c49592642483d2b860..07ba44c4a1c3eedd8631d9b31b64c60d06e9c173 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/* (C) 1998-2001 Ullrich von Bassewitz                                       */
 /*               Wacholderweg 14                                             */
 /*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -66,7 +66,7 @@ void ObjWrite24 (unsigned long V);
 
 void ObjWrite32 (unsigned long V);
 /* Write a 32 bit value to the file */
-         
+
 void ObjWriteVar (unsigned long V);
 /* Write a variable sized value to the file in special encoding */
 
@@ -115,6 +115,12 @@ void ObjStartDbgSyms (void);
 void ObjEndDbgSyms (void);
 /* Mark the end of the debug symbol section */
 
+void ObjStartLineInfos (void);
+/* Mark the start of the line info section */
+
+void ObjEndLineInfos (void);
+/* Mark the end of the line info section */
+
 
 
 /* End of objfile.h */