From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 470F63858CD1 for ; Fri, 26 Apr 2024 18:32:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 470F63858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 470F63858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::532 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714156351; cv=none; b=gtC1ytjhicdCMQMto4ppGfFWDva3WyUtDdq/hsDMD2Ny0/sGnbFJQwYx0zS1cTFgykDaa7usqxyEaKgEVadnli4AIbi5t9nwOXbWbU6Z+thjVGIiwl+Fxbdxm4aBb9ozs9G+y9qKaxVA2F7LsdKgJnmpC1km8U4aK1G+xOJz2d0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714156351; c=relaxed/simple; bh=SxFOoQZSYia/FQ9tSFVUoU+a8+wbcnMmzSGnCRn9Y9Y=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=g8YbUL3HrzE6dtIsuXN9cBNMuff0Vl46Bbahsmh2IQ8lPtChfEDLxtlbUrcisTrH9TCxsnkL8Jl3Ldks3I7ADxL8EP5cWI08A1Az9jBKjaP19diAAtsOAB5jDfhBZlBel0E+jEf3JTkU+sH+JOvYTE8EvR+ZoE/5tYU24dCrh2c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-56e1baf0380so3503123a12.3 for ; Fri, 26 Apr 2024 11:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714156345; x=1714761145; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VKfPbTcTHaz4wER1ZaArMwotJTbWr0wi9Jvx+t/LdHc=; b=aGxfUJaMKERLty4vvecsmA4zgVsFc5GoszkB6pLhoZdwgf4uCLTnCCFc9dIDqmDUMj wm13Ke5TgyK7GKeD8VzMPRX/4OxatCw+zLq37js3XnPa/T+Qm24xue2vVmjtujHwfBIu 3FEJoteIdra/E4bCCoqxjzoc8VZQpCf+Y2hwsuMcheza/WQ/535ITIy8ndW4upn/ImIP lV2eOPysYnYK6hUzGloig2fA1LjoAcnzTkmm8Tu4QneuuWKaQqx9g6O7m8MN6mImqWND XBGJelrBOh1KIiRKGD16fIuvV9zmI31D7Rw+r9/3r8XAKqJiq1NLp2j3eXF8RYrU4LxU Zj6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714156345; x=1714761145; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VKfPbTcTHaz4wER1ZaArMwotJTbWr0wi9Jvx+t/LdHc=; b=n7zTzNV9dyPV+U10Qe73tAyTO8ChiHQ1bJFdSJK40XiWxVISTevXq7VeKdGDmukYQS eche62wKUzc5h6qTW0Zp6jRuw1aw8K+4h/LodYZI2OXjEYnZLJvH+CK3nhm2RGk7yJiR xYOHwofQrVz9QScXMhyMNdAZ8LbPLF8TNQ+HZCD5UnQGCE8+YBmg5rewIcKcI7ap1kWX 6unx4iQhp74udwGFXfjpa2ioB+cComnsqtp3U2MA86qYLv+DXtWWr5RKLWQcZSTL7Qq0 IQ2JFbX5MK18+h9Lpi9/jQh736omKTzl5Z7qW6uBQ+Cbll6vLR53mSYFcbCklTZvvaOZ tVrg== X-Gm-Message-State: AOJu0YxoYh2f4MWKFDsjp+O8RETb+JahqOHm7qkjpK1m55ObGJAOiUDy wxoBu6CXOk3K72p3OH9VHqECQL0FbH9xcoMVvyhxG6wBlyurgQ8MIQ3VcsjDMxDmhcs1mzyhEXt Gv3cOb6OmH9/5l6DNkMRztpbjdpA= X-Google-Smtp-Source: AGHT+IFgc3BcFQwKD219w8x08Aik3hdmMGQg5qChD/12Sq5M3O9M6B8XVYitH6BmAk3zaRvnrIauDnq2maSUzE4ooQI= X-Received: by 2002:a50:d74b:0:b0:572:2f0d:d165 with SMTP id i11-20020a50d74b000000b005722f0dd165mr2500604edj.4.1714156344643; Fri, 26 Apr 2024 11:32:24 -0700 (PDT) MIME-Version: 1.0 References: <20240425172019.863412-1-johan.sternerup@gmail.com> <87jzklgwig.fsf@tromey.com> <87frv9gvxk.fsf@tromey.com> In-Reply-To: <87frv9gvxk.fsf@tromey.com> From: Johan Sternerup Date: Fri, 26 Apr 2024 20:32:13 +0200 Message-ID: Subject: Re: [PATCH] Handle DAP "stepOut" request in outermost frame To: Tom Tromey Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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: On Thu, Apr 25, 2024 at 8:05=E2=80=AFPM Tom Tromey wrote: > > Tom> Maybe one way forward would be a new helper function to be run on th= e > Tom> gdb thread, that incorporates the new check. > > Another way might be to revisit this idea, documented in a comment in > next.py: > > # This is a server-side request because it is funny: it wants to > # 'continue' but also return a result, which precludes using > # response=3DFalse. Using 'continue &' would mostly work ok, but this > # yields races when a stop occurs before the response is sent back to > # the client. > > That is, solve the stop event race by deferring such events, and then > have all stepping commands add "&" for background execution. Then they > could all be ordinary requests (on the gdb thread with response), and > any exceptions thrown early by the commands would affect the response. > > Tom Thanks for your swift reply and comments. I think your suggestion to use background execution makes a lot of sense. I'm not sure I've understood the details though. For all the stepping comma= nds we would have a request with response=3DTrue and in_dap_thread=3DFalse, i.e= . we would pass our stepping command with a '&' to the gdb thread while waiting for the response in the dap thread. So then the dap thread would be blocked in send_gdb_with_response(). Eventually the gdb thread would process the request and I guess immediately return any error or success. Only after the step request has been made can a stop event be triggered and since the gdb thread is busy handling the request the _on_stop shouldn't be allowed to run right? Then the stopped event will also always reach the dap thread after the dap thread received the response. Are there maybe several gdb threads or are gdb events/commands not processed in an event loop? Maybe the background comman= d is executed in a real asynchronous way so that I also need a two-step procedure in the gdb thread, one for the request and another one for the answer. Then I could understand the race. As you can understand I'm not (yet) that familiar with the code base so need some further guidance to pull this off.