From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123634 invoked by alias); 24 Jun 2016 02:55:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 123595 invoked by uid 89); 24 Jun 2016 02:55:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=findex, @findex, 923, Built X-HELO: gproxy1-pub.mail.unifiedlayer.com Received: from gproxy1-pub.mail.unifiedlayer.com (HELO gproxy1-pub.mail.unifiedlayer.com) (69.89.25.95) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Fri, 24 Jun 2016 02:55:28 +0000 Received: (qmail 29666 invoked by uid 0); 24 Jun 2016 02:55:26 -0000 Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy1.mail.unifiedlayer.com with SMTP; 24 Jun 2016 02:55:26 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id ASvP1t00A2f2jeq01SvS8z; Thu, 23 Jun 2016 20:55:26 -0600 X-Authority-Analysis: v=2.1 cv=KpLehwmN c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=PnD2wP_eR3oA:10 a=7XZj0uCbPdcA:10 a=pD_ry4oyNxEA:10 a=zstS-IiYAAAA:8 a=20KFwNOVAAAA:8 a=EEv4D6HehZUUA0uG_bwA:9 a=4G6NA9xxw8l3yy4pmD5M:22 a=e_O65bzb51kRm2y5VmPK:22 Received: from [75.171.172.174] (port=55280 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1bGHH8-0005Ql-Ui; Thu, 23 Jun 2016 20:55:23 -0600 From: Tom Tromey To: Pedro Alves Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [RFA 3/3] PR python/19293 - invalidate frame cache when unwinders change References: <1465612923-24880-1-git-send-email-tom@tromey.com> <1465612923-24880-4-git-send-email-tom@tromey.com> <40f46408-1830-5929-5bee-fd49398900cf@redhat.com> Date: Fri, 24 Jun 2016 02:55:00 -0000 In-Reply-To: <40f46408-1830-5929-5bee-fd49398900cf@redhat.com> (Pedro Alves's message of "Fri, 17 Jun 2016 20:11:24 +0100") Message-ID: <87twgjuwh4.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.94 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 75.171.172.174 authed with tom+tromey.com} X-Exim-ID: 1bGHH8-0005Ql-Ui X-Source-Sender: (bapiya) [75.171.172.174]:55280 X-Source-Auth: tom+tromey.com X-Email-Count: 0 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-SW-Source: 2016-06/txt/msg00395.txt.bz2 Pedro> Seems reasonable to me. Couple nits below. Here's the updated patch. This still needs doc review. Tom commit dd5cd89e2345325da2361a3a72a11420de01e802 Author: Tom Tromey Date: Thu Jun 9 15:20:09 2016 -0600 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-06-23 Tom Tromey 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-06-23 Tom Tromey PR python/19293: * python.texi (Frames In Python): Document gdb.invalidate_cached_frames. 2016-06-23 Tom Tromey PR python/19293: * gdb.python/py-unwind-maint.exp: Update tests. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1ce5757..ee356bf 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2016-06-23 Tom Tromey + + 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-06-09 Tom Tromey * jit.c (jit_reader_load_command, jit_reader_unload_command): Call diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 3186ff2..3d051d8 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,9 @@ +2016-06-23 Tom Tromey + + PR python/19293: + * python.texi (Frames In Python): Document + gdb.invalidate_cached_frames. + 2016-06-21 Pedro Alves * gdb.texinfo (Interpreters): Update intepreter-exec section, diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 6623d8e..f218ad6 100644 --- 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 @code{unwind_stop_reason} method further down in this section). @end defun +@findex gdb.invalidate_cached_frames +@defun gdb.invalidate_cached_frames +@value{GDBN} internally keeps a cache of the frames that have been +unwound. This function invalidates this cache. + +This function should not generally be called by ordinary Python code. +It is documented for the sake of completeness. +@end defun + A @code{gdb.Frame} object has the following methods: @defun Frame.is_valid () 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} }; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 8b5274d..ad11415 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2016-06-23 Tom Tromey + PR python/19293: + * gdb.python/py-unwind-maint.exp: Update tests. + +2016-06-23 Tom Tromey + PR gdb/16483: * gdb.python/py-framefilter.exp: Add "info frame-filter" test before any filters are loaded. diff --git a/gdb/testsuite/gdb.python/py-unwind-maint.exp b/gdb/testsuite/gdb.python/py-unwind-maint.exp index e89d284..3a98cb1 100644 --- 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 { return -1 } -gdb_test "source ${pyfile}" "Python script imported" "import python scripts" +gdb_test_sequence "source ${pyfile}" "import python scripts" { + "Python script imported" + "py_unwind_maint_ps_unwinder called" + "global_unwinder called" +} gdb_test_sequence "info unwinder" "Show all unwinders" { "Global:" @@ -50,7 +54,10 @@ gdb_test_sequence "continue" "Unwinders called" { "global_unwinder called" } -gdb_test "disable unwinder global .*" "1 unwinder disabled" "Unwinder disabled" +gdb_test_sequence "disable unwinder global .*" "Unwinder disabled" { + "1 unwinder disabled" + "py_unwind_maint_ps_unwinder called" +} gdb_test_sequence "info unwinder" "Show with global unwinder disabled" { "Global:"