summaryrefslogtreecommitdiff
path: root/sys/src/cmd/snap
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-11-22 20:27:27 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2018-11-22 20:27:27 +0100
commit434de8db8da082f214652a9fdb7e6a0fa3aea537 (patch)
treea7c832d7a46b5a87ff03bbd5fdb0182dbff2e373 /sys/src/cmd/snap
parent6bd0764167a0fbebb5ee90bf1a9c30e8d119442b (diff)
snap: use Mach->szaddr as the width of the stack pointer (fixes snap on amd64)
to read the value of the stack pointer register, snap used Machdata->szreg to determine the width of the SP register in the Ureg structure. however, the value does not match the Ureg.sp type for a number of architectures (mips2, amd64) and it is unclear if this was an oversight as it is rarely used (snap is indeed the only user) or if it was intended for a different purpose. so we use szaddr instead which matches the stack pointer width in the Ureg and fixes the truncated stack issue on amd64.
Diffstat (limited to 'sys/src/cmd/snap')
-rw-r--r--sys/src/cmd/snap/take.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/src/cmd/snap/take.c b/sys/src/cmd/snap/take.c
index bb139ef11..2d0c88af3 100644
--- a/sys/src/cmd/snap/take.c
+++ b/sys/src/cmd/snap/take.c
@@ -166,18 +166,17 @@ stackptr(Proc *proc, int fd)
if((dreg = proc->d[Pregs]) == nil)
return 0;
- if(r->roffs+mach->szreg > dreg->len) {
+ if(r->roffs+mach->szaddr > dreg->len) {
fprint(2, "SP register too far into registers?\n");
return 0;
}
q = dreg->data+r->roffs;
- switch(mach->szreg) {
- case 2: return machdata->swab(*(ushort*)q);
+ switch(mach->szaddr) {
case 4: return machdata->swal(*(ulong*)q);
case 8: return machdata->swav(*(uvlong*)q);
default:
- fprint(2, "register size is %d bytes?\n", mach->szreg);
+ fprint(2, "address size is %d bytes?\n", mach->szaddr);
return 0;
}
}