From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 1EC983858D37 for ; Tue, 14 Mar 2023 13:08:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EC983858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x12f.google.com with SMTP id a13so2208880ilr.9 for ; Tue, 14 Mar 2023 06:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1678799324; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=zAQxJ3jouuye2vKcFZ3tWFIuJqY6ZhWyQO4fn18iN6Y=; b=N49Z8/vTi1ppPkjV/DP+SserAvFgJYVVoInDAooI3WlxArNI8OCjQbXDt73ninVW/X nEPoo16FOV7s3IJgLzXtrF7QWBwHXSMJ40oFY55c10/Itq0MCG2fNxbAde7rq/OtfMpM fVxKkfJ+2XtoILgTQ3MNo3D7c8RmjHcHxgGnbSbtjjKp1EzeoPb49n5jwQ+nH0RTmzqm UVkm0F5vPD4p5iiWQx5XdJuVHTa16/W/WXaY6P8ahP5zoCnzp1c9sl//stLtw7M6wey5 rosM7jk+YMxYLM9HejLhP/yXKMpkJ8HmA+7KYWBwWX+qf6OsfoIWTjSrsaUyxN/n+XF+ joPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678799324; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zAQxJ3jouuye2vKcFZ3tWFIuJqY6ZhWyQO4fn18iN6Y=; b=LjWkwoQN0QXMtHW0yio/5fC//slZ8DLF9NkN/xUzjKnDoII9SUT9XIR7Ux6r81QIfm G3C6fGjFMuMxlayN2ieV78afwkd4xUbk4yXHkFyKHA5iHkcnGrNwZf/2fhPi4BMUu683 IpOBcKsSdOGMIH3zTin2/wmmIVNXlNIvWX5vMPQuadx5Hda97Tbay5bbtKA1+yacfVVX eLHU/7ep95Lu/iTDMYmyGW6OICi9LHIwwJk74/3Gd/pvgsgdOiEU9tCc6fKINgTo6KYJ SYnbweLok3BmgxShWPgj6vCL1wcnI5EV4CZhaPXt+DQu3jPCjU5jIC1sN6YQrYsGhzkS P5yA== X-Gm-Message-State: AO0yUKVHqZXpg+f5Fo6TCG33tdwmQLn92/8RF0ae6HKuoxMTQlZ8nths 78NVyk1UgvFBilNQzghHNf/hWMQZQtbGO7ynMe0= X-Google-Smtp-Source: AK7set+V97W8jtujr/jIFR7+kaARHaY79AGfRM7jgUwyBOMscxlxWHmvVk9SuyUPKX9kQuqdalKVug== X-Received: by 2002:a05:6e02:160c:b0:315:2eec:4055 with SMTP id t12-20020a056e02160c00b003152eec4055mr2581470ilu.11.1678799324309; Tue, 14 Mar 2023 06:08:44 -0700 (PDT) Received: from murgatroyd (71-211-185-113.hlrn.qwest.net. [71.211.185.113]) by smtp.gmail.com with ESMTPSA id g6-20020a056602248600b0073d7d30fb3dsm792930ioe.54.2023.03.14.06.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 06:08:43 -0700 (PDT) From: Tom Tromey To: Tom de Vries Cc: Tom Tromey , Tom Tromey via Gdb-patches Subject: Re: [PATCH] Fix DAP stackTrace through frames without debuginfo 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> X-Attribution: Tom Date: Tue, 14 Mar 2023 07:08:43 -0600 In-Reply-To: (Tom de Vries's message of "Thu, 9 Mar 2023 21:35:15 +0100") Message-ID: <873567lbtw.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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: Tom> Sorry, yet another error. Could you try this one instead? 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]