Skip to content

Commit c3ed8d6

Browse files
committed
Make %p consistent with glibc and musl
See #61
1 parent 937d921 commit c3ed8d6

File tree

11 files changed

+141
-73
lines changed

11 files changed

+141
-73
lines changed

libc/fmt/fmt.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,9 @@ hidden int __fmt(void *fn, void *arg, const char *format, va_list va) {
259259
alphabet = "0123456789abcdef";
260260
switch ((d = *format++)) {
261261
case 'p':
262-
flags |= FLAGS_ZEROPAD;
263-
width = POINTER_XDIGITS;
262+
flags |= FLAGS_HASH;
264263
log2base = 4;
265-
signbit = 47;
264+
signbit = 63;
266265
goto FormatNumber;
267266
case 'X':
268267
alphabet = "0123456789ABCDEF";

test/libc/fmt/fmt_test.c

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,56 @@
1717
│ PERFORMANCE OF THIS SOFTWARE. │
1818
╚─────────────────────────────────────────────────────────────────────────────*/
1919
#include "libc/fmt/fmt.h"
20+
#include "libc/limits.h"
2021
#include "libc/math.h"
2122
#include "libc/runtime/gc.h"
2223
#include "libc/str/str.h"
2324
#include "libc/testlib/testlib.h"
2425
#include "libc/x/x.h"
2526

26-
TEST(RealFormatting, g) {
27+
TEST(fmt, d) {
28+
EXPECT_STREQ("-123", gc(xasprintf("%d", -123)));
29+
EXPECT_STREQ("-1", gc(xasprintf("%d", -1)));
30+
EXPECT_STREQ("1", gc(xasprintf("%d", 1)));
31+
EXPECT_STREQ("16", gc(xasprintf("%d", 16)));
32+
EXPECT_STREQ("2147483647", gc(xasprintf("%d", INT_MAX)));
33+
EXPECT_STREQ("-2147483648", gc(xasprintf("%d", INT_MIN)));
34+
EXPECT_STREQ(" -123", gc(xasprintf("%10d", -123)));
35+
EXPECT_STREQ(" -1", gc(xasprintf("%10d", -1)));
36+
EXPECT_STREQ(" 1", gc(xasprintf("%10d", 1)));
37+
EXPECT_STREQ(" 16", gc(xasprintf("%10d", 16)));
38+
EXPECT_STREQ("2147483647", gc(xasprintf("%10d", INT_MAX)));
39+
EXPECT_STREQ("-2147483648", gc(xasprintf("%10d", INT_MIN)));
40+
EXPECT_STREQ("-000000123", gc(xasprintf("%010d", -123)));
41+
EXPECT_STREQ("-000000001", gc(xasprintf("%010d", -1)));
42+
EXPECT_STREQ("0000000001", gc(xasprintf("%010d", 1)));
43+
EXPECT_STREQ("0000000016", gc(xasprintf("%010d", 16)));
44+
EXPECT_STREQ("2147483647", gc(xasprintf("%010d", INT_MAX)));
45+
EXPECT_STREQ("-2147483648", gc(xasprintf("%010d", INT_MIN)));
46+
EXPECT_STREQ("-123 ", gc(xasprintf("%-10d", -123)));
47+
EXPECT_STREQ("-1 ", gc(xasprintf("%-10d", -1)));
48+
EXPECT_STREQ("1 ", gc(xasprintf("%-10d", 1)));
49+
EXPECT_STREQ("16 ", gc(xasprintf("%-10d", 16)));
50+
EXPECT_STREQ("2147483647", gc(xasprintf("%-10d", INT_MAX)));
51+
EXPECT_STREQ("-2147483648", gc(xasprintf("%-10d", INT_MIN)));
52+
EXPECT_STREQ(" -123", gc(xasprintf("%+10d", -123)));
53+
EXPECT_STREQ(" -1", gc(xasprintf("%+10d", -1)));
54+
EXPECT_STREQ(" +1", gc(xasprintf("%+10d", 1)));
55+
EXPECT_STREQ(" +16", gc(xasprintf("%+10d", 16)));
56+
EXPECT_STREQ("+2147483647", gc(xasprintf("%+10d", INT_MAX)));
57+
EXPECT_STREQ("-2147483648", gc(xasprintf("%+10d", INT_MIN)));
58+
EXPECT_STREQ("-123", gc(xasprintf("% d", -123)));
59+
EXPECT_STREQ("-1", gc(xasprintf("% d", -1)));
60+
EXPECT_STREQ(" 1", gc(xasprintf("% d", 1)));
61+
EXPECT_STREQ(" 16", gc(xasprintf("% d", 16)));
62+
EXPECT_STREQ(" 2147483647", gc(xasprintf("% d", INT_MAX)));
63+
EXPECT_STREQ("-2147483648", gc(xasprintf("% d", INT_MIN)));
64+
}
65+
66+
TEST(fmt, g) {
2767
EXPECT_STREQ("1", gc(xasprintf("%g", 1.)));
68+
EXPECT_STREQ(" 1", gc(xasprintf("% g", 1.)));
69+
EXPECT_STREQ("+1", gc(xasprintf("%+g", 1.)));
2870
EXPECT_STREQ("-1", gc(xasprintf("%g", -1.)));
2971
EXPECT_STREQ("10", gc(xasprintf("%g", 10.)));
3072
EXPECT_STREQ("10", gc(xasprintf("%.0g", 10.)));
@@ -68,7 +110,7 @@ TEST(RealFormatting, g) {
68110
EXPECT_STREQ(" 1.79769E+308", gc(xasprintf("%13G", __DBL_MAX__)));
69111
}
70112

71-
TEST(RealFormatting, f) {
113+
TEST(fmt, f) {
72114
EXPECT_STREQ("3.141593", gc(xasprintf("%f", 0x1.921fb54442d1846ap+1)));
73115
EXPECT_STREQ("3.1415926535897931",
74116
gc(xasprintf("%.16f", 0x1.921fb54442d1846ap+1)));
@@ -133,7 +175,7 @@ TEST(RealFormatting, f) {
133175
gc(xasprintf("%10F", __DBL_MAX__)));
134176
}
135177

136-
TEST(RealFormatting, e) {
178+
TEST(fmt, e) {
137179
EXPECT_STREQ("3.14159", gc(xasprintf("%g", 0x1.921fb54442d1846ap+1)));
138180
EXPECT_STREQ("3.141592653589793",
139181
gc(xasprintf("%.16g", 0x1.921fb54442d1846ap+1)));
@@ -173,7 +215,7 @@ TEST(RealFormatting, e) {
173215
EXPECT_STREQ(" +1.797693E+308", gc(xasprintf("%+24E", __DBL_MAX__)));
174216
}
175217

176-
TEST(RealFormatting, a) {
218+
TEST(fmt, a) {
177219
EXPECT_STREQ("0x1.921fb54442d18p+1",
178220
gc(xasprintf("%a", 0x1.921fb54442d1846ap+1)));
179221
EXPECT_STREQ("0X1.921FB54442D18P+1",
@@ -197,3 +239,40 @@ TEST(RealFormatting, a) {
197239
EXPECT_STREQ(" 0X1.E9A488E8A71DEP+14", gc(xasprintf("%24A", 31337.1337)));
198240
EXPECT_STREQ(" -0X1.E9A488E8A71DEP+14", gc(xasprintf("%24A", -31337.1337)));
199241
}
242+
243+
TEST(fmt, p) {
244+
EXPECT_STREQ("0x1", gc(xasprintf("%p", 1)));
245+
EXPECT_STREQ("0x10", gc(xasprintf("%p", 16)));
246+
EXPECT_STREQ("0x31337", gc(xasprintf("%p", 0x31337)));
247+
EXPECT_STREQ("0xffffffff", gc(xasprintf("%p", 0xffffffff)));
248+
EXPECT_STREQ("0xffff800000031337", gc(xasprintf("%p", 0xffff800000031337)));
249+
EXPECT_STREQ(" 0x1", gc(xasprintf("%10p", 1)));
250+
EXPECT_STREQ(" 0x10", gc(xasprintf("%10p", 16)));
251+
EXPECT_STREQ(" 0x31337", gc(xasprintf("%10p", 0x31337)));
252+
EXPECT_STREQ("0xffffffff", gc(xasprintf("%10p", 0xffffffff)));
253+
EXPECT_STREQ("0xffff800000031337", gc(xasprintf("%10p", 0xffff800000031337)));
254+
EXPECT_STREQ("0x00000001", gc(xasprintf("%010p", 1)));
255+
EXPECT_STREQ("0x00000010", gc(xasprintf("%010p", 16)));
256+
EXPECT_STREQ("0x00031337", gc(xasprintf("%010p", 0x31337)));
257+
EXPECT_STREQ("0xffffffff", gc(xasprintf("%010p", 0xffffffff)));
258+
EXPECT_STREQ("0xffff800000031337",
259+
gc(xasprintf("%010p", 0xffff800000031337)));
260+
EXPECT_STREQ("0x1 ", gc(xasprintf("%-10p", 1)));
261+
EXPECT_STREQ("0x10 ", gc(xasprintf("%-10p", 16)));
262+
EXPECT_STREQ("0x31337 ", gc(xasprintf("%-10p", 0x31337)));
263+
EXPECT_STREQ("0xffffffff", gc(xasprintf("%-10p", 0xffffffff)));
264+
EXPECT_STREQ("0xffff800000031337",
265+
gc(xasprintf("%-10p", 0xffff800000031337)));
266+
EXPECT_STREQ(" 0x1", gc(xasprintf("%+10p", 1)));
267+
EXPECT_STREQ(" 0x10", gc(xasprintf("%+10p", 16)));
268+
EXPECT_STREQ(" 0x31337", gc(xasprintf("%+10p", 0x31337)));
269+
EXPECT_STREQ("0xffffffff", gc(xasprintf("%+10p", 0xffffffff)));
270+
EXPECT_STREQ("0xffff800000031337",
271+
gc(xasprintf("%+10p", 0xffff800000031337)));
272+
EXPECT_STREQ(" 0x1", gc(xasprintf("% 10p", 1)));
273+
EXPECT_STREQ(" 0x10", gc(xasprintf("% 10p", 16)));
274+
EXPECT_STREQ(" 0x31337", gc(xasprintf("% 10p", 0x31337)));
275+
EXPECT_STREQ("0xffffffff", gc(xasprintf("% 10p", 0xffffffff)));
276+
EXPECT_STREQ("0xffff800000031337",
277+
gc(xasprintf("% 10p", 0xffff800000031337)));
278+
}

test/libc/fmt/palandprintf_test.c

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -482,34 +482,6 @@ TEST(sprintf, testOverflow_truncationNotSaturation) {
482482
EXPECT_STREQ("Test16 65535", Format("%s%hhi %hu", "Test", 10000, 0xFFFFFFFF));
483483
}
484484

485-
TEST(sprintf, test_pointer) {
486-
sprintf(buffer, "%p", (void *)0x1234U);
487-
if (sizeof(void *) == 4U) {
488-
EXPECT_STREQ("00001234", buffer);
489-
} else {
490-
EXPECT_STREQ("000000001234", buffer);
491-
}
492-
sprintf(buffer, "%p", (void *)0x12345678U);
493-
if (sizeof(void *) == 4U) {
494-
EXPECT_STREQ("12345678", buffer);
495-
} else {
496-
EXPECT_STREQ("000012345678", buffer);
497-
}
498-
sprintf(buffer, "%p-%p", (void *)0x12345678U, (void *)0x7EDCBA98U);
499-
if (sizeof(void *) == 4U) {
500-
EXPECT_STREQ("12345678-7edcba98", buffer);
501-
} else {
502-
EXPECT_STREQ("000012345678-00007edcba98", buffer);
503-
}
504-
if (sizeof(uintptr_t) == sizeof(uint64_t)) {
505-
sprintf(buffer, "%p", (void *)(uintptr_t)0xFFFFFFFFU);
506-
EXPECT_STREQ("0000ffffffff", buffer);
507-
} else {
508-
sprintf(buffer, "%p", (void *)(uintptr_t)0xFFFFFFFFU);
509-
EXPECT_STREQ("ffffffff", buffer);
510-
}
511-
}
512-
513485
TEST(sprintf, test_unknown_flag) {
514486
EXPECT_STREQ("kmarco", Format("%kmarco", 42, 37));
515487
}
@@ -595,22 +567,6 @@ TEST(xasprintf, test) {
595567
free(pp);
596568
}
597569

598-
TEST(xasprintf, nullPointer) {
599-
ASSERT_STREQ("000000000000", gc(xasprintf("%p", NULL)));
600-
}
601-
602-
TEST(xasprintf, pointer_doesntShowNonCanonicalZeroes) {
603-
ASSERT_STREQ("100000000010", gc(xasprintf("%p", 0x0000100000000010)));
604-
ASSERT_STREQ("0x100000000010", gc(xasprintf("%#p", 0x0000100000000010)));
605-
}
606-
607-
TEST(xasprintf, nonCanonicalPointer_discardsHighBits_ratherThanSaturate) {
608-
ASSERT_STREQ("100000000010", gc(xasprintf("%p", 0x1000100000000010)));
609-
ASSERT_STREQ("0x100000000010", gc(xasprintf("%#p", 0x1000100000000010)));
610-
ASSERT_STREQ("7fffffffffff", gc(xasprintf("%p", 0x7fffffffffff)));
611-
ASSERT_STREQ("0x7fffffffffff", gc(xasprintf("%#p", 0x7fffffffffff)));
612-
}
613-
614570
TEST(xasprintf, hugeNtoa) {
615571
ASSERT_STREQ(
616572
"0b1111111111111111111111111111111111111111111111111111111111111111111111"

test/libc/stdio/fgets_test.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
2+
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
3+
╞══════════════════════════════════════════════════════════════════════════════╡
4+
│ Copyright 2021 Justine Alexandra Roberts Tunney │
5+
│ │
6+
│ Permission to use, copy, modify, and/or distribute this software for │
7+
│ any purpose with or without fee is hereby granted, provided that the │
8+
│ above copyright notice and this permission notice appear in all copies. │
9+
│ │
10+
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
11+
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
12+
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
13+
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
14+
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
15+
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
16+
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
17+
│ PERFORMANCE OF THIS SOFTWARE. │
18+
╚─────────────────────────────────────────────────────────────────────────────*/
19+
#include "libc/mem/mem.h"
20+
#include "libc/stdio/stdio.h"
21+
#include "libc/testlib/hyperion.h"
22+
#include "libc/testlib/testlib.h"
23+
24+
TEST(fgets, test) {
25+
FILE *f;
26+
char buf[29];
27+
f = fmemopen(strdup(kHyperion), kHyperionSize, "r+");
28+
ASSERT_STREQ("The fall of Hyperion - a Dre", fgets(buf, sizeof(buf), f));
29+
ASSERT_STREQ("am\n", fgets(buf, sizeof(buf), f));
30+
ASSERT_STREQ("John Keats\n", fgets(buf, sizeof(buf), f));
31+
fclose(f);
32+
}

tool/build/blinkenlights.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ static void DrawMemoryZoomed(struct Panel *p, struct MemoryView *view,
12951295
free(ranges.p);
12961296
high = false;
12971297
for (c = i = 0; i < p->bottom - p->top; ++i) {
1298-
AppendFmt(&p->lines[i], "%p ",
1298+
AppendFmt(&p->lines[i], "%012lx ",
12991299
(view->start + i) * DUMPWIDTH * (1ull << view->zoom));
13001300
for (j = 0; j < DUMPWIDTH; ++j, ++c) {
13011301
a = ((view->start + i) * DUMPWIDTH + j + 0) * (1ull << view->zoom);
@@ -1331,7 +1331,7 @@ static void DrawMemoryUnzoomed(struct Panel *p, struct MemoryView *view,
13311331
bool high, changed;
13321332
high = false;
13331333
for (i = 0; i < p->bottom - p->top; ++i) {
1334-
AppendFmt(&p->lines[i], "%p ", (view->start + i) * DUMPWIDTH);
1334+
AppendFmt(&p->lines[i], "%012lx ", (view->start + i) * DUMPWIDTH);
13351335
for (j = 0; j < DUMPWIDTH; ++j) {
13361336
k = (view->start + i) * DUMPWIDTH + j;
13371337
c = VirtualBing(k);
@@ -1421,7 +1421,7 @@ static void DrawBreakpoints(struct Panel *p) {
14211421
sym = DisFindSym(dis, addr);
14221422
name = sym != -1 ? dis->syms.stab + dis->syms.p[sym].name : "UNKNOWN";
14231423
s = buf;
1424-
s += sprintf(s, "%p ", addr);
1424+
s += sprintf(s, "%012lx ", addr);
14251425
CHECK_LT(Demangle(s, name, DIS_MAX_SYMBOL_LENGTH), buf + ARRAYLEN(buf));
14261426
AppendPanel(p, line - breakpointsstart, buf);
14271427
if (sym != -1 && addr != dis->syms.p[sym].addr) {
@@ -1461,7 +1461,7 @@ static void DrawFrames(struct Panel *p) {
14611461
sym = DisFindSym(dis, rp);
14621462
name = sym != -1 ? dis->syms.stab + dis->syms.p[sym].name : "UNKNOWN";
14631463
s = line;
1464-
s += sprintf(s, "%p %p ", Read64(m->ss) + bp, rp);
1464+
s += sprintf(s, "%012lx %012lx ", Read64(m->ss) + bp, rp);
14651465
s = Demangle(s, name, DIS_MAX_SYMBOL_LENGTH);
14661466
AppendPanel(p, i - framesstart, line);
14671467
if (sym != -1 && rp != dis->syms.p[sym].addr) {
@@ -1501,14 +1501,15 @@ static void CheckFramePointerImpl(void) {
15011501
sp = Read64(m->sp);
15021502
while (bp) {
15031503
if (!(r = FindReal(m, Read64(m->ss) + bp))) {
1504-
LOGF("corrupt frame: %p", bp);
1504+
LOGF("corrupt frame: %012lx", bp);
15051505
ThrowProtectionFault(m);
15061506
}
15071507
sp = bp;
15081508
bp = Read64(r + 0) - 0;
15091509
rp = Read64(r + 8) - 1;
15101510
if (!bp && !(m->bofram[0] <= rp && rp <= m->bofram[1])) {
1511-
LOGF("bad frame !(%p <= %p <= %p)", m->bofram[0], rp, m->bofram[1]);
1511+
LOGF("bad frame !(%012lx <= %012lx <= %012lx)", m->bofram[0], rp,
1512+
m->bofram[1]);
15121513
ThrowProtectionFault(m);
15131514
}
15141515
}
@@ -1831,7 +1832,7 @@ static void OnDebug(void) {
18311832
}
18321833

18331834
static void OnSegmentationFault(void) {
1834-
snprintf(systemfailure, sizeof(systemfailure), "SEGMENTATION FAULT %p",
1835+
snprintf(systemfailure, sizeof(systemfailure), "SEGMENTATION FAULT %012lx",
18351836
m->faultaddr);
18361837
LaunchDebuggerReactively();
18371838
}
@@ -2189,7 +2190,7 @@ static void OnBinbase(struct Machine *m) {
21892190
unsigned i;
21902191
int64_t skew;
21912192
skew = m->xedd->op.disp * 512;
2192-
LOGF("skew binbase %,ld @ %p", skew, GetIp());
2193+
LOGF("skew binbase %,ld @ %012lx", skew, GetIp());
21932194
for (i = 0; i < dis->syms.i; ++i) dis->syms.p[i].addr += skew;
21942195
for (i = 0; i < dis->loads.i; ++i) dis->loads.p[i].addr += skew;
21952196
for (i = 0; i < breakpoints.i; ++i) breakpoints.p[i].addr += skew;
@@ -2562,7 +2563,7 @@ static void Exec(void) {
25622563
if (!(interrupt = setjmp(m->onhalt))) {
25632564
if (!(action & CONTINUE) &&
25642565
(bp = IsAtBreakpoint(&breakpoints, GetIp())) != -1) {
2565-
LOGF("BREAK1 %p", breakpoints.p[bp].addr);
2566+
LOGF("BREAK1 %012lx", breakpoints.p[bp].addr);
25662567
tuimode = true;
25672568
LoadInstruction(m);
25682569
ExecuteInstruction(m);
@@ -2573,7 +2574,7 @@ static void Exec(void) {
25732574
for (;;) {
25742575
LoadInstruction(m);
25752576
if ((bp = IsAtBreakpoint(&breakpoints, GetIp())) != -1) {
2576-
LOGF("BREAK2 %p", breakpoints.p[bp].addr);
2577+
LOGF("BREAK2 %012lx", breakpoints.p[bp].addr);
25772578
action &= ~(FINISH | NEXT | CONTINUE);
25782579
tuimode = true;
25792580
break;
@@ -2625,7 +2626,7 @@ static void Tui(void) {
26252626
if ((action & (FINISH | NEXT | CONTINUE)) &&
26262627
(bp = IsAtBreakpoint(&breakpoints, GetIp())) != -1) {
26272628
action &= ~(FINISH | NEXT | CONTINUE);
2628-
LOGF("BREAK %p", breakpoints.p[bp].addr);
2629+
LOGF("BREAK %012lx", breakpoints.p[bp].addr);
26292630
}
26302631
} else {
26312632
m->xedd = (struct XedDecodedInst *)m->icache[0];

tool/build/lib/diself.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static void DisCanonizeSyms(struct Dis *d) {
144144
d->syms.n = i;
145145
}
146146
for (i = 0; i < d->syms.i; ++i) {
147-
DEBUGF("%p-%p %s", d->syms.p[i].addr,
147+
DEBUGF("%012lx-%012lx %s", d->syms.p[i].addr,
148148
d->syms.p[i].addr + (d->syms.p[i].size ? d->syms.p[i].size - 1 : 0),
149149
d->syms.stab + d->syms.p[i].name);
150150
}

tool/build/lib/loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void LoadElf(struct Machine *m, struct Elf *elf) {
7878
unsigned i;
7979
Elf64_Phdr *phdr;
8080
m->ip = elf->base = elf->ehdr->e_entry;
81-
VERBOSEF("LOADELF ENTRY %p", m->ip);
81+
VERBOSEF("LOADELF ENTRY %012lx", m->ip);
8282
for (i = 0; i < elf->ehdr->e_phnum; ++i) {
8383
phdr = GetElfSegmentHeaderAddress(elf->ehdr, elf->size, i);
8484
switch (phdr->p_type) {

tool/build/lib/pml4tfmt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ static void FormatStartPage(struct Pml4tFormater *pp, int64_t start) {
4949
pp->t = true;
5050
pp->start = start;
5151
if (pp->lines++) AppendChar(&pp->b, '\n');
52-
AppendFmt(&pp->b, "%p-", start);
52+
AppendFmt(&pp->b, "%012lx-", start);
5353
}
5454

5555
static void FormatEndPage(struct Pml4tFormater *pp, int64_t end) {
5656
int64_t size;
5757
pp->t = false;
5858
size = end - pp->start;
59-
AppendFmt(&pp->b, "%p %p %,ld bytes", end - 1, size, size);
59+
AppendFmt(&pp->b, "%012lx %012lx %,ld bytes", end - 1, size, size);
6060
}
6161

6262
static void *GetPt(struct Machine *m, uint64_t r) {

tool/build/lib/syscall.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,16 +530,16 @@ static int64_t OpBrk(struct Machine *m, int64_t addr) {
530530
}
531531

532532
static int OpMunmap(struct Machine *m, int64_t virt, uint64_t size) {
533-
VERBOSEF("MUNMAP%s %p %,ld", GetSimulated(), virt, size);
533+
VERBOSEF("MUNMAP%s %012lx %,ld", GetSimulated(), virt, size);
534534
return FreeVirtual(m, virt, size);
535535
}
536536

537537
static int64_t OpMmap(struct Machine *m, int64_t virt, size_t size, int prot,
538538
int flags, int fd, int64_t offset) {
539539
void *tmp;
540540
uint64_t key;
541-
VERBOSEF("MMAP%s %p %,ld %#x %#x %d %#lx", GetSimulated(), virt, size, prot,
542-
flags, fd, offset);
541+
VERBOSEF("MMAP%s %012lx %,ld %#x %#x %d %#lx", GetSimulated(), virt, size,
542+
prot, flags, fd, offset);
543543
if (prot & PROT_READ) {
544544
key = 0x0205;
545545
if (prot & PROT_WRITE) key |= 2;
@@ -821,12 +821,12 @@ static ssize_t OpWrite(struct Machine *m, int fd, int64_t addr, size_t size) {
821821
if ((rc = m->fds.p[fd].cb->writev(m->fds.p[fd].fd, iv.p, iv.i)) != -1) {
822822
SetReadAddr(m, addr, rc);
823823
} else {
824-
VERBOSEF("write(%d [%d], %p, %zu) failed: %s", fd, m->fds.p[fd].fd,
824+
VERBOSEF("write(%d [%d], %012lx, %zu) failed: %s", fd, m->fds.p[fd].fd,
825825
addr, size, strerror(errno));
826826
}
827827
}
828828
} else {
829-
VERBOSEF("write(%d, %p, %zu) bad fd", fd, addr, size);
829+
VERBOSEF("write(%d, %012lx, %zu) bad fd", fd, addr, size);
830830
rc = ebadf();
831831
}
832832
FreeIovs(&iv);

0 commit comments

Comments
 (0)