* [PATCH 1/5] Add generic debug option
@ 2012-03-08 6:39 Cong Wang
2012-03-08 6:39 ` [PATCH 2/5] ppc: move DEBUG code to --debug Cong Wang
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Cong Wang @ 2012-03-08 6:39 UTC (permalink / raw)
To: kexec; +Cc: Cong Wang, Simon Horman
Currently the debugging code is under #ifdef DEBUG, which
means when we want to debug, we have to re-compile the source
code with -DDEBUG. This is not convenient, we want to have
a generic --debug option so that we can enable debugging code
without re-compiling.
This patch moves the arch-specific --debug to generic place
and moves code under #ifdef DEBUG to --debug on x86.
BTW, the size of kexec binary increases very little after this patch.
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
kexec/arch/i386/crashdump-x86.c | 74 +++++++++++++-----------------
kexec/arch/i386/include/arch/options.h | 1 -
kexec/arch/i386/kexec-beoboot-x86.c | 12 +----
kexec/arch/i386/kexec-bzImage.c | 18 ++-----
kexec/arch/i386/kexec-x86.h | 2 +-
kexec/arch/i386/x86-linux-setup.c | 1 -
kexec/arch/ppc/include/arch/options.h | 3 +-
kexec/arch/ppc/kexec-dol-ppc.c | 8 +---
kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 4 +-
kexec/crashdump.c | 5 +-
kexec/kexec-elf-rel.c | 11 ++--
kexec/kexec.c | 4 ++
kexec/kexec.h | 15 +++---
13 files changed, 63 insertions(+), 95 deletions(-)
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 436797a..590c883 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -76,9 +76,7 @@ static int get_kernel_paddr(struct kexec_info *UNUSED(info),
if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) {
elf_info->kern_paddr_start = start;
-#ifdef DEBUG
- printf("kernel load physical addr start = 0x%016Lx\n", start);
-#endif
+ dbgprintf("kernel load physical addr start = 0x%016Lx\n", start);
return 0;
}
@@ -150,10 +148,8 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
/* Align size to page size boundary. */
size = (size + align - 1) & (~(align - 1));
elf_info->kern_size = size;
-#ifdef DEBUG
- printf("kernel vaddr = 0x%lx size = 0x%llx\n",
+ dbgprintf("kernel vaddr = 0x%lx size = 0x%llx\n",
saddr, size);
-#endif
return 0;
}
}
@@ -211,10 +207,8 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
if (count != 2)
continue;
str = line + consumed;
-#ifdef DEBUG
- printf("%016Lx-%016Lx : %s",
+ dbgprintf("%016Lx-%016Lx : %s",
start, end, str);
-#endif
/* Only Dumping memory of type System RAM. */
if (memcmp(str, "System RAM\n", 11) == 0) {
type = RANGE_RAM;
@@ -290,15 +284,15 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
}
*range = crash_memory_range;
*ranges = memory_ranges;
-#ifdef DEBUG
+
int i;
- printf("CRASH MEMORY RANGES\n");
+ dbgprintf("CRASH MEMORY RANGES\n");
for(i = 0; i < memory_ranges; i++) {
start = crash_memory_range[i].start;
end = crash_memory_range[i].end;
- printf("%016Lx-%016Lx\n", start, end);
+ dbgprintf("%016Lx-%016Lx\n", start, end);
}
-#endif
+
return 0;
}
@@ -385,17 +379,17 @@ static int add_memmap(struct memory_range *memmap_p, unsigned long long addr,
memmap_p[j+1] = memmap_p[j];
memmap_p[tidx].start = addr;
memmap_p[tidx].end = addr + size - 1;
-#ifdef DEBUG
- printf("Memmap after adding segment\n");
+
+ dbgprintf("Memmap after adding segment\n");
for (i = 0; i < CRASH_MAX_MEMMAP_NR; i++) {
mstart = memmap_p[i].start;
mend = memmap_p[i].end;
if (mstart == 0 && mend == 0)
break;
- printf("%016llx - %016llx\n",
+ dbgprintf("%016llx - %016llx\n",
mstart, mend);
}
-#endif
+
return 0;
}
@@ -471,18 +465,18 @@ static int delete_memmap(struct memory_range *memmap_p, unsigned long long addr,
memmap_p[j-1] = memmap_p[j];
memmap_p[j-1].start = memmap_p[j-1].end = 0;
}
-#ifdef DEBUG
- printf("Memmap after deleting segment\n");
+
+ dbgprintf("Memmap after deleting segment\n");
for (i = 0; i < CRASH_MAX_MEMMAP_NR; i++) {
mstart = memmap_p[i].start;
mend = memmap_p[i].end;
if (mstart == 0 && mend == 0) {
break;
}
- printf("%016llx - %016llx\n",
+ dbgprintf("%016llx - %016llx\n",
mstart, mend);
}
-#endif
+
return 0;
}
@@ -546,10 +540,10 @@ static int cmdline_add_memmap(char *cmdline, struct memory_range *memmap_p)
die("Command line overflow\n");
strcat(cmdline, str_mmap);
}
-#ifdef DEBUG
- printf("Command line after adding memmap\n");
- printf("%s\n", cmdline);
-#endif
+
+ dbgprintf("Command line after adding memmap\n");
+ dbgprintf("%s\n", cmdline);
+
return 0;
}
@@ -574,10 +568,10 @@ static int cmdline_add_elfcorehdr(char *cmdline, unsigned long addr)
if (cmdlen > (COMMAND_LINE_SIZE - 1))
die("Command line overflow\n");
strcat(cmdline, str);
-#ifdef DEBUG
- printf("Command line after adding elfcorehdr\n");
- printf("%s\n", cmdline);
-#endif
+
+ dbgprintf("Command line after adding elfcorehdr\n");
+ dbgprintf("%s\n", cmdline);
+
return 0;
}
@@ -606,9 +600,9 @@ static int get_crash_notes(int cpu, uint64_t *addr, uint64_t *len)
*addr = x86__pa(vaddr + (cpu * MAX_NOTE_BYTES));
*len = MAX_NOTE_BYTES;
-#ifdef DEBUG
- printf("crash_notes addr = %Lx\n", *addr);
-#endif
+
+ dbgprintf("crash_notes addr = %Lx\n", *addr);
+
fclose(fp);
return 0;
} else
@@ -658,10 +652,9 @@ static int cmdline_add_memmap_acpi(char *cmdline, unsigned long start,
die("Command line overflow\n");
strcat(cmdline, str_mmap);
-#ifdef DEBUG
- printf("Command line after adding acpi memmap\n");
- printf("%s\n", cmdline);
-#endif
+ dbgprintf("Command line after adding acpi memmap\n");
+ dbgprintf("%s\n", cmdline);
+
return 0;
}
@@ -688,15 +681,12 @@ static void get_backup_area(unsigned long *start, unsigned long *end)
if (count != 2)
continue;
str = line + consumed;
-#ifdef DEBUG
- printf("%016lx-%016lx : %s",
+ dbgprintf("%016lx-%016lx : %s",
mstart, mend, str);
-#endif
+
/* Hopefully there is only one RAM region in the first 640K */
if (memcmp(str, "System RAM\n", 11) == 0 && mend <= 0xa0000 ) {
-#ifdef DEBUG
- printf("%s: %016lx-%016lx : %s", __func__, mstart, mend, str);
-#endif
+ dbgprintf("%s: %016lx-%016lx : %s", __func__, mstart, mend, str);
*start = mstart;
*end = mend;
fclose(fp);
diff --git a/kexec/arch/i386/include/arch/options.h b/kexec/arch/i386/include/arch/options.h
index 990527c..89dbd26 100644
--- a/kexec/arch/i386/include/arch/options.h
+++ b/kexec/arch/i386/include/arch/options.h
@@ -67,7 +67,6 @@
{ "args-elf", 0, NULL, OPT_ARGS_ELF }, \
{ "args-linux", 0, NULL, OPT_ARGS_LINUX }, \
{ "args-none", 0, NULL, OPT_ARGS_NONE }, \
- { "debug", 0, NULL, OPT_DEBUG }, \
{ "module", 1, 0, OPT_MOD }, \
{ "real-mode", 0, NULL, OPT_REAL_MODE },
diff --git a/kexec/arch/i386/kexec-beoboot-x86.c b/kexec/arch/i386/kexec-beoboot-x86.c
index 6d459ae..a65e094 100644
--- a/kexec/arch/i386/kexec-beoboot-x86.c
+++ b/kexec/arch/i386/kexec-beoboot-x86.c
@@ -64,8 +64,7 @@ int beoboot_probe(const char *buf, off_t len)
void beoboot_usage(void)
{
- printf( "-d, --debug Enable debugging to help spot a failure.\n"
- " --real-mode Use the kernels real mode entry point.\n"
+ printf( " --real-mode Use the kernels real mode entry point.\n"
);
/* No parameters are parsed */
@@ -81,14 +80,13 @@ int beoboot_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
struct beoboot_header bb_header;
const char *command_line, *kernel, *initrd;
- int debug, real_mode_entry;
+ int real_mode_entry;
int opt;
int result;
/* See options.h -- add any more there, too. */
static const struct option options[] = {
KEXEC_ARCH_OPTIONS
- { "debug", 0, 0, OPT_DEBUG },
{ "real-mode", 0, 0, OPT_REAL_MODE },
{ 0, 0, 0, 0 },
};
@@ -97,7 +95,6 @@ int beoboot_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
/*
* Parse the command line arguments
*/
- debug = 0;
real_mode_entry = 0;
while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
switch(opt) {
@@ -109,9 +106,6 @@ int beoboot_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
case '?':
usage();
return -1;
- case OPT_DEBUG:
- debug = 1;
- break;
case OPT_REAL_MODE:
real_mode_entry = 1;
break;
@@ -134,7 +128,7 @@ int beoboot_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
kernel, bb_header.kernel_size,
command_line, bb_header.cmdline_size,
initrd, bb_header.initrd_size,
- real_mode_entry, debug);
+ real_mode_entry);
return result;
}
diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
index 29e9165..54c4427 100644
--- a/kexec/arch/i386/kexec-bzImage.c
+++ b/kexec/arch/i386/kexec-bzImage.c
@@ -85,8 +85,7 @@ int bzImage_probe(const char *buf, off_t len)
void bzImage_usage(void)
{
- printf( "-d, --debug Enable debugging to help spot a failure.\n"
- " --real-mode Use the kernels real mode entry point.\n"
+ printf( " --real-mode Use the kernels real mode entry point.\n"
" --command-line=STRING Set the kernel command line to STRING.\n"
" --append=STRING Set the kernel command line to STRING.\n"
" --reuse-cmdline Use kernel command line from running system.\n"
@@ -100,7 +99,7 @@ int do_bzImage_load(struct kexec_info *info,
const char *kernel, off_t kernel_len,
const char *command_line, off_t command_line_len,
const char *initrd, off_t initrd_len,
- int real_mode_entry, int debug)
+ int real_mode_entry)
{
struct x86_linux_header setup_header;
struct x86_linux_param_header *real_mode;
@@ -297,7 +296,7 @@ int do_bzImage_load(struct kexec_info *info,
printf("Starting the kernel in real mode\n");
regs32.eip = elf_rel_get_addr(&info->rhdr, "entry16");
}
- if (real_mode_entry && debug) {
+ if (real_mode_entry && kexec_debug) {
unsigned long entry16_debug, pre32, first32;
uint32_t old_first32;
/* Find the location of the symbols */
@@ -338,14 +337,13 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len,
char *ramdisk_buf;
off_t ramdisk_length;
int command_line_len;
- int debug, real_mode_entry;
+ int real_mode_entry;
int opt;
int result;
/* See options.h -- add any more there, too. */
static const struct option options[] = {
KEXEC_ARCH_OPTIONS
- { "debug", 0, 0, OPT_DEBUG },
{ "command-line", 1, 0, OPT_APPEND },
{ "append", 1, 0, OPT_APPEND },
{ "reuse-cmdline", 0, 0, OPT_REUSE_CMDLINE },
@@ -356,10 +354,6 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len,
};
static const char short_options[] = KEXEC_ARCH_OPT_STR "d";
- /*
- * Parse the command line arguments
- */
- debug = 0;
real_mode_entry = 0;
ramdisk = 0;
ramdisk_length = 0;
@@ -373,8 +367,6 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len,
case '?':
usage();
return -1;
- case OPT_DEBUG:
- debug = 1;
break;
case OPT_APPEND:
append = optarg;
@@ -403,7 +395,7 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len,
buf, len,
command_line, command_line_len,
ramdisk_buf, ramdisk_length,
- real_mode_entry, debug);
+ real_mode_entry);
free(command_line);
return result;
diff --git a/kexec/arch/i386/kexec-x86.h b/kexec/arch/i386/kexec-x86.h
index aca1841..dfcc51d 100644
--- a/kexec/arch/i386/kexec-x86.h
+++ b/kexec/arch/i386/kexec-x86.h
@@ -70,7 +70,7 @@ int do_bzImage_load(struct kexec_info *info,
const char *kernel, off_t kernel_len,
const char *command_line, off_t command_line_len,
const char *initrd, off_t initrd_len,
- int real_mode_entry, int debug);
+ int real_mode_entry);
int beoboot_probe(const char *buf, off_t len);
int beoboot_load(int argc, char **argv, const char *buf, off_t len,
diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
index 0528cea..95c9f97 100644
--- a/kexec/arch/i386/x86-linux-setup.c
+++ b/kexec/arch/i386/x86-linux-setup.c
@@ -13,7 +13,6 @@
* GNU General Public License for more details.
*
*/
-/* #define DEBUG 1 */
#define _GNU_SOURCE
#include <stdint.h>
#include <stdio.h>
diff --git a/kexec/arch/ppc/include/arch/options.h b/kexec/arch/ppc/include/arch/options.h
index 0c00ea7..b2176ab 100644
--- a/kexec/arch/ppc/include/arch/options.h
+++ b/kexec/arch/ppc/include/arch/options.h
@@ -40,8 +40,7 @@
{"initrd", 1, 0, OPT_APPEND},\
{"gamecube", 1, 0, OPT_GAMECUBE},\
{"dtb", 1, 0, OPT_DTB},\
- {"reuse-node", 1, 0, OPT_NODES},\
- {"debug", 0, 0, OPT_DEBUG},
+ {"reuse-node", 1, 0, OPT_NODES},
#define KEXEC_ALL_OPT_STR KEXEC_OPT_STR
diff --git a/kexec/arch/ppc/kexec-dol-ppc.c b/kexec/arch/ppc/kexec-dol-ppc.c
index 8de5293..5fc5e06 100644
--- a/kexec/arch/ppc/kexec-dol-ppc.c
+++ b/kexec/arch/ppc/kexec-dol-ppc.c
@@ -311,8 +311,7 @@ int dol_ppc_probe(const char *buf, off_t dol_length)
void dol_ppc_usage(void)
{
printf
- ("-d, --debug Enable debugging to help spot a failure.\n"
- " --command-line=STRING Set the kernel command line to STRING.\n"
+ (" --command-line=STRING Set the kernel command line to STRING.\n"
" --append=STRING Set the kernel command line to STRING.\n");
}
@@ -339,7 +338,6 @@ int dol_ppc_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
/* See options.h -- add any more there, too. */
static const struct option options[] = {
KEXEC_ARCH_OPTIONS
- {"debug", 0, 0, OPT_DEBUG},
{"command-line", 1, 0, OPT_APPEND},
{"append", 1, 0, OPT_APPEND},
{0, 0, 0, 0},
@@ -349,7 +347,6 @@ int dol_ppc_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
/*
* Parse the command line arguments
*/
- debug = 0;
command_line = 0;
while ((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
switch (opt) {
@@ -361,9 +358,6 @@ int dol_ppc_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
case '?':
usage();
return -1;
- case OPT_DEBUG:
- debug = 1;
- break;
case OPT_APPEND:
command_line = optarg;
break;
diff --git a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
index 8b2e0e5..a1291a6 100644
--- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
+++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
@@ -60,9 +60,7 @@ static const char *reloc_name(unsigned long r_type)
void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), unsigned long r_type,
void *location, unsigned long address, unsigned long value)
{
-#ifdef DEBUG
- fprintf(stderr, "%s\n", reloc_name(r_type));
-#endif
+ dbgprintf("%s\n", reloc_name(r_type));
switch(r_type) {
case R_X86_64_NONE:
break;
diff --git a/kexec/crashdump.c b/kexec/crashdump.c
index 847d080..cdd3ef6 100644
--- a/kexec/crashdump.c
+++ b/kexec/crashdump.c
@@ -102,9 +102,8 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len)
die("Cannot parse %s: %s\n", crash_notes, strerror(errno));
*addr = (uint64_t) temp;
*len = MAX_NOTE_BYTES; /* we should get this from the kernel instead */
-#ifdef DEBUG
- printf("%s: crash_notes addr = %Lx\n", __FUNCTION__, *addr);
-#endif
+
+ dbgprintf("%s: crash_notes addr = %Lx\n", __FUNCTION__, *addr);
fclose(fp);
return 0;
diff --git a/kexec/kexec-elf-rel.c b/kexec/kexec-elf-rel.c
index f102fb8..c04c972 100644
--- a/kexec/kexec-elf-rel.c
+++ b/kexec/kexec-elf-rel.c
@@ -363,8 +363,8 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
name = ehdr->e_shdr[ehdr->e_shstrndx].sh_data;
name += ehdr->e_shdr[sym.st_shndx].sh_name;
}
-#ifdef DEBUG
- fprintf(stderr, "sym: %10s info: %02x other: %02x shndx: %lx value: %lx size: %lx\n",
+
+ dbgprintf("sym: %10s info: %02x other: %02x shndx: %lx value: %lx size: %lx\n",
name,
sym.st_info,
sym.st_other,
@@ -372,7 +372,6 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
sym.st_value,
sym.st_size);
-#endif
if (sym.st_shndx == STN_UNDEF) {
/*
* NOTE: ppc64 elf .ro shows up a UNDEF section.
@@ -405,10 +404,10 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info,
value = sym.st_value;
value += sec_base;
value += rel.r_addend;
-#ifdef DEBUG
- fprintf(stderr, "sym: %s value: %lx addr: %lx\n",
+
+ dbgprintf("sym: %s value: %lx addr: %lx\n",
name, value, address);
-#endif
+
machine_apply_elf_rel(ehdr, rel.r_type,
(void *)location, address, value);
}
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 89e725e..19133fa 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -50,6 +50,7 @@
unsigned long long mem_min = 0;
unsigned long long mem_max = ULONG_MAX;
static unsigned long kexec_flags = 0;
+int kexec_debug = 0;
void die(char *fmt, ...)
{
@@ -893,6 +894,7 @@ void usage(void)
" context of current kernel during kexec.\n"
" --load-jump-back-helper Load a helper image to jump back\n"
" to original kernel.\n"
+ " -d, --debug Enable debugging to help spot a failure.\n"
"\n"
"Supported kernel file types and options: \n");
for (i = 0; i < file_types; i++) {
@@ -1066,6 +1068,8 @@ int main(int argc, char *argv[])
case OPT_VERSION:
version();
return 0;
+ case OPT_DEBUG:
+ kexec_debug = 1;
case OPT_NOIFDOWN:
do_ifdown = 0;
break;
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 9b59890..dfd3630 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -95,6 +95,13 @@ do { \
} while(0)
extern unsigned long long mem_min, mem_max;
+extern int kexec_debug;
+
+#define dbgprintf(...) \
+do { \
+ if (kexec_debug) \
+ fprintf(stderr, __VA_ARGS__); \
+} while(0)
struct kexec_segment {
const void *buf;
@@ -198,6 +205,7 @@ extern int file_types;
{ "mem-min", 1, 0, OPT_MEM_MIN }, \
{ "mem-max", 1, 0, OPT_MEM_MAX }, \
{ "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \
+ { "debug", 0, 0, OPT_DEBUG }, \
#define KEXEC_OPT_STR "hvdfxluet:p"
@@ -258,13 +266,6 @@ extern int add_backup_segments(struct kexec_info *info,
#define MAX_LINE 160
-#ifdef DEBUG
-#define dbgprintf(_args...) do {printf(_args);} while(0)
-#else
-static inline int __attribute__ ((format (printf, 1, 2)))
- dbgprintf(const char *UNUSED(fmt), ...) {return 0;}
-#endif
-
char *concat_cmdline(const char *base, const char *append);
#endif /* KEXEC_H */
--
1.7.7.6
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 2/5] ppc: move DEBUG code to --debug 2012-03-08 6:39 [PATCH 1/5] Add generic debug option Cong Wang @ 2012-03-08 6:39 ` Cong Wang 2012-03-15 6:38 ` Simon Horman 2012-03-08 6:39 ` [PATCH 3/5] arm: " Cong Wang ` (3 subsequent siblings) 4 siblings, 1 reply; 11+ messages in thread From: Cong Wang @ 2012-03-08 6:39 UTC (permalink / raw) To: kexec; +Cc: Cong Wang, Simon Horman Like patch 1/5, this one moves code under #if DEBUG to --debug on ppc arch. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> --- kexec/arch/ppc/crashdump-powerpc.c | 18 ++++++++---------- kexec/arch/ppc/fixup_dtb.c | 25 +++++++++++-------------- kexec/arch/ppc/fs2dt.c | 6 +++--- kexec/arch/ppc/kexec-ppc.c | 17 ++++++++--------- kexec/arch/ppc/libfdt-wrapper.c | 4 ++-- kexec/arch/ppc64/crashdump-ppc64.c | 16 ++++++---------- kexec/arch/ppc64/kexec-elf-ppc64.c | 23 +++++++++++------------ kexec/arch/ppc64/kexec-ppc64.c | 9 +++------ 8 files changed, 52 insertions(+), 66 deletions(-) diff --git a/kexec/arch/ppc/crashdump-powerpc.c b/kexec/arch/ppc/crashdump-powerpc.c index 7c9dbff..1bef69b 100644 --- a/kexec/arch/ppc/crashdump-powerpc.c +++ b/kexec/arch/ppc/crashdump-powerpc.c @@ -226,15 +226,15 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) *range = crash_memory_range; *ranges = memory_ranges; -#if DEBUG + int j; - printf("CRASH MEMORY RANGES\n"); + dbgprintf("CRASH MEMORY RANGES\n"); for (j = 0; j < *ranges; j++) { start = crash_memory_range[j].start; end = crash_memory_range[j].end; - fprintf(stderr, "%016Lx-%016Lx\n", start, end); + dbgprintf("%016Lx-%016Lx\n", start, end); } -#endif + return 0; err: @@ -289,9 +289,9 @@ static int add_cmdline_param(char *cmdline, unsigned long long addr, if (cmdlen > (COMMAND_LINE_SIZE - 1)) die("Command line overflow\n"); strcat(cmdline, str); -#if DEBUG - fprintf(stderr, "Command line after adding elfcorehdr: %s\n", cmdline); -#endif + + dbgprintf("Command line after adding elfcorehdr: %s\n", cmdline); + return 0; } @@ -403,10 +403,8 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size) usablemem_rgns.ranges[usablemem_rgns.size].start = base; usablemem_rgns.ranges[usablemem_rgns.size++].end = end; -#ifdef DEBUG - fprintf(stderr, "usable memory rgns size:%u base:%llx size:%llx\n", + dbgprintf("usable memory rgns size:%u base:%llx size:%llx\n", usablemem_rgns.size, base, size); -#endif } int is_crashkernel_mem_reserved(void) diff --git a/kexec/arch/ppc/fixup_dtb.c b/kexec/arch/ppc/fixup_dtb.c index 189e0c7..e5f2717 100644 --- a/kexec/arch/ppc/fixup_dtb.c +++ b/kexec/arch/ppc/fixup_dtb.c @@ -17,25 +17,26 @@ const char proc_dts[] = "/proc/device-tree"; -#ifdef DEBUG static void print_fdt_reserve_regions(void) { int i, num; + if (!kexec_debug) + return; /* Print out a summary of the final reserve regions */ num = fdt_num_mem_rsv(blob_buf); - printf ("reserve regions: %d\n", num); + dbgprintf ("reserve regions: %d\n", num); for (i = 0; i < num; i++) { uint64_t offset, size; if (fdt_get_mem_rsv(blob_buf, i, &offset, &size) == 0) { - printf("%d: offset: %llx, size: %llx\n", i, offset, size); + dbgprintf("%d: offset: %llx, size: %llx\n", i, offset, size); } else { - printf("Error retreiving reserved region\n"); + dbgprintf("Error retreiving reserved region\n"); } } } -#endif + static void fixup_nodes(char *nodes[]) { @@ -203,9 +204,7 @@ static void fixup_reserve_regions(struct kexec_info *info, char *blob_buf) out: ; -#ifdef DEBUG print_fdt_reserve_regions(); -#endif } static void fixup_memory(struct kexec_info *info, char *blob_buf) @@ -369,23 +368,23 @@ char *fixup_dtb_init(struct kexec_info *info, char *blob_buf, off_t *blob_size, return blob_buf; } -#ifdef DEBUG static void save_fixed_up_dtb(char *blob_buf, off_t blob_size) { FILE *fp; + if (!kexec_debug) + return; fp = fopen("debug.dtb", "w"); if (fp) { if ( blob_size == fwrite(blob_buf, sizeof(char), blob_size, fp)) { - printf("debug.dtb written\n"); + dbgprintf("debug.dtb written\n"); } else { - printf("Unable to write debug.dtb\n"); + dbgprintf("Unable to write debug.dtb\n"); } } else { - printf("Unable to dump flat device tree to debug.dtb\n"); + dbgprintf("Unable to dump flat device tree to debug.dtb\n"); } } -#endif char *fixup_dtb_finalize(struct kexec_info *info, char *blob_buf, off_t *blob_size, char *nodes[], char *cmdline) @@ -400,9 +399,7 @@ char *fixup_dtb_finalize(struct kexec_info *info, char *blob_buf, off_t *blob_si blob_buf = (char *)dt_ops.finalize(); *blob_size = fdt_totalsize(blob_buf); -#ifdef DEBUG save_fixed_up_dtb(blob_buf, *blob_size); -#endif return blob_buf; } diff --git a/kexec/arch/ppc/fs2dt.c b/kexec/arch/ppc/fs2dt.c index 733515a..cdae69e 100644 --- a/kexec/arch/ppc/fs2dt.c +++ b/kexec/arch/ppc/fs2dt.c @@ -273,9 +273,9 @@ static void putprops(char *fn, struct dirent **nlist, int numlist) memcpy(dt, local_cmdline, cmd_len); len = cmd_len; *dt_len = cmd_len; -#if DEBUG - fprintf(stderr, "Modified cmdline:%s\n", local_cmdline); -#endif + + dbgprintf("Modified cmdline:%s\n", local_cmdline); + } dt += (len + 3)/4; diff --git a/kexec/arch/ppc/kexec-ppc.c b/kexec/arch/ppc/kexec-ppc.c index 57852dc..6075477 100644 --- a/kexec/arch/ppc/kexec-ppc.c +++ b/kexec/arch/ppc/kexec-ppc.c @@ -378,9 +378,9 @@ static int get_base_ranges(void) nr_memory_ranges = local_memory_ranges; sort_base_ranges(); memory_max = base_memory_range[nr_memory_ranges - 1].end; -#ifdef DEBUG - fprintf(stderr, "get base memory ranges:%d\n", nr_memory_ranges); -#endif + + dbgprintf("get base memory ranges:%d\n", nr_memory_ranges); + return 0; } @@ -716,13 +716,13 @@ static int get_devtree_details(unsigned long kexec_flags) sort_ranges(); -#ifdef DEBUG + int k; for (k = 0; k < i; k++) - fprintf(stderr, "exclude_range sorted exclude_range[%d] " + dbgprintf("exclude_range sorted exclude_range[%d] " "start:%llx, end:%llx\n", k, exclude_range[k].start, exclude_range[k].end); -#endif + return 0; error_openfile: @@ -812,13 +812,12 @@ static int setup_memory_ranges(unsigned long kexec_flags) } else nr_memory_ranges = j; -#ifdef DEBUG + int k; for (k = 0; k < j; k++) - fprintf(stderr, "setup_memory_ranges memory_range[%d] " + dbgprintf("setup_memory_ranges memory_range[%d] " "start:%llx, end:%llx\n", k, memory_range[k].start, memory_range[k].end); -#endif return 0; out: diff --git a/kexec/arch/ppc/libfdt-wrapper.c b/kexec/arch/ppc/libfdt-wrapper.c index f56ccc0..5fbd3a8 100644 --- a/kexec/arch/ppc/libfdt-wrapper.c +++ b/kexec/arch/ppc/libfdt-wrapper.c @@ -27,15 +27,15 @@ #include <page.h> #include <libfdt.h> #include "ops.h" +#include "../../kexec.h" -#define DEBUG 0 #define BAD_ERROR(err) (((err) < 0) \ && ((err) != -FDT_ERR_NOTFOUND) \ && ((err) != -FDT_ERR_EXISTS)) #define check_err(err) \ ({ \ - if (BAD_ERROR(err) || ((err < 0) && DEBUG)) \ + if (BAD_ERROR(err) || ((err < 0) && kexec_debug)) \ printf("%s():%d %s\n\r", __func__, __LINE__, \ fdt_strerror(err)); \ if (BAD_ERROR(err)) \ diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c index d52b438..5805cdb 100644 --- a/kexec/arch/ppc64/crashdump-ppc64.c +++ b/kexec/arch/ppc64/crashdump-ppc64.c @@ -304,15 +304,15 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) *range = crash_memory_range; *ranges = memory_ranges; -#if DEBUG + int j; - printf("CRASH MEMORY RANGES\n"); + dbgprintf("CRASH MEMORY RANGES\n"); for(j = 0; j < *ranges; j++) { start = crash_memory_range[j].start; end = crash_memory_range[j].end; - fprintf(stderr, "%016Lx-%016Lx\n", start, end); + dbgprintf("%016Lx-%016Lx\n", start, end); } -#endif + return 0; err: @@ -367,9 +367,7 @@ static int add_cmdline_param(char *cmdline, uint64_t addr, char *cmdstr, if (cmdlen > (COMMAND_LINE_SIZE - 1)) die("Command line overflow\n"); strcat(cmdline, str); -#if DEBUG - fprintf(stderr, "Command line after adding elfcorehdr: %s\n", cmdline); -#endif + dbgprintf("Command line after adding elfcorehdr: %s\n", cmdline); return 0; } @@ -478,10 +476,8 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size) usablemem_rgns.ranges[usablemem_rgns.size].start = base; usablemem_rgns.ranges[usablemem_rgns.size++].end = end; -#ifdef DEBUG - fprintf(stderr, "usable memory rgns size:%u base:%llx size:%llx\n", + dbgprintf("usable memory rgns size:%u base:%llx size:%llx\n", usablemem_rgns.size, base, size); -#endif } int is_crashkernel_mem_reserved(void) diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c index abd83dd..f68f2bc 100644 --- a/kexec/arch/ppc64/kexec-elf-ppc64.c +++ b/kexec/arch/ppc64/kexec-elf-ppc64.c @@ -294,7 +294,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len, /* Set debug */ elf_rel_set_symbol(&info->rhdr, "debug", &my_debug, sizeof(my_debug)); -#ifdef DEBUG + my_kernel = 0; my_dt_offset = 0; my_panic_kernel = 0; @@ -318,19 +318,18 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len, sizeof(toc_addr)); elf_rel_get_symbol(&info->rhdr, "debug", &my_debug, sizeof(my_debug)); - fprintf(stderr, "info->entry is %p\n", info->entry); - fprintf(stderr, "kernel is %llx\n", (unsigned long long)my_kernel); - fprintf(stderr, "dt_offset is %llx\n", + dbgprintf("info->entry is %p\n", info->entry); + dbgprintf("kernel is %llx\n", (unsigned long long)my_kernel); + dbgprintf("dt_offset is %llx\n", (unsigned long long)my_dt_offset); - fprintf(stderr, "run_at_load flag is %x\n", my_run_at_load); - fprintf(stderr, "panic_kernel is %x\n", my_panic_kernel); - fprintf(stderr, "backup_start is %llx\n", + dbgprintf("run_at_load flag is %x\n", my_run_at_load); + dbgprintf("panic_kernel is %x\n", my_panic_kernel); + dbgprintf("backup_start is %llx\n", (unsigned long long)my_backup_start); - fprintf(stderr, "stack is %llx\n", (unsigned long long)my_stack); - fprintf(stderr, "toc_addr is %llx\n", (unsigned long long)toc_addr); - fprintf(stderr, "purgatory size is %zu\n", purgatory_size); - fprintf(stderr, "debug is %d\n", my_debug); -#endif + dbgprintf("stack is %llx\n", (unsigned long long)my_stack); + dbgprintf("toc_addr is %llx\n", (unsigned long long)toc_addr); + dbgprintf("purgatory size is %zu\n", purgatory_size); + dbgprintf("debug is %d\n", my_debug); for (i = 0; i < info->nr_segments; i++) fprintf(stderr, "segment[%d].mem:%p memsz:%zu\n", i, diff --git a/kexec/arch/ppc64/kexec-ppc64.c b/kexec/arch/ppc64/kexec-ppc64.c index 48ea421..2f12907 100644 --- a/kexec/arch/ppc64/kexec-ppc64.c +++ b/kexec/arch/ppc64/kexec-ppc64.c @@ -594,13 +594,12 @@ static int get_devtree_details(unsigned long kexec_flags) sort_ranges(); -#ifdef DEBUG int k; for (k = 0; k < i; k++) - fprintf(stderr, "exclude_range sorted exclude_range[%d] " + dbgprintf("exclude_range sorted exclude_range[%d] " "start:%llx, end:%llx\n", k, exclude_range[k].start, exclude_range[k].end); -#endif + return 0; error_openfile: @@ -687,13 +686,11 @@ int setup_memory_ranges(unsigned long kexec_flags) } nr_memory_ranges = j; -#ifdef DEBUG int k; for (k = 0; k < j; k++) - fprintf(stderr, "setup_memory_ranges memory_range[%d] " + dbgprintf("setup_memory_ranges memory_range[%d] " "start:%llx, end:%llx\n", k, memory_range[k].start, memory_range[k].end); -#endif return 0; out: _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] ppc: move DEBUG code to --debug 2012-03-08 6:39 ` [PATCH 2/5] ppc: move DEBUG code to --debug Cong Wang @ 2012-03-15 6:38 ` Simon Horman 0 siblings, 0 replies; 11+ messages in thread From: Simon Horman @ 2012-03-15 6:38 UTC (permalink / raw) To: Cong Wang; +Cc: linuxppc-dev, kexec [CC linuxppc-dev@ozlabs.org] On Thu, Mar 08, 2012 at 02:39:39PM +0800, Cong Wang wrote: > Like patch 1/5, this one moves code under #if DEBUG to --debug > on ppc arch. > > Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> > --- > kexec/arch/ppc/crashdump-powerpc.c | 18 ++++++++---------- > kexec/arch/ppc/fixup_dtb.c | 25 +++++++++++-------------- > kexec/arch/ppc/fs2dt.c | 6 +++--- > kexec/arch/ppc/kexec-ppc.c | 17 ++++++++--------- > kexec/arch/ppc/libfdt-wrapper.c | 4 ++-- > kexec/arch/ppc64/crashdump-ppc64.c | 16 ++++++---------- > kexec/arch/ppc64/kexec-elf-ppc64.c | 23 +++++++++++------------ > kexec/arch/ppc64/kexec-ppc64.c | 9 +++------ > 8 files changed, 52 insertions(+), 66 deletions(-) > > diff --git a/kexec/arch/ppc/crashdump-powerpc.c b/kexec/arch/ppc/crashdump-powerpc.c > index 7c9dbff..1bef69b 100644 > --- a/kexec/arch/ppc/crashdump-powerpc.c > +++ b/kexec/arch/ppc/crashdump-powerpc.c > @@ -226,15 +226,15 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) > > *range = crash_memory_range; > *ranges = memory_ranges; > -#if DEBUG > + > int j; > - printf("CRASH MEMORY RANGES\n"); > + dbgprintf("CRASH MEMORY RANGES\n"); > for (j = 0; j < *ranges; j++) { > start = crash_memory_range[j].start; > end = crash_memory_range[j].end; > - fprintf(stderr, "%016Lx-%016Lx\n", start, end); > + dbgprintf("%016Lx-%016Lx\n", start, end); > } > -#endif > + > return 0; > > err: > @@ -289,9 +289,9 @@ static int add_cmdline_param(char *cmdline, unsigned long long addr, > if (cmdlen > (COMMAND_LINE_SIZE - 1)) > die("Command line overflow\n"); > strcat(cmdline, str); > -#if DEBUG > - fprintf(stderr, "Command line after adding elfcorehdr: %s\n", cmdline); > -#endif > + > + dbgprintf("Command line after adding elfcorehdr: %s\n", cmdline); > + > return 0; > } > > @@ -403,10 +403,8 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size) > usablemem_rgns.ranges[usablemem_rgns.size].start = base; > usablemem_rgns.ranges[usablemem_rgns.size++].end = end; > > -#ifdef DEBUG > - fprintf(stderr, "usable memory rgns size:%u base:%llx size:%llx\n", > + dbgprintf("usable memory rgns size:%u base:%llx size:%llx\n", > usablemem_rgns.size, base, size); > -#endif > } > > int is_crashkernel_mem_reserved(void) > diff --git a/kexec/arch/ppc/fixup_dtb.c b/kexec/arch/ppc/fixup_dtb.c > index 189e0c7..e5f2717 100644 > --- a/kexec/arch/ppc/fixup_dtb.c > +++ b/kexec/arch/ppc/fixup_dtb.c > @@ -17,25 +17,26 @@ > > const char proc_dts[] = "/proc/device-tree"; > > -#ifdef DEBUG > static void print_fdt_reserve_regions(void) > { > int i, num; > > + if (!kexec_debug) > + return; > /* Print out a summary of the final reserve regions */ > num = fdt_num_mem_rsv(blob_buf); blob_buf does not exist in the context of this function. So clearly it hasn't been compiled or exercised for a while. I propose removing it altogether. It can always be re-added latter if someone fixes and tests it - I do not have access to any ppc hw to do so. > - printf ("reserve regions: %d\n", num); > + dbgprintf ("reserve regions: %d\n", num); > for (i = 0; i < num; i++) { > uint64_t offset, size; > > if (fdt_get_mem_rsv(blob_buf, i, &offset, &size) == 0) { > - printf("%d: offset: %llx, size: %llx\n", i, offset, size); > + dbgprintf("%d: offset: %llx, size: %llx\n", i, offset, size); > } else { > - printf("Error retreiving reserved region\n"); > + dbgprintf("Error retreiving reserved region\n"); > } > } > } > -#endif > + > > static void fixup_nodes(char *nodes[]) > { > @@ -203,9 +204,7 @@ static void fixup_reserve_regions(struct kexec_info *info, char *blob_buf) > > out: ; > > -#ifdef DEBUG > print_fdt_reserve_regions(); > -#endif > } > > static void fixup_memory(struct kexec_info *info, char *blob_buf) > @@ -369,23 +368,23 @@ char *fixup_dtb_init(struct kexec_info *info, char *blob_buf, off_t *blob_size, > return blob_buf; > } > > -#ifdef DEBUG > static void save_fixed_up_dtb(char *blob_buf, off_t blob_size) > { > FILE *fp; > > + if (!kexec_debug) > + return; > fp = fopen("debug.dtb", "w"); > if (fp) { > if ( blob_size == fwrite(blob_buf, sizeof(char), blob_size, fp)) { > - printf("debug.dtb written\n"); > + dbgprintf("debug.dtb written\n"); > } else { > - printf("Unable to write debug.dtb\n"); > + dbgprintf("Unable to write debug.dtb\n"); > } > } else { > - printf("Unable to dump flat device tree to debug.dtb\n"); > + dbgprintf("Unable to dump flat device tree to debug.dtb\n"); > } > } > -#endif > > char *fixup_dtb_finalize(struct kexec_info *info, char *blob_buf, off_t *blob_size, > char *nodes[], char *cmdline) > @@ -400,9 +399,7 @@ char *fixup_dtb_finalize(struct kexec_info *info, char *blob_buf, off_t *blob_si > blob_buf = (char *)dt_ops.finalize(); > *blob_size = fdt_totalsize(blob_buf); > > -#ifdef DEBUG > save_fixed_up_dtb(blob_buf, *blob_size); > -#endif > > return blob_buf; > } > diff --git a/kexec/arch/ppc/fs2dt.c b/kexec/arch/ppc/fs2dt.c > index 733515a..cdae69e 100644 > --- a/kexec/arch/ppc/fs2dt.c > +++ b/kexec/arch/ppc/fs2dt.c > @@ -273,9 +273,9 @@ static void putprops(char *fn, struct dirent **nlist, int numlist) > memcpy(dt, local_cmdline, cmd_len); > len = cmd_len; > *dt_len = cmd_len; > -#if DEBUG > - fprintf(stderr, "Modified cmdline:%s\n", local_cmdline); > -#endif > + > + dbgprintf("Modified cmdline:%s\n", local_cmdline); > + > } > > dt += (len + 3)/4; > diff --git a/kexec/arch/ppc/kexec-ppc.c b/kexec/arch/ppc/kexec-ppc.c > index 57852dc..6075477 100644 > --- a/kexec/arch/ppc/kexec-ppc.c > +++ b/kexec/arch/ppc/kexec-ppc.c > @@ -378,9 +378,9 @@ static int get_base_ranges(void) > nr_memory_ranges = local_memory_ranges; > sort_base_ranges(); > memory_max = base_memory_range[nr_memory_ranges - 1].end; > -#ifdef DEBUG > - fprintf(stderr, "get base memory ranges:%d\n", nr_memory_ranges); > -#endif > + > + dbgprintf("get base memory ranges:%d\n", nr_memory_ranges); > + > return 0; > } > > @@ -716,13 +716,13 @@ static int get_devtree_details(unsigned long kexec_flags) > > sort_ranges(); > > -#ifdef DEBUG > + > int k; > for (k = 0; k < i; k++) > - fprintf(stderr, "exclude_range sorted exclude_range[%d] " > + dbgprintf("exclude_range sorted exclude_range[%d] " > "start:%llx, end:%llx\n", k, exclude_range[k].start, > exclude_range[k].end); > -#endif > + > return 0; > > error_openfile: > @@ -812,13 +812,12 @@ static int setup_memory_ranges(unsigned long kexec_flags) > } else > nr_memory_ranges = j; > > -#ifdef DEBUG > + > int k; > for (k = 0; k < j; k++) > - fprintf(stderr, "setup_memory_ranges memory_range[%d] " > + dbgprintf("setup_memory_ranges memory_range[%d] " > "start:%llx, end:%llx\n", k, memory_range[k].start, > memory_range[k].end); > -#endif > return 0; > > out: > diff --git a/kexec/arch/ppc/libfdt-wrapper.c b/kexec/arch/ppc/libfdt-wrapper.c > index f56ccc0..5fbd3a8 100644 > --- a/kexec/arch/ppc/libfdt-wrapper.c > +++ b/kexec/arch/ppc/libfdt-wrapper.c > @@ -27,15 +27,15 @@ > #include <page.h> > #include <libfdt.h> > #include "ops.h" > +#include "../../kexec.h" > > -#define DEBUG 0 > #define BAD_ERROR(err) (((err) < 0) \ > && ((err) != -FDT_ERR_NOTFOUND) \ > && ((err) != -FDT_ERR_EXISTS)) > > #define check_err(err) \ > ({ \ > - if (BAD_ERROR(err) || ((err < 0) && DEBUG)) \ > + if (BAD_ERROR(err) || ((err < 0) && kexec_debug)) \ > printf("%s():%d %s\n\r", __func__, __LINE__, \ > fdt_strerror(err)); \ > if (BAD_ERROR(err)) \ > diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c > index d52b438..5805cdb 100644 > --- a/kexec/arch/ppc64/crashdump-ppc64.c > +++ b/kexec/arch/ppc64/crashdump-ppc64.c > @@ -304,15 +304,15 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) > > *range = crash_memory_range; > *ranges = memory_ranges; > -#if DEBUG > + > int j; > - printf("CRASH MEMORY RANGES\n"); > + dbgprintf("CRASH MEMORY RANGES\n"); > for(j = 0; j < *ranges; j++) { > start = crash_memory_range[j].start; > end = crash_memory_range[j].end; > - fprintf(stderr, "%016Lx-%016Lx\n", start, end); > + dbgprintf("%016Lx-%016Lx\n", start, end); > } > -#endif > + > return 0; > > err: > @@ -367,9 +367,7 @@ static int add_cmdline_param(char *cmdline, uint64_t addr, char *cmdstr, > if (cmdlen > (COMMAND_LINE_SIZE - 1)) > die("Command line overflow\n"); > strcat(cmdline, str); > -#if DEBUG > - fprintf(stderr, "Command line after adding elfcorehdr: %s\n", cmdline); > -#endif > + dbgprintf("Command line after adding elfcorehdr: %s\n", cmdline); > return 0; > } > > @@ -478,10 +476,8 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size) > usablemem_rgns.ranges[usablemem_rgns.size].start = base; > usablemem_rgns.ranges[usablemem_rgns.size++].end = end; > > -#ifdef DEBUG > - fprintf(stderr, "usable memory rgns size:%u base:%llx size:%llx\n", > + dbgprintf("usable memory rgns size:%u base:%llx size:%llx\n", > usablemem_rgns.size, base, size); > -#endif > } > > int is_crashkernel_mem_reserved(void) > diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c > index abd83dd..f68f2bc 100644 > --- a/kexec/arch/ppc64/kexec-elf-ppc64.c > +++ b/kexec/arch/ppc64/kexec-elf-ppc64.c > @@ -294,7 +294,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len, > > /* Set debug */ > elf_rel_set_symbol(&info->rhdr, "debug", &my_debug, sizeof(my_debug)); > -#ifdef DEBUG > + > my_kernel = 0; > my_dt_offset = 0; > my_panic_kernel = 0; > @@ -318,19 +318,18 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len, > sizeof(toc_addr)); > elf_rel_get_symbol(&info->rhdr, "debug", &my_debug, sizeof(my_debug)); > > - fprintf(stderr, "info->entry is %p\n", info->entry); > - fprintf(stderr, "kernel is %llx\n", (unsigned long long)my_kernel); > - fprintf(stderr, "dt_offset is %llx\n", > + dbgprintf("info->entry is %p\n", info->entry); > + dbgprintf("kernel is %llx\n", (unsigned long long)my_kernel); > + dbgprintf("dt_offset is %llx\n", > (unsigned long long)my_dt_offset); > - fprintf(stderr, "run_at_load flag is %x\n", my_run_at_load); > - fprintf(stderr, "panic_kernel is %x\n", my_panic_kernel); > - fprintf(stderr, "backup_start is %llx\n", > + dbgprintf("run_at_load flag is %x\n", my_run_at_load); > + dbgprintf("panic_kernel is %x\n", my_panic_kernel); > + dbgprintf("backup_start is %llx\n", > (unsigned long long)my_backup_start); > - fprintf(stderr, "stack is %llx\n", (unsigned long long)my_stack); > - fprintf(stderr, "toc_addr is %llx\n", (unsigned long long)toc_addr); > - fprintf(stderr, "purgatory size is %zu\n", purgatory_size); > - fprintf(stderr, "debug is %d\n", my_debug); > -#endif > + dbgprintf("stack is %llx\n", (unsigned long long)my_stack); > + dbgprintf("toc_addr is %llx\n", (unsigned long long)toc_addr); > + dbgprintf("purgatory size is %zu\n", purgatory_size); > + dbgprintf("debug is %d\n", my_debug); > > for (i = 0; i < info->nr_segments; i++) > fprintf(stderr, "segment[%d].mem:%p memsz:%zu\n", i, > diff --git a/kexec/arch/ppc64/kexec-ppc64.c b/kexec/arch/ppc64/kexec-ppc64.c > index 48ea421..2f12907 100644 > --- a/kexec/arch/ppc64/kexec-ppc64.c > +++ b/kexec/arch/ppc64/kexec-ppc64.c > @@ -594,13 +594,12 @@ static int get_devtree_details(unsigned long kexec_flags) > > sort_ranges(); > > -#ifdef DEBUG > int k; > for (k = 0; k < i; k++) > - fprintf(stderr, "exclude_range sorted exclude_range[%d] " > + dbgprintf("exclude_range sorted exclude_range[%d] " > "start:%llx, end:%llx\n", k, exclude_range[k].start, > exclude_range[k].end); > -#endif > + > return 0; > > error_openfile: > @@ -687,13 +686,11 @@ int setup_memory_ranges(unsigned long kexec_flags) > } > nr_memory_ranges = j; > > -#ifdef DEBUG > int k; > for (k = 0; k < j; k++) > - fprintf(stderr, "setup_memory_ranges memory_range[%d] " > + dbgprintf("setup_memory_ranges memory_range[%d] " > "start:%llx, end:%llx\n", k, memory_range[k].start, > memory_range[k].end); > -#endif > return 0; > > out: > _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/5] arm: move DEBUG code to --debug 2012-03-08 6:39 [PATCH 1/5] Add generic debug option Cong Wang 2012-03-08 6:39 ` [PATCH 2/5] ppc: move DEBUG code to --debug Cong Wang @ 2012-03-08 6:39 ` Cong Wang 2012-03-08 6:39 ` [PATCH 4/5] mips: " Cong Wang ` (2 subsequent siblings) 4 siblings, 0 replies; 11+ messages in thread From: Cong Wang @ 2012-03-08 6:39 UTC (permalink / raw) To: kexec; +Cc: Cong Wang, Simon Horman Like patch 1/5, this one moves code under #if DEBUG to --debug on arm arch. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> --- kexec/arch/arm/crashdump-arm.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c index e9b22bf..213dae2 100644 --- a/kexec/arch/arm/crashdump-arm.c +++ b/kexec/arch/arm/crashdump-arm.c @@ -219,7 +219,6 @@ static void cmdline_add_mem(char *cmdline, unsigned long size) cmdline[COMMAND_LINE_SIZE - 1] = '\0'; } -#ifdef DEBUG static unsigned long long range_size(const struct memory_range *r) { return r->end - r->start + 1; @@ -229,6 +228,9 @@ static void dump_memory_ranges(void) { int i; + if (!kexec_debug) + return; + dbgprintf("crashkernel: [%#llx - %#llx] (%ldM)\n", crash_reserved_mem.start, crash_reserved_mem.end, (unsigned long)range_size(&crash_reserved_mem) >> 20); @@ -239,9 +241,6 @@ static void dump_memory_ranges(void) r->start, r->end, (unsigned long)range_size(r) >> 20); } } -#else -static inline void dump_memory_ranges(void) {} -#endif /** * load_crashdump_segments() - loads additional segments needed for kdump -- 1.7.7.6 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/5] mips: move DEBUG code to --debug 2012-03-08 6:39 [PATCH 1/5] Add generic debug option Cong Wang 2012-03-08 6:39 ` [PATCH 2/5] ppc: move DEBUG code to --debug Cong Wang 2012-03-08 6:39 ` [PATCH 3/5] arm: " Cong Wang @ 2012-03-08 6:39 ` Cong Wang 2012-03-08 6:39 ` [PATCH 5/5] sh: " Cong Wang 2012-03-13 0:21 ` [PATCH 1/5] Add generic debug option Simon Horman 4 siblings, 0 replies; 11+ messages in thread From: Cong Wang @ 2012-03-08 6:39 UTC (permalink / raw) To: kexec; +Cc: Cong Wang, Simon Horman Like patch 1/5, this one moves code under #if DEBUG to --debug on mips arch. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> --- kexec/arch/mips/crashdump-mips.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-) diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c index e90b362..f988698 100644 --- a/kexec/arch/mips/crashdump-mips.c +++ b/kexec/arch/mips/crashdump-mips.c @@ -60,9 +60,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info) if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) { elf_info->kern_paddr_start = start; -#ifdef DEBUG - printf("kernel load physical addr start = 0x%lx\n", start); -#endif + dbgprintf("kernel load physical addr start = 0x%lx\n", start); return 0; } @@ -82,12 +80,10 @@ static int get_kernel_vaddr_and_size(struct crash_elf_info *elf_info, start_offset; if (parse_iomem_single("Kernel data\n", NULL, &end) == 0) { elf_info->kern_size = end - elf_info->kern_paddr_start; -#ifdef DEBUG - printf("kernel_vaddr= 0x%llx paddr %llx\n", + dbgprintf("kernel_vaddr= 0x%llx paddr %llx\n", elf_info->kern_vaddr_start, elf_info->kern_paddr_start); - printf("kernel size = 0x%llx\n", elf_info->kern_size); -#endif + dbgprintf("kernel size = 0x%llx\n", elf_info->kern_size); return 0; } fprintf(stderr, "Cannot determine kernel virtual load addr and size\n"); @@ -400,11 +396,9 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr); cmdline_add_savemaxmem(mod_cmdline, saved_max_mem); -#ifdef DEBUG - printf("CRASH MEMORY RANGES:\n"); - printf("%016Lx-%016Lx\n", crash_reserved_mem.start, + dbgprintf("CRASH MEMORY RANGES:\n"); + dbgprintf("%016Lx-%016Lx\n", crash_reserved_mem.start, crash_reserved_mem.end); -#endif return 0; } -- 1.7.7.6 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/5] sh: move DEBUG code to --debug 2012-03-08 6:39 [PATCH 1/5] Add generic debug option Cong Wang ` (2 preceding siblings ...) 2012-03-08 6:39 ` [PATCH 4/5] mips: " Cong Wang @ 2012-03-08 6:39 ` Cong Wang 2012-03-13 0:21 ` [PATCH 1/5] Add generic debug option Simon Horman 4 siblings, 0 replies; 11+ messages in thread From: Cong Wang @ 2012-03-08 6:39 UTC (permalink / raw) To: kexec; +Cc: Cong Wang, Simon Horman Like patch 1/5, this one moves code under #if DEBUG to --debug on sh arch. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> --- kexec/arch/sh/crashdump-sh.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kexec/arch/sh/crashdump-sh.c b/kexec/arch/sh/crashdump-sh.c index f3c8c74..68ca756 100644 --- a/kexec/arch/sh/crashdump-sh.c +++ b/kexec/arch/sh/crashdump-sh.c @@ -142,9 +142,9 @@ static int add_cmdline_param(char *cmdline, uint64_t addr, char *cmdstr, if (cmdlen > (COMMAND_LINE_SIZE - 1)) die("Command line overflow\n"); strcat(cmdline, str); -#if DEBUG - fprintf(stderr, "Command line after adding elfcorehdr: %s\n", cmdline); -#endif + + dbgprintf("Command line after adding elfcorehdr: %s\n", cmdline); + return 0; } -- 1.7.7.6 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/5] Add generic debug option 2012-03-08 6:39 [PATCH 1/5] Add generic debug option Cong Wang ` (3 preceding siblings ...) 2012-03-08 6:39 ` [PATCH 5/5] sh: " Cong Wang @ 2012-03-13 0:21 ` Simon Horman 2012-03-13 2:58 ` Cong Wang 4 siblings, 1 reply; 11+ messages in thread From: Simon Horman @ 2012-03-13 0:21 UTC (permalink / raw) To: Cong Wang; +Cc: kexec On Thu, Mar 08, 2012 at 02:39:38PM +0800, Cong Wang wrote: > Currently the debugging code is under #ifdef DEBUG, which > means when we want to debug, we have to re-compile the source > code with -DDEBUG. This is not convenient, we want to have > a generic --debug option so that we can enable debugging code > without re-compiling. > > This patch moves the arch-specific --debug to generic place > and moves code under #ifdef DEBUG to --debug on x86. > > BTW, the size of kexec binary increases very little after this patch. Hi Cong, In general I am happy with making kexec easier to use. However, it would be nice not to make kexec-tools even bigger than it already is. Its size already seems to be an issue for some people on ARM at least. Do you have some feeling for the change in binary size on architectures other than i386? > Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> > --- > kexec/arch/i386/crashdump-x86.c | 74 +++++++++++++----------------- > kexec/arch/i386/include/arch/options.h | 1 - > kexec/arch/i386/kexec-beoboot-x86.c | 12 +---- > kexec/arch/i386/kexec-bzImage.c | 18 ++----- > kexec/arch/i386/kexec-x86.h | 2 +- > kexec/arch/i386/x86-linux-setup.c | 1 - > kexec/arch/ppc/include/arch/options.h | 3 +- > kexec/arch/ppc/kexec-dol-ppc.c | 8 +--- > kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 4 +- > kexec/crashdump.c | 5 +- > kexec/kexec-elf-rel.c | 11 ++-- > kexec/kexec.c | 4 ++ > kexec/kexec.h | 15 +++--- > 13 files changed, 63 insertions(+), 95 deletions(-) > > diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c > index 436797a..590c883 100644 > --- a/kexec/arch/i386/crashdump-x86.c > +++ b/kexec/arch/i386/crashdump-x86.c > @@ -76,9 +76,7 @@ static int get_kernel_paddr(struct kexec_info *UNUSED(info), > > if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) { > elf_info->kern_paddr_start = start; > -#ifdef DEBUG > - printf("kernel load physical addr start = 0x%016Lx\n", start); > -#endif > + dbgprintf("kernel load physical addr start = 0x%016Lx\n", start); > return 0; > } > > @@ -150,10 +148,8 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info), > /* Align size to page size boundary. */ > size = (size + align - 1) & (~(align - 1)); > elf_info->kern_size = size; > -#ifdef DEBUG > - printf("kernel vaddr = 0x%lx size = 0x%llx\n", > + dbgprintf("kernel vaddr = 0x%lx size = 0x%llx\n", > saddr, size); > -#endif > return 0; > } > } > @@ -211,10 +207,8 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, > if (count != 2) > continue; > str = line + consumed; > -#ifdef DEBUG > - printf("%016Lx-%016Lx : %s", > + dbgprintf("%016Lx-%016Lx : %s", > start, end, str); > -#endif > /* Only Dumping memory of type System RAM. */ > if (memcmp(str, "System RAM\n", 11) == 0) { > type = RANGE_RAM; > @@ -290,15 +284,15 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, > } > *range = crash_memory_range; > *ranges = memory_ranges; > -#ifdef DEBUG > + > int i; > - printf("CRASH MEMORY RANGES\n"); > + dbgprintf("CRASH MEMORY RANGES\n"); > for(i = 0; i < memory_ranges; i++) { > start = crash_memory_range[i].start; > end = crash_memory_range[i].end; > - printf("%016Lx-%016Lx\n", start, end); > + dbgprintf("%016Lx-%016Lx\n", start, end); > } > -#endif > + > return 0; > } > > @@ -385,17 +379,17 @@ static int add_memmap(struct memory_range *memmap_p, unsigned long long addr, > memmap_p[j+1] = memmap_p[j]; > memmap_p[tidx].start = addr; > memmap_p[tidx].end = addr + size - 1; > -#ifdef DEBUG > - printf("Memmap after adding segment\n"); > + > + dbgprintf("Memmap after adding segment\n"); > for (i = 0; i < CRASH_MAX_MEMMAP_NR; i++) { > mstart = memmap_p[i].start; > mend = memmap_p[i].end; > if (mstart == 0 && mend == 0) > break; > - printf("%016llx - %016llx\n", > + dbgprintf("%016llx - %016llx\n", > mstart, mend); > } > -#endif > + > return 0; > } > > @@ -471,18 +465,18 @@ static int delete_memmap(struct memory_range *memmap_p, unsigned long long addr, > memmap_p[j-1] = memmap_p[j]; > memmap_p[j-1].start = memmap_p[j-1].end = 0; > } > -#ifdef DEBUG > - printf("Memmap after deleting segment\n"); > + > + dbgprintf("Memmap after deleting segment\n"); > for (i = 0; i < CRASH_MAX_MEMMAP_NR; i++) { > mstart = memmap_p[i].start; > mend = memmap_p[i].end; > if (mstart == 0 && mend == 0) { > break; > } > - printf("%016llx - %016llx\n", > + dbgprintf("%016llx - %016llx\n", > mstart, mend); > } > -#endif > + > return 0; > } > > @@ -546,10 +540,10 @@ static int cmdline_add_memmap(char *cmdline, struct memory_range *memmap_p) > die("Command line overflow\n"); > strcat(cmdline, str_mmap); > } > -#ifdef DEBUG > - printf("Command line after adding memmap\n"); > - printf("%s\n", cmdline); > -#endif > + > + dbgprintf("Command line after adding memmap\n"); > + dbgprintf("%s\n", cmdline); > + > return 0; > } > > @@ -574,10 +568,10 @@ static int cmdline_add_elfcorehdr(char *cmdline, unsigned long addr) > if (cmdlen > (COMMAND_LINE_SIZE - 1)) > die("Command line overflow\n"); > strcat(cmdline, str); > -#ifdef DEBUG > - printf("Command line after adding elfcorehdr\n"); > - printf("%s\n", cmdline); > -#endif > + > + dbgprintf("Command line after adding elfcorehdr\n"); > + dbgprintf("%s\n", cmdline); > + > return 0; > } > > @@ -606,9 +600,9 @@ static int get_crash_notes(int cpu, uint64_t *addr, uint64_t *len) > > *addr = x86__pa(vaddr + (cpu * MAX_NOTE_BYTES)); > *len = MAX_NOTE_BYTES; > -#ifdef DEBUG > - printf("crash_notes addr = %Lx\n", *addr); > -#endif > + > + dbgprintf("crash_notes addr = %Lx\n", *addr); > + > fclose(fp); > return 0; > } else > @@ -658,10 +652,9 @@ static int cmdline_add_memmap_acpi(char *cmdline, unsigned long start, > die("Command line overflow\n"); > strcat(cmdline, str_mmap); > > -#ifdef DEBUG > - printf("Command line after adding acpi memmap\n"); > - printf("%s\n", cmdline); > -#endif > + dbgprintf("Command line after adding acpi memmap\n"); > + dbgprintf("%s\n", cmdline); > + > return 0; > } > > @@ -688,15 +681,12 @@ static void get_backup_area(unsigned long *start, unsigned long *end) > if (count != 2) > continue; > str = line + consumed; > -#ifdef DEBUG > - printf("%016lx-%016lx : %s", > + dbgprintf("%016lx-%016lx : %s", > mstart, mend, str); > -#endif > + > /* Hopefully there is only one RAM region in the first 640K */ > if (memcmp(str, "System RAM\n", 11) == 0 && mend <= 0xa0000 ) { > -#ifdef DEBUG > - printf("%s: %016lx-%016lx : %s", __func__, mstart, mend, str); > -#endif > + dbgprintf("%s: %016lx-%016lx : %s", __func__, mstart, mend, str); > *start = mstart; > *end = mend; > fclose(fp); > diff --git a/kexec/arch/i386/include/arch/options.h b/kexec/arch/i386/include/arch/options.h > index 990527c..89dbd26 100644 > --- a/kexec/arch/i386/include/arch/options.h > +++ b/kexec/arch/i386/include/arch/options.h > @@ -67,7 +67,6 @@ > { "args-elf", 0, NULL, OPT_ARGS_ELF }, \ > { "args-linux", 0, NULL, OPT_ARGS_LINUX }, \ > { "args-none", 0, NULL, OPT_ARGS_NONE }, \ > - { "debug", 0, NULL, OPT_DEBUG }, \ > { "module", 1, 0, OPT_MOD }, \ > { "real-mode", 0, NULL, OPT_REAL_MODE }, > > diff --git a/kexec/arch/i386/kexec-beoboot-x86.c b/kexec/arch/i386/kexec-beoboot-x86.c > index 6d459ae..a65e094 100644 > --- a/kexec/arch/i386/kexec-beoboot-x86.c > +++ b/kexec/arch/i386/kexec-beoboot-x86.c > @@ -64,8 +64,7 @@ int beoboot_probe(const char *buf, off_t len) > > void beoboot_usage(void) > { > - printf( "-d, --debug Enable debugging to help spot a failure.\n" > - " --real-mode Use the kernels real mode entry point.\n" > + printf( " --real-mode Use the kernels real mode entry point.\n" > ); > > /* No parameters are parsed */ > @@ -81,14 +80,13 @@ int beoboot_load(int argc, char **argv, const char *buf, off_t UNUSED(len), > struct beoboot_header bb_header; > const char *command_line, *kernel, *initrd; > > - int debug, real_mode_entry; > + int real_mode_entry; > int opt; > int result; > > /* See options.h -- add any more there, too. */ > static const struct option options[] = { > KEXEC_ARCH_OPTIONS > - { "debug", 0, 0, OPT_DEBUG }, > { "real-mode", 0, 0, OPT_REAL_MODE }, > { 0, 0, 0, 0 }, > }; > @@ -97,7 +95,6 @@ int beoboot_load(int argc, char **argv, const char *buf, off_t UNUSED(len), > /* > * Parse the command line arguments > */ > - debug = 0; > real_mode_entry = 0; > while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) { > switch(opt) { > @@ -109,9 +106,6 @@ int beoboot_load(int argc, char **argv, const char *buf, off_t UNUSED(len), > case '?': > usage(); > return -1; > - case OPT_DEBUG: > - debug = 1; > - break; > case OPT_REAL_MODE: > real_mode_entry = 1; > break; > @@ -134,7 +128,7 @@ int beoboot_load(int argc, char **argv, const char *buf, off_t UNUSED(len), > kernel, bb_header.kernel_size, > command_line, bb_header.cmdline_size, > initrd, bb_header.initrd_size, > - real_mode_entry, debug); > + real_mode_entry); > > return result; > } > diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c > index 29e9165..54c4427 100644 > --- a/kexec/arch/i386/kexec-bzImage.c > +++ b/kexec/arch/i386/kexec-bzImage.c > @@ -85,8 +85,7 @@ int bzImage_probe(const char *buf, off_t len) > > void bzImage_usage(void) > { > - printf( "-d, --debug Enable debugging to help spot a failure.\n" > - " --real-mode Use the kernels real mode entry point.\n" > + printf( " --real-mode Use the kernels real mode entry point.\n" > " --command-line=STRING Set the kernel command line to STRING.\n" > " --append=STRING Set the kernel command line to STRING.\n" > " --reuse-cmdline Use kernel command line from running system.\n" > @@ -100,7 +99,7 @@ int do_bzImage_load(struct kexec_info *info, > const char *kernel, off_t kernel_len, > const char *command_line, off_t command_line_len, > const char *initrd, off_t initrd_len, > - int real_mode_entry, int debug) > + int real_mode_entry) > { > struct x86_linux_header setup_header; > struct x86_linux_param_header *real_mode; > @@ -297,7 +296,7 @@ int do_bzImage_load(struct kexec_info *info, > printf("Starting the kernel in real mode\n"); > regs32.eip = elf_rel_get_addr(&info->rhdr, "entry16"); > } > - if (real_mode_entry && debug) { > + if (real_mode_entry && kexec_debug) { > unsigned long entry16_debug, pre32, first32; > uint32_t old_first32; > /* Find the location of the symbols */ > @@ -338,14 +337,13 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len, > char *ramdisk_buf; > off_t ramdisk_length; > int command_line_len; > - int debug, real_mode_entry; > + int real_mode_entry; > int opt; > int result; > > /* See options.h -- add any more there, too. */ > static const struct option options[] = { > KEXEC_ARCH_OPTIONS > - { "debug", 0, 0, OPT_DEBUG }, > { "command-line", 1, 0, OPT_APPEND }, > { "append", 1, 0, OPT_APPEND }, > { "reuse-cmdline", 0, 0, OPT_REUSE_CMDLINE }, > @@ -356,10 +354,6 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len, > }; > static const char short_options[] = KEXEC_ARCH_OPT_STR "d"; > > - /* > - * Parse the command line arguments > - */ > - debug = 0; > real_mode_entry = 0; > ramdisk = 0; > ramdisk_length = 0; > @@ -373,8 +367,6 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len, > case '?': > usage(); > return -1; > - case OPT_DEBUG: > - debug = 1; > break; > case OPT_APPEND: > append = optarg; > @@ -403,7 +395,7 @@ int bzImage_load(int argc, char **argv, const char *buf, off_t len, > buf, len, > command_line, command_line_len, > ramdisk_buf, ramdisk_length, > - real_mode_entry, debug); > + real_mode_entry); > > free(command_line); > return result; > diff --git a/kexec/arch/i386/kexec-x86.h b/kexec/arch/i386/kexec-x86.h > index aca1841..dfcc51d 100644 > --- a/kexec/arch/i386/kexec-x86.h > +++ b/kexec/arch/i386/kexec-x86.h > @@ -70,7 +70,7 @@ int do_bzImage_load(struct kexec_info *info, > const char *kernel, off_t kernel_len, > const char *command_line, off_t command_line_len, > const char *initrd, off_t initrd_len, > - int real_mode_entry, int debug); > + int real_mode_entry); > > int beoboot_probe(const char *buf, off_t len); > int beoboot_load(int argc, char **argv, const char *buf, off_t len, > diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c > index 0528cea..95c9f97 100644 > --- a/kexec/arch/i386/x86-linux-setup.c > +++ b/kexec/arch/i386/x86-linux-setup.c > @@ -13,7 +13,6 @@ > * GNU General Public License for more details. > * > */ > -/* #define DEBUG 1 */ > #define _GNU_SOURCE > #include <stdint.h> > #include <stdio.h> > diff --git a/kexec/arch/ppc/include/arch/options.h b/kexec/arch/ppc/include/arch/options.h > index 0c00ea7..b2176ab 100644 > --- a/kexec/arch/ppc/include/arch/options.h > +++ b/kexec/arch/ppc/include/arch/options.h > @@ -40,8 +40,7 @@ > {"initrd", 1, 0, OPT_APPEND},\ > {"gamecube", 1, 0, OPT_GAMECUBE},\ > {"dtb", 1, 0, OPT_DTB},\ > - {"reuse-node", 1, 0, OPT_NODES},\ > - {"debug", 0, 0, OPT_DEBUG}, > + {"reuse-node", 1, 0, OPT_NODES}, > > #define KEXEC_ALL_OPT_STR KEXEC_OPT_STR > > diff --git a/kexec/arch/ppc/kexec-dol-ppc.c b/kexec/arch/ppc/kexec-dol-ppc.c > index 8de5293..5fc5e06 100644 > --- a/kexec/arch/ppc/kexec-dol-ppc.c > +++ b/kexec/arch/ppc/kexec-dol-ppc.c > @@ -311,8 +311,7 @@ int dol_ppc_probe(const char *buf, off_t dol_length) > void dol_ppc_usage(void) > { > printf > - ("-d, --debug Enable debugging to help spot a failure.\n" > - " --command-line=STRING Set the kernel command line to STRING.\n" > + (" --command-line=STRING Set the kernel command line to STRING.\n" > " --append=STRING Set the kernel command line to STRING.\n"); > > } > @@ -339,7 +338,6 @@ int dol_ppc_load(int argc, char **argv, const char *buf, off_t UNUSED(len), > /* See options.h -- add any more there, too. */ > static const struct option options[] = { > KEXEC_ARCH_OPTIONS > - {"debug", 0, 0, OPT_DEBUG}, > {"command-line", 1, 0, OPT_APPEND}, > {"append", 1, 0, OPT_APPEND}, > {0, 0, 0, 0}, > @@ -349,7 +347,6 @@ int dol_ppc_load(int argc, char **argv, const char *buf, off_t UNUSED(len), > /* > * Parse the command line arguments > */ > - debug = 0; > command_line = 0; > while ((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) { > switch (opt) { > @@ -361,9 +358,6 @@ int dol_ppc_load(int argc, char **argv, const char *buf, off_t UNUSED(len), > case '?': > usage(); > return -1; > - case OPT_DEBUG: > - debug = 1; > - break; > case OPT_APPEND: > command_line = optarg; > break; > diff --git a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c > index 8b2e0e5..a1291a6 100644 > --- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c > +++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c > @@ -60,9 +60,7 @@ static const char *reloc_name(unsigned long r_type) > void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), unsigned long r_type, > void *location, unsigned long address, unsigned long value) > { > -#ifdef DEBUG > - fprintf(stderr, "%s\n", reloc_name(r_type)); > -#endif > + dbgprintf("%s\n", reloc_name(r_type)); > switch(r_type) { > case R_X86_64_NONE: > break; > diff --git a/kexec/crashdump.c b/kexec/crashdump.c > index 847d080..cdd3ef6 100644 > --- a/kexec/crashdump.c > +++ b/kexec/crashdump.c > @@ -102,9 +102,8 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len) > die("Cannot parse %s: %s\n", crash_notes, strerror(errno)); > *addr = (uint64_t) temp; > *len = MAX_NOTE_BYTES; /* we should get this from the kernel instead */ > -#ifdef DEBUG > - printf("%s: crash_notes addr = %Lx\n", __FUNCTION__, *addr); > -#endif > + > + dbgprintf("%s: crash_notes addr = %Lx\n", __FUNCTION__, *addr); > > fclose(fp); > return 0; > diff --git a/kexec/kexec-elf-rel.c b/kexec/kexec-elf-rel.c > index f102fb8..c04c972 100644 > --- a/kexec/kexec-elf-rel.c > +++ b/kexec/kexec-elf-rel.c > @@ -363,8 +363,8 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, > name = ehdr->e_shdr[ehdr->e_shstrndx].sh_data; > name += ehdr->e_shdr[sym.st_shndx].sh_name; > } > -#ifdef DEBUG > - fprintf(stderr, "sym: %10s info: %02x other: %02x shndx: %lx value: %lx size: %lx\n", > + > + dbgprintf("sym: %10s info: %02x other: %02x shndx: %lx value: %lx size: %lx\n", > name, > sym.st_info, > sym.st_other, > @@ -372,7 +372,6 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, > sym.st_value, > sym.st_size); > > -#endif > if (sym.st_shndx == STN_UNDEF) { > /* > * NOTE: ppc64 elf .ro shows up a UNDEF section. > @@ -405,10 +404,10 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, > value = sym.st_value; > value += sec_base; > value += rel.r_addend; > -#ifdef DEBUG > - fprintf(stderr, "sym: %s value: %lx addr: %lx\n", > + > + dbgprintf("sym: %s value: %lx addr: %lx\n", > name, value, address); > -#endif > + > machine_apply_elf_rel(ehdr, rel.r_type, > (void *)location, address, value); > } > diff --git a/kexec/kexec.c b/kexec/kexec.c > index 89e725e..19133fa 100644 > --- a/kexec/kexec.c > +++ b/kexec/kexec.c > @@ -50,6 +50,7 @@ > unsigned long long mem_min = 0; > unsigned long long mem_max = ULONG_MAX; > static unsigned long kexec_flags = 0; > +int kexec_debug = 0; > > void die(char *fmt, ...) > { > @@ -893,6 +894,7 @@ void usage(void) > " context of current kernel during kexec.\n" > " --load-jump-back-helper Load a helper image to jump back\n" > " to original kernel.\n" > + " -d, --debug Enable debugging to help spot a failure.\n" > "\n" > "Supported kernel file types and options: \n"); > for (i = 0; i < file_types; i++) { > @@ -1066,6 +1068,8 @@ int main(int argc, char *argv[]) > case OPT_VERSION: > version(); > return 0; > + case OPT_DEBUG: > + kexec_debug = 1; > case OPT_NOIFDOWN: > do_ifdown = 0; > break; > diff --git a/kexec/kexec.h b/kexec/kexec.h > index 9b59890..dfd3630 100644 > --- a/kexec/kexec.h > +++ b/kexec/kexec.h > @@ -95,6 +95,13 @@ do { \ > } while(0) > > extern unsigned long long mem_min, mem_max; > +extern int kexec_debug; > + > +#define dbgprintf(...) \ > +do { \ > + if (kexec_debug) \ > + fprintf(stderr, __VA_ARGS__); \ > +} while(0) > > struct kexec_segment { > const void *buf; > @@ -198,6 +205,7 @@ extern int file_types; > { "mem-min", 1, 0, OPT_MEM_MIN }, \ > { "mem-max", 1, 0, OPT_MEM_MAX }, \ > { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ > + { "debug", 0, 0, OPT_DEBUG }, \ > > #define KEXEC_OPT_STR "hvdfxluet:p" > > @@ -258,13 +266,6 @@ extern int add_backup_segments(struct kexec_info *info, > > #define MAX_LINE 160 > > -#ifdef DEBUG > -#define dbgprintf(_args...) do {printf(_args);} while(0) > -#else > -static inline int __attribute__ ((format (printf, 1, 2))) > - dbgprintf(const char *UNUSED(fmt), ...) {return 0;} > -#endif > - > char *concat_cmdline(const char *base, const char *append); > > #endif /* KEXEC_H */ > -- > 1.7.7.6 > _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/5] Add generic debug option 2012-03-13 0:21 ` [PATCH 1/5] Add generic debug option Simon Horman @ 2012-03-13 2:58 ` Cong Wang 2012-03-15 6:48 ` Simon Horman 0 siblings, 1 reply; 11+ messages in thread From: Cong Wang @ 2012-03-13 2:58 UTC (permalink / raw) To: Simon Horman; +Cc: kexec On 03/13/2012 08:21 AM, Simon Horman wrote: > On Thu, Mar 08, 2012 at 02:39:38PM +0800, Cong Wang wrote: >> Currently the debugging code is under #ifdef DEBUG, which >> means when we want to debug, we have to re-compile the source >> code with -DDEBUG. This is not convenient, we want to have >> a generic --debug option so that we can enable debugging code >> without re-compiling. >> >> This patch moves the arch-specific --debug to generic place >> and moves code under #ifdef DEBUG to --debug on x86. >> >> BTW, the size of kexec binary increases very little after this patch. > > Hi Cong, > > In general I am happy with making kexec easier to use. However, it would > be nice not to make kexec-tools even bigger than it already is. Its size > already seems to be an issue for some people on ARM at least. Do you > have some feeling for the change in binary size on architectures other than > i386? > Hi, I only tested the patches on x86 and ppc. Sorry I don't have a chance to test it on ARM, on ARM it just adds a small function dump_memory_ranges(), if this would be a problem, feel free to drop patch 3/5. :) Thanks. _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/5] Add generic debug option 2012-03-13 2:58 ` Cong Wang @ 2012-03-15 6:48 ` Simon Horman 2012-03-20 13:29 ` Cong Wang 0 siblings, 1 reply; 11+ messages in thread From: Simon Horman @ 2012-03-15 6:48 UTC (permalink / raw) To: Cong Wang; +Cc: kexec On Tue, Mar 13, 2012 at 10:58:40AM +0800, Cong Wang wrote: > On 03/13/2012 08:21 AM, Simon Horman wrote: > >On Thu, Mar 08, 2012 at 02:39:38PM +0800, Cong Wang wrote: > >>Currently the debugging code is under #ifdef DEBUG, which > >>means when we want to debug, we have to re-compile the source > >>code with -DDEBUG. This is not convenient, we want to have > >>a generic --debug option so that we can enable debugging code > >>without re-compiling. > >> > >>This patch moves the arch-specific --debug to generic place > >>and moves code under #ifdef DEBUG to --debug on x86. > >> > >>BTW, the size of kexec binary increases very little after this patch. > > > >Hi Cong, > > > >In general I am happy with making kexec easier to use. However, it would > >be nice not to make kexec-tools even bigger than it already is. Its size > >already seems to be an issue for some people on ARM at least. Do you > >have some feeling for the change in binary size on architectures other than > >i386? > > > > Hi, > > I only tested the patches on x86 and ppc. > > Sorry I don't have a chance to test it on ARM, on ARM it just adds a > small function dump_memory_ranges(), if this would be a problem, > feel free to drop patch 3/5. :) Hi, As per my post to the ppc patch, it did not seem to compile for me. I will push the remaining patches. For reference before and after sizes for the non-ppc architectures are as follows. x86_32 ------ gcc (GCC) 4.1.1 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. before: text data bss dec hex filename 141357 828 57948 200133 30dc5 ./build/sbin/kexec after: text data bss dec hex filename 145233 828 57948 204009 31ce9 ./build/sbin/kexec x86_64 ------ gcc (Debian 4.6.2-4) 4.6.2 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. before: text data bss dec hex filename 180875 1552 66344 248771 3cbc3 ./build/sbin/kexec after: text data bss dec hex filename 185371 1552 66344 253267 3dd53 ./build/sbin/kexec arm --- gcc (Sourcery G++ Lite 2011.03-41) 4.5.2 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. before: text data bss dec hex filename 96914 704 16988 114606 1bfae ./build/sbin/kexec after: text data bss dec hex filename 97262 704 16988 114954 1c10a ./build/sbin/kexec mips ---- gcc (Sourcery G++ Lite 4.4-303) 4.4.1 Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. before: text data bss dec hex filename 98160 784 11688 110632 1b028 ./build/sbin/kexec after: text data bss dec hex filename 98560 784 11688 111032 1b1b8 ./build/sbin/kexec sh -- gcc (Sourcery G++ Lite 4.4-200) 4.4.1 Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. before: text data bss dec hex filename 110675 696 11332 122703 1df4f ./build/sbin/kexec after: text data bss dec hex filename 110783 696 11332 122811 1dfbb ./build/sbin/kexec _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/5] Add generic debug option 2012-03-15 6:48 ` Simon Horman @ 2012-03-20 13:29 ` Cong Wang 2012-04-06 2:22 ` Simon Horman 0 siblings, 1 reply; 11+ messages in thread From: Cong Wang @ 2012-03-20 13:29 UTC (permalink / raw) To: Simon Horman; +Cc: kexec On 03/15/2012 02:48 PM, Simon Horman wrote: > On Tue, Mar 13, 2012 at 10:58:40AM +0800, Cong Wang wrote: >> On 03/13/2012 08:21 AM, Simon Horman wrote: >>> On Thu, Mar 08, 2012 at 02:39:38PM +0800, Cong Wang wrote: >>>> Currently the debugging code is under #ifdef DEBUG, which >>>> means when we want to debug, we have to re-compile the source >>>> code with -DDEBUG. This is not convenient, we want to have >>>> a generic --debug option so that we can enable debugging code >>>> without re-compiling. >>>> >>>> This patch moves the arch-specific --debug to generic place >>>> and moves code under #ifdef DEBUG to --debug on x86. >>>> >>>> BTW, the size of kexec binary increases very little after this patch. >>> >>> Hi Cong, >>> >>> In general I am happy with making kexec easier to use. However, it would >>> be nice not to make kexec-tools even bigger than it already is. Its size >>> already seems to be an issue for some people on ARM at least. Do you >>> have some feeling for the change in binary size on architectures other than >>> i386? >>> >> >> Hi, >> >> I only tested the patches on x86 and ppc. >> >> Sorry I don't have a chance to test it on ARM, on ARM it just adds a >> small function dump_memory_ranges(), if this would be a problem, >> feel free to drop patch 3/5. :) > > Hi, > > As per my post to the ppc patch, it did not seem to compile for me. I did compiling and run tests on ppc64 if you mean ppc32 by "ppc". > I will push the remaining patches. For reference before and after > sizes for the non-ppc architectures are as follows. > Ok, I will re-send the ppc patch soon. Thank you! _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/5] Add generic debug option 2012-03-20 13:29 ` Cong Wang @ 2012-04-06 2:22 ` Simon Horman 0 siblings, 0 replies; 11+ messages in thread From: Simon Horman @ 2012-04-06 2:22 UTC (permalink / raw) To: Cong Wang; +Cc: kexec On Tue, Mar 20, 2012 at 09:29:49PM +0800, Cong Wang wrote: > On 03/15/2012 02:48 PM, Simon Horman wrote: > >On Tue, Mar 13, 2012 at 10:58:40AM +0800, Cong Wang wrote: > >>On 03/13/2012 08:21 AM, Simon Horman wrote: > >>>On Thu, Mar 08, 2012 at 02:39:38PM +0800, Cong Wang wrote: > >>>>Currently the debugging code is under #ifdef DEBUG, which > >>>>means when we want to debug, we have to re-compile the source > >>>>code with -DDEBUG. This is not convenient, we want to have > >>>>a generic --debug option so that we can enable debugging code > >>>>without re-compiling. > >>>> > >>>>This patch moves the arch-specific --debug to generic place > >>>>and moves code under #ifdef DEBUG to --debug on x86. > >>>> > >>>>BTW, the size of kexec binary increases very little after this patch. > >>> > >>>Hi Cong, > >>> > >>>In general I am happy with making kexec easier to use. However, it would > >>>be nice not to make kexec-tools even bigger than it already is. Its size > >>>already seems to be an issue for some people on ARM at least. Do you > >>>have some feeling for the change in binary size on architectures other than > >>>i386? > >>> > >> > >>Hi, > >> > >>I only tested the patches on x86 and ppc. > >> > >>Sorry I don't have a chance to test it on ARM, on ARM it just adds a > >>small function dump_memory_ranges(), if this would be a problem, > >>feel free to drop patch 3/5. :) > > > >Hi, > > > >As per my post to the ppc patch, it did not seem to compile for me. > > I did compiling and run tests on ppc64 if you mean ppc32 by "ppc". > > >I will push the remaining patches. For reference before and after > >sizes for the non-ppc architectures are as follows. > > > > Ok, I will re-send the ppc patch soon. Thank you! Sorry, I missed this. But yes, I think it was 32bit ppc where I saw the problem. _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-04-06 2:22 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-03-08 6:39 [PATCH 1/5] Add generic debug option Cong Wang 2012-03-08 6:39 ` [PATCH 2/5] ppc: move DEBUG code to --debug Cong Wang 2012-03-15 6:38 ` Simon Horman 2012-03-08 6:39 ` [PATCH 3/5] arm: " Cong Wang 2012-03-08 6:39 ` [PATCH 4/5] mips: " Cong Wang 2012-03-08 6:39 ` [PATCH 5/5] sh: " Cong Wang 2012-03-13 0:21 ` [PATCH 1/5] Add generic debug option Simon Horman 2012-03-13 2:58 ` Cong Wang 2012-03-15 6:48 ` Simon Horman 2012-03-20 13:29 ` Cong Wang 2012-04-06 2:22 ` Simon Horman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox