From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 9768639450EC for ; Tue, 10 Mar 2020 14:08:29 +0000 (GMT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 842CCAEA7 for ; Tue, 10 Mar 2020 14:08:28 +0000 (UTC) Date: Tue, 10 Mar 2020 15:08:26 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb] Fix segv in "maint print symbols" for ada exec Message-ID: <20200310140825.GA20400@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2020 14:08:32 -0000 Hi, When using the executable from test-case gdb.ada/access_to_packed_array.exp (read-in using -readnow) and printing the symbols using "maint print symbols", we run into a segv: ... $ gdb -readnow -batch access_to_packed_array/foo -ex "maint print symbols" ... info: array (<>) of character; computed at runtime ptr: range 0 .. 2147483647; computed at runtime Aborted (core dumped) ... What happens is that dwarf2_evaluate_property gets called and sets the local frame variable to the current frame, which happens to be NULL. Subsequently the PROP_LOCLIST handling code is executed, where get_frame_address_in_block gets called with argument NULL, and the segv is triggered. Fix this by handling a NULL frame in the PROP_LOCLIST handling code in dwarf2_evaluate_property. Build and reg-tested on x86_64-linux. OK for trunk? Thanks, - Tom [gdb] Fix segv in "maint print symbols" for ada exec gdb/ChangeLog: 2020-03-10 Tom de Vries * dwarf2/loc.c (dwarf2_evaluate_property): Handle NULL frame in PROP_LOCLIST handling code. gdb/testsuite/ChangeLog: 2020-03-10 Tom de Vries * gdb.ada/access_to_packed_array.exp: Test printing of expanded symtabs. --- gdb/dwarf2/loc.c | 6 +++++- gdb/testsuite/gdb.ada/access_to_packed_array.exp | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index a5074da8bf..5155cff60d 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -2511,11 +2511,15 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, { struct dwarf2_property_baton *baton = (struct dwarf2_property_baton *) prop->data.baton; - CORE_ADDR pc = get_frame_address_in_block (frame); + CORE_ADDR pc; const gdb_byte *data; struct value *val; size_t size; + if (frame == NULL + || !get_frame_address_in_block_if_available (frame, &pc)) + return false; + data = dwarf2_find_location_expression (&baton->loclist, &size, pc); if (data != NULL) { diff --git a/gdb/testsuite/gdb.ada/access_to_packed_array.exp b/gdb/testsuite/gdb.ada/access_to_packed_array.exp index 61ad230ec0..a2a80a1659 100644 --- a/gdb/testsuite/gdb.ada/access_to_packed_array.exp +++ b/gdb/testsuite/gdb.ada/access_to_packed_array.exp @@ -22,6 +22,12 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } } clean_restart ${testfile} +gdb_test_no_output "maint expand-symtabs" +gdb_test "set logging redirect on" +gdb_test "set logging on" +gdb_test "maint print symbols" +gdb_test "set logging off" +file delete gdb.txt set bp_location [gdb_get_line_number "BREAK" ${testdir}/foo.adb] runto "foo.adb:$bp_location"