Make %p consistent with glibc and musl

See #61
This commit is contained in:
Justine Tunney 2021-03-06 14:26:36 -08:00
parent 937d921018
commit c3ed8d6c7f
11 changed files with 141 additions and 73 deletions

View file

@ -1295,7 +1295,7 @@ static void DrawMemoryZoomed(struct Panel *p, struct MemoryView *view,
free(ranges.p);
high = false;
for (c = i = 0; i < p->bottom - p->top; ++i) {
AppendFmt(&p->lines[i], "%p ",
AppendFmt(&p->lines[i], "%012lx ",
(view->start + i) * DUMPWIDTH * (1ull << view->zoom));
for (j = 0; j < DUMPWIDTH; ++j, ++c) {
a = ((view->start + i) * DUMPWIDTH + j + 0) * (1ull << view->zoom);
@ -1331,7 +1331,7 @@ static void DrawMemoryUnzoomed(struct Panel *p, struct MemoryView *view,
bool high, changed;
high = false;
for (i = 0; i < p->bottom - p->top; ++i) {
AppendFmt(&p->lines[i], "%p ", (view->start + i) * DUMPWIDTH);
AppendFmt(&p->lines[i], "%012lx ", (view->start + i) * DUMPWIDTH);
for (j = 0; j < DUMPWIDTH; ++j) {
k = (view->start + i) * DUMPWIDTH + j;
c = VirtualBing(k);
@ -1421,7 +1421,7 @@ static void DrawBreakpoints(struct Panel *p) {
sym = DisFindSym(dis, addr);
name = sym != -1 ? dis->syms.stab + dis->syms.p[sym].name : "UNKNOWN";
s = buf;
s += sprintf(s, "%p ", addr);
s += sprintf(s, "%012lx ", addr);
CHECK_LT(Demangle(s, name, DIS_MAX_SYMBOL_LENGTH), buf + ARRAYLEN(buf));
AppendPanel(p, line - breakpointsstart, buf);
if (sym != -1 && addr != dis->syms.p[sym].addr) {
@ -1461,7 +1461,7 @@ static void DrawFrames(struct Panel *p) {
sym = DisFindSym(dis, rp);
name = sym != -1 ? dis->syms.stab + dis->syms.p[sym].name : "UNKNOWN";
s = line;
s += sprintf(s, "%p %p ", Read64(m->ss) + bp, rp);
s += sprintf(s, "%012lx %012lx ", Read64(m->ss) + bp, rp);
s = Demangle(s, name, DIS_MAX_SYMBOL_LENGTH);
AppendPanel(p, i - framesstart, line);
if (sym != -1 && rp != dis->syms.p[sym].addr) {
@ -1501,14 +1501,15 @@ static void CheckFramePointerImpl(void) {
sp = Read64(m->sp);
while (bp) {
if (!(r = FindReal(m, Read64(m->ss) + bp))) {
LOGF("corrupt frame: %p", bp);
LOGF("corrupt frame: %012lx", bp);
ThrowProtectionFault(m);
}
sp = bp;
bp = Read64(r + 0) - 0;
rp = Read64(r + 8) - 1;
if (!bp && !(m->bofram[0] <= rp && rp <= m->bofram[1])) {
LOGF("bad frame !(%p <= %p <= %p)", m->bofram[0], rp, m->bofram[1]);
LOGF("bad frame !(%012lx <= %012lx <= %012lx)", m->bofram[0], rp,
m->bofram[1]);
ThrowProtectionFault(m);
}
}
@ -1831,7 +1832,7 @@ static void OnDebug(void) {
}
static void OnSegmentationFault(void) {
snprintf(systemfailure, sizeof(systemfailure), "SEGMENTATION FAULT %p",
snprintf(systemfailure, sizeof(systemfailure), "SEGMENTATION FAULT %012lx",
m->faultaddr);
LaunchDebuggerReactively();
}
@ -2189,7 +2190,7 @@ static void OnBinbase(struct Machine *m) {
unsigned i;
int64_t skew;
skew = m->xedd->op.disp * 512;
LOGF("skew binbase %,ld @ %p", skew, GetIp());
LOGF("skew binbase %,ld @ %012lx", skew, GetIp());
for (i = 0; i < dis->syms.i; ++i) dis->syms.p[i].addr += skew;
for (i = 0; i < dis->loads.i; ++i) dis->loads.p[i].addr += skew;
for (i = 0; i < breakpoints.i; ++i) breakpoints.p[i].addr += skew;
@ -2562,7 +2563,7 @@ static void Exec(void) {
if (!(interrupt = setjmp(m->onhalt))) {
if (!(action & CONTINUE) &&
(bp = IsAtBreakpoint(&breakpoints, GetIp())) != -1) {
LOGF("BREAK1 %p", breakpoints.p[bp].addr);
LOGF("BREAK1 %012lx", breakpoints.p[bp].addr);
tuimode = true;
LoadInstruction(m);
ExecuteInstruction(m);
@ -2573,7 +2574,7 @@ static void Exec(void) {
for (;;) {
LoadInstruction(m);
if ((bp = IsAtBreakpoint(&breakpoints, GetIp())) != -1) {
LOGF("BREAK2 %p", breakpoints.p[bp].addr);
LOGF("BREAK2 %012lx", breakpoints.p[bp].addr);
action &= ~(FINISH | NEXT | CONTINUE);
tuimode = true;
break;
@ -2625,7 +2626,7 @@ static void Tui(void) {
if ((action & (FINISH | NEXT | CONTINUE)) &&
(bp = IsAtBreakpoint(&breakpoints, GetIp())) != -1) {
action &= ~(FINISH | NEXT | CONTINUE);
LOGF("BREAK %p", breakpoints.p[bp].addr);
LOGF("BREAK %012lx", breakpoints.p[bp].addr);
}
} else {
m->xedd = (struct XedDecodedInst *)m->icache[0];