PR9681 - gdb lets you set watchpoints on nonexistent struct members

Pedro Alves pedro@codesourcery.com
Wed Dec 31 18:26:00 GMT 2008


PR9681 is about a regression that makes gdb now let you set
watchpoints on nonexistent struct members.

From the report:

 This snapshot of gdb will happily allow you to put watchpoints on structure
 members which don't exist:
   (gdb) watch myfoo.nosuchmember
   Watchpoint 2: myfoo.nosuchmember

This bug was introduced with the support to setting watchpoints
in inaccessible memory, back around February/March:

 http://sourceware.org/ml/gdb-patches/2008-02/msg00472.html

The issue is that the watchpoint command is considering all errors
to be of type inaccessible-memory, due to the usage
of gdb_evaluate_expression.  Prior to that change, we used
evaluate_expression, which did let exceptions probagate.  In this
particular case of a nonexistent member, it's at evaluation time
that the member is found to be non-existent, although but it's at
parse time that we find that myfoo does or not exist, so
'watch mybar' didn't regress.

The root issue here, is that we're interested in letting
watchpoints the evaluate to inaccessible memory to still
succeed in being created.  All other errors should be treated
as real errors.  So, this patch adds a new MEMORY_ERROR exception/error
type --- this way we can more accuratelly filter the error type
we want to ignore.  There may be places throwing a generic error instead
of using memory_error, I didn't do a general audit, but those would
better be fixed anyway.

No regressions on x86_64-linux, new test included.

Ok?

-- 
Pedro Alves
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr9681.diff
Type: text/x-diff
Size: 5249 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20081231/d117994c/attachment.bin>


More information about the Gdb-patches mailing list