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

Dmitry V. Levin ldv at strace.io
Thu Jan 11 00:27:29 UTC 2024


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");

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.

> +			break;
>  		case 'o':
>  			outfname = optarg;
>  			break;

A change in the interface would also require a test, a documentation
update, and a NEWS entry.


-- 
ldv


More information about the Strace-devel mailing list