From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 564B83875B62 for ; Tue, 6 Dec 2022 19:27:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 564B83875B62 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-x134.google.com with SMTP id o13so6924073ilc.7 for ; Tue, 06 Dec 2022 11:27:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nqh1+euKOpBjz1ulXAOzepQLrd1l8zCO041lUug9NX4=; b=YwKPiruccPcZxEe5HilUA585l2GhubG4qCtPqBjZercqHFYvfhaWD0UIpYchpLxLZQ uxInJQv76ov++JzSy2SlOcMWlq9rttXeI42+8YMMBKxy5Nu6iiQk+GTtxHdFFQZnLkDe x9QoeZph3Z8/outWpOYBfGjq9TpCoSY2PrmHVIC6XwuazDgY+1ogGFCq4Iokf9XLeL+H XpsS5oPmrmn0RZ0g+jtv4alzU92FS8W043BaZeTGc+O9lWXlgBETv2B5ec+tT6eFBF0h 1BQd9KTM6T7TLzVdENHgFm9ciooEsaQNByvG5xCR/AEN5Z/I+gdiaH57cwfXTYsaArll CnLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nqh1+euKOpBjz1ulXAOzepQLrd1l8zCO041lUug9NX4=; b=d9EGZ8PsosLAj1MWI39ApHbkJLz+9Hznx0pg/jevhoQNV4U6qm6ZLL/1xm0AJac0b4 RJkmXVuGycnYEQvnnnfcc6GZWuHUfZQ57aj5DWmsxxUOX9vpHKB3zjdHNaSJIsCxQX98 E+B7o5dV+W6L3HlXw1mZ6XYcIWdq7CExiom/itiScHIHaPjC+IrF/6jXn/5OH2+1pvru O9Un2DrKLLP+J2xUOFwml8VUHwQxzGKambZ+Ye6+njlAOLnRRFasXlgxqqNYRCZ0axsx Ri3b1ixe1LjOPwh/wUgRVPITrWqzWcpTX8uGGWgxbMoFmlnlAKj8v8jNsanQsMj0dI91 bQzg== X-Gm-Message-State: ANoB5pn3UeGUjEG5N+AjlQLACZm1fnPTBk5aSqv69UWav4iHYRVyshj5 y/NNpq7Z5Rhxl/s7rKM0wrYRWveUneebet0F X-Google-Smtp-Source: AA0mqf76E2eiGZaz2DbaDuUOHkDYrAI/42Lk3ZhKQH80qQkwKQIIF1TMEaEAY2fxbNe66p8JmlSXBw== X-Received: by 2002:a92:cccd:0:b0:302:58d0:2510 with SMTP id u13-20020a92cccd000000b0030258d02510mr33959666ilq.27.1670354872520; Tue, 06 Dec 2022 11:27:52 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id n9-20020a056602340900b006e00556dc9esm3800185ioz.16.2022.12.06.11.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 11:27:52 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Let user C-c when waiting for DWARF index finalization Date: Tue, 6 Dec 2022 12:27:43 -0700 Message-Id: <20221206192743.2827834-1-tromey@adacore.com> X-Mailer: git-send-email 2.34.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 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: In PR gdb/29854, Simon pointed out that it would be good to be able to use C-c when the DWARF cooked index is waiting for finalization. The idea here is to be able to interrupt a command like "break" -- not to stop the finalization process itself, which runs in a worker thread. This patch implements this idea, by changing the index wait functions to, by default, allow a quit. Polling is done, because there doesn't seem to be a better way to interrupt a wait on a std::future. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29854 --- gdb/dwarf2/cooked-index.c | 17 +++++++++++++++++ gdb/dwarf2/cooked-index.h | 11 +++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 0aa026c7779..a0b75a311b1 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -25,6 +25,7 @@ #include "ada-lang.h" #include "split-name.h" #include +#include /* Hash function for cooked_index_entry. */ @@ -282,6 +283,22 @@ cooked_index::find (gdb::string_view name, bool completing) return range (lower, upper); } +/* See cooked-index.h. */ + +void +cooked_index::wait (bool allow_quit) +{ + if (allow_quit) + { + using namespace std::chrono_literals; + auto duration = 15ms; + while (m_future.wait_for (duration) == std::future_status::timeout) + QUIT; + } + else + m_future.wait (); +} + cooked_index_vector::cooked_index_vector (vec_type &&vec) : m_vector (std::move (vec)) { diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 2ea32781be5..5412149588a 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -212,10 +212,7 @@ class cooked_index void finalize (); /* Wait for this index's finalization to be complete. */ - void wait () - { - m_future.wait (); - } + void wait (bool allow_quit = true); friend class cooked_index_vector; @@ -325,8 +322,10 @@ class cooked_index_vector : public dwarf_scanner_base end up writing to freed memory. Waiting for finalization to complete avoids this problem; and the cost seems ignorable because creating and immediately destroying the debug info is a - relatively rare thing to do. */ - wait (); + relatively rare thing to do. Do not allow quitting from this + wait. */ + for (auto &item : m_vector) + item->wait (false); } /* A range over a vector of subranges. */ -- 2.34.3