• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修訂30a7bb833cbd848b1814f18b91dfdafba4e86839 (tree)
時間2016-11-09 01:10:57
作者Tom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

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

  1. 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.

Change Summary

差異

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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+
16 2016-11-08 Yao Qi <yao.qi@linaro.org>
27
38 * ada-lang.h (ada_val_print): Remove second parameter. Remove
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -1116,7 +1116,13 @@ py_print_frame (PyObject *filter, int flags,
11161116
11171117 if (paddr != Py_None)
11181118 {
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+
11201126 has_addr = 1;
11211127 }
11221128 Py_DECREF (paddr);
@@ -1213,10 +1219,10 @@ py_print_frame (PyObject *filter, int flags,
12131219 }
12141220 else if (PyLong_Check (py_func))
12151221 {
1216- CORE_ADDR addr = PyLong_AsUnsignedLongLong (py_func);
1222+ CORE_ADDR addr;
12171223 struct bound_minimal_symbol msymbol;
12181224
1219- if (PyErr_Occurred ())
1225+ if (get_addr_from_python (py_func, &addr) < 0)
12201226 {
12211227 do_cleanups (cleanup_stack);
12221228 return EXT_LANG_BT_ERROR;
@@ -1340,6 +1346,12 @@ py_print_frame (PyObject *filter, int flags,
13401346 if (py_line != Py_None)
13411347 {
13421348 line = PyLong_AsLong (py_line);
1349+ if (PyErr_Occurred ())
1350+ {
1351+ do_cleanups (cleanup_stack);
1352+ return EXT_LANG_BT_ERROR;
1353+ }
1354+
13431355 TRY
13441356 {
13451357 ui_out_text (out, ":");
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -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+
16 2016-10-29 Manish Goregaokar <manish@mozilla.com>
27
38 * gdb.rust/simple.exp: Add tests for `sizeof(expr)`
--- a/gdb/testsuite/gdb.python/py-framefilter.py
+++ b/gdb/testsuite/gdb.python/py-framefilter.py
@@ -92,6 +92,12 @@ class ElidingFrameDecorator(FrameDecorator):
9292 def elided(self):
9393 return iter(self.elided_frames)
9494
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+
95101 class ElidingIterator:
96102 def __init__(self, ii):
97103 self.input_iterator = ii