diff options
author | Tom Tromey <tom@tromey.com> | 2016-10-31 11:10:35 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2016-11-08 09:10:57 -0700 |
commit | 30a7bb833cbd848b1814f18b91dfdafba4e86839 (patch) | |
tree | 50efadf7d1b250680cf09cbfd1783580f9cd9cd5 /gdb/testsuite/gdb.python | |
parent | e8b24d9ff5b9419fc079f5fe975fac6f499f8bfb (diff) |
Fix some error-handling bugs in python frame filters
While writing a Python frame filter, I found a few bugs in the current
frame filter code. In particular:
* One spot converts a Python long to a CORE_ADDR using PyLong_AsLong.
However, this can fail on overflow. I changed this to use
get_addr_from_python.
* Another spot is doing the same but with PyLong_AsUnsignedLongLong; I
changed this as well just for consistency.
* Converting line numbers can print "-1" if conversion from long
fails. This isn't fatal but just a bit ugly.
I've included a test case for the first issue. The line number one
didn't seem important enough to bother with.
2016-11-08 Tom Tromey <tom@tromey.com>
* python/py-framefilter.c (py_print_frame): Use
get_addr_from_python. Check for errors when getting line number.
2016-11-08 Tom Tromey <tom@tromey.com>
* gdb.python/py-framefilter.py (ElidingFrameDecorator.address):
New method.
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r-- | gdb/testsuite/gdb.python/py-framefilter.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-framefilter.py b/gdb/testsuite/gdb.python/py-framefilter.py index 8fdff84990..25809114c4 100644 --- a/gdb/testsuite/gdb.python/py-framefilter.py +++ b/gdb/testsuite/gdb.python/py-framefilter.py @@ -92,6 +92,12 @@ class ElidingFrameDecorator(FrameDecorator): def elided(self): return iter(self.elided_frames) + def address (self): + # Regression test for an overflow in the python layer. + bitsize = 8 * gdb.lookup_type('void').pointer().sizeof + mask = (1 << bitsize) - 1 + return 0xffffffffffffffff & mask + class ElidingIterator: def __init__(self, ii): self.input_iterator = ii |