GNU Binutils with patches for OS216
Revisión | e0f3fd7c44cebec7d787893b9c800e7de509cb32 (tree) |
---|---|
Tiempo | 2016-07-13 04:56:07 |
Autor | Tom Tromey <tom@trom...> |
Commiter | Tom Tromey |
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.
@@ -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 | + | |
1 | 11 | 2016-07-07 Walfred Tedeschi <walfred.tedeschi@intel.com> |
2 | 12 | |
3 | 13 | * cp-namespace.c (cp_lookup_bare_symbol): Initialize |
@@ -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 | + | |
1 | 7 | 2016-06-21 Pedro Alves <palves@redhat.com> |
2 | 8 | |
3 | 9 | * gdb.texinfo (Interpreters): Update intepreter-exec section, |
@@ -3838,6 +3838,15 @@ frames, as expressed by the given @var{reason} code (an integer, see the | ||
3838 | 3838 | @code{unwind_stop_reason} method further down in this section). |
3839 | 3839 | @end defun |
3840 | 3840 | |
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 | + | |
3841 | 3850 | A @code{gdb.Frame} object has the following methods: |
3842 | 3851 | |
3843 | 3852 | @defun Frame.is_valid () |
@@ -136,6 +136,8 @@ def do_enable_unwinder(arg, flag): | ||
136 | 136 | if locus_re.match(objfile.filename): |
137 | 137 | total += do_enable_unwinder1(objfile.frame_unwinders, name_re, |
138 | 138 | flag) |
139 | + if total > 0: | |
140 | + gdb.invalidate_cached_frames() | |
139 | 141 | print("%d unwinder%s %s" % (total, "" if total == 1 else "s", |
140 | 142 | "enabled" if flag else "disabled")) |
141 | 143 |
@@ -92,3 +92,4 @@ def register_unwinder(locus, unwinder, replace=False): | ||
92 | 92 | unwinder.name) |
93 | 93 | i += 1 |
94 | 94 | locus.frame_unwinders.insert(0, unwinder) |
95 | + gdb.invalidate_cached_frames() |
@@ -885,6 +885,15 @@ gdbpy_find_pc_line (PyObject *self, PyObject *args) | ||
885 | 885 | return result; |
886 | 886 | } |
887 | 887 | |
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 | + | |
888 | 897 | /* Read a file as Python code. |
889 | 898 | This is the extension_language_script_ops.script_sourcer "method". |
890 | 899 | FILE is the file to load. FILENAME is name of the file FILE. |
@@ -2071,6 +2080,12 @@ Return the selected inferior object." }, | ||
2071 | 2080 | { "inferiors", gdbpy_inferiors, METH_NOARGS, |
2072 | 2081 | "inferiors () -> (gdb.Inferior, ...).\n\ |
2073 | 2082 | 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 | + | |
2074 | 2089 | {NULL, NULL, 0, NULL} |
2075 | 2090 | }; |
2076 | 2091 |
@@ -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 | + | |
1 | 6 | 2016-07-12 Yao Qi <yao.qi@linaro.org> |
2 | 7 | |
3 | 8 | * lib/selftest-support.exp (selftest_setup): Match the output |
@@ -34,7 +34,11 @@ if ![runto_main ] then { | ||
34 | 34 | return -1 |
35 | 35 | } |
36 | 36 | |
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 | +} | |
38 | 42 | |
39 | 43 | gdb_test_sequence "info unwinder" "Show all unwinders" { |
40 | 44 | "Global:" |
@@ -50,7 +54,10 @@ gdb_test_sequence "continue" "Unwinders called" { | ||
50 | 54 | "global_unwinder called" |
51 | 55 | } |
52 | 56 | |
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 | +} | |
54 | 61 | |
55 | 62 | gdb_test_sequence "info unwinder" "Show with global unwinder disabled" { |
56 | 63 | "Global:" |