[PATCH] gdb 9.1: fix delay when doing -var-list-children From To command
Паша Клюев
pkluiev@mail.ru
Mon May 25 18:01:20 GMT 2020
If some C-program source code has
int arrayInt[2000000];
Execute the command
-var-create PD * arrayInt
and then call
-var-list-children --simple-values "VAR" 0 1000
The answer we will wait tens of seconds or a minute. We will wait tens of seconds or a minute for an answer. The wait time will depend on the size of the array.
diff ./gdb-9.1/gdb/varobj.c ./gdb-9.1-patched/gdb/varobj.c
--- ./gdb-9.1/gdb/varobj.c 2020-02-08 15:50:14.000000000 +0300
+++ ./gdb-9.1-patched/gdb/varobj.c 2020-05-21 17:59:19.053876869 +0300
@@ -865,7 +865,25 @@
while (var->children.size () < var->num_children)
var->children.push_back (NULL);
- for (int i = 0; i < var->num_children; i++)
+ /* patch begin
+ Cause:
+ Slow execution of -var-list-children command for big arrays
+ Example of source code:
+ int arrayInt[2000000];
+ Commands:
+ -var-create PD * arrayInt
+ -var-list-children --simple-values "PD" 0 1000
+ Output:
+ The -var-list-children command waits a very long time
+ Fix:
+ Implements cycle for only needed childrens, from 'from' to 'to' numbers
+ varobj_restrict_range function shift top for correct the 'from' and 'to' numbers
+ After fixing:
+ Command -var-list-children runs without delay
+ */
+ varobj_restrict_range (var->children, from, to);
+ for (int i = *from; i < *to; i++)
+ /* patch end */
{
if (var->children[i] == NULL)
{
@@ -877,7 +895,13 @@
}
}
- varobj_restrict_range (var->children, from, to);
+ /* patch begin
+ Cause:
+ see above
+ */
+ // varobj_restrict_range (var->children, from, to);
+ /* PD patch end */
+
return var->children;
}
--
Regards Pavel.
More information about the Gdb-patches
mailing list