aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-06-09 15:20:09 -0600
committerTom Tromey <tom@tromey.com>2016-07-12 13:56:07 -0600
commite0f3fd7c44cebec7d787893b9c800e7de509cb32 (patch)
tree482011f3bd7e241f048825d653d56f2ab45a4cd5 /gdb/python
parentcf143069f39b4feeeca175f88b6d1a5c1cb0fee4 (diff)
downloadbinutils-e0f3fd7c44cebec7d787893b9c800e7de509cb32.zip
binutils-e0f3fd7c44cebec7d787893b9c800e7de509cb32.tar.gz
binutils-e0f3fd7c44cebec7d787893b9c800e7de509cb32.tar.bz2
PR python/19293 - invalidate frame cache when unwinders change
PR python/19293 notes that when a Python unwinder is disabled, the frame cache is not invalidated. This means that disabling an unwinder doesn't have any immediate effect -- but in my experience it's often the case that I want to enable or disable an unwinder in order to see what happens. This patch adds a new gdb.invalidate_cached_frames function and arranges for the relevant bits of library code to call it. I've only partially documented this function, considering a warning sufficient without going into all the reasons ordinary code should not call it. The name of the new function was taken from a comment in frame.h next to reinit_frame_cache. No new test as I think the updates to the existing test are sufficient to show that the code is working as intended. Built and regtested on x86-64 Fedora 23. 2016-07-12 Tom Tromey <tom@tromey.com> PR python/19293: * python/lib/gdb/command/unwinders.py (do_enable_unwinder): Call gdb.invalidate_cached_frames. * python/lib/gdb/unwinder.py (register_unwinder): Call gdb.invalidate_cached_frames. * python/python.c (gdbpy_invalidate_cached_frames): New function. (python_GdbMethods): Add entry for invalidate_cached_frames. 2016-07-12 Tom Tromey <tom@tromey.com> PR python/19293: * python.texi (Frames In Python): Document gdb.invalidate_cached_frames. 2016-07-12 Tom Tromey <tom@tromey.com> PR python/19293: * gdb.python/py-unwind-maint.exp: Update tests.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/lib/gdb/command/unwinders.py2
-rw-r--r--gdb/python/lib/gdb/unwinder.py1
-rw-r--r--gdb/python/python.c15
3 files changed, 18 insertions, 0 deletions
diff --git a/gdb/python/lib/gdb/command/unwinders.py b/gdb/python/lib/gdb/command/unwinders.py
index a9b9d8a..8fd0136 100644
--- a/gdb/python/lib/gdb/command/unwinders.py
+++ b/gdb/python/lib/gdb/command/unwinders.py
@@ -136,6 +136,8 @@ def do_enable_unwinder(arg, flag):
if locus_re.match(objfile.filename):
total += do_enable_unwinder1(objfile.frame_unwinders, name_re,
flag)
+ if total > 0:
+ gdb.invalidate_cached_frames()
print("%d unwinder%s %s" % (total, "" if total == 1 else "s",
"enabled" if flag else "disabled"))
diff --git a/gdb/python/lib/gdb/unwinder.py b/gdb/python/lib/gdb/unwinder.py
index 14b2758..67a37cb 100644
--- a/gdb/python/lib/gdb/unwinder.py
+++ b/gdb/python/lib/gdb/unwinder.py
@@ -92,3 +92,4 @@ def register_unwinder(locus, unwinder, replace=False):
unwinder.name)
i += 1
locus.frame_unwinders.insert(0, unwinder)
+ gdb.invalidate_cached_frames()
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 3a272a9..621e201 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -885,6 +885,15 @@ gdbpy_find_pc_line (PyObject *self, PyObject *args)
return result;
}
+/* Implementation of gdb.invalidate_cached_frames. */
+
+static PyObject *
+gdbpy_invalidate_cached_frames (PyObject *self, PyObject *args)
+{
+ reinit_frame_cache ();
+ Py_RETURN_NONE;
+}
+
/* Read a file as Python code.
This is the extension_language_script_ops.script_sourcer "method".
FILE is the file to load. FILENAME is name of the file FILE.
@@ -2071,6 +2080,12 @@ Return the selected inferior object." },
{ "inferiors", gdbpy_inferiors, METH_NOARGS,
"inferiors () -> (gdb.Inferior, ...).\n\
Return a tuple containing all inferiors." },
+
+ { "invalidate_cached_frames", gdbpy_invalidate_cached_frames, METH_NOARGS,
+ "invalidate_cached_frames () -> None.\n\
+Invalidate any cached frame objects in gdb.\n\
+Intended for internal use only." },
+
{NULL, NULL, 0, NULL}
};