GNU Binutils with patches for OS216
修訂 | 30a7bb833cbd848b1814f18b91dfdafba4e86839 (tree) |
---|---|
時間 | 2016-11-09 01:10:57 |
作者 | Tom Tromey <tom@trom...> |
Commiter | Tom Tromey |
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.
* Another spot is doing the same but with PyLong_AsUnsignedLongLong; I
* Converting line numbers can print "-1" if conversion from long
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.
@@ -1,3 +1,8 @@ | ||
1 | +2016-11-08 Tom Tromey <tom@tromey.com> | |
2 | + | |
3 | + * python/py-framefilter.c (py_print_frame): Use | |
4 | + get_addr_from_python. Check for errors when getting line number. | |
5 | + | |
1 | 6 | 2016-11-08 Yao Qi <yao.qi@linaro.org> |
2 | 7 | |
3 | 8 | * ada-lang.h (ada_val_print): Remove second parameter. Remove |
@@ -1116,7 +1116,13 @@ py_print_frame (PyObject *filter, int flags, | ||
1116 | 1116 | |
1117 | 1117 | if (paddr != Py_None) |
1118 | 1118 | { |
1119 | - address = PyLong_AsLong (paddr); | |
1119 | + if (get_addr_from_python (paddr, &address) < 0) | |
1120 | + { | |
1121 | + Py_DECREF (paddr); | |
1122 | + do_cleanups (cleanup_stack); | |
1123 | + return EXT_LANG_BT_ERROR; | |
1124 | + } | |
1125 | + | |
1120 | 1126 | has_addr = 1; |
1121 | 1127 | } |
1122 | 1128 | Py_DECREF (paddr); |
@@ -1213,10 +1219,10 @@ py_print_frame (PyObject *filter, int flags, | ||
1213 | 1219 | } |
1214 | 1220 | else if (PyLong_Check (py_func)) |
1215 | 1221 | { |
1216 | - CORE_ADDR addr = PyLong_AsUnsignedLongLong (py_func); | |
1222 | + CORE_ADDR addr; | |
1217 | 1223 | struct bound_minimal_symbol msymbol; |
1218 | 1224 | |
1219 | - if (PyErr_Occurred ()) | |
1225 | + if (get_addr_from_python (py_func, &addr) < 0) | |
1220 | 1226 | { |
1221 | 1227 | do_cleanups (cleanup_stack); |
1222 | 1228 | return EXT_LANG_BT_ERROR; |
@@ -1340,6 +1346,12 @@ py_print_frame (PyObject *filter, int flags, | ||
1340 | 1346 | if (py_line != Py_None) |
1341 | 1347 | { |
1342 | 1348 | line = PyLong_AsLong (py_line); |
1349 | + if (PyErr_Occurred ()) | |
1350 | + { | |
1351 | + do_cleanups (cleanup_stack); | |
1352 | + return EXT_LANG_BT_ERROR; | |
1353 | + } | |
1354 | + | |
1343 | 1355 | TRY |
1344 | 1356 | { |
1345 | 1357 | ui_out_text (out, ":"); |
@@ -1,3 +1,8 @@ | ||
1 | +2016-11-08 Tom Tromey <tom@tromey.com> | |
2 | + | |
3 | + * gdb.python/py-framefilter.py (ElidingFrameDecorator.address): | |
4 | + New method. | |
5 | + | |
1 | 6 | 2016-10-29 Manish Goregaokar <manish@mozilla.com> |
2 | 7 | |
3 | 8 | * gdb.rust/simple.exp: Add tests for `sizeof(expr)` |
@@ -92,6 +92,12 @@ class ElidingFrameDecorator(FrameDecorator): | ||
92 | 92 | def elided(self): |
93 | 93 | return iter(self.elided_frames) |
94 | 94 | |
95 | + def address (self): | |
96 | + # Regression test for an overflow in the python layer. | |
97 | + bitsize = 8 * gdb.lookup_type('void').pointer().sizeof | |
98 | + mask = (1 << bitsize) - 1 | |
99 | + return 0xffffffffffffffff & mask | |
100 | + | |
95 | 101 | class ElidingIterator: |
96 | 102 | def __init__(self, ii): |
97 | 103 | self.input_iterator = ii |