From: Nick Bowler Date: Fri, 4 May 2012 22:47:11 +0000 (-0400) Subject: upkg: Print out object file offsets at high verbosity levels. X-Git-Url: https://git.draconx.ca/gitweb/upkg.git/commitdiff_plain/45c92fd47dad10216eb2589b81f35a13cd1837f5 upkg: Print out object file offsets at high verbosity levels. 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. --- diff --git a/src/upkg.c b/src/upkg.c index 6b48f72..7448aba 100644 --- a/src/upkg.c +++ b/src/upkg.c @@ -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; }