149

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
Jay Conrod
  • 28,943
  • 19
  • 98
  • 110

1 Answers1

202

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

rogerdpack
  • 62,887
  • 36
  • 269
  • 388
Matthew Slattery
  • 45,290
  • 8
  • 103
  • 119
  • 15
    This doesn't work for "nested" or array arguments, e.g. `ioctl(3, SNDCTL_TMR_TEMPO or TCGETA, {B9600 -opost -isig -icanon -echo ...})` – Marki555 Dec 19 '15 at 00:13
  • 8
    it was solved at http://stackoverflow.com/questions/34365928/show-complete-arguments-in-strace/34373478#34373478 – Vladimir Kunschikov Mar 16 '16 at 14:25
  • 3
    As another user noted in a comment [here](https://stackoverflow.com/questions/34365928/show-complete-arguments-in-strace-even-in-curly-brackets/34373478#34373478) "-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. – DarkFranX Jun 14 '18 at 14:32
  • 2
    `-v` alone did not work for in verson 5.5. However, using `-s strsize` alone, without `-v` actually solves abbreviation problem for "nested" arguments. – xiay Aug 03 '21 at 05:28
  • 1
    `strace -s 1000 myBinary` – Ben Sep 02 '21 at 19:41
  • 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. – TonyG Jun 29 '22 at 18:36