Patch: implement new dynamic varobj spec

Vladimir Prus vladimir@codesourcery.com
Wed Sep 16 05:39:00 GMT 2009


Nick Roberts wrote:

>  > Nick> 2) If is_map is true, rather than:
>  > [...]
>  > Nick> I would prefer GDB to output:
>  > Nick>   var1.0       = "map_element"
>  > Nick>   var1.0.key   = key0
>  > Nick>   var1.0.value = value0
>  > 
>  > Nick> That way the values could be displayed as a tree:
>  > 
>  > I considered this back at the start.  The problem with doing this is
>  > that the key need not be a scalar.  It could be a struct or some other
>  > complicated varobj with children.
> 
> It's probably unusual for the key to be a structure 

Rather, it's very typical in C++. std::map<std::string, whatever> is used
all over.

> but that wouldn't be a 
> problem and it in could be expanded in turn.  Something like (I'm not a C++
> programmer and maybe values would need some kind of comparator to be defined):
> 
>    struct values
>    {
>      int a;
>      float b;
>    };
> 
>   map<values*, string> m1;
> 
>   struct values val = {a : 5, b : 7.5};
>   struct values *v;
>   *v = val;
>   
>   m1[v] = "a string";
> 
> 
> -var-create - * m1
> -var-list-children -var1
> 
>    var1.0       = "map_element"
>    var1.0.key   = key0
>    var1.0.key.a = 5
>    var1.0.key.b = 7.5
>    var1.0.value = "a string"

What if 'values' wishes to have a field named 'key'? 

- Volodya




More information about the Gdb-patches mailing list