• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

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

Revisióne0f3fd7c44cebec7d787893b9c800e7de509cb32 (tree)
Tiempo2016-07-13 04:56:07
AutorTom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

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.

Cambiar Resumen

Diferencia incremental

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
1+2016-07-12 Tom Tromey <tom@tromey.com>
2+
3+ PR python/19293:
4+ * python/lib/gdb/command/unwinders.py (do_enable_unwinder): Call
5+ gdb.invalidate_cached_frames.
6+ * python/lib/gdb/unwinder.py (register_unwinder): Call
7+ gdb.invalidate_cached_frames.
8+ * python/python.c (gdbpy_invalidate_cached_frames): New function.
9+ (python_GdbMethods): Add entry for invalidate_cached_frames.
10+
111 2016-07-07 Walfred Tedeschi <walfred.tedeschi@intel.com>
212
313 * cp-namespace.c (cp_lookup_bare_symbol): Initialize
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,9 @@
1+2016-07-12 Tom Tromey <tom@tromey.com>
2+
3+ PR python/19293:
4+ * python.texi (Frames In Python): Document
5+ gdb.invalidate_cached_frames.
6+
17 2016-06-21 Pedro Alves <palves@redhat.com>
28
39 * gdb.texinfo (Interpreters): Update intepreter-exec section,
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -3838,6 +3838,15 @@ frames, as expressed by the given @var{reason} code (an integer, see the
38383838 @code{unwind_stop_reason} method further down in this section).
38393839 @end defun
38403840
3841+@findex gdb.invalidate_cached_frames
3842+@defun gdb.invalidate_cached_frames
3843+@value{GDBN} internally keeps a cache of the frames that have been
3844+unwound. This function invalidates this cache.
3845+
3846+This function should not generally be called by ordinary Python code.
3847+It is documented for the sake of completeness.
3848+@end defun
3849+
38413850 A @code{gdb.Frame} object has the following methods:
38423851
38433852 @defun Frame.is_valid ()
--- 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):
136136 if locus_re.match(objfile.filename):
137137 total += do_enable_unwinder1(objfile.frame_unwinders, name_re,
138138 flag)
139+ if total > 0:
140+ gdb.invalidate_cached_frames()
139141 print("%d unwinder%s %s" % (total, "" if total == 1 else "s",
140142 "enabled" if flag else "disabled"))
141143
--- 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):
9292 unwinder.name)
9393 i += 1
9494 locus.frame_unwinders.insert(0, unwinder)
95+ gdb.invalidate_cached_frames()
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -885,6 +885,15 @@ gdbpy_find_pc_line (PyObject *self, PyObject *args)
885885 return result;
886886 }
887887
888+/* Implementation of gdb.invalidate_cached_frames. */
889+
890+static PyObject *
891+gdbpy_invalidate_cached_frames (PyObject *self, PyObject *args)
892+{
893+ reinit_frame_cache ();
894+ Py_RETURN_NONE;
895+}
896+
888897 /* Read a file as Python code.
889898 This is the extension_language_script_ops.script_sourcer "method".
890899 FILE is the file to load. FILENAME is name of the file FILE.
@@ -2071,6 +2080,12 @@ Return the selected inferior object." },
20712080 { "inferiors", gdbpy_inferiors, METH_NOARGS,
20722081 "inferiors () -> (gdb.Inferior, ...).\n\
20732082 Return a tuple containing all inferiors." },
2083+
2084+ { "invalidate_cached_frames", gdbpy_invalidate_cached_frames, METH_NOARGS,
2085+ "invalidate_cached_frames () -> None.\n\
2086+Invalidate any cached frame objects in gdb.\n\
2087+Intended for internal use only." },
2088+
20742089 {NULL, NULL, 0, NULL}
20752090 };
20762091
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
1+2016-07-12 Tom Tromey <tom@tromey.com>
2+
3+ PR python/19293:
4+ * gdb.python/py-unwind-maint.exp: Update tests.
5+
16 2016-07-12 Yao Qi <yao.qi@linaro.org>
27
38 * lib/selftest-support.exp (selftest_setup): Match the output
--- a/gdb/testsuite/gdb.python/py-unwind-maint.exp
+++ b/gdb/testsuite/gdb.python/py-unwind-maint.exp
@@ -34,7 +34,11 @@ if ![runto_main ] then {
3434 return -1
3535 }
3636
37-gdb_test "source ${pyfile}" "Python script imported" "import python scripts"
37+gdb_test_sequence "source ${pyfile}" "import python scripts" {
38+ "Python script imported"
39+ "py_unwind_maint_ps_unwinder called"
40+ "global_unwinder called"
41+}
3842
3943 gdb_test_sequence "info unwinder" "Show all unwinders" {
4044 "Global:"
@@ -50,7 +54,10 @@ gdb_test_sequence "continue" "Unwinders called" {
5054 "global_unwinder called"
5155 }
5256
53-gdb_test "disable unwinder global .*" "1 unwinder disabled" "Unwinder disabled"
57+gdb_test_sequence "disable unwinder global .*" "Unwinder disabled" {
58+ "1 unwinder disabled"
59+ "py_unwind_maint_ps_unwinder called"
60+}
5461
5562 gdb_test_sequence "info unwinder" "Show with global unwinder disabled" {
5663 "Global:"