Commit 9bb5adf7 authored by Alejandro Mery's avatar Alejandro Mery
Browse files

script_bin: add pr_debug() helper

parent 3cabfc51
...@@ -26,8 +26,14 @@ ...@@ -26,8 +26,14 @@
#include "script.h" #include "script.h"
#include "script_bin.h" #include "script_bin.h"
#define pr_info(...) fprintf(stderr, "fex2bin: " __VA_ARGS__) #define pr_info(...) errf("fexc-bin: " __VA_ARGS__)
#define pr_err(...) pr_info("E: " __VA_ARGS__) #define pr_err(...) errf("E: fexc-bin: " __VA_ARGS__)
#ifdef DEBUG
#define pr_debug(...) errf("D: fexc-bin: " __VA_ARGS__)
#else
#define pr_debug(...)
#endif
#define PTR(B, OFF) (void*)((char*)(B)+(OFF)) #define PTR(B, OFF) (void*)((char*)(B)+(OFF))
#define WORDS(S) (((S)+(sizeof(uint32_t)-1))/(sizeof(uint32_t))) #define WORDS(S) (((S)+(sizeof(uint32_t)-1))/(sizeof(uint32_t)))
...@@ -86,11 +92,9 @@ size_t script_bin_size(struct script *script, ...@@ -86,11 +92,9 @@ size_t script_bin_size(struct script *script,
(*sections)*sizeof(struct script_bin_section) + (*sections)*sizeof(struct script_bin_section) +
(*entries)*sizeof(struct script_bin_entry) + (*entries)*sizeof(struct script_bin_entry) +
words*sizeof(uint32_t); words*sizeof(uint32_t);
#ifdef VERBOSE pr_debug("sections:%zu entries:%zu data:%zu/%zu -> %zu\n",
pr_info("sections:%zu entries:%zu data:%zu/%zu -> %zu\n",
*sections, *entries, words, words*sizeof(uint32_t), *sections, *entries, words, words*sizeof(uint32_t),
bin_size); bin_size);
#endif
return bin_size; return bin_size;
} }
...@@ -110,17 +114,13 @@ int script_generate_bin(void *bin, size_t UNUSED(bin_size), ...@@ -110,17 +114,13 @@ int script_generate_bin(void *bin, size_t UNUSED(bin_size),
entry = (void*)section+sections*sizeof(*section); entry = (void*)section+sections*sizeof(*section);
data = (void*)entry+entries*sizeof(*entry); data = (void*)entry+entries*sizeof(*entry);
#ifdef VERBOSE pr_debug("head....:%p\n", head);
pr_info("head....:%p\n", head); pr_debug("section.:%p (offset:%zu, each:%zu)\n", section,
pr_info("section.:%p (offset:%zu, each:%zu)\n", section, (void*)section-bin, sizeof(*section));
(void*)section-bin, pr_debug("entry...:%p (offset:%zu, each:%zu)\n", entry,
sizeof(*section)); (void*)entry-bin, sizeof(*entry));
pr_info("entry...:%p (offset:%zu, each:%zu)\n", entry, pr_debug("data....:%p (offset:%zu)\n", data,
(void*)entry-bin,
sizeof(*entry));
pr_info("data....:%p (offset:%zu)\n", data,
(void*)data-bin); (void*)data-bin);
#endif
head->sections = sections; head->sections = sections;
head->version[0] = 0; head->version[0] = 0;
...@@ -189,23 +189,18 @@ int script_generate_bin(void *bin, size_t UNUSED(bin_size), ...@@ -189,23 +189,18 @@ int script_generate_bin(void *bin, size_t UNUSED(bin_size),
data += size; data += size;
entry->pattern |= (size>>2); entry->pattern |= (size>>2);
#ifdef VERBOSE pr_debug("%s.%s <%p> (type:%d, words:%d (%zu), offset:%d)\n",
pr_info("%s.%s <%p> (type:%d, words:%d (%zu), offset:%d)\n", section->name, entry->name, entry,
section->name, entry->name,
entry,
(entry->pattern>>16) & 0xffff, (entry->pattern>>16) & 0xffff,
(entry->pattern>>0) & 0xffff, size, (entry->pattern>>0) & 0xffff, size,
entry->offset); entry->offset);
#endif
c++; c++;
entry++; entry++;
} }
section->length = c; section->length = c;
#ifdef VERBOSE pr_debug("%s <%p> (length:%d, offset:%d)\n",
pr_info("%s <%p> (length:%d, offset:%d)\n",
section->name, section, section->length, section->offset); section->name, section, section->length, section->offset);
#endif
section++; section++;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment