[PATCH v1] strace: Enhance --string-limit/-s to remove max string length limit

Gautam Menghani gautammenghani201 at gmail.com
Tue Jan 23 03:39:36 UTC 2024


On Mon, Jan 22, 2024 at 12:13:22AM +0200, Dmitry V. Levin wrote:
> On Sun, Jan 21, 2024 at 04:16:02PM +0530, Gautam Menghani wrote:
> [...]
> > @@ -1774,7 +1784,7 @@ print_array_ex(struct tcb *const tcp,
> >  		if (cur == start_addr)
> >  			tprint_array_begin();
> >  
> > -		if (cur >= abbrev_end) {
> > +		if (truncation_needed(cur, abbrev_end)) {
> >  			tprint_more_data_follows();
> >  			cur = end_addr;
> >  			truncated = true;
> 
> How this change has been tested?
> From a very cursory look, this doesn't look correct: both cur
> and abbrev_end are addresses pointing to the tracee's memory.


Yes, it looks like I missed testing this part, and from initial testing, there are more changes needed:
--- a/src/util.c
+++ b/src/util.c
@@ -1755,7 +1755,7 @@ print_array_ex(struct tcb *const tcp,
        }
 
        const kernel_ulong_t abbrev_end =
-               (abbrev(tcp) && max_strlen < nmemb) ?
+               (abbrev(tcp) && truncation_needed(nmemb, max_strlen + 1)) ?
                        start_addr + elem_size * max_strlen : end_addr;

I tested this above change with utime.c
../src/strace -s inf ./futimesat 2> utimeinf1


> 
> > diff --git a/tests/gen_tests.in b/tests/gen_tests.in
> > index bf2bcb2f2..4ee039709 100644
> > --- a/tests/gen_tests.in
> > +++ b/tests/gen_tests.in
> > @@ -1140,6 +1140,7 @@ trace_statfs	test_trace_expr '' -e%statfs
> >  trace_statfs_like	test_trace_expr '' -e%%statfs
> >  trie_test    run_prog
> >  truncate
> > +truncate -s inf
> >  truncate64
> >  ugetrlimit	-a28 'QUIRK:START-OF-TEST-OUTPUT:ugetrlimit(0x10 /* RLIMIT_??? */, NULL)'
> >  umask	-a11
> 
> I haven't looked into the test itself, but this is definitely not correct:
> since different tests must have different names, you cannot have two tests
> called "truncate".

Noted, will rework this and send a v2
Please let me know if anything else needs rework apart from the 2 things mentioned.

Thanks, 
Gautam

> 
> -- 
> ldv


More information about the Strace-devel mailing list