summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-05-13 12:13:02 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-05-13 12:13:02 +0000
commita29ef617f340410c3aaf007ce9c11290486b9749 (patch)
tree103421998927aeadc6e802921e305c1be227e10b /utils
parent6034978c84d6d800686bc7fd301b016c41b48da8 (diff)
downloadrockbox-a29ef617f340410c3aaf007ce9c11290486b9749.tar.gz
rockbox-a29ef617f340410c3aaf007ce9c11290486b9749.tar.bz2
rockbox-a29ef617f340410c3aaf007ce9c11290486b9749.zip
sbtools: be more verbose on debug and fix a bug (uninitialized structure)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29867 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/sbtools/elf.c1
-rw-r--r--utils/sbtools/elftosb.c17
2 files changed, 18 insertions, 0 deletions
diff --git a/utils/sbtools/elf.c b/utils/sbtools/elf.c
index de8d9f93c5..fed09cd6ff 100644
--- a/utils/sbtools/elf.c
+++ b/utils/sbtools/elf.c
@@ -359,6 +359,7 @@ bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read,
elf_printf_fn_t printf, void *user)
{
#define error_printf(...) ({printf(user, true, __VA_ARGS__); return false;})
+
/* read header */
Elf32_Ehdr ehdr;
if(!read(user, 0, &ehdr, sizeof(ehdr)))
diff --git a/utils/sbtools/elftosb.c b/utils/sbtools/elftosb.c
index 88c784734a..f791a4cca0 100644
--- a/utils/sbtools/elftosb.c
+++ b/utils/sbtools/elftosb.c
@@ -111,6 +111,8 @@ static key_array_t read_keys(const char *key_file, int *num_keys)
bugp("reading key file");
close(fd);
+ if(g_debug)
+ printf("Parsing key file '%s'...\n", key_file);
*num_keys = size ? 1 : 0;
char *ptr = buf;
/* allow trailing newline at the end (but no space after it) */
@@ -137,6 +139,13 @@ static key_array_t read_keys(const char *key_file, int *num_keys)
bugp(" invalid key, it should be a 128-bit key written in hexadecimal\n");
keys[i][j] = (a << 4) | b;
}
+ if(g_debug)
+ {
+ printf("Add key: ");
+ for(int j = 0; j < 16; j++)
+ printf("%02x", keys[i][j]);
+ printf("\n");
+ }
pos += 32;
}
free(buf);
@@ -376,6 +385,8 @@ static struct cmd_file_t *read_command_file(const char *file)
bugp("reading command file");
close(fd);
+ if(g_debug)
+ printf("Parsing command file '%s'...\n", file);
struct cmd_file_t *cmd_file = xmalloc(sizeof(struct cmd_file_t));
memset(cmd_file, 0, sizeof(struct cmd_file_t));
@@ -397,6 +408,7 @@ static struct cmd_file_t *read_command_file(const char *file)
if(lexem.type == LEX_RBRACE)
break;
struct cmd_source_t *src = xmalloc(sizeof(struct cmd_source_t));
+ memset(src, 0, sizeof(struct cmd_source_t));
src->next = cmd_file->source_list;
if(lexem.type != LEX_IDENTIFIER)
bug("invalid command file: identifier expected in sources");
@@ -562,6 +574,8 @@ static void load_elf_by_id(struct cmd_file_t *cmd_file, const char *id)
int fd = open(src->filename, O_RDONLY);
if(fd < 0)
bug("cannot open '%s' (id '%s')\n", src->filename, id);
+ if(g_debug)
+ printf("Loading ELF file '%s'...\n", src->filename);
elf_init(&src->elf);
src->elf_loaded = elf_read_file(&src->elf, elf_read, elf_printf, &fd);
close(fd);
@@ -573,6 +587,9 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file)
{
struct sb_file_t *sb = xmalloc(sizeof(struct sb_file_t));
memset(sb, 0, sizeof(struct sb_file_t));
+
+ if(g_debug)
+ printf("Applying command file...\n");
/* count sections */
struct cmd_section_t *csec = cmd_file->section_list;
while(csec)