mem: add xlat styles support to print_mmap_flags
* mem.c (print_mmap_flags): Respect xlat_verbosity. * tests/mmap.c (main): Update expected output. * tests/old_mmap.c (main): Likewise. Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
This commit is contained in:
parent
956dc3ed36
commit
0933b30869
18
mem.c
18
mem.c
@ -76,7 +76,17 @@ SYS_FUNC(brk)
|
||||
static void
|
||||
print_mmap_flags(kernel_ulong_t flags)
|
||||
{
|
||||
printxval64(mmap_flags, flags & MAP_TYPE, "MAP_???");
|
||||
if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
|
||||
tprintf("%#lx", flags);
|
||||
|
||||
if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
|
||||
return;
|
||||
|
||||
if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
|
||||
tprints(" /* ");
|
||||
|
||||
printxvals_ex(flags & MAP_TYPE, "MAP_???", XLAT_STYLE_ABBREV,
|
||||
mmap_flags, NULL);
|
||||
flags &= ~MAP_TYPE;
|
||||
|
||||
const unsigned int mask = MAP_HUGE_MASK << MAP_HUGE_SHIFT;
|
||||
@ -85,12 +95,16 @@ print_mmap_flags(kernel_ulong_t flags)
|
||||
flags &= ~mask;
|
||||
if (flags) {
|
||||
tprints("|");
|
||||
printflags64(mmap_flags, flags, NULL);
|
||||
printflags_ex(flags, NULL, XLAT_STYLE_ABBREV,
|
||||
mmap_flags, NULL);
|
||||
}
|
||||
|
||||
if (hugetlb_value)
|
||||
tprintf("|%u<<MAP_HUGE_SHIFT",
|
||||
hugetlb_value >> MAP_HUGE_SHIFT);
|
||||
|
||||
if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE)
|
||||
tprints(" */");
|
||||
}
|
||||
|
||||
static void
|
||||
|
13
tests/mmap.c
13
tests/mmap.c
@ -77,15 +77,14 @@ main(int ac, char **av)
|
||||
perror_msg_and_fail("mmap");
|
||||
#if XLAT_RAW
|
||||
printf("%s(%p, %lu, %#x, "
|
||||
"%#x|%#x, %d, %#jx) = %p\n",
|
||||
name, addr, length1, PROT_READ | PROT_WRITE, MAP_PRIVATE,
|
||||
MAP_ANONYMOUS, fd, uoffset, p);
|
||||
"%#x, %d, %#jx) = %p\n",
|
||||
name, addr, length1, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, fd, uoffset, p);
|
||||
#elif XLAT_VERBOSE
|
||||
printf("%s(%p, %lu, %#x /* PROT_READ|PROT_WRITE */, "
|
||||
"%#x /* MAP_PRIVATE */|%#x /* MAP_ANONYMOUS */, %d, %#jx) "
|
||||
"= %p\n",
|
||||
name, addr, length1, PROT_READ | PROT_WRITE, MAP_PRIVATE,
|
||||
MAP_ANONYMOUS, fd, uoffset, p);
|
||||
"%#x /* MAP_PRIVATE|MAP_ANONYMOUS */, %d, %#jx) = %p\n",
|
||||
name, addr, length1, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, fd, uoffset, p);
|
||||
#else
|
||||
printf("%s(%p, %lu, PROT_READ|PROT_WRITE, "
|
||||
"MAP_PRIVATE|MAP_ANONYMOUS, %d, %#jx) = %p\n",
|
||||
|
@ -80,14 +80,13 @@ main(void)
|
||||
|
||||
rc = syscall(__NR_mmap, args);
|
||||
# if XLAT_RAW
|
||||
printf("mmap(%#lx, %lu, %#x, %#x|%#x, %d, %#lx) = %ld %s (%m)\n",
|
||||
args1_c[0], args1_c[1], PROT_READ|PROT_EXEC, MAP_FILE, MAP_FIXED,
|
||||
printf("mmap(%#lx, %lu, %#x, %#x, %d, %#lx) = %ld %s (%m)\n",
|
||||
args1_c[0], args1_c[1], PROT_READ|PROT_EXEC, MAP_FILE | MAP_FIXED,
|
||||
(int) args1_c[4], args1_c[5], rc, errno2name());
|
||||
# elif XLAT_VERBOSE
|
||||
printf("mmap(%#lx, %lu, %#x /* PROT_READ|PROT_EXEC */"
|
||||
", %#x /* MAP_FILE */|%#x /* MAP_FIXED */"
|
||||
", %d, %#lx) = %ld %s (%m)\n",
|
||||
args1_c[0], args1_c[1], PROT_READ|PROT_EXEC, MAP_FILE, MAP_FIXED,
|
||||
", %#x /* MAP_FILE|MAP_FIXED */, %d, %#lx) = %ld %s (%m)\n",
|
||||
args1_c[0], args1_c[1], PROT_READ|PROT_EXEC, MAP_FILE | MAP_FIXED,
|
||||
(int) args1_c[4], args1_c[5], rc, errno2name());
|
||||
# else
|
||||
printf("mmap(%#lx, %lu, PROT_READ|PROT_EXEC, MAP_FILE|MAP_FIXED"
|
||||
@ -100,14 +99,13 @@ main(void)
|
||||
rc = syscall(__NR_mmap, args);
|
||||
# ifndef PATH_TRACING
|
||||
# if XLAT_RAW
|
||||
printf("mmap(NULL, %lu, %#x, %#x|%#x, %d, %#lx) = %#lx\n",
|
||||
args2_c[1], PROT_READ|PROT_WRITE, MAP_PRIVATE, MAP_ANONYMOUS,
|
||||
printf("mmap(NULL, %lu, %#x, %#x, %d, %#lx) = %#lx\n",
|
||||
args2_c[1], PROT_READ|PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
|
||||
(int) args2_c[4], args2_c[5], rc);
|
||||
# elif XLAT_VERBOSE
|
||||
printf("mmap(NULL, %lu, %#x /* PROT_READ|PROT_WRITE */"
|
||||
", %#x /* MAP_PRIVATE */|%#x /* MAP_ANONYMOUS */"
|
||||
", %d, %#lx) = %#lx\n",
|
||||
args2_c[1], PROT_READ|PROT_WRITE, MAP_PRIVATE, MAP_ANONYMOUS,
|
||||
", %#x /* MAP_PRIVATE|MAP_ANONYMOUS */, %d, %#lx) = %#lx\n",
|
||||
args2_c[1], PROT_READ|PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
|
||||
(int) args2_c[4], args2_c[5], rc);
|
||||
# else
|
||||
printf("mmap(NULL, %lu, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS"
|
||||
|
Loading…
Reference in New Issue
Block a user