Do not define printnum_long_int on systems with constant current_wordsize

* defs.h: Check [!current_wordsize] instead
of [SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] to select
definitions of printnum_slong, printnum_ulong, and printnum_ptr.
* util.c: Check [!current_wordsize] instead
of [SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] to decide
whether to compile printnum_long_int.
This commit is contained in:
Дмитрий Левин 2016-12-26 13:50:14 +00:00
parent 825acc827e
commit 3fb2f299d2
2 changed files with 47 additions and 47 deletions

90
defs.h
View File

@ -597,51 +597,6 @@ extern void
printstr_ex(struct tcb *, kernel_ulong_t addr, kernel_ulong_t len,
unsigned int user_style);
#define DECL_PRINTNUM(name) \
extern bool \
printnum_ ## name(struct tcb *, kernel_ulong_t addr, const char *fmt) \
ATTRIBUTE_FORMAT((printf, 3, 0))
DECL_PRINTNUM(short);
DECL_PRINTNUM(int);
DECL_PRINTNUM(int64);
#undef DECL_PRINTNUM
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
extern bool
printnum_long_int(struct tcb *, kernel_ulong_t addr,
const char *fmt_long, const char *fmt_int)
ATTRIBUTE_FORMAT((printf, 3, 0))
ATTRIBUTE_FORMAT((printf, 4, 0));
# define printnum_slong(tcp, addr) \
printnum_long_int((tcp), (addr), "%" PRId64, "%d")
# define printnum_ulong(tcp, addr) \
printnum_long_int((tcp), (addr), "%" PRIu64, "%u")
# define printnum_ptr(tcp, addr) \
printnum_long_int((tcp), (addr), "%#" PRIx64, "%#x")
#elif SIZEOF_LONG > 4
# define printnum_slong(tcp, addr) \
printnum_int64((tcp), (addr), "%" PRId64)
# define printnum_ulong(tcp, addr) \
printnum_int64((tcp), (addr), "%" PRIu64)
# define printnum_ptr(tcp, addr) \
printnum_int64((tcp), (addr), "%#" PRIx64)
#else
# define printnum_slong(tcp, addr) \
printnum_int((tcp), (addr), "%d")
# define printnum_ulong(tcp, addr) \
printnum_int((tcp), (addr), "%u")
# define printnum_ptr(tcp, addr) \
printnum_int((tcp), (addr), "%#x")
#endif
#define DECL_PRINTPAIR(name) \
extern bool \
printpair_ ## name(struct tcb *, kernel_ulong_t addr, const char *fmt) \
ATTRIBUTE_FORMAT((printf, 3, 0))
DECL_PRINTPAIR(int);
DECL_PRINTPAIR(int64);
#undef DECL_PRINTPAIR
extern void
printpathn(struct tcb *, kernel_ulong_t addr, unsigned int n);
@ -841,6 +796,51 @@ extern unsigned current_klongsize;
# endif
#endif
#define DECL_PRINTNUM(name) \
extern bool \
printnum_ ## name(struct tcb *, kernel_ulong_t addr, const char *fmt) \
ATTRIBUTE_FORMAT((printf, 3, 0))
DECL_PRINTNUM(short);
DECL_PRINTNUM(int);
DECL_PRINTNUM(int64);
#undef DECL_PRINTNUM
#ifndef current_wordsize
extern bool
printnum_long_int(struct tcb *, kernel_ulong_t addr,
const char *fmt_long, const char *fmt_int)
ATTRIBUTE_FORMAT((printf, 3, 0))
ATTRIBUTE_FORMAT((printf, 4, 0));
# define printnum_slong(tcp, addr) \
printnum_long_int((tcp), (addr), "%" PRId64, "%d")
# define printnum_ulong(tcp, addr) \
printnum_long_int((tcp), (addr), "%" PRIu64, "%u")
# define printnum_ptr(tcp, addr) \
printnum_long_int((tcp), (addr), "%#" PRIx64, "%#x")
#elif current_wordsize > 4
# define printnum_slong(tcp, addr) \
printnum_int64((tcp), (addr), "%" PRId64)
# define printnum_ulong(tcp, addr) \
printnum_int64((tcp), (addr), "%" PRIu64)
# define printnum_ptr(tcp, addr) \
printnum_int64((tcp), (addr), "%#" PRIx64)
#else /* current_wordsize == 4 */
# define printnum_slong(tcp, addr) \
printnum_int((tcp), (addr), "%d")
# define printnum_ulong(tcp, addr) \
printnum_int((tcp), (addr), "%u")
# define printnum_ptr(tcp, addr) \
printnum_int((tcp), (addr), "%#x")
#endif
#define DECL_PRINTPAIR(name) \
extern bool \
printpair_ ## name(struct tcb *, kernel_ulong_t addr, const char *fmt) \
ATTRIBUTE_FORMAT((printf, 3, 0))
DECL_PRINTPAIR(int);
DECL_PRINTPAIR(int64);
#undef DECL_PRINTPAIR
/* In many, many places we play fast and loose and use
* tprintf("%d", (int) tcp->u_arg[N]) to print fds, pids etc.
* We probably need to use widen_to_long() instead:

4
util.c
View File

@ -506,7 +506,7 @@ DEF_PRINTNUM(short, short)
DEF_PRINTNUM(int64, uint64_t)
DEF_PRINTPAIR(int64, uint64_t)
#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
#ifndef current_wordsize
bool
printnum_long_int(struct tcb *const tcp, const kernel_ulong_t addr,
const char *const fmt_long, const char *const fmt_int)
@ -517,7 +517,7 @@ printnum_long_int(struct tcb *const tcp, const kernel_ulong_t addr,
return printnum_int(tcp, addr, fmt_int);
}
}
#endif
#endif /* !current_wordsize */
const char *
sprinttime(time_t t)