c++ - Eclipse CDT (4.5.1) works slow with pretty printing -


i have problem huge nested data structures (from json spirit). while debugging, when structure filled data, eclipse starts work slow, after every step waits printed data gdb. thing eclipse gathers lot of information local variables when not expanding data structure. when pretty print off, works, of course can't see inside stl containers.

i using printers gdb svn

here little piece of code can make similar problems:

#include <iostream> #include <string> #include <map>  int main() {     std::map<std::string, std::map<std::string, std::map<std::string, std::string>>> mega_map;      const int factor = 50;     (int c = 0; c < factor; ++c){         std::map<std::string, std::map<std::string, std::string>> b_map;         (int b = 0; b < factor; ++b){             std::map<std::string, std::string> a_map;             (int = 0; < factor; ++a){                 std::string a_str = "a";                 a_str += (std::to_string(a));                 auto a_pair = std::make_pair("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + a_str, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");                 a_map.insert(a_pair);             }             std::string b_str = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";             b_str += (std::to_string(b));             b_map[b_str] = a_map;         }         std::string c_str = "cccccccccccccccccccccccccccccccccccccccc";         c_str += (std::to_string(c));         mega_map[c_str] = b_map;     }     return 0; } 

just make brake @ 'return', , see takes lot of time in 'variables' window. during time can't debug.

there flag in gdb set print elements number-of-elements can limit number of elements in containers print, works while not interested in these nested structures, settings affects other containers inspect.

any ideas how fix it?

thanks.

we (colleagues , i) hit , investigated issue today, , here's our conclusion. unfortunately, didn't find way solve problem using settings only, found changes in cdt , gdb alleviate it. if can build own cdt or gdb may you.

cdt asks gdb locals using -stack-list-locals, argument values well. pretty-printed container, gdb ends including children:

std::vector of length 20, capacity 20 = {<children here>} 

for nested data structures, can end huge. 1 fix make cdt not ask values. use variable objects , ask values needed expand data structures. here's diff:

diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/mistack.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/mistack.java index c319eb8..23bbb8a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/mistack.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/mistack.java @@ -859,7 +859,7 @@ implements istack, icachingservice {             fmicommandcache.execute(                     // don't ask value when visualizing trace data, since                     // data not there, , command fail -                   fcommandfactory.createmistacklistlocals(framedmc, !ftracevisualization), +                   fcommandfactory.createmistacklistlocals(framedmc, false),                     new datarequestmonitor<mistacklistlocalsinfo>(getexecutor(), rm) {                         @override                         protected void handlesuccess() { @@ -988,7 +988,7 @@ implements istack, icachingservice {                 // result without values                 // don't ask value when visualizing trace data, since                 // data not there, , command fail -               fcommandfactory.createmistacklistlocals(framedmc, !ftracevisualization), +               fcommandfactory.createmistacklistlocals(framedmc, false),                 new datarequestmonitor<mistacklistlocalsinfo>(getexecutor(), countingrm) {                     @override                     protected void handlesuccess() { 

there other cases cdt issue requests make gdb spit out full recursive data structure, if have variable selected in variables view or if hover it. you'll notice full expanded value in "details" section. if don't have variable selected step, steps quickly.

the possible fix in gdb not make output pretty printed data structures recursively. hack example limits them 1 level of children:

diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 66929bf..b213699 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -700,7 +700,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,    /* print section */    print_result = print_string_repr (printer.get (), hint.get (), stream,                     recurse, options, language, gdbarch); -  if (print_result != string_repr_error) +  if (print_result != string_repr_error && recurse == 0)      print_children (printer.get (), hint.get (), stream, recurse, options,             language, print_result == string_repr_none); 

a contribution upstream gdb considered recursion limit setting reasonnable value.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -