What we did for this is along the lines Daniel suggested. When we
find multiple matches to a breakpoint, we return "matches", and then
a list of matches, something like:
^done,matches={b={index="0",canonical="-[NSException
raise]",binary="/
System/Library/Frameworks/Foundation.framework/Versions/C/
Foundation",line="0",addr="0x9294d008"},b=
{index="1",canonical="raise",binary="/usr/lib/
libSystem.B.dylib",line="0",addr="0x9012f940"}}
Then you have to provide some way for the UI to turn around and set
the breakpoints it wants to set. You aren't really guaranteed that
the UI will know how to cons up a breakpoint expression that will
return the breakpoint you want. We tried using the canonical form,
and with that and the shared library you could do it mostly, except
if we start doing things like template breakpoints. So we added a -l
option to -break-insert that takes a list of the indices and sets the
breakpoints for that list.
It might have been cleaner to tie the list to the original -break-
insert command, like having -break-insert pass back a cookie along
with the matches, and then do:
-break-confirm <cookie> <list>
But I wanted to keep it stateless to make the implementation in gdb
simpler. So the UI just sends the -break-insert twice, the second
time with the list. You can also send "-1" for the list, and we will
automatically accept all the breakpoints.