[RFC PATCH] src/strace: Add a 'no-truncate' option to disable truncation

Gautam Menghani gautammenghani201 at gmail.com
Thu Jan 11 18:28:42 UTC 2024


On Thu, Jan 11, 2024 at 02:27:29AM +0200, Dmitry V. Levin wrote:
> On Wed, Jan 10, 2024 at 10:37:28PM +0530, Gautam Menghani wrote:
> > Introduce the "no-truncate" flag to disable truncation in strace
> > output. This fixes issue 269 on github [1].
> > 
> > Signed-off-by: Gautam Menghani <gautammenghani201 at gmail.com>
> > ---
> > [1]: https://github.com/strace/strace/issues/269
> > 
> >  src/strace.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/strace.c b/src/strace.c
> > index 780e51e91..5d80f6c1e 100644
> > --- a/src/strace.c
> > +++ b/src/strace.c
> > @@ -2296,7 +2296,7 @@ init(int argc, char *argv[])
> >  #endif
> >  
> >  	static const char optstring[] =
> > -		"+a:Ab:cCdDe:E:fFhiI:kno:O:p:P:qrs:S:tTu:U:vVwxX:yYzZ";
> > +		"+a:Ab:cCdDe:E:fFhiI:knNo:O:p:P:qrs:S:tTu:U:vVwxX:yYzZ";
> >  
> >  	enum {
> >  		GETOPT_SECCOMP = 0x100,
> > @@ -2350,6 +2350,7 @@ init(int argc, char *argv[])
> >  		{ "stack-traces" ,	optional_argument, 0, GETOPT_STACK },
> >  		{ "syscall-limit",	required_argument, 0, GETOPT_SYSCALL_LIMIT },
> >  		{ "syscall-number",	no_argument,	   0, 'n' },
> > +		{ "no-truncate",	no_argument,	0, 'N' },
> >  		{ "output",		required_argument, 0, 'o' },
> >  		{ "summary-syscall-overhead", required_argument, 0, 'O' },
> >  		{ "attach",		required_argument, 0, 'p' },
> > @@ -2537,6 +2538,10 @@ init(int argc, char *argv[])
> >  		case 'n':
> >  			nflag = 1;
> >  			break;
> > +		case 'N':
> 
> Why do you think adding a short option for this would be a good idea?
> 
> > +			qualify_abbrev("none");

Looking at the current supported options, I didn't see an obvious way to modify the 
existing flags to solve this issue, so I thought of this way. Please do suggest a 
better way if any.

Also we have "--abbrev=none" and "-v" which are equivalent. Likewise, we have 
"--string-limit=<size>". Can we repurpose this to say "--string-limit=none" which will
disable truncation? 

> 
> This is essentially -v, why would you want this new option to imply -v?
> 
> > +			max_strlen = -1U / 4;
> 
> This doesn't implement what the commit message says.  While setting the
> maximum string size to 1G raises the limit by setting it to some
> relatively large value, it doesn't remove the limit completely.  In fact,
> there is no problem in allocating larger strings on a 64-bit system.
> 

Noted, will work on eliminating the limit completely.

> > +			break;
> >  		case 'o':
> >  			outfname = optarg;
> >  			break;
> 
> A change in the interface would also require a test, a documentation
> update, and a NEWS entry.
>

Yes right, just wanted to get initial comments before working on these areas.
 
> 
> -- 
> ldv

Thanks,
Gautam


More information about the Strace-devel mailing list