Use kernel_ulong_t instead of unsigned long long where appropriate

* defs.h (printaddr_ull): Rename to printaddr_klu, change argument
type from unsigned long long to kernel_ulong_t.  All callers updated.
(getarg_ull): Rename to getarg_klu, change return value type
from unsigned long long to kernel_ulong_t.  All callers updated.
(PRI_kl, PRI_kld, PRI_klu, PRI_klx): New macros.
* bjm.c (SYS_FUNC(init_module)): Print kernel_ulong_t type using
PRI_klu format.
* desc.c (SYS_FUNC(pselect6)): Likewise.
* fadvise.c (SYS_FUNC(fadvise64)): Likewise.
* lookup_dcookie.c (SYS_FUNC(lookup_dcookie)): Likewise.
* mq.c (SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive)): Likewise.
* kcmp.c (SYS_FUNC(kcmp)): Print kernel_ulong_t type using
PRI_klx format.
* keyctl.c (SYS_FUNC(keyctl)): Likewise.
* pkeys.c (SYS_FUNC(pkey_alloc)): Likewise.
* prctl.c (print_prctl_args, SYS_FUNC(prctl), SYS_FUNC(arch_prctl)):
Print kernel_ulong_t type using PRI_kld, PRI_klu, or PRI_klx format.
* util.c (printaddr_ull): Rename to printaddr_klu, change argument
type from unsigned long long to kernel_ulong_t, print it using
PRI_klx format.
(getarg_ull): Rename to getarg_klu, change return value type
from unsigned long long to kernel_ulong_t, print it using
PRI_klx format.
This commit is contained in:
Дмитрий Левин 2016-12-19 16:56:45 +00:00
parent e42dac4361
commit a2485b86e7
12 changed files with 53 additions and 41 deletions

4
bjm.c
View File

@ -44,8 +44,8 @@ SYS_FUNC(delete_module)
SYS_FUNC(init_module)
{
printaddr_ull(getarg_ull(tcp, 0));
tprintf(", %llu, ", getarg_ull(tcp, 1));
printaddr_klu(getarg_klu(tcp, 0));
tprintf(", %" PRI_klu ", ", getarg_klu(tcp, 1));
printstr(tcp, tcp->u_arg[2], -1);
return RVAL_DECODED;

View File

@ -153,7 +153,7 @@ SYS_FUNC(setns)
SYS_FUNC(unshare)
{
printflags64(unshare_flags, getarg_ull(tcp, 0), "CLONE_???");
printflags64(unshare_flags, getarg_klu(tcp, 0), "CLONE_???");
return RVAL_DECODED;
}

16
defs.h
View File

@ -571,14 +571,14 @@ extern int getllval(struct tcb *, unsigned long long *, int);
extern int printllval(struct tcb *, const char *, int)
ATTRIBUTE_FORMAT((printf, 2, 0));
extern void printaddr_ull(unsigned long long);
extern void printaddr_klu(kernel_ulong_t addr);
extern int printxvals(const uint64_t, const char *, const struct xlat *, ...)
ATTRIBUTE_SENTINEL;
extern int printxval_searchn(const struct xlat *xlat, size_t xlat_size,
uint64_t val, const char *dflt);
#define printxval_search(xlat__, val__, dflt__) \
printxval_searchn(xlat__, ARRAY_SIZE(xlat__), val__, dflt__)
extern unsigned long long getarg_ull(struct tcb *tcp, int argn);
extern kernel_ulong_t getarg_klu(struct tcb *tcp, int argn);
extern int printargs(struct tcb *);
extern int printargs_u(struct tcb *);
extern int printargs_d(struct tcb *);
@ -709,7 +709,7 @@ extern void unwind_capture_stacktrace(struct tcb* tcp);
static inline void
printaddr(unsigned long addr)
{
printaddr_ull(addr);
printaddr_klu(addr);
}
static inline void
@ -913,6 +913,16 @@ scno_is_valid(kernel_scno_t scno)
#define SYS_FUNC(syscall_name) int SYS_FUNC_NAME(sys_ ## syscall_name)(struct tcb *tcp)
#if SIZEOF_KERNEL_LONG_T > SIZEOF_LONG
# define PRI_kl "ll"
#else
# define PRI_kl "l"
#endif
#define PRI_kld PRI_kl"d"
#define PRI_klu PRI_kl"u"
#define PRI_klx PRI_kl"x"
/*
* The kernel used to define 64-bit types on 64-bit systems on a per-arch
* basis. Some architectures would use unsigned long and others would use

2
desc.c
View File

@ -261,7 +261,7 @@ SYS_FUNC(pselect6)
/* NB: kernel requires data[1] == NSIG / 8 */
print_sigset_addr_len(tcp, (unsigned long) data[0],
(unsigned long) data[1]);
tprintf(", %llu}", (unsigned long long) data[1]);
tprintf(", %" PRI_klu "}", data[1]);
}
}

View File

@ -42,7 +42,7 @@ SYS_FUNC(fadvise64)
printfd(tcp, tcp->u_arg[0]);
argn = printllval(tcp, ", %lld", 1);
tprintf(", %llu, ", getarg_ull(tcp, argn++));
tprintf(", %" PRI_klu ", ", getarg_klu(tcp, argn++));
printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
return RVAL_DECODED;

6
kcmp.c
View File

@ -33,8 +33,8 @@ SYS_FUNC(kcmp)
pid_t pid1 = tcp->u_arg[0];
pid_t pid2 = tcp->u_arg[1];
int type = tcp->u_arg[2];
unsigned long long idx1 = getarg_ull(tcp, 3);
unsigned long long idx2 = getarg_ull(tcp, 4);
kernel_ulong_t idx1 = getarg_klu(tcp, 3);
kernel_ulong_t idx2 = getarg_klu(tcp, 4);
tprintf("%d, %d, ", pid1, pid2);
printxval(kcmp_types, type, "KCMP_???");
@ -51,7 +51,7 @@ SYS_FUNC(kcmp)
case KCMP_VM:
break;
default:
tprintf(", %#llx, %#llx", idx1, idx2);
tprintf(", %#" PRI_klx ", %#" PRI_klx, idx1, idx2);
}
return RVAL_DECODED;

View File

@ -268,10 +268,10 @@ keyctl_dh_compute(struct tcb *tcp, kernel_ulong_t params, kernel_ulong_t buf,
SYS_FUNC(keyctl)
{
int cmd = tcp->u_arg[0];
unsigned long long arg2 = getarg_ull(tcp, 1);
unsigned long long arg3 = getarg_ull(tcp, 2);
unsigned long long arg4 = getarg_ull(tcp, 3);
unsigned long long arg5 = getarg_ull(tcp, 4);
kernel_ulong_t arg2 = getarg_klu(tcp, 1);
kernel_ulong_t arg3 = getarg_klu(tcp, 2);
kernel_ulong_t arg4 = getarg_klu(tcp, 3);
kernel_ulong_t arg5 = getarg_klu(tcp, 4);
if (entering(tcp)) {
printxval(keyctl_commands, cmd, "KEYCTL_???");
@ -363,7 +363,9 @@ SYS_FUNC(keyctl)
return 0;
default:
tprintf("%#llx, %#llx, %#llx, %#llx", arg2, arg3, arg4, arg5);
tprintf("%#" PRI_klx ", %#" PRI_klx
", %#" PRI_klx ", %#" PRI_klx,
arg2, arg3, arg4, arg5);
break;
}

View File

@ -43,7 +43,7 @@ SYS_FUNC(lookup_dcookie)
printstr(tcp, tcp->u_arg[argn], tcp->u_rval);
/* len */
tprintf(", %llu", getarg_ull(tcp, argn + 1));
tprintf(", %" PRI_klu, getarg_klu(tcp, argn + 1));
return 0;
}

4
mq.c
View File

@ -49,7 +49,7 @@ SYS_FUNC(mq_timedsend)
{
tprintf("%d, ", (int) tcp->u_arg[0]);
printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
tprintf(", %llu, %u, ", getarg_ull(tcp, 2),
tprintf(", %" PRI_klu ", %u, ", getarg_klu(tcp, 2),
(unsigned int) tcp->u_arg[3]);
print_timespec(tcp, tcp->u_arg[4]);
return RVAL_DECODED;
@ -64,7 +64,7 @@ SYS_FUNC(mq_timedreceive)
printstr(tcp, tcp->u_arg[1], tcp->u_rval);
else
printaddr(tcp->u_arg[1]);
tprintf(", %llu, ", getarg_ull(tcp, 2));
tprintf(", %" PRI_klu ", ", getarg_klu(tcp, 2));
printnum_int(tcp, tcp->u_arg[3], "%u");
tprintf(", ");
/*

View File

@ -4,8 +4,8 @@
SYS_FUNC(pkey_alloc)
{
tprintf("%#llx, ", getarg_ull(tcp, 0));
printflags64(pkey_access, getarg_ull(tcp, 1), "PKEY_???");
tprintf("%#" PRI_klx ", ", getarg_klu(tcp, 0));
printflags64(pkey_access, getarg_klu(tcp, 1), "PKEY_???");
return RVAL_DECODED;
}

30
prctl.c
View File

@ -70,21 +70,21 @@ print_prctl_args(struct tcb *tcp, const unsigned int first)
unsigned int i;
for (i = first; i < tcp->s_ent->nargs; ++i)
tprintf(", %#llx", getarg_ull(tcp, i));
tprintf(", %#" PRI_klx, getarg_klu(tcp, i));
}
SYS_FUNC(prctl)
{
const unsigned int option = tcp->u_arg[0];
const unsigned long long arg2 = getarg_ull(tcp, 1);
const unsigned long long arg3 = getarg_ull(tcp, 2);
const kernel_ulong_t arg2 = getarg_klu(tcp, 1);
const kernel_ulong_t arg3 = getarg_klu(tcp, 2);
/*
* PR_SET_VMA is the only command which actually uses these arguments
* currently, and it is available only on Android for now.
*/
#ifdef __ANDROID__
const unsigned long long arg4 = getarg_ull(tcp, 3);
const unsigned long long arg5 = getarg_ull(tcp, 4);
const kernel_ulong_t arg4 = getarg_klu(tcp, 3);
const kernel_ulong_t arg5 = getarg_klu(tcp, 4);
#endif
unsigned int i;
@ -194,7 +194,7 @@ SYS_FUNC(prctl)
case PR_SET_FPEXC:
case PR_SET_KEEPCAPS:
case PR_SET_TIMING:
tprintf(", %llu", arg2);
tprintf(", %" PRI_klu, arg2);
return RVAL_DECODED;
case PR_SET_DUMPABLE:
@ -234,7 +234,7 @@ SYS_FUNC(prctl)
printxval64(pr_mce_kill_policy, arg3,
"PR_MCE_KILL_???");
else
tprintf("%#llx", arg3);
tprintf("%#" PRI_klx, arg3);
print_prctl_args(tcp, 3);
return RVAL_DECODED;
@ -250,8 +250,8 @@ SYS_FUNC(prctl)
# endif
case PR_SET_VMA:
if (arg2 == PR_SET_VMA_ANON_NAME) {
tprintf(", PR_SET_VMA_ANON_NAME, %#llx", arg3);
tprintf(", %llu, ", arg4);
tprintf(", PR_SET_VMA_ANON_NAME, %#" PRI_klx, arg3);
tprintf(", %" PRI_klu ", ", arg4);
printstr(tcp, arg5, -1);
} else {
/* There are no other sub-options now, but there
@ -270,7 +270,7 @@ SYS_FUNC(prctl)
case PR_SET_PDEATHSIG:
tprints(", ");
if (arg2 > 128)
tprintf("%llu", arg2);
tprintf("%" PRI_klu, arg2);
else
tprints(signame(arg2));
return RVAL_DECODED;
@ -280,7 +280,7 @@ SYS_FUNC(prctl)
if ((int) arg2 == -1)
tprints("PR_SET_PTRACER_ANY");
else
tprintf("%llu", arg2);
tprintf("%" PRI_klu, arg2);
return RVAL_DECODED;
case PR_SET_SECCOMP:
@ -303,7 +303,7 @@ SYS_FUNC(prctl)
return RVAL_DECODED;
case PR_SET_TIMERSLACK:
tprintf(", %lld", arg2);
tprintf(", %" PRI_kld, arg2);
return RVAL_DECODED;
case PR_SET_TSC:
@ -318,7 +318,7 @@ SYS_FUNC(prctl)
case PR_SET_NO_NEW_PRIVS:
case PR_SET_THP_DISABLE:
tprintf(", %llu", arg2);
tprintf(", %" PRI_klu, arg2);
print_prctl_args(tcp, 2);
return RVAL_DECODED;
@ -356,7 +356,7 @@ SYS_FUNC(prctl)
SYS_FUNC(arch_prctl)
{
const unsigned int option = tcp->u_arg[0];
const unsigned long long addr = getarg_ull(tcp, 1);
const kernel_ulong_t addr = getarg_klu(tcp, 1);
if (entering(tcp))
printxval(archvals, option, "ARCH_???");
@ -371,7 +371,7 @@ SYS_FUNC(arch_prctl)
return 0;
}
tprintf(", %#llx", addr);
tprintf(", %#" PRI_klx, addr);
return RVAL_DECODED;
}
#endif /* X86_64 || X32 */

10
util.c
View File

@ -467,12 +467,12 @@ printflags64(const struct xlat *xlat, uint64_t flags, const char *dflt)
}
void
printaddr_ull(const unsigned long long addr)
printaddr_klu(const kernel_ulong_t addr)
{
if (!addr)
tprints("NULL");
else
tprintf("%#llx", addr);
tprintf("%#" PRI_klx, addr);
}
#define DEF_PRINTNUM(name, type) \
@ -1490,8 +1490,8 @@ print_array(struct tcb *tcp,
return cur >= end_addr;
}
unsigned long long
getarg_ull(struct tcb *tcp, int argn)
kernel_ulong_t
getarg_klu(struct tcb *tcp, int argn)
{
#if HAVE_STRUCT_TCB_EXT_ARG
# if SUPPORTED_PERSONALITIES > 1
@ -1511,7 +1511,7 @@ printargs(struct tcb *tcp)
const int n = tcp->s_ent->nargs;
int i;
for (i = 0; i < n; ++i)
tprintf("%s%#llx", i ? ", " : "", getarg_ull(tcp, i));
tprintf("%s%#" PRI_klx, i ? ", " : "", getarg_klu(tcp, i));
return RVAL_DECODED;
}