forked from pool/strace
Accepting request 32493 from devel:tools
Copy from devel:tools/strace based on submit request 32493 from user rguenther OBS-URL: https://build.opensuse.org/request/show/32493 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/strace?expand=0&rev=19
This commit is contained in:
parent
d71de13e6e
commit
e02a000f40
@ -1,99 +0,0 @@
|
|||||||
--- net.c
|
|
||||||
+++ net.c
|
|
||||||
@@ -1281,13 +1281,15 @@ struct tcb *tcp;
|
|
||||||
} else if (!tcp->u_arg[2])
|
|
||||||
tprintf("%#lx, NULL", tcp->u_arg[1]);
|
|
||||||
else {
|
|
||||||
- if (tcp->u_arg[1] == 0 || syserror(tcp)) {
|
|
||||||
+ int len;
|
|
||||||
+ if (tcp->u_arg[1] == 0 || syserror(tcp)
|
|
||||||
+ || umove (tcp, tcp->u_arg[2], &len) < 0) {
|
|
||||||
tprintf("%#lx", tcp->u_arg[1]);
|
|
||||||
} else {
|
|
||||||
- printsock(tcp, tcp->u_arg[1], tcp->u_arg[2]);
|
|
||||||
+ printsock(tcp, tcp->u_arg[1], len);
|
|
||||||
}
|
|
||||||
tprintf(", ");
|
|
||||||
- printnum(tcp, tcp->u_arg[2], "%lu");
|
|
||||||
+ printnum_int(tcp, tcp->u_arg[2], "%u");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
--- process.c
|
|
||||||
+++ process.c
|
|
||||||
@@ -765,12 +765,13 @@ setarg(tcp, argnum)
|
|
||||||
{
|
|
||||||
#if defined (IA64)
|
|
||||||
{
|
|
||||||
- unsigned long *bsp, *ap;
|
|
||||||
+ unsigned long *ap;
|
|
||||||
+ long bsp;
|
|
||||||
|
|
||||||
- if (upeek(tcp->pid, PT_AR_BSP, (long *) &bsp) , 0)
|
|
||||||
+ if (upeek(tcp->pid, PT_AR_BSP, &bsp) , 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
- ap = ia64_rse_skip_regs(bsp, argnum);
|
|
||||||
+ ap = ia64_rse_skip_regs((unsigned long *) bsp, argnum);
|
|
||||||
errno = 0;
|
|
||||||
ptrace(PTRACE_POKEDATA, tcp->pid, (char *) ap, tcp->u_arg[argnum]);
|
|
||||||
if (errno)
|
|
||||||
@@ -2289,6 +2290,18 @@ static const struct xlat ptrace_cmds[] =
|
|
||||||
#ifdef PTRACE_SETVRREGS
|
|
||||||
{ PTRACE_SETVRREGS, "PTRACE_SETVRREGS", },
|
|
||||||
#endif
|
|
||||||
+#ifdef PTRACE_SETOPTIONS
|
|
||||||
+ { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS", },
|
|
||||||
+#endif
|
|
||||||
+#ifdef PTRACE_GETEVENTMSG
|
|
||||||
+ { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG", },
|
|
||||||
+#endif
|
|
||||||
+#ifdef PTRACE_GETSIGINFO
|
|
||||||
+ { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO", },
|
|
||||||
+#endif
|
|
||||||
+#ifdef PTRACE_SETSIGINFO
|
|
||||||
+ { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO", },
|
|
||||||
+#endif
|
|
||||||
#ifdef SUNOS4
|
|
||||||
{ PTRACE_READDATA, "PTRACE_READDATA" },
|
|
||||||
{ PTRACE_WRITEDATA, "PTRACE_WRITEDATA" },
|
|
||||||
--- resource.c
|
|
||||||
+++ resource.c
|
|
||||||
@@ -388,10 +388,10 @@ struct tcb *tcp;
|
|
||||||
si.loads[2]);
|
|
||||||
tprintf("totalram=%lu, freeram=%lu, ",
|
|
||||||
si.totalram, si.freeram);
|
|
||||||
- tprintf("sharedram=%lu, bufferram=%lu} ",
|
|
||||||
+ tprintf("sharedram=%lu, bufferram=%lu, ",
|
|
||||||
si.sharedram, si.bufferram);
|
|
||||||
- tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
|
|
||||||
- si.totalswap, si.freeswap, si.procs);
|
|
||||||
+ tprintf("totalswap=%lu, freeswap=%lu, procs=%hu, mem_unit=%u}",
|
|
||||||
+ si.totalswap, si.freeswap, si.procs, si.mem_unit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
--- strace-graph
|
|
||||||
+++ strace-graph
|
|
||||||
@@ -229,7 +229,7 @@ sub handle_trace {
|
|
||||||
push @$seq, ['EXEC', $filename, $argv];
|
|
||||||
|
|
||||||
$pr{$pid}{seq} = $seq;
|
|
||||||
- } elsif ($call eq 'fork' || $call eq 'clone' || $call eq 'vfork') {
|
|
||||||
+ } elsif ($call eq 'fork' || $call eq 'clone' || $call eq 'clone2' || $call eq 'vfork') {
|
|
||||||
return if $result == 0;
|
|
||||||
|
|
||||||
my $seq = $pr{$pid}{seq};
|
|
||||||
--- util.c
|
|
||||||
+++ util.c
|
|
||||||
@@ -1319,9 +1319,8 @@ arg_setup(struct tcb *tcp, arg_setup_sta
|
|
||||||
|
|
||||||
sof = (cfm >> 0) & 0x7f;
|
|
||||||
sol = (cfm >> 7) & 0x7f;
|
|
||||||
- bsp = (long) ia64_rse_skip_regs((unsigned long *) bsp, -sof + sol);
|
|
||||||
+ *state = ia64_rse_skip_regs((unsigned long *) bsp, -sof + sol);
|
|
||||||
|
|
||||||
- *state = (unsigned long *) bsp;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:95e7b7470e04f22c3ec8dc6d0b1fdd8944306cb5313c84c4545cd83abada26d0
|
|
||||||
size 480973
|
|
70
strace-4.5.19.diff
Normal file
70
strace-4.5.19.diff
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
Index: resource.c
|
||||||
|
===================================================================
|
||||||
|
--- resource.c.orig 2009-04-14 14:51:00.000000000 +0200
|
||||||
|
+++ resource.c 2010-02-13 21:24:23.000000000 +0100
|
||||||
|
@@ -373,10 +373,10 @@ sys_sysinfo(struct tcb *tcp)
|
||||||
|
si.loads[2]);
|
||||||
|
tprintf("totalram=%lu, freeram=%lu, ",
|
||||||
|
si.totalram, si.freeram);
|
||||||
|
- tprintf("sharedram=%lu, bufferram=%lu} ",
|
||||||
|
+ tprintf("sharedram=%lu, bufferram=%lu, ",
|
||||||
|
si.sharedram, si.bufferram);
|
||||||
|
- tprintf("totalswap=%lu, freeswap=%lu, procs=%hu}",
|
||||||
|
- si.totalswap, si.freeswap, si.procs);
|
||||||
|
+ tprintf("totalswap=%lu, freeswap=%lu, procs=%hu, mem_unit=%u}",
|
||||||
|
+ si.totalswap, si.freeswap, si.procs, si.mem_unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
Index: strace-graph
|
||||||
|
===================================================================
|
||||||
|
--- strace-graph.orig 2009-07-08 16:57:27.000000000 +0200
|
||||||
|
+++ strace-graph 2010-02-13 21:24:23.000000000 +0100
|
||||||
|
@@ -229,7 +229,7 @@ sub handle_trace {
|
||||||
|
push @$seq, ['EXEC', $filename, $argv];
|
||||||
|
|
||||||
|
$pr{$pid}{seq} = $seq;
|
||||||
|
- } elsif ($call eq 'fork' || $call eq 'clone' || $call eq 'vfork') {
|
||||||
|
+ } elsif ($call eq 'fork' || $call eq 'clone' || $call eq 'clone2' || $call eq 'vfork') {
|
||||||
|
return if $result == 0;
|
||||||
|
|
||||||
|
my $seq = $pr{$pid}{seq};
|
||||||
|
Index: util.c
|
||||||
|
===================================================================
|
||||||
|
--- util.c.orig 2009-10-12 21:54:21.000000000 +0200
|
||||||
|
+++ util.c 2010-02-13 21:24:23.000000000 +0100
|
||||||
|
@@ -1407,9 +1407,8 @@ arg_setup(struct tcb *tcp, arg_setup_sta
|
||||||
|
|
||||||
|
sof = (cfm >> 0) & 0x7f;
|
||||||
|
sol = (cfm >> 7) & 0x7f;
|
||||||
|
- bsp = (long) ia64_rse_skip_regs((unsigned long *) bsp, -sof + sol);
|
||||||
|
+ *state = ia64_rse_skip_regs((unsigned long *) bsp, -sof + sol);
|
||||||
|
|
||||||
|
- *state = (unsigned long *) bsp;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Index: configure
|
||||||
|
===================================================================
|
||||||
|
--- configure.orig 2009-10-21 19:41:11.000000000 +0200
|
||||||
|
+++ configure 2010-02-13 21:25:46.000000000 +0100
|
||||||
|
@@ -5880,6 +5880,7 @@ for ac_header in linux/icmp.h linux/in6.
|
||||||
|
do :
|
||||||
|
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||||
|
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include <stddef.h>
|
||||||
|
+#include <sys/socket.h>
|
||||||
|
#include <linux/socket.h>
|
||||||
|
"
|
||||||
|
eval as_val=\$$as_ac_Header
|
||||||
|
Index: configure.ac
|
||||||
|
===================================================================
|
||||||
|
--- configure.ac.orig 2009-10-12 21:54:43.000000000 +0200
|
||||||
|
+++ configure.ac 2010-02-13 21:25:22.000000000 +0100
|
||||||
|
@@ -258,6 +258,7 @@ AC_CHECK_HEADERS([ \
|
||||||
|
], [], [])
|
||||||
|
AC_CHECK_HEADERS([linux/icmp.h linux/in6.h linux/netlink.h linux/if_packet.h],
|
||||||
|
[], [], [#include <stddef.h>
|
||||||
|
+#include <sys/socket.h>
|
||||||
|
#include <linux/socket.h>])
|
||||||
|
AC_CHECK_HEADERS([asm/sigcontext.h], [], [], [#include <signal.h>])
|
||||||
|
AC_CHECK_TYPES([struct sigcontext_struct,
|
3
strace-4.5.19.tar.bz2
Normal file
3
strace-4.5.19.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:8997ce919e971b0ec45cd7006c6e1f9c7c0bce68ab59e3a629e1ddeda5013d08
|
||||||
|
size 499565
|
@ -1,3 +1,51 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Feb 13 21:27:50 CET 2010 - rguenther@suse.de
|
||||||
|
|
||||||
|
- Update to version 4.5.19.
|
||||||
|
* When command exits, strace now exits with the same exit status.
|
||||||
|
If command is terminated by a signal, strace terminates itself
|
||||||
|
with the same signal, so that strace can be used as a wrapper
|
||||||
|
process transparent to the invoking parent process.
|
||||||
|
When using -p option, the exit status of strace is zero unless
|
||||||
|
there was an unexpected error in doing the tracing.
|
||||||
|
(Addresses Fedora bug #105371 and Debian bug #37665)
|
||||||
|
* Implemented decoding of new Linux syscalls: accept4, dup3,
|
||||||
|
epoll_create1, eventfd2, inotify_init1, pipe2, signalfd4.
|
||||||
|
* Implemented decoding of socket type flags introduced in Linux 2.6.27.
|
||||||
|
* Implemented decoding of accept4 socketcall.
|
||||||
|
* Enhanced prctl decoding.
|
||||||
|
* Enhanced nanosleep decoding.
|
||||||
|
* Enhanced ptrace decoding.
|
||||||
|
* Enhanced futex decoding.
|
||||||
|
* Enhanced CAP_* decoding.
|
||||||
|
* Enhanced SIOCS* ioctls decoding.
|
||||||
|
* Enhanced fcntl F_* flags decoding.
|
||||||
|
* Enhanced semop/semtimedop decoding.
|
||||||
|
* Updated ARM architecture support.
|
||||||
|
* Added Blackfin architecture support.
|
||||||
|
* Added AVR32 architecture support.
|
||||||
|
* Added CRIS architecture support.
|
||||||
|
* Made strace detect when traced process suddenly disappeared.
|
||||||
|
* Fixed syscall numbers for tee and sync_file_range.
|
||||||
|
(Addresses Debian bug #503124)
|
||||||
|
* Fixed several bugs in strings decoder, including potential heap
|
||||||
|
memory corruption.
|
||||||
|
(Addresses Fedora bugs #470529, #478324 and #511035)
|
||||||
|
* Marked sendfile(2) as a network syscall.
|
||||||
|
(Addresses Debian bug #509499)
|
||||||
|
* Fixed accept(2) decoding.
|
||||||
|
* Fixed sigtimedwait(2) decoding.
|
||||||
|
* Fixed build on ARM EABI.
|
||||||
|
(Addresses Debian bugs #520084 and #535564, and Fedora bug #507576)
|
||||||
|
* Fixed display of 32-bit fcntl(F_SETLK) on 64-bit architectures.
|
||||||
|
(Addresses Red Hat bug #471169)
|
||||||
|
* Fixed display of 32-bit argv array on 64-bit architectures.
|
||||||
|
(Addresses Fedora bug #519480)
|
||||||
|
* Fixed display of 32-bit struct sigaction on 64-bit architectures.
|
||||||
|
* Fixed HPPA architecture support.
|
||||||
|
(Addresses Debian bugs #437928 and #546619)
|
||||||
|
- fix check for linux/netlink.h
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Feb 1 12:31:40 UTC 2010 - jengelh@medozas.de
|
Mon Feb 1 12:31:40 UTC 2010 - jengelh@medozas.de
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# spec file for package strace (Version 4.5.18)
|
# spec file for package strace (Version 4.5.19)
|
||||||
#
|
#
|
||||||
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||||
#
|
#
|
||||||
@ -27,13 +27,12 @@ AutoReqProv: on
|
|||||||
Obsoletes: strace-64bit
|
Obsoletes: strace-64bit
|
||||||
%endif
|
%endif
|
||||||
#
|
#
|
||||||
Version: 4.5.18
|
Version: 4.5.19
|
||||||
Release: 12
|
Release: 1
|
||||||
Summary: A utility to trace the system calls of a program
|
Summary: A utility to trace the system calls of a program
|
||||||
Source: http://dl.sourceforge.net/strace/strace-%{version}.tar.bz2
|
Source: http://dl.sourceforge.net/strace/strace-%{version}.tar.bz2
|
||||||
Source2: baselibs.conf
|
Source2: baselibs.conf
|
||||||
Patch: strace-%{version}.diff
|
Patch: strace-%{version}.diff
|
||||||
Patch1: string-quote.diff
|
|
||||||
Url: http://sourceforge.net/projects/strace/
|
Url: http://sourceforge.net/projects/strace/
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
|
|
||||||
@ -53,7 +52,6 @@ Authors:
|
|||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
%patch
|
%patch
|
||||||
%patch1
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
export CFLAGS="$RPM_OPT_FLAGS"
|
export CFLAGS="$RPM_OPT_FLAGS"
|
||||||
|
@ -1,194 +0,0 @@
|
|||||||
2008-11-09 Dmitry V. Levin <ldv@altlinux.org>
|
|
||||||
|
|
||||||
* util.c (string_quote): Fix support for NUL-terminated string.
|
|
||||||
Add comments.
|
|
||||||
(printpathn): Fix the case when "..." was appended to the output
|
|
||||||
but no truncation was actually made. Add comments.
|
|
||||||
(printstr): Fix memory allocation. Fix two cases when "..." was
|
|
||||||
appended to the output but no truncation was actually made.
|
|
||||||
Add comments.
|
|
||||||
|
|
||||||
Index: util.c
|
|
||||||
===================================================================
|
|
||||||
RCS file: /cvsroot/strace/strace/util.c,v
|
|
||||||
retrieving revision 1.80
|
|
||||||
retrieving revision 1.81
|
|
||||||
diff -u -a -p -u -p -a -r1.80 -r1.81
|
|
||||||
--- util.c 10 Nov 2008 22:21:41 -0000 1.80
|
|
||||||
+++ util.c 10 Nov 2008 23:19:13 -0000 1.81
|
|
||||||
@@ -407,6 +407,12 @@ unsigned long uid;
|
|
||||||
|
|
||||||
static char path[MAXPATHLEN + 1];
|
|
||||||
|
|
||||||
+/*
|
|
||||||
+ * Quote string `instr' of length `size'
|
|
||||||
+ * Write up to (3 + `size' * 4) bytes to `outstr' buffer.
|
|
||||||
+ * If `len' < 0, treat `instr' as a NUL-terminated string
|
|
||||||
+ * and quote at most (`size' - 1) bytes.
|
|
||||||
+ */
|
|
||||||
static int
|
|
||||||
string_quote(const char *instr, char *outstr, int len, int size)
|
|
||||||
{
|
|
||||||
@@ -417,12 +423,18 @@ string_quote(const char *instr, char *ou
|
|
||||||
if (xflag > 1)
|
|
||||||
usehex = 1;
|
|
||||||
else if (xflag) {
|
|
||||||
+ /* Check for presence of symbol which require
|
|
||||||
+ to hex-quote the whole string. */
|
|
||||||
for (i = 0; i < size; ++i) {
|
|
||||||
c = ustr[i];
|
|
||||||
- if (len < 0 && i == size - 2 && c != '\0')
|
|
||||||
- ++i;
|
|
||||||
- if (len < 0 && c == '\0')
|
|
||||||
- break;
|
|
||||||
+ /* Check for NUL-terminated string. */
|
|
||||||
+ if (len < 0) {
|
|
||||||
+ if (c == '\0')
|
|
||||||
+ break;
|
|
||||||
+ /* Quote at most size - 1 bytes. */
|
|
||||||
+ if (i == size - 1)
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
if (!isprint(c) && !isspace(c)) {
|
|
||||||
usehex = 1;
|
|
||||||
break;
|
|
||||||
@@ -433,20 +445,31 @@ string_quote(const char *instr, char *ou
|
|
||||||
*s++ = '\"';
|
|
||||||
|
|
||||||
if (usehex) {
|
|
||||||
+ /* Hex-quote the whole string. */
|
|
||||||
for (i = 0; i < size; ++i) {
|
|
||||||
c = ustr[i];
|
|
||||||
- if (len < 0 && c == '\0')
|
|
||||||
- break;
|
|
||||||
+ /* Check for NUL-terminated string. */
|
|
||||||
+ if (len < 0) {
|
|
||||||
+ if (c == '\0')
|
|
||||||
+ break;
|
|
||||||
+ /* Quote at most size - 1 bytes. */
|
|
||||||
+ if (i == size - 1)
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
sprintf(s, "\\x%02x", c);
|
|
||||||
s += 4;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < size; ++i) {
|
|
||||||
c = ustr[i];
|
|
||||||
- if (len < 0 && i == size - 2 && c != '\0')
|
|
||||||
- ++i;
|
|
||||||
- if (len < 0 && c == '\0')
|
|
||||||
- break;
|
|
||||||
+ /* Check for NUL-terminated string. */
|
|
||||||
+ if (len < 0) {
|
|
||||||
+ if (c == '\0')
|
|
||||||
+ break;
|
|
||||||
+ /* Quote at most size - 1 bytes. */
|
|
||||||
+ if (i == size - 1)
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
switch (c) {
|
|
||||||
case '\"': case '\\':
|
|
||||||
*s++ = '\\';
|
|
||||||
@@ -495,18 +518,25 @@ string_quote(const char *instr, char *ou
|
|
||||||
return i == size;
|
|
||||||
}
|
|
||||||
|
|
||||||
+/*
|
|
||||||
+ * Print path string specified by address `addr' and length `n'.
|
|
||||||
+ * If path length exceeds `n', append `...' to the output.
|
|
||||||
+ */
|
|
||||||
void
|
|
||||||
printpathn(struct tcb *tcp, long addr, int n)
|
|
||||||
{
|
|
||||||
- if (n > sizeof path - 1)
|
|
||||||
- n = sizeof path - 1;
|
|
||||||
-
|
|
||||||
- if (addr == 0) {
|
|
||||||
+ if (!addr) {
|
|
||||||
tprintf("NULL");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /* Cap path length to the path buffer size,
|
|
||||||
+ and NUL-terminate the buffer. */
|
|
||||||
+ if (n > sizeof path - 1)
|
|
||||||
+ n = sizeof path - 1;
|
|
||||||
path[n] = '\0';
|
|
||||||
+
|
|
||||||
+ /* Fetch one byte more to find out whether path length > n. */
|
|
||||||
if (umovestr(tcp, addr, n + 1, path) < 0)
|
|
||||||
tprintf("%#lx", addr);
|
|
||||||
else {
|
|
||||||
@@ -515,7 +545,8 @@ printpathn(struct tcb *tcp, long addr, i
|
|
||||||
|
|
||||||
if (trunc)
|
|
||||||
path[n] = '\0';
|
|
||||||
- if (string_quote(path, outstr, -1, n + 1) || trunc)
|
|
||||||
+ (void) string_quote(path, outstr, -1, n + 1);
|
|
||||||
+ if (trunc)
|
|
||||||
strcat(outstr, "...");
|
|
||||||
tprintf("%s", outstr);
|
|
||||||
}
|
|
||||||
@@ -527,6 +558,11 @@ printpath(struct tcb *tcp, long addr)
|
|
||||||
printpathn(tcp, addr, sizeof path - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
+/*
|
|
||||||
+ * Print string specified by address `addr' and length `len'.
|
|
||||||
+ * If `len' < 0, treat the string as a NUL-terminated string.
|
|
||||||
+ * If string length exceeds `max_strlen', append `...' to the output.
|
|
||||||
+ */
|
|
||||||
void
|
|
||||||
printstr(struct tcb *tcp, long addr, int len)
|
|
||||||
{
|
|
||||||
@@ -538,32 +574,39 @@ printstr(struct tcb *tcp, long addr, int
|
|
||||||
tprintf("NULL");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
- if (!str) {
|
|
||||||
- if ((str = malloc(max_strlen + 1)) == NULL
|
|
||||||
- || (outstr = malloc(4*max_strlen
|
|
||||||
- + sizeof "\"\"...")) == NULL) {
|
|
||||||
- fprintf(stderr, "out of memory\n");
|
|
||||||
- tprintf("%#lx", addr);
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
+ /* Allocate static buffers if they are not allocated yet. */
|
|
||||||
+ if (!str)
|
|
||||||
+ str = malloc(max_strlen + 1);
|
|
||||||
+ if (!outstr)
|
|
||||||
+ outstr = malloc(4 * max_strlen + sizeof "\"...\"");
|
|
||||||
+ if (!str || !outstr) {
|
|
||||||
+ fprintf(stderr, "out of memory\n");
|
|
||||||
+ tprintf("%#lx", addr);
|
|
||||||
+ return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len < 0) {
|
|
||||||
+ /*
|
|
||||||
+ * Treat as a NUL-terminated string: fetch one byte more
|
|
||||||
+ * because string_quote() quotes one byte less.
|
|
||||||
+ */
|
|
||||||
size = max_strlen + 1;
|
|
||||||
+ str[max_strlen] = '\0';
|
|
||||||
if (umovestr(tcp, addr, size, str) < 0) {
|
|
||||||
tprintf("%#lx", addr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
- size = MIN(len, max_strlen + 1);
|
|
||||||
+ size = MIN(len, max_strlen);
|
|
||||||
if (umoven(tcp, addr, size, str) < 0) {
|
|
||||||
tprintf("%#lx", addr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (string_quote(str, outstr, len, size))
|
|
||||||
+ if (string_quote(str, outstr, len, size) &&
|
|
||||||
+ (len < 0 || len > max_strlen))
|
|
||||||
strcat(outstr, "...");
|
|
||||||
|
|
||||||
tprintf("%s", outstr);
|
|
Loading…
Reference in New Issue
Block a user