[CRIU] [PATCH 4/4] piegen: prefix piegen's output

Laurent Dufour ldufour at linux.vnet.ibm.com
Wed Jun 10 06:00:42 PDT 2015


Add prefix to the piegen's error and debug output to avoid confusion and
fix few debug lines.

Signed-off-by: Laurent Dufour <ldufour at linux.vnet.ibm.com>
---
 pie/piegen/elf.c    | 12 ++++++++----
 pie/piegen/piegen.h |  6 +++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/pie/piegen/elf.c b/pie/piegen/elf.c
index 6c5099d4bdab..8f8448b7bc72 100644
--- a/pie/piegen/elf.c
+++ b/pie/piegen/elf.c
@@ -79,7 +79,8 @@ int handle_elf(void *mem, size_t size)
 	s64 toc_offset = 0;
 #endif
 
-	pr_debug("Header\n------------\n");
+	pr_debug("Header\n");
+	pr_debug("------------\n");
 	pr_debug("\ttype 0x%x machine 0x%x version 0x%x\n",
 		 (unsigned)hdr->e_type, (unsigned)hdr->e_machine, (unsigned)hdr->e_version);
 
@@ -108,7 +109,8 @@ int handle_elf(void *mem, size_t size)
 	ptr_func_exit(secstrings_hdr);
 	ptr_func_exit(secstrings);
 
-	pr_debug("Sections\n------------\n");
+	pr_debug("Sections\n");
+	pr_debug("------------\n");
 	for (i = 0; i < hdr->e_shnum; i++) {
 		Shdr_t *sh = mem + hdr->e_shoff + hdr->e_shentsize * i;
 		ptr_func_exit(sh);
@@ -140,7 +142,8 @@ int handle_elf(void *mem, size_t size)
 		goto err;
 	}
 
-	pr_debug("Symbols\n------------\n");
+	pr_debug("Symbols\n");
+	pr_debug("------------\n");
 	strtab_hdr = sec_hdrs[symtab_hdr->sh_link];
 	ptr_func_exit(strtab_hdr);
 
@@ -198,7 +201,8 @@ int handle_elf(void *mem, size_t size)
 
 	pr_out("static __maybe_unused elf_reloc_t %s[] = {\n", opts.var_name);
 
-	pr_debug("Relocations\n------------\n");
+	pr_debug("Relocations\n");
+	pr_debug("------------\n");
 	for (i = 0; i < hdr->e_shnum; i++) {
 		Shdr_t *sh = sec_hdrs[i];
 		Shdr_t *sh_rel;
diff --git a/pie/piegen/piegen.h b/pie/piegen/piegen.h
index 0f64cbd8fe77..8488c0abb989 100644
--- a/pie/piegen/piegen.h
+++ b/pie/piegen/piegen.h
@@ -27,9 +27,9 @@ extern int handle_elf_ppc64(void *mem, size_t size);
 
 #define pr_out(fmt, ...)	fprintf(fout, fmt, ##__VA_ARGS__)
 
-#define pr_debug(fmt, ...)	printf(fmt, ##__VA_ARGS__)
+#define pr_debug(fmt, ...)	printf("%s: "fmt, opts.stream_name, ##__VA_ARGS__)
 
-#define pr_err(fmt, ...)	fprintf(stderr, "Error (%s:%d): "fmt, __FILE__, __LINE__, ##__VA_ARGS__)
-#define pr_perror(fmt, ...)	fprintf(stderr, "Error (%s:%d): "fmt "%m\n", __FILE__, __LINE__, ##__VA_ARGS__)
+#define pr_err(fmt, ...)	fprintf(stderr, "%s: Error (%s:%d): "fmt, opts.stream_name, __FILE__, __LINE__, ##__VA_ARGS__)
+#define pr_perror(fmt, ...)	fprintf(stderr, "%s: Error (%s:%d): "fmt "%m\n", opts.stream_name, __FILE__, __LINE__, ##__VA_ARGS__)
 
 #endif /* __ELFTIL_H__ */
-- 
1.9.1



More information about the CRIU mailing list