From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 5841B3858D37 for ; Tue, 14 Mar 2023 13:28:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5841B3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6CCF721B39; Tue, 14 Mar 2023 13:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678800532; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VC7zOc1ZJc8cTlM+OaxcSk9YXQJQG/CUQGlgF/NCVEA=; b=nFOIuFUyc+a18W3eJboPx+w9D91G7ylMEVJYbK7bxG2T2+Z5Ga9awEXDeCiGlhDUq+qUE6 kwjs2rMn3KZmawoDovG3hyGQgGRbrdVbJG36NwB/oj9GPBSC/FiwQ40l+w+uJqWXcxlvzc brNaDYbWz5HrWYa5gzrTSsEJ/3Kmi/8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678800532; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VC7zOc1ZJc8cTlM+OaxcSk9YXQJQG/CUQGlgF/NCVEA=; b=hfpU5ujHPBYhxWNyKLE4x1eEPStiwFuihycb0y31NVsMGruRwzrbin8lMtnbRxtinUUGk9 nl/Ewt0WTSZ9JqBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 58B6913A1B; Tue, 14 Mar 2023 13:28:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 7KSAFJR2EGRheQAAMHmgww (envelope-from ); Tue, 14 Mar 2023 13:28:52 +0000 Message-ID: <6bd32147-5a69-46a5-681b-4eb705ed9d05@suse.de> Date: Tue, 14 Mar 2023 14:28:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] Fix DAP stackTrace through frames without debuginfo To: Tom Tromey Cc: Tom Tromey via Gdb-patches References: <20230215194847.3805619-1-tromey@adacore.com> <874jqx7vux.fsf@tromey.com> <87fsaenfj9.fsf@tromey.com> <1c5fbdb3-4307-eba8-9976-673a11655bee@suse.de> <87356dojbh.fsf@tromey.com> <873567lbtw.fsf@tromey.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <873567lbtw.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 3/14/23 14:08, Tom Tromey wrote: > Tom> Sorry, yet another error. > > Could you try this one instead? > This fixes the failure for me, and I've tested both gdb.dap test-cases, so ... Tested-by: Tom de Vries Thanks, - Tom > Tom > > commit 28705d727f9c90a77a8b7f78b60ac97f010abf48 > Author: Tom Tromey > Date: Tue Mar 14 07:05:13 2023 -0600 > > Fix DAP frame bug with older versions of Python > > Tom de Vries pointed out that one DAP test failed on Python 3.6 > because gdb.Frame is not hashable. > > This patch fixes the problem by using a list to hold the frames. This > is less efficient but there normally won't be that many frames. > > diff --git a/gdb/python/lib/gdb/dap/frames.py b/gdb/python/lib/gdb/dap/frames.py > index 337bbedae0f..08209d0b361 100644 > --- a/gdb/python/lib/gdb/dap/frames.py > +++ b/gdb/python/lib/gdb/dap/frames.py > @@ -18,20 +18,17 @@ import gdb > from .startup import in_gdb_thread > > > -# Map from frame (thread,level) pair to frame ID numbers. Note we > -# can't use the frame itself here as it is not hashable. > -_frame_ids = {} > - > -# Map from frame ID number back to frames. > -_id_to_frame = {} > +# A list of all the frames we've reported. A frame's index in the > +# list is its ID. We don't use a hash here because frames are not > +# hashable. > +_all_frames = [] > > > # Clear all the frame IDs. > @in_gdb_thread > def _clear_frame_ids(evt): > - global _frame_ids, _id_to_frame > - _frame_ids = {} > - _id_to_frame = {} > + global _all_frames > + _all_frames = [] > > > # Clear the frame ID map whenever the inferior runs. > @@ -41,17 +38,17 @@ gdb.events.cont.connect(_clear_frame_ids) > @in_gdb_thread > def frame_id(frame): > """Return the frame identifier for FRAME.""" > - global _frame_ids, _id_to_frame > - pair = (gdb.selected_thread().global_num, frame.level) > - if pair not in _frame_ids: > - id = len(_frame_ids) > - _frame_ids[pair] = id > - _id_to_frame[id] = frame > - return _frame_ids[pair] > + global _all_frames > + for i in range(0, len(_all_frames)): > + if _all_frames[i] == frame: > + return i > + result = len(_all_frames) > + _all_frames.append(frame) > + return result > > > @in_gdb_thread > def frame_for_id(id): > """Given a frame identifier ID, return the corresponding frame.""" > - global _id_to_frame > - return _id_to_frame[id] > + global _all_frames > + return _all_frames[id]