1515static CallInfo * last_ci = NULL ;
1616static int dump_lua_state = 0 ;
1717static int table_dump_limit = 16 ;
18+ static int table_entry_limit = 100 ;
1819
1920static gimli_hash_t derefed = NULL ;
2021
@@ -91,6 +92,7 @@ static int show_table(gimli_proc_t proc, Table *tp, int limit)
9192{
9293 int i ;
9394 int printed = 0 ;
95+ int entries = 0 ;
9496 int indent = 2 + ((table_dump_limit - limit + 1 ) * 2 );
9597 Table t ;
9698 char ptrbuf [64 ];
@@ -116,6 +118,8 @@ static int show_table(gimli_proc_t proc, Table *tp, int limit)
116118 return 1 ;
117119 }
118120
121+ int total_entries = t .sizearray + twoto (t .lsizenode );
122+
119123 printf ("{ " );
120124 for (i = 0 ; i < t .sizearray ; i ++ ) {
121125 TValue val ;
@@ -128,13 +132,20 @@ static int show_table(gimli_proc_t proc, Table *tp, int limit)
128132 continue ;
129133 }
130134
135+ if (entries >= table_entry_limit ) {
136+ printf ("%.*s... (%d more entries not shown)\n" ,
137+ indent , indent_str , total_entries - entries );
138+ goto done ;
139+ }
140+
131141 if (!printed ) {
132142 printed = 1 ;
133143 printf ("\n" );
134144 }
135145 printf ("%.*s[%d] = " , indent , indent_str , i + 1 );
136146 show_tvalue (proc , t .array + i , limit - 1 );
137147 printf ("\n" );
148+ entries ++ ;
138149 }
139150
140151 for (i = twoto (t .lsizenode ) - 1 ; i >= 0 ; i -- ) {
@@ -147,6 +158,12 @@ static int show_table(gimli_proc_t proc, Table *tp, int limit)
147158 continue ;
148159 }
149160
161+ if (entries >= table_entry_limit ) {
162+ printf ("%.*s... (%d more entries not shown)\n" ,
163+ indent , indent_str , total_entries - entries );
164+ goto done ;
165+ }
166+
150167 if (!printed ) {
151168 printed = 1 ;
152169 printf ("\n" );
@@ -157,7 +174,9 @@ static int show_table(gimli_proc_t proc, Table *tp, int limit)
157174 printf ("] = " );
158175 show_tvalue (proc , (TValue * )(t .node + i ), limit - 1 );
159176 printf ("\n" );
177+ entries ++ ;
160178 }
179+ done :
161180 if (printed ) {
162181 indent -= 4 ;
163182 if (indent < 4 ) indent = 4 ;
@@ -417,6 +436,13 @@ int gimli_module_init(int api_version)
417436 table_dump_limit = val ;
418437 }
419438 }
439+ dump = getenv ("GIMLI_LUA_TABLE_ENTRY_LIMIT" );
440+ if (dump ) {
441+ int val = atoi (dump );
442+ if (val > 0 ) {
443+ table_entry_limit = val ;
444+ }
445+ }
420446 derefed = gimli_hash_new (NULL );
421447
422448 gimli_module_register_var_printer_for_types (lua_state_typenames , 1 ,
0 commit comments