aboutsummaryrefslogtreecommitdiff
path: root/lens_default.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-11-19 01:00:54 +0100
committerPetr Machata <pmachata@redhat.com>2012-11-19 01:00:54 +0100
commit6248a0ac394b2aa3b2267eaa1220a90b609b6f86 (patch)
treee8776e23481fddc12f73dc1d91381116ec76a7d6 /lens_default.c
parent307b90b158b79ba3aae61d5c6612b4769b10be5f (diff)
downloadltrace-6248a0ac394b2aa3b2267eaa1220a90b609b6f86.tar.gz
Guard number of expanded structures of the same type
The logic behind that is that if we limit array output, we should similarly limit linked list output. Number of expansions of the same-typed structure is a reasonable metric for that. Double recursive structures will expand a bit too much, but on the other hand we want the stuff that is typed out in the configure file to display fully, and not be considered for trimming. Test suite included.
Diffstat (limited to 'lens_default.c')
-rw-r--r--lens_default.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/lens_default.c b/lens_default.c
index f3e328f..7ad2ee4 100644
--- a/lens_default.c
+++ b/lens_default.c
@@ -261,8 +261,28 @@ format_pointer(FILE *stream, struct value *value, struct value_dict *arguments)
if (pointers.elt_size == 0)
VECT_INIT(&pointers, struct value *);
- size_t len = vect_size(&pointers);
+ /* Trim number of expanded structures of the same type. Even
+ * for non-recursive structure, we don't want to expand all of
+ * it if it's huge. */
size_t i;
+ size_t len = vect_size(&pointers);
+ assert(value->type->type == ARGTYPE_POINTER);
+ struct arg_type_info *pointee = value->type->u.ptr_info.info;
+ if (pointee->type == ARGTYPE_STRUCT) {
+ size_t depth = 0;
+ for (i = 0; i < len; ++i) {
+ struct value *old
+ = *VECT_ELEMENT(&pointers, struct value *, i);
+ assert(old->type->type == ARGTYPE_POINTER);
+ struct arg_type_info *old_pointee
+ = old->type->u.ptr_info.info;
+ if (old_pointee == pointee)
+ depth++;
+ }
+ if (depth >= options.arraylen)
+ return fprintf(stream, "...");
+ }
+
for (i = len; i-- > 0 ;) {
struct value **old = VECT_ELEMENT(&pointers, struct value *, i);
int rc = value_equal(value, *old, arguments);