This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: asynchronous MI output commands


On Thursday 11 May 2006 14:55, Bob Rossi wrote:

> > > >     const GDBMI::Value& children = r["children"];
> > > >
> > > >     for (unsigned i = 0; i < children.size(); ++i)
> > > >     {
> > > >         QString exp = children[i]["exp"].literal();
> > > >
> > > >
> > > > If you have specific structures for each response this won't be very
> > > > much simpler.
> > >
> > > Sorry, I've described this before, but apparently not good enough. I
> > > definatly can create the abstract parse tree with out knowing the input
> > > command. However, then I want to create C data structures for each
> > > MI output.
> >
> > Why? With C data structures, the above frontend code will be only
> > marginally simpler.
>
> I don't believe that to be the case at all. Look at the C data structure
> code I have for the -break-list data structure. If a GUI had to use this I
> think they would be happy.

So, instead of say:

    bp["number"].toInt()

I'd write:

    bp.number

? Well, that's what I call "marginally better". It's better, but not likely to 
make big practical difference.

Also, you propose C interface, so is not directly usable in frontend written 
in C++. Such frontend will likely to have it's own class for breakpoint, and 
would have to convert from your structure to that class.

I guess if you want to make MI parser for your own use, any approach is fine. 
But if you want to make some kind of "standard" MI parser for other frontends 
to use, I'm not sure that providing such pre-made structures will be a 
selling point.

> Look at what I had to do to get the breakpoint structure populated. I
> don't consider this even close to the same complexity as above. 

What do you mean as "above" and why having more complex code is a good thing? 

> I do 
> know that I have some code duplicated that could be in a function, and
> some other cleanups, but I still think it's far more difficult.

I think the code you've presented indeed has too much copy-paste. For example:

 			else if (strcmp (result_ptr->variable, "addr") == 0)
 			{
 			  if (result_ptr->value->value_choice == GDBMI_CSTRING)
 			  {
 			    if (convert_cstring (result_ptr->value->option.cstring,
                      &ptr->address) == -1) 
                  {
 			      fprintf (stderr, "%s:%d\n", __FILE__, __LINE__);
 			      return -1;
 			    }
 			  }
 			}

is a pattern that repeats for many of fields. While in my interface, you'd 
call:

   bp["addr"].literal()

to get exactly same effect. Except that in your code, no error is emitted when 
"addr" field is not of string type ;-)

Maybe if you provide functions  'get_literal' and 'get_integer' and 
'get_bool_yn', the size of code can be reduced considerably.

- Volodya


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]