svn commit: r311546 - in stable: 10/usr.bin/kdump 11/usr.bin/kdump
John Baldwin
jhb at FreeBSD.org
Fri Jan 6 20:32:36 UTC 2017
Author: jhb
Date: Fri Jan 6 20:32:34 2017
New Revision: 311546
URL: https://svnweb.freebsd.org/changeset/base/311546
Log:
MFC 306562: Handle 64-bit system call arguments (off_t, id_t).
In particular, 64-bit system call arguments use up two register_t
arguments for 32-bit processes. They must also be aligned on a 64-bit
boundary on 32-bit powerpc processes. This fixes the decoding of
lseek(), procctl(), and wait6() arguments for 32-bit processes (both
native and via freebsd32).
Note that the ktrace system call return record only returns a single
register, so the return value of lseek is always truncated to the low
32-bits for 32-bit processes.
Modified:
stable/10/usr.bin/kdump/kdump.c
Directory Properties:
stable/10/ (props changed)
Changes in other areas also in this revision:
Modified:
stable/11/usr.bin/kdump/kdump.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/10/usr.bin/kdump/kdump.c
==============================================================================
--- stable/10/usr.bin/kdump/kdump.c Fri Jan 6 20:25:08 2017 (r311545)
+++ stable/10/usr.bin/kdump/kdump.c Fri Jan 6 20:32:34 2017 (r311546)
@@ -79,6 +79,7 @@ extern int errno;
#include <netdb.h>
#include <nl_types.h>
#include <pwd.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -128,6 +129,27 @@ static struct ktr_header ktr_header;
#define TIME_FORMAT "%b %e %T %Y"
#define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
+#define print_number64(first,i,n,c) do { \
+ uint64_t __v; \
+ \
+ if (quad_align && (((ptrdiff_t)((i) - (first))) & 1) == 1) { \
+ (i)++; \
+ (n)--; \
+ } \
+ if (quad_slots == 2) \
+ __v = (uint64_t)(uint32_t)(i)[0] | \
+ ((uint64_t)(uint32_t)(i)[1]) << 32; \
+ else \
+ __v = (uint64_t)*(i); \
+ if (decimal) \
+ printf("%c%jd", (c), (intmax_t)__v); \
+ else \
+ printf("%c%#jx", (c), (uintmax_t)__v); \
+ (i) += quad_slots; \
+ (n) -= quad_slots; \
+ (c) = ','; \
+} while (0)
+
#define print_number(i,n,c) do { \
if (decimal) \
printf("%c%jd", c, (intmax_t)*i); \
@@ -611,8 +633,9 @@ void
ktrsyscall(struct ktr_syscall *ktr, u_int flags)
{
int narg = ktr->ktr_narg;
- register_t *ip;
+ register_t *ip, *first;
intmax_t arg;
+ int quad_align, quad_slots;
if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) ||
(ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0))
@@ -622,11 +645,19 @@ ktrsyscall(struct ktr_syscall *ktr, u_in
if (syscallno)
printf("[%d]", ktr->ktr_code);
}
- ip = &ktr->ktr_args[0];
+ ip = first = &ktr->ktr_args[0];
if (narg) {
char c = '(';
if (fancy &&
(flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) {
+ quad_align = 0;
+ if (flags & SV_ILP32) {
+#ifdef __powerpc__
+ quad_align = 1;
+#endif
+ quad_slots = 2;
+ } else
+ quad_slots = 1;
switch (ktr->ktr_code) {
case SYS_bindat:
case SYS_connectat:
@@ -708,7 +739,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_in
c = ',';
ip++;
narg--;
- print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
print_number(ip, narg, c);
putchar(',');
wait6optname(*ip);
@@ -907,7 +938,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_in
print_number(ip, narg, c);
/* Hidden 'pad' argument, not in lseek(2) */
print_number(ip, narg, c);
- print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
putchar(',');
whencename(*ip);
ip++;
@@ -916,8 +947,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_in
#endif
case SYS_lseek:
print_number(ip, narg, c);
- /* Hidden 'pad' argument, not in lseek(2) */
- print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
putchar(',');
whencename(*ip);
ip++;
@@ -1196,7 +1226,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_in
c = ',';
ip++;
narg--;
- print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
putchar(',');
procctlcmdname(*ip);
ip++;
More information about the svn-src-all
mailing list