This is the mail archive of the gdb-prs@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]

[Bug python/11688] wrap MI commands in python


http://sourceware.org/bugzilla/show_bug.cgi?id=11688

--- Comment #6 from matt rice <ratmice at gmail dot com> 2012-01-06 22:14:29 UTC ---
Created attachment 6151
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6151
2nd implementation of ui-out for python

here's the ui-out portion from my latest attempt at this separated from the
mi_execute stuff,  I'm not entirely pleased with the python objects this
creates, as it does not always return consistent types.

break-list is a nice easy way to hit all of the edge cases where ui-out does
this.

# first it returns None... for no breakpoints
gdb.mi_execute("break-list", None)['body'] == None
gdb.mi_execute("break-insert", ("main"))
# then it returns a dictionary
gdb.mi_execute("break-list", None)['body']['bkpt']['number']
gdb.mi_execute("break-insert", ("main"))
# now its been promoted to a list as there are 2 breakpoints.
gdb.mi_execute("break-list", None)['body']['bkpt'][-1]['number']

thus i am hesitant to think it returns objects of acceptable quality, unless
used in a fashion which doesn't hit these edge cases.

It does seem possible that we might be able to rid ourselves of these
by expanding the existing ui_out_type,

enum ui_out_type
  {
    ui_out_type_tuple,
    ui_out_type_list
  };

the necessary additions would be something along the lines of:
ui_out_type_tuple_with_duplicate_keys
ui_out_type_deprecated_tuple_list
ui_out_type_deprecated_tuple_list_with_duplicate_keys

(duplicate keys are the cause of object->array promotion,
and empty lists/tuples are the cause of None.)

that would also mean updating all callers, which seems like quite the endeavor.

Other than that the code still needs lots of error handling, but alas I don't
really want to finish that if the type schizophrenia means its a dead end.

all of this does make me think that a 'py-mi-version' independent of mi-version
for the return values might be warranted.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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