Better debugging output

This commit is contained in:
topjohnwu 2018-11-01 01:16:15 -04:00
parent f45b0686d2
commit 3e2afd4b1d
2 changed files with 21 additions and 19 deletions

View File

@ -145,8 +145,8 @@ int boot_img::parse_image(const char * image) {
flags |= MTK_KERNEL;
k_hdr = new mtk_hdr();
memcpy(k_hdr, kernel, sizeof(mtk_hdr));
fprintf(stderr, "KERNEL [%u]\n", k_hdr->size);
fprintf(stderr, "NAME [%s]\n", k_hdr->name);
fprintf(stderr, "KERNEL [%u]\n", k_hdr->size);
fprintf(stderr, "NAME [%s]\n", k_hdr->name);
kernel += 512;
hdr->kernel_size -= 512;
k_fmt = check_fmt(kernel, hdr->kernel_size);
@ -156,8 +156,8 @@ int boot_img::parse_image(const char * image) {
flags |= MTK_RAMDISK;
r_hdr = new mtk_hdr();
memcpy(r_hdr, ramdisk, sizeof(mtk_hdr));
fprintf(stderr, "RAMDISK [%u]\n", r_hdr->size);
fprintf(stderr, "NAME [%s]\n", r_hdr->name);
fprintf(stderr, "RAMDISK [%u]\n", r_hdr->size);
fprintf(stderr, "NAME [%s]\n", r_hdr->name);
ramdisk += 512;
hdr->ramdisk_size -= 512;
r_fmt = check_fmt(ramdisk, hdr->ramdisk_size);
@ -165,9 +165,9 @@ int boot_img::parse_image(const char * image) {
char fmt[16];
get_fmt_name(k_fmt, fmt);
fprintf(stderr, "KERNEL_FMT\t[%s]\n", fmt);
fprintf(stderr, "KERNEL_FMT [%s]\n", fmt);
get_fmt_name(r_fmt, fmt);
fprintf(stderr, "RAMDISK_FMT\t[%s]\n", fmt);
fprintf(stderr, "RAMDISK_FMT [%s]\n", fmt);
return flags & CHROMEOS_FLAG ? CHROMEOS_RET : 0;
default:
@ -210,18 +210,18 @@ void boot_img::find_dtb() {
dtb = kernel + i;
dt_size = hdr->kernel_size - i;
hdr->kernel_size = i;
fprintf(stderr, "DTB\t\t[%u]\n", dt_size);
fprintf(stderr, "DTB [%u]\n", dt_size);
break;
}
}
void boot_img::print_hdr() {
fprintf(stderr, "HEADER_VER\t[%u]\n", header_version());
fprintf(stderr, "KERNEL_SZ\t[%u]\n", hdr->kernel_size);
fprintf(stderr, "RAMDISK_SZ\t[%u]\n", hdr->ramdisk_size);
fprintf(stderr, "SECOND_SZ\t[%u]\n", hdr->second_size);
fprintf(stderr, "EXTRA_SZ\t[%u]\n", extra_size());
fprintf(stderr, "RECOV_DTBO_SZ\t[%u]\n", recovery_dtbo_size());
fprintf(stderr, "HEADER_VER [%u]\n", header_version());
fprintf(stderr, "KERNEL_SZ [%u]\n", hdr->kernel_size);
fprintf(stderr, "RAMDISK_SZ [%u]\n", hdr->ramdisk_size);
fprintf(stderr, "SECOND_SZ [%u]\n", hdr->second_size);
fprintf(stderr, "EXTRA_SZ [%u]\n", extra_size());
fprintf(stderr, "RECOV_DTBO_SZ [%u]\n", recovery_dtbo_size());
uint32_t ver = os_version();
if (ver) {
@ -233,17 +233,18 @@ void boot_img::print_hdr() {
a = (version >> 14) & 0x7f;
b = (version >> 7) & 0x7f;
c = version & 0x7f;
fprintf(stderr, "OS_VERSION\t[%d.%d.%d]\n", a, b, c);
fprintf(stderr, "OS_VERSION [%d.%d.%d]\n", a, b, c);
y = (patch_level >> 4) + 2000;
m = patch_level & 0xf;
fprintf(stderr, "PATCH_LEVEL\t[%d-%02d]\n", y, m);
fprintf(stderr, "PATCH_LEVEL [%d-%02d]\n", y, m);
}
fprintf(stderr, "PAGESIZE\t[%u]\n", page_size());
fprintf(stderr, "NAME\t\t[%s]\n", name());
fprintf(stderr, "CMDLINE\t\t[%s]\n", cmdline());
fprintf(stderr, "CHECKSUM\t[");
fprintf(stderr, "PAGESIZE [%u]\n", page_size());
fprintf(stderr, "NAME [%s]\n", name());
fprintf(stderr, "CMDLINE [%.512s", cmdline());
fprintf(stderr, "%.1024s]\n", extra_cmdline());
fprintf(stderr, "CHECKSUM [");
for (int i = 0; id()[i]; ++i)
fprintf(stderr, "%02x", id()[i]);
fprintf(stderr, "]\n");

View File

@ -200,6 +200,7 @@ static_cast<boot_img_hdr_v1 *>(hdr)->x)
dyn_get(name, char *);
dyn_get(cmdline, char *);
dyn_get(id, char *);
dyn_get(extra_cmdline, char *);
hdr_get(os_version, uint32_t);
hdr_get(recovery_dtbo_size, uint32_t);