This is the mail archive of the gdb-patches@sources.redhat.com 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]

rbreak works poorly with ObjC methods


Hey gdb'ers,

rbreak_command gets a list of functions matching a regular expression,
then caonicalizes those into filename:function-name and sets
breakpoints on the canonicalized form.  For an Objective-C method
that takes an argument, this form sent to break_command will be
something like
   basicclass.m:'+[BasicClass newWithArg:]'

The filename is separated out by linespec.c:locate_first_half().
locate_first_half will correctly handle filename.m:+[classname
arg:] type arguments, but it cannot cope when the apostrophy is
added and there is a second ":" after the filename-function name
separator.

Unfortunately this can be fixed in several ways. :-)  I believe
the best is to change the way rbreak_command canonicalizes its
arguments to be in the form
   "basicclass.m:+[BasicClass newWithArg:]"

An example patch of this is attached.

Another way to fix this is to modify linespec.c's is_objc_method_format
to recognize a third ObjC method pattern -- :'-[ ... ] -- in addition
to the two it already does.  This fix seems pretty lame in my
opinion--it's pushing the ObjC method spotter in the direction of
being its own little decode_line_1.  A patch showing how this would look
is also attached to this mail note.

The third way to fix this is to add the smarts to detect filename:' ... '
to locate_first_half() itself.  This has the benefit that
is_objc_method_format is still used to detect the actual objc method
and the smarts about the added apostrphy are pushed up to this function.
An example of this approach is also attached.  (Ignore the APPLE LOCAL
markers - this just happens to be the first one I tried)


I'll also attach a testsuite addition to basicclass.exp that shows the
failure.  It's an annoying one because the rbreak command stops setting
breakpoints as soon as one of them fails, so any regexp that happens to
match an ObjC method name with a colon in it will not complete.

None of these changes introduce any new testsuite regressions on
x86 Linux & gcc 3.3.1 -gdwarf2.


Any opinions about how this is best addressed?  I'm rooting for 
rbreak_command myself.  I can file a GNATS bug to track this if
anyone would prefer.


Jason

Attachment: rbreak_command.txt
Description: Text document

Attachment: is_objc_method_format.txt
Description: Text document

Attachment: loate_first_half.txt
Description: Text document

Attachment: testsuite.txt
Description: Text document


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