truss: support for amd64

This commit is contained in:
cinap_lenrek 2014-02-12 19:27:08 +01:00
parent ad38f0eb1c
commit cd17077749
2 changed files with 12 additions and 7 deletions

View file

@ -150,6 +150,8 @@ defn UPCSPRET() {
// return sys call number, address of first argument, location of syscall return value // return sys call number, address of first argument, location of syscall return value
if objtype == "386" then if objtype == "386" then
return { code(*(*PC-4)), code(*SP+4), code(*AX) }; return { code(*(*PC-4)), code(*SP+4), code(*AX) };
if objtype == "amd64" then
return { code(*BP), code(*SP+8), code(*AX) };
if (objtype == "mips") || (objtype == "mips2") then if (objtype == "mips") || (objtype == "mips2") then
return { code(*(*PC-4) & 0xffff), code(*SP+4), code(*R1) }; return { code(*(*PC-4) & 0xffff), code(*SP+4), code(*R1) };
if objtype == "arm" then if objtype == "arm" then
@ -161,6 +163,7 @@ defn UPCSPRET() {
defn trapoffset() { defn trapoffset() {
// return offset from entry point to trap instr // return offset from entry point to trap instr
if objtype == "386" then return 5; if objtype == "386" then return 5;
if objtype == "amd64" then return 12;
if objtype == "mips" then return 8; if objtype == "mips" then return 8;
if objtype == "mips2" then return 8; if objtype == "mips2" then return 8;
if objtype == "arm" then return 8; // untested if objtype == "arm" then return 8; // untested
@ -170,6 +173,7 @@ defn trapoffset() {
defn trapreason() { defn trapreason() {
// return reason for trap // return reason for trap
if objtype == "386" then return reason(*TRAP); if objtype == "386" then return reason(*TRAP);
if objtype == "amd64" then return reason(*TYPE);
if objtype == "mips" then return reason(*CAUSE); if objtype == "mips" then return reason(*CAUSE);
if objtype == "mips2" then return reason(*CAUSE); if objtype == "mips2" then return reason(*CAUSE);
if objtype == "arm" then return "unknown trap"; // untested if objtype == "arm" then return "unknown trap"; // untested

View file

@ -198,7 +198,7 @@ defn new() {
} }
defn truss() { defn truss() {
local pc, lst, offset, prevpc, pcspret, ret; local pc, lst, offset, prevpc, pcspret, arg, ret;
offset = trapoffset(); offset = trapoffset();
@ -225,33 +225,34 @@ defn truss() {
trussflush(); trussflush();
prevpc = *PC; prevpc = *PC;
step(); step();
arg = eval pcspret[1];
ret = eval pcspret[2]; ret = eval pcspret[2];
print("\treturn value: ", ret\D, "\n"); print("\treturn value: ", ret\D, "\n");
if (ret>=0) && (match(prevpc, readPC)>=0) then { if (ret>=0) && (match(prevpc, readPC)>=0) then {
print("\tdata: "); print("\tdata: ");
printtextordata(*((eval pcspret[1])+4), ret); printtextordata(arg[1], ret);
print("\n"); print("\n");
} }
if (ret>=0) && (match(prevpc, fd2pathPC)>=0) then { if (ret>=0) && (match(prevpc, fd2pathPC)>=0) then {
print("\tdata: \"", *(*((eval pcspret[1])+4)\s), "\"\n"); print("\tdata: \"", *(arg[1]\s), "\"\n");
} }
if (ret>=0) && (match(prevpc, errstrPC)>=0) then { if (ret>=0) && (match(prevpc, errstrPC)>=0) then {
print("\tdata: \"", *(*(eval pcspret[1])\s), "\"\n"); print("\tdata: \"", *(arg[1]\s), "\"\n");
} }
if (ret>=0) && (match(prevpc, awaitPC)>=0) then { if (ret>=0) && (match(prevpc, awaitPC)>=0) then {
print("\tdata: "); print("\tdata: ");
printtextordata(*(eval pcspret[1]), ret); printtextordata(arg[0], ret);
print("\n"); print("\n");
} }
// compatibility hacks for old kernel: // compatibility hacks for old kernel:
if (ret>=0) && (match(prevpc, _waitPC)>=0) then { if (ret>=0) && (match(prevpc, _waitPC)>=0) then {
print("\tdata: "); print("\tdata: ");
printtextordata(*(eval pcspret[1]), 12+3*12+64); printtextordata(arg[0], 12+3*12+64);
print("\n"); print("\n");
} }
if (ret>=0) && (match(prevpc, _errstrPC)>=0) then { if (ret>=0) && (match(prevpc, _errstrPC)>=0) then {
print("\tdata: "); print("\tdata: ");
printtextordata(*(eval pcspret[1]), 64); printtextordata(arg[0], 64);
print("\n"); print("\n");
} }
} }