upkg: Print out object file offsets at high verbosity levels.
authorNick Bowler <nbowler@draconx.ca>
Fri, 4 May 2012 22:47:11 +0000 (18:47 -0400)
committerNick Bowler <nbowler@draconx.ca>
Tue, 8 May 2012 23:47:07 +0000 (19:47 -0400)
When debugging deserialize methods, it can be useful to see the actual
location within the package file of the object being deserialized.  Add
a mode to print out these raw offsets when displaying object info at
high (-vvv) verbosity levels.

src/upkg.c

index 6b48f72c92988277137e0702619bbb1e4d7a9041..7448aba63baf3878b7d48f19da645245e9cfa619 100644 (file)
@@ -278,6 +278,7 @@ static int object_info(GTypeModule *pkg, unsigned long idx)
        class = upkg_export_class(upkg, idx, &package);
        printf(" (%s.%s)\n", package, class);
 
+       /* Print out object properties. */
        if (verbose >= 1) {
                GParamSpec **props;
                GObject *obj;
@@ -295,7 +296,7 @@ static int object_info(GTypeModule *pkg, unsigned long idx)
                        GValue val = {0};
                        char *valstr;
 
-                       printf("  %s: ", props[i]->name);
+                       printf("  property %s: ", props[i]->name);
                        fflush(stdout);
 
                        g_value_init(&val, props[i]->value_type);
@@ -308,6 +309,22 @@ static int object_info(GTypeModule *pkg, unsigned long idx)
                g_object_unref(obj);
        }
 
+       /* Print raw file info. */
+       if (verbose >= 3) {
+               struct upkg_file *f = upkg_export_open(upkg, idx);
+               if (!f) {
+                       fprintf(stderr, "%s: failed to open export.\n",
+                                       progname);
+                       return -1;
+               }
+
+               printf("  file size: %lu\n", f->len);
+               printf("  file start: %#lx\n", f->base);
+               printf("  file end: %#lx\n", f->base + f->len);
+
+               upkg_export_close(f);
+       }
+
        return 0;
 }