summaryrefslogtreecommitdiffstats
path: root/usr.bin/truss/ia64-fbsd.c
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2003-11-09 03:48:13 +0000
committermarcel <marcel@FreeBSD.org>2003-11-09 03:48:13 +0000
commit3f532e652b08331243d297085d4f13318e94f586 (patch)
tree89caf91024722473ad91738e243659a20d561f8b /usr.bin/truss/ia64-fbsd.c
parent9162843df044ab6081d73ed699fe186f4a6fe779 (diff)
downloadFreeBSD-src-3f532e652b08331243d297085d4f13318e94f586.zip
FreeBSD-src-3f532e652b08331243d297085d4f13318e94f586.tar.gz
Port truss(1) to 64-bit architectures:
o Syscall return values do not fit in int on 64-bit architectures. Change the type of retval in <arch>_syscall_exit() to long and change the prototype of said function to return a long as well. o Change the prototype of print_syscall_ret() to take a long for the return address and change the format string accordingly. o Replace the code sequence tmp = malloc(X); sprintf(tmp, format, ...); with X by definition too small on 64-bit platforms by asprintf(&tmp, format, ...); With these changes the output makes sense again, although it does mess up the tabulation on ia64. Go widescreen... Not tested on: alpha, sparc64.
Diffstat (limited to 'usr.bin/truss/ia64-fbsd.c')
-rw-r--r--usr.bin/truss/ia64-fbsd.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/usr.bin/truss/ia64-fbsd.c b/usr.bin/truss/ia64-fbsd.c
index c7d61b9..55af8d7 100644
--- a/usr.bin/truss/ia64-fbsd.c
+++ b/usr.bin/truss/ia64-fbsd.c
@@ -257,11 +257,12 @@ ia64_syscall_entry(struct trussinfo *trussinfo, int nargs) {
* the sytem call number instead of, say, an error status).
*/
-int
-ia64_syscall_exit(struct trussinfo *trussinfo, int syscall_num __unused) {
+long
+ia64_syscall_exit(struct trussinfo *trussinfo, int syscall_num __unused)
+{
char buf[32];
struct reg regs;
- int retval;
+ long retval;
int i;
int errorp;
struct syscall *sc;
@@ -291,10 +292,8 @@ ia64_syscall_exit(struct trussinfo *trussinfo, int syscall_num __unused) {
sc = fsc.sc;
if (!sc) {
- for (i = 0; i < fsc.nargs; i++) {
- fsc.s_args[i] = malloc(12);
- sprintf(fsc.s_args[i], "0x%lx", fsc.args[i]);
- }
+ for (i = 0; i < fsc.nargs; i++)
+ asprintf(&fsc.s_args[i], "0x%lx", fsc.args[i]);
} else {
/*
* Here, we only look for arguments that have OUT masked in --
@@ -307,12 +306,10 @@ ia64_syscall_exit(struct trussinfo *trussinfo, int syscall_num __unused) {
* If an error occurred, than don't bothe getting the data;
* it may not be valid.
*/
- if (errorp) {
- temp = malloc(12);
- sprintf(temp, "0x%lx", fsc.args[sc->args[i].offset]);
- } else {
+ if (errorp)
+ asprintf(&temp, "0x%lx", fsc.args[sc->args[i].offset]);
+ else
temp = print_arg(Procfd, &sc->args[i], fsc.args);
- }
fsc.s_args[i] = temp;
}
}
OpenPOWER on IntegriCloud