Prevent strace from abbreviating arguments?
Asked Answered
C

1

156

I'm trying to use strace to find out what commands a program executes using execve. Some of the arguments in these commands are quite long, and strace is abbreviating the arguments to execve (I see "..." after about 30 characters), preventing me from getting any useful information. How can I get the full text of each argument?

I've read the man page. The -v option prints the environment, which is useful, but the arguments are still truncated.

strace -f -e trace=execve -v -p 1234

I also tried passing verbose=all, but this just gives some extra information about SIGCHLD.

strace -f -e verbose=all trace=execve -v -p 1234
Czardom answered 13/7, 2011 at 0:15 Comment(0)
C
210

You want the -v -s strsize option, which specifies the maximum length of a string to display (the default is 32).

Carleencarlen answered 13/7, 2011 at 0:39 Comment(6)
This doesn't work for "nested" or array arguments, e.g. ioctl(3, SNDCTL_TMR_TEMPO or TCGETA, {B9600 -opost -isig -icanon -echo ...})Wanwand
it was solved at #34366428Semple
As another user noted in a comment here "-v argument works as of 4.15 and seems to have been there since the creation time of the Git repo." So you don't have to alter the source of the package, -v should work just fine with nested objects.Songster
-v alone did not work for in verson 5.5. However, using -s strsize alone, without -v actually solves abbreviation problem for "nested" arguments.Pebbly
strace -s 1000 myBinaryEuphroe
To be clear: in Ubuntu v20+, strace -v -s 9999 does show the unabbreviated string/array in calls to execve() ... of course as well as more extensive detail for everything else.Adamsen

© 2022 - 2024 — McMap. All rights reserved.