From f05e2dcc1f36f7d4e7e71b059cddc735f56ec0aa Mon Sep 17 00:00:00 2001 From: Andrey Vagin Date: Mon, 16 Jan 2012 13:53:51 +0300 Subject: [PATCH] restorer: don't use printk in restorer BUG_ON_HANDLER from util.h may be used in restorer. E.g. #include #include Now the process will be segfaulted and you can find a line number in assemgler code. We will print messages a bit late. Signed-off-by: Andrey Vagin Acked-by: Pavel Emelyanov --- include/restorer.h | 16 ---------------- include/util.h | 8 ++++++++ restorer.c | 1 + 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/include/restorer.h b/include/restorer.h index d58169b79..03807a960 100644 --- a/include/restorer.h +++ b/include/restorer.h @@ -345,20 +345,4 @@ task_get_entry(struct task_entries *base, int pid) return NULL; } -/* We need own handler */ - -#ifdef BUG_ON_HANDLER -# undef BUG_ON_HANDLER -#endif - -#define BUG_ON_HANDLER(condition) \ - do { \ - if ((condition)) { \ - long tgid = sys_gettid(); \ - write_hex_n(0x5a5a5a5a); \ - write_num_n(__LINE__); \ - sys_tgkill(tgid, tgid, SIGABRT); \ - } \ - } while (0) - #endif /* CR_RESTORER_H__ */ diff --git a/include/util.h b/include/util.h index 4e98c13c5..c7dc8df92 100644 --- a/include/util.h +++ b/include/util.h @@ -87,6 +87,13 @@ extern void printk(const char *format, ...); } while (0) #ifndef BUG_ON_HANDLER +#ifdef CR_NOGLIBC +#define BUG_ON_HANDLER(condition) \ + do { \ + if ((condition)) \ + *(unsigned long *)NULL = 0xdead0000 + __LINE__; \ + } while (0) +#else # define BUG_ON_HANDLER(condition) \ do { \ if ((condition)) { \ @@ -95,6 +102,7 @@ extern void printk(const char *format, ...); } \ } while (0) #endif +#endif #define BUG_ON(condition) BUG_ON_HANDLER((condition)) diff --git a/restorer.c b/restorer.c index 6bf427e01..03ddce2aa 100644 --- a/restorer.c +++ b/restorer.c @@ -1,3 +1,4 @@ +#define CR_NOGLIBC #include #include