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.
This commit is contained in:
parent
6bd0764167
commit
434de8db8d
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue