From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7833) id 0242F3858429; Thu, 11 Aug 2022 14:17:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0242F3858429 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Lancelot SIX To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/varobj: Only re-evaluate invalid globals during re_set X-Act-Checkin: binutils-gdb X-Git-Author: Lancelot SIX X-Git-Refname: refs/heads/master X-Git-Oldrev: ccb5e559ef13f1c7a32312199f7887b463c56216 X-Git-Newrev: 906dca17d429f468d49a6cc4753993581c51a899 Message-Id: <20220811141730.0242F3858429@sourceware.org> Date: Thu, 11 Aug 2022 14:17:30 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2022 14:17:30 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D906dca17d429= f468d49a6cc4753993581c51a899 commit 906dca17d429f468d49a6cc4753993581c51a899 Author: Lancelot SIX Date: Wed Aug 10 22:23:29 2022 +0100 gdb/varobj: Only re-evaluate invalid globals during re_set =20 When doing varobj_re_set, we currently try to recreate floating varobj. This was introduced by 4e969b4f0128 "Re-evaluate floating varobj as part of varobj_invalidate" to deal with use a after free issue. However since bc20e562ec0 "Fix use after free in varobj" we now ensure that we never have dangling pointers so this all recreation is not strictly needed anymore for floating varobjs. =20 This commit proposes to remove this recreation process for floating varobjs. =20 Tested on x86_64-linux. Diff: --- gdb/testsuite/gdb.mi/mi-var-invalidate.exp | 4 ++-- gdb/varobj.c | 18 +++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp b/gdb/testsuite/gdb= .mi/mi-var-invalidate.exp index 1b2c68df18e..348515671c1 100644 --- a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp +++ b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp @@ -75,8 +75,8 @@ mi_runto_main # Change format of floating variable immediately after reload reveals a # bug where gdb still uses a free'd pointer. mi_gdb_test "-var-set-format float_simple hexadecimal" \ - "\\^done,format=3D\"hexadecimal\",value=3D\"\\\[-1\\\]\"" \ - "set format variable float_simple" + "\\^done,format=3D\"hexadecimal\",value=3D\"\\\[3\\\]\"" \ + "set format variable float_simple" =20 # Check local variable is "invalid". mi_gdb_test "-var-update linteger" \ diff --git a/gdb/varobj.c b/gdb/varobj.c index 55a7bd97f43..d3df608c55f 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -2359,29 +2359,21 @@ all_root_varobjs (gdb::function_view func) static void varobj_re_set_iter (struct varobj *var) { - /* Invalidated globals and floating var must be re-evaluated. */ - if (var->root->global || var->root->floating) + /* Invalidated global varobjs must be re-evaluated. */ + if (!var->root->is_valid && var->root->global) { struct varobj *tmp_var; =20 /* Try to create a varobj with same expression. If we succeed - replace the old varobj, otherwise invalidate it. */ + and have a global replace the old varobj. */ tmp_var =3D varobj_create (nullptr, var->name.c_str (), (CORE_ADDR) = 0, - var->root->floating - ? USE_SELECTED_FRAME : USE_CURRENT_FRAME); - if (tmp_var !=3D nullptr) + USE_CURRENT_FRAME); + if (tmp_var !=3D nullptr && tmp_var->root->global) { - gdb_assert (var->root->floating =3D=3D tmp_var->root->floating); tmp_var->obj_name =3D var->obj_name; varobj_delete (var, 0); install_variable (tmp_var); } - else if (var->root->global) - { - /* Only invalidate globals as floating vars might still be valid in - some other frame. */ - var->root->is_valid =3D false; - } } }