IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
strace already has a mechanism to use fopen64 for output when the 64-bit
version of fopen is available on 32-bit architectures. Apply this
mechanism for other three functions to make strace fully adopted for
64-bit types.
* strace.c (struct_stat, stat_file, struct_dirent, read_dir,
struct_rlimit, set_rlimit): New macros.
(startup_attach): Use read_dir.
(startup_child): Use struct_stat and stat_file.
(main): Use struct_rlimit and set_rlimit.
struct dirent from libc should not be used for umove'ing into because it
contains fixed size d_name.
* file.c (printdir): Rename to print_old_dirent.
[SH64]: Decode using struct kernel_dirent.
[!SH64]: Decode using an open-coded struct with 32-bit d_ino and d_off.
(sys_readdir): Update.
sendfile parser used to decode off_t* parameter as a pointer to host
off_t type. With this change, it is decoded as a pointer to target long
type.
* io.c (print_off_t): New function.
(sys_sendfile): Use it.
* linux/aarch64/syscallent1.h: Use sys_sendfile64 for sendfile decoding.
* linux/tile/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Use sys_sendfile64 for sendfile64 decoding.
* linux/metag/syscallent.h: Correct sendfile syscall name.
* linux/or1k/syscallent.h: Likewise.
* configure.ac: When libaio.h is available, check for
struct iocb.u.c.flags, IO_CMD_PWRITE and IO_CMD_PWRITEV.
* desc.c (print_common_flags): Check for HAVE_STRUCT_IOCB_U_C_FLAGS.
(sys_io_submit): Check for HAVE_DECL_IO_CMD_PWRITE and
HAVE_DECL_IO_CMD_PWRITEV.
Busybox version of timeout doesn't have --version option.
Relax check_prog to handle those cases.
* tests/init.sh (check_prog): Use type builtin to check program
availability.
Signed-off-by: Maxin B. John <maxin.john@enea.com>
* syscall.c [I386 || ARM || OR1K || METAG] (ARCH_REGS_FOR_GETREGSET):
New macro.
(get_regset): Implement for AARCH64, METAG, OR1K and X32.
(get_regs) [AARCH64 || METAG || OR1K || X32]: Use it.
count_syscall() was calling setitimer/getitimer once in order to find
smallest "tick" OS uses in time accounting, in order to use it
for syscalls which apparently spent less than that time in syscall.
The code assumed that this "tick" is not zero... but it is zero
on linux-3.6.11. Which means that this hack doesn't work...
At least this change prevents this measurement from being done
_repeatedly_, by initializing one_tick to -1, not 0.
While at it, added comments in count_syscall() explaining what we are doing.
Optimized call_summary_pers() a bit, by eliminating redundant tv -> float
conversions, and prevented 0.0/0.0 which was resulting in "% time"
being shown as "-nan" if total CPU time spent was 0.000000
(try "strace -c /bin/true").
The code seems to seriously underestimate CPU usage:
"strace -c ls -lR /usr/share >/dev/null" shows total time spent
in syscalls to be only ~10..20% of what "time ls -lR /usr/share >/dev/null"
shows.
It might be useful to have a mode where we show wall clock time
spent in syscalls, not CPU time. It might also be more accurate.
text data bss dec hex filename
245019 676 5708 251403 3d60b strace_old
244923 684 5676 251283 3d593 strace
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
We don't call setlocale, thus we always use C locale.
But libc supports various other locales, and therefore
its ctype interface is general and at times inefficient.
For example, in glibc these macros result in function call,
whereas for e.g. isprint(c) just c >= ' ' && c <= 0x7e
suffices.
By open-coding ctype checks (we have only 4 of them)
we avoid function calls, we get smaller code:
text data bss dec hex filename
245127 680 5708 251515 3d67b strace_old
245019 676 5708 251403 3d60b strace
and we don't link in ctype tables (beneficial for static builds).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
PAGE_SHIFT couldn't be reliably obtained at compile time,
thanks to Chris Metcalf for the hint.
* mem.c: Do not include <sys/user.h>.
[SH64] Do not include <asm/page.h>.
(get_pagesize): New function.
(sys_mmap_pgoff, sys_old_mmap_pgoff): Use it.
While at it, added a small optimization of not remembering
the path twice if it happens to be the same.
text data bss dec hex filename
245111 680 10860 256651 3ea8b strace_old
245075 680 9804 255559 3e647 strace
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
or1k was missing TM on many memory-related syscalls
sys_lookup_dcookie is 3-arg on 64-bit arches, and isn't TF
sys_recvmsg is 3-arg on all arches
sys_nfsservctl is 3-arg on all arches
sys_timerfd_create is 2-arg on all arches
sys_[f]truncate64 is 4-arg or 3-arg, never 5-arg
truncate64 is TF
sys_[l]lseek is TD
fstat[64] is TD
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Add support for Imagination Technologies Meta architecture (the
architecture/ABI is usually referred to as metag in code). The Meta
Linux kernel port is in the process of being upstreamed for v3.9 so it
uses generic system call numbers.
sys_lookup_dcookie writes a filename to buffer argument, so I've set
TF flag.
nfsservctl appears to be set to sys_ni_syscall in asm-generic/unistd.h
so I've left it blank.
truncate64/ftruncate64/pread64/pwrite64/readahead have unaligned 64bit
args which are packed tightly on metag, so less arguments on metag.
fchdir/llseek takes a file descriptor so s/TF/TD/
sync_file_range has 2 64bit args so uses 6 args, so s/4/6/
timerfd_create/msgget/msgctl/msgrcv/semget/segtimedop/semop/shmget/
shmctl/shmat/shmdt/recvmsg/migrate_pages have different number of args.
oldgetrlimit is just getrlimit for metag.
add TM flag to various memory syscalls.
metag doesn't directly use sys_mmap_pgoff for mmap2.
prlimit64/process_vm_readv/process_vm_writev take a pid so add TP flag.
fanotify_init doesn't appear to take a file descriptor so remove TD.
Add kcmp syscall.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Christian Svensson <blue@cmd.nu>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Without this fix the tilegx build fails when it hits the new #error
about SIZEOF_LONG > 4.
* util.c (printllval): Fix printing of long long values on TILE.
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
To not waste an option letter for just one trick,
extend -b to take a parameter:
"on which syscalls do you want to detach?".
Currently supports only execve.
While at it, fixed (by removing non-Linux and stale info)
and extended manpage text about -f.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Cleanup sloppy error handling.
First, EFAULT kind of errors from process_vm_readv by itself is not
something unusual, so a warning message will not be issued unless a
short read is detected.
Second, clients of umoven and umovestr are not prepared to detect and
handle short reads that can happen in these functions. The most safe
way to handle them is to return an error code.
* util.c (umoven, umovestr): Cleanup handling of errors coming from
process_vm_readv and PTRACE_PEEKDATA.
This fixes regression introduced by commit v4.7-111-g9cbc15b.
* syscall.c: Merge all nsyscalls* enums into single enum.
Likewise merge nerrnos*, nsignals*, and nioctlents* into single enums.
There is no need to print literal strings through "%s".
Only untrusted strings such as filenames need that.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
umoven() uses process_vm_readv() when available but it returns the
return value of that syscall, which is the number of bytes copied,
while its callers expect it to simply return zero on success.
It was causing syscalls that take a user-space argument to print
the abbreviated version, e.g.:
epoll_ctl(5, EPOLL_CTL_ADD, 10, {...})
Instead of:
epoll_ctl(5, EPOLL_CTL_ADD, 10, {EPOLLIN, {u32=10, u64=10}})
* util.c (umoven): Make umove[n] report success as 0, not >=0,
stop returning "success" on partial reads.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
With -D, strdup'ing of pathname is necessary only on NOMMU.
Don't set skip_startup_execve to 1 if NOMMU and not in daemonized mode
(try "strace [-D] -b env echo HI" to see whether we detach on correct execve).
Fix test_ptrace_FOO shortcuts on NOMMU to always assume success
and _properly_ set all variables.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This is a 14 year old bug (!).
It wasn't biting us merely because outstr[80] was static, thus ended up
in bss and whatever was after it "accidentally" provided the NUL byte.
When dumpstr was changed to use on-stack buffer, the bug reared its ugly head.
This is a rewrite which is smaller and should be significantly faster
for _long_ strings.
text data bss dec hex filename
244627 680 10860 256167 3e8a7 strace.t9/strace
244563 680 10860 256103 3e867 strace.ta/strace
* util.c (dumpstr): Rewrite to be faster and smaller.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
MAX_QUALS was 2048, even though most arches used less than 500 entries
in it. MAX_QUALS had to be maintained by hand to be higher than syscall
count. It also limited the highest possible fd to track.
This change makes qual_flagsN[] arrays start sized to the required minimum
(number of syscalls) and grow dynamically if user requested
-e read=BIGNUM. As a precaution, BIGNUM should be < 2^15, but this limit
can be raised with no cost for normal strace invocations.
qual_flags is now a define to qual_vec[current_personality].
As a bonus, this patch aliases sysent, errnoent, signalent, ioctlent
names in one-personality arches to their corresponding <foo>0 arrays,
removing one indirection level.
text data bss dec hex filename
244471 700 12928 258099 3f033 strace.t7/strace
244627 680 10860 256167 3e8a7 strace.t8/strace
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This is a preparatory mass replace patch with no code changes.
The future change will need to typedef sysent to sysent0,
which results in compile failures when "struct sysent" string
gets mangled into "struct sysent0".
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
We have hundreds of uses of these macros.
Result is more efficient and 1.1 kbyte shorter code:
text data bss dec hex filename
245579 700 12928 259207 3f487 strace.t5/strace
244471 700 12928 258099 3f033 strace.t6/strace
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>