]> git.sur5r.net Git - cc65/blobdiff - src/cc65/codeseg.c
cleanup
[cc65] / src / cc65 / codeseg.c
index 57bf95cec62b7207565c16a57a7467546148b853..ba89ccddad4742ba07d0c63b81ea2f2c3c532e84 100644 (file)
@@ -68,7 +68,6 @@ static void MoveLabelsToPool (CodeSeg* S, CodeEntry* E)
     unsigned LabelCount = GetCodeLabelCount (E);
     while (LabelCount--) {
        CodeLabel* L = GetCodeLabel (E, LabelCount);
-       L->Flags &= ~LF_DEF;
        L->Owner = 0;
        CollAppend (&S->Labels, L);
     }
@@ -436,7 +435,7 @@ void AddCodeEntry (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap)
            break;
 
        default:
-           E = ParseInsn (S, LI, L);             
+           E = ParseInsn (S, LI, L);
            break;
     }
 
@@ -944,23 +943,33 @@ void OutputCodeSeg (const CodeSeg* S, FILE* F)
        /* Get the next entry */
        const CodeEntry* E = CollConstAt (&S->Entries, I);
        /* Check if the line info has changed. If so, output the source line
-        * if the option is enabled.
+        * if the option is enabled and output debug line info if the debug
+        * option is enabled.
         */
        if (E->LI != LI) {
+           /* Line info has changed, remember the new line info */
            LI = E->LI;
+
+           /* Add the source line as a comment */
            if (AddSource) {
-               /* Skip spaces to make the output somewhat more readable */
-               const char* Line = LI->Line;
-               while (IsBlank (*Line)) {
-                   ++Line;
-               }
-               fprintf (F, ";\n; %s\n;\n", Line);
+               fprintf (F, ";\n; %s\n;\n", LI->Line);
+           }
+
+           /* Add line debug info */
+           if (DebugInfo) {
+               fprintf (F, "\t.dbg\tline, \"%s\", %u\n",
+                        GetInputName (LI), GetInputLine (LI));
            }
        }
        /* Output the code */
        OutputCodeEntry (E, F);
     }
 
+    /* If debug info is enabled, terminate the last line number information */
+    if (DebugInfo) {
+       fprintf (F, "\t.dbg\tline\n");
+    }
+
     /* If this is a segment for a function, leave the function */
     if (S->Func) {
        fprintf (F, "\n.endproc\n\n");