]> git.sur5r.net Git - cc65/blobdiff - src/od65/dump.c
Rather stay with OFF_YEAR as it is an "officially" name.
[cc65] / src / od65 / dump.c
index 6ad35103e387bdc3bac8eac2779555d3ae5ff8cf..b15dac59f7187fefa76c74dc80b933eab2313340 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2002-2011, Ullrich von Bassewitz                                      */
+/* (C) 2002-2012, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
@@ -46,7 +46,6 @@
 #include "objdefs.h"
 #include "optdefs.h"
 #include "scopedefs.h"
-#include "segdefs.h"
 #include "symdefs.h"
 #include "xmalloc.h"
 
@@ -136,6 +135,20 @@ static void SkipLineInfoList (FILE* F)
 
 
 
+static void SkipSpanList (FILE* F)
+/* Skip a span list from the given file */
+{
+    /* Count preceeds the list */
+    unsigned long Count = ReadVar (F);
+
+    /* Skip indices */
+    while (Count--) {
+        (void) ReadVar (F);
+    }
+}
+
+
+
 static void SkipExpr (FILE* F)
 /* Skip an expression from the given file */
 {
@@ -159,8 +172,9 @@ static void SkipExpr (FILE* F)
                break;
 
            case EXPR_SECTION:
+            case EXPR_BANK:
                /* Read the segment number */
-               (void) Read8 (F);
+               (void) ReadVar (F);
                break;
 
            default:
@@ -378,7 +392,7 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
 
            case OPT_ARGNUM:
                printf ("      Data:%26lu", Val);
-               if (Type == OPT_DATETIME) {
+               if (Type == OPT_DATETIME) {
                    /* Print the time as a string */
                    printf ("  (%s)", TimeToStr (Val));
                }
@@ -484,8 +498,9 @@ void DumpObjSegments (FILE* F, unsigned long Offset)
         unsigned long NextSeg   = ftell (F) + DataSize;
                const char*   Name      = GetString (&StrPool, ReadVar (F));
        unsigned      Len       = strlen (Name);
-       unsigned long Size      = Read32 (F);
-       unsigned      Align     = (1U << Read8 (F));
+        unsigned      Flags     = ReadVar (F);
+       unsigned long Size      = ReadVar (F);
+               unsigned long Align     = ReadVar (F);
                unsigned char AddrSize  = Read8 (F);
         unsigned long FragCount = ReadVar (F);
 
@@ -494,8 +509,9 @@ void DumpObjSegments (FILE* F, unsigned long Offset)
 
        /* Print the data */
        printf ("      Name:%*s\"%s\"\n", (int)(24-Len), "", Name);
+        printf ("      Flags:%25u\n", Flags);
                printf ("      Size:%26lu\n", Size);
-       printf ("      Alignment:%21u\n", Align);
+       printf ("      Alignment:%21lu\n", Align);
        printf ("      Address size:%14s0x%02X  (%s)\n", "", AddrSize,
                 AddrSizeToStr (AddrSize));
                printf ("      Fragment count:%16lu\n", FragCount);
@@ -544,7 +560,8 @@ void DumpObjImports (FILE* F, unsigned long Offset)
                const char*   Name     = GetString (&StrPool, ReadVar (F));
        unsigned      Len      = strlen (Name);
 
-        /* Skip the line infos */
+        /* Skip both line info lists */
+        SkipLineInfoList (F);
         SkipLineInfoList (F);
 
        /* Print the header */
@@ -613,7 +630,8 @@ void DumpObjExports (FILE* F, unsigned long Offset)
             Size = ReadVar (F);
         }
 
-        /* Skip the line infos */
+        /* Skip both line infos lists */
+        SkipLineInfoList (F);
         SkipLineInfoList (F);
 
        /* Print the header */
@@ -676,6 +694,8 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
 
        unsigned long   Value = 0;
         unsigned long   Size = 0;
+        unsigned        ImportId = 0;
+        unsigned        ExportId = 0;
 
                /* Read the data for one symbol */
                unsigned Type          = ReadVar (F);
@@ -691,8 +711,15 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
         if (SYM_HAS_SIZE (Type)) {
             Size = ReadVar (F);
         }
+        if (SYM_IS_IMPORT (Type)) {
+            ImportId = ReadVar (F);
+        }
+        if (SYM_IS_EXPORT (Type)) {
+            ExportId = ReadVar (F);
+        }
 
-        /* Skip the line infos */
+        /* Skip both line info lists */
+        SkipLineInfoList (F);
         SkipLineInfoList (F);
 
        /* Print the header */
@@ -710,6 +737,12 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
                if (SYM_HAS_SIZE (Type)) {
            printf ("      Size:%20s0x%04lX  (%lu)\n", "", Size, Size);
        }
+               if (SYM_IS_IMPORT (Type)) {
+           printf ("      Import:%24u\n", ImportId);
+       }
+               if (SYM_IS_EXPORT (Type)) {
+           printf ("      Export:%24u\n", ExportId);
+       }
     }
 
     /* Destroy the string pool */
@@ -755,20 +788,24 @@ void DumpObjLineInfo (FILE* F, unsigned long Offset)
     for (I = 0; I < Count; ++I) {
 
        FilePos   Pos;
-
-        /* Type of line info */
-        unsigned Type = ReadVar (F);
+        unsigned  Type;
 
                /* File position of line info */
        ReadFilePos (F, &Pos);
 
+        /* Type of line info */
+        Type = ReadVar (F);
+
+        /* Skip the spans */
+        SkipSpanList (F);
+
        /* Print the header */
        printf ("    Index:%27u\n", I);
 
        /* Print the data */
         printf ("      Type:%26u\n", LI_GET_TYPE (Type));
         printf ("      Count:%25u\n", LI_GET_COUNT (Type));
-               printf ("      Line:%26lu\n", Pos.Line);
+               printf ("      Line:%26u\n", Pos.Line);
                printf ("      Col:%27u\n", Pos.Col);
                printf ("      Name:%26u\n", Pos.Name);
     }
@@ -817,8 +854,6 @@ void DumpObjScopes (FILE* F, unsigned long Offset)
 
         const char*     Name;
         unsigned        Len;
-        unsigned        SegCount;
-        unsigned        J;
 
         /* Read the data */
         unsigned        ParentId = ReadVar (F);
@@ -846,17 +881,14 @@ void DumpObjScopes (FILE* F, unsigned long Offset)
            printf ("      Size:%20s0x%04lX  (%lu)\n", "", Size, Size);
        }
 
-        /* Segment ranges */
-        SegCount = ReadVar (F);
-        printf ("      Segment ranges:\n");
-        printf ("        Count:%23u\n", SegCount);
-
-        for (J = 0; J < SegCount; ++J) {
-            printf ("        Index:%23u\n", J);
-            printf ("          Segment:%19lu\n", ReadVar (F));
-            printf ("          Start:%13s0x%06lX\n", "", ReadVar (F));
-            printf ("          End:%15s0x%06lX\n", "", ReadVar (F));
+        /* Label */
+        if (SCOPE_HAS_LABEL (Flags)) {
+            unsigned LabelId = ReadVar (F);
+            printf ("      Label id:%22u\n", LabelId);
         }
+
+        /* Skip the spans */
+        SkipSpanList (F);
     }
 
     /* Destroy the string pool */
@@ -897,10 +929,10 @@ void DumpObjSegSize (FILE* F, unsigned long Offset)
         unsigned long NextSeg  = ftell (F) + DataSize;
        const char*   Name     = GetString (&StrPool, ReadVar (F));
        unsigned      Len      = strlen (Name);
-       unsigned long Size     = Read32 (F);
+       unsigned long Size     = ReadVar (F);
 
         /* Skip alignment, type and fragment count */
-        (void) Read8 (F);
+        (void) ReadVar (F);
         (void) Read8 (F);
         (void) ReadVar (F);
 
@@ -917,3 +949,4 @@ void DumpObjSegSize (FILE* F, unsigned long Offset)
 
 
 
+