summaryrefslogtreecommitdiffstats
path: root/usr.bin/truss/i386-linux.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/i386-linux.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/i386-linux.c')
-rw-r--r--usr.bin/truss/i386-linux.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/usr.bin/truss/i386-linux.c b/usr.bin/truss/i386-linux.c
index e2f17e7..94943d6 100644
--- a/usr.bin/truss/i386-linux.c
+++ b/usr.bin/truss/i386-linux.c
@@ -261,11 +261,12 @@ const int bsd_to_linux_errno[] = {
-6,
};
-int
-i386_linux_syscall_exit(struct trussinfo *trussinfo, int syscall_num __unused) {
+long
+i386_linux_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;
@@ -295,10 +296,8 @@ i386_linux_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 --
@@ -311,12 +310,10 @@ i386_linux_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