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

Fixed C++ overload resolution, added primitive g++ exception support


As the subject says, i have patches to do this.

I implemented primitive g++ exception catch catch and catch throw 
support by breakpointing __start_cp_handler and throw_helper.

In my beos port's exception_callback routine, i then check to see if we 
are in either of these procedures, and if we are, look at the right 
number of frames upwards, and give that as the location of the throw/
catch. (It's about 20 lines of code, max. It's not really specific to beos
at all, it's just using the find_pc_* routines).

Works perfectly, as far as i can tell. I've tested it using multiple
catches, function try blocks, etc.
Unfortunately, there really is no better way to do this with g++ right 
now, as it doesn't have any callbacks or anything (I scoured the 
sources).
It might be work it to interpert the .eh_frame section, but that's more 
work than i care to implement for a gain of not much for me.
It would, however, be trivial to implement catching of unexpected
exceptions as well, if anyone cared.

Of course, this won't work with g++ that isn't using the new exception
handling.
But then, they would have nothing before, so they don't lose anything.
:)

I also fixed C++ overload resolution.
There were two major problems.
In the order i ran into them:

1. gdb wasn't ignoring whitespace when comparing names in 
search_struct_method and search_struct_field.

So it wouldn't ever find operator[], because it was named operator [].

I added a STREQ_IW macro in defs.h that wraps strcmp_iw from utils.c
I replaced the STREQ's in the search_struct_*  with STREQ_IW
Also in check_typedef.

Once this was done, it found the functions fine.
Next up, was 
2. gdb is screwing up the function ranking. Right in the comments it 
says that nargs includes the this pointer in it's count, and nparams 
doesn't, but it doesn't take this into account.  So i made it take it 
into account, and all of the sudden, it could resolve overloads 
properly in most cases.
I can succesfully do a print AnSTLVector.begin() and AnSTLVector[0], 
and if AnSTLVector was a vector of strings, I could do *
(AnSTLVector.begin()).length(), and get the right answer. 
It still can't figure out that it can cast const char * to basic 
string.
I can't tell if this is because i missed a few places i need to make 
the compares ignore whitespace where they aren't, or if it never 
worked.

The patches for all of this are clean, and against 20000110 snapshot.
Anyone interested?
If so, i'll get copyright assignment filled out.


Unfortunately, my patches for the BeOS port itself aren't clean.
I wrote the beos port when gdb wasn't real good at threads (4.17), and 
BeOS's debugger interface wasn't as nice as it is now.  I basically had 
to work around gdb in most cases, rather than work with it (Fer 
instance, I couldn't get cpu registers for a given thread except when 
that thread stopped. So i had to track them on my own. Let me tell you 
how many stacks i've bashed).
Nowadays, it appears GDB has enough thread support for me to report, 
and do it right.  Hopefully, it does.

--Dan


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