From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 0330E3858D20 for ; Fri, 5 May 2023 14:01:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0330E3858D20 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-out2.suse.de (Postfix) with ESMTPS id 2E4AF1FFB7; Fri, 5 May 2023 14:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1683295298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=swgB6RQ+6D7n5+Mfo2lZEx7Lki488EV42Bnd7YUsEHY=; b=y/P0YjYDHVUvXwmzHY5aR0n2VEYVU1lzBWE9hrbtXWiPycl3atHS+0UezMRsyn8MTDlRHx /R9sf+otkhH+23BM0RnXh5s1FmveE3YkY21cNobRMpF8fvJtxTk8L37juyLaZvYkpQuRKd hE/JYYVXYf2QeuOYNeFnCzMslZM7sXk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1683295298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=swgB6RQ+6D7n5+Mfo2lZEx7Lki488EV42Bnd7YUsEHY=; b=3IukTgZ2Vqt0a4SZpG5HDCKm/OjW0hQYor2g4Rmt3dHYF6Fib6SUnrUNAJn8B9hAgbsB3M IjeymbviSkgaKWCQ== 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 1A4EF13488; Fri, 5 May 2023 14:01:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id C8VoBUIMVWRfZwAAMHmgww (envelope-from ); Fri, 05 May 2023 14:01:38 +0000 Message-ID: <26e25059-112a-1cfb-24cd-9c1a29e1eaa8@suse.de> Date: Fri, 5 May 2023 16:01:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [RFC 3/3] [gdb/dap] Allow WAIT_FOR_EVENTS input Content-Language: en-US To: Tom Tromey , Tom de Vries via Gdb-patches References: <20230314130535.6369-1-tdevries@suse.de> <20230314130535.6369-4-tdevries@suse.de> <87354audpd.fsf@tromey.com> From: Tom de Vries In-Reply-To: <87354audpd.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 5/5/23 15:09, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries via Gdb-patches writes: > > Tom> Modify the dap input format to allow a WAIT_FOR_EVENTS line: > Tom> ... > Tom> Content-Length: 54 > Tom> WAIT_FOR_EVENTS: 1 > Tom> {"seq": 1, "type": "request", "command": "initialize"} > Tom> Content-Length: 163 > Tom> ... > Tom> that ensures that we wait for a specific amount of events before continuing > Tom> to process input. > > I don't understand the use for this. The idea is that I'm trying to reproduce gdb.dap test-cases outside the test-suite, and I need something to play the role of _dap_wait_for_event. Otherwise, I sent requests before I have an acknowledgement that expected events due to previous requests have occurred. More concretely, let's run gdb.dap/bt-nodebug.exp. Now, we copy the gdb.in.1 to use as input: ... $ cp leap-15-4/build/gdb/testsuite/outputs/gdb.dap/bt-nodebug/gdb.in.1 gdb.in ... Let's use it as described in the cover letter: ... $ gdb -q -iex "set debug dap-log-file dap.log" -i dap < gdb.in Content-Length: 473 {"request_seq": 1, "type": "response", "command": "initialize", "body": {"supportsTerminateRequest": true, "supportTerminateDebuggee": true, "supportsFunctionBreakpoints": true, "supportsInstructionBreakpoints": true, "supportsDelayedStackTraceLoading": true, "supportsDisassembleRequest": true, "supportsConfigurationDoneRequest": true, "supportsReadMemoryRequest": true, "supportsWriteMemoryRequest": true, "supportsSteppingGranularity": true}, "success": true, "seq": 1}Content-Length: 51 {"type": "event", "event": "initialized", "seq": 2}Content-Length: 86 {"request_seq": 2, "type": "response", "command": "launch", "success": true, "seq": 3}Content-Length: 299 {"type": "event", "event": "breakpoint", "body": {"reason": "new", "breakpoint": {"id": 1, "verified": true, "source": {"name": "bt-main.c", "path": "/data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.dap/bt-main.c", "sourceReference": 0}, "line": 23, "instructionReference": "0x4004ab"}}, "seq": 4}Content-Length: 337 {"request_seq": 3, "type": "response", "command": "setFunctionBreakpoints", "body": {"breakpoints": [{"id": 1, "verified": true, "source": {"name": "bt-main.c", "path": "/data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.dap/bt-main.c", "sourceReference": 0}, "line": 23, "instructionReference": "0x4004ab"}]}, "success": true, "seq": 5}Content-Length: 97 {"request_seq": 4, "type": "response", "command": "configurationDone", "success": true, "seq": 6}Content-Length: 186 {"type": "event", "event": "output", "body": {"category": "stdout", "output": "Breakpoint 1 at 0x4004ab: file /data/vries/gdb/src/gdb/testsuite/gdb.dap/bt-main.c, line 23.\n"}, "seq": 7}Content-Length: 92 {"type": "event", "event": "thread", "body": {"reason": "started", "threadId": 1}, "seq": 8}Content-Length: 137 {"request_seq": 5, "type": "response", "command": "stackTrace", "body": {"stackFrames": [], "totalFrames": 0}, "success": true, "seq": 9}Content-Length: 91 {"request_seq": 6, "type": "response", "command": "disconnect", "success": true, "seq": 10}$ ... As we can see the backtrace is empty. After playing with this a few times, we get instead: ... $ gdb -q -iex "set debug dap-log-file dap.log" -i dap < gdb.in Content-Length: 473 {"request_seq": 1, "type": "response", "command": "initialize", "body": {"supportsTerminateRequest": true, "supportTerminateDebuggee": true, "supportsFunctionBreakpoints": true, "supportsInstructionBreakpoints": true, "supportsDelayedStackTraceLoading": true, "supportsDisassembleRequest": true, "supportsConfigurationDoneRequest": true, "supportsReadMemoryRequest": true, "supportsWriteMemoryRequest": true, "supportsSteppingGranularity": true}, "success": true, "seq": 1}Content-Length: 51 {"type": "event", "event": "initialized", "seq": 2}Content-Length: 86 {"request_seq": 2, "type": "response", "command": "launch", "success": true, "seq": 3}Content-Length: 299 {"type": "event", "event": "breakpoint", "body": {"reason": "new", "breakpoint": {"id": 1, "verified": true, "source": {"name": "bt-main.c", "path": "/data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.dap/bt-main.c", "sourceReference": 0}, "line": 23, "instructionReference": "0x4004ab"}}, "seq": 4}Content-Length: 186 {"type": "event", "event": "output", "body": {"category": "stdout", "output": "Breakpoint 1 at 0x4004ab: file /data/vries/gdb/src/gdb/testsuite/gdb.dap/bt-main.c, line 23.\n"}, "seq": 5}Content-Length: 337 {"request_seq": 3, "type": "response", "command": "setFunctionBreakpoints", "body": {"breakpoints": [{"id": 1, "verified": true, "source": {"name": "bt-main.c", "path": "/data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.dap/bt-main.c", "sourceReference": 0}, "line": 23, "instructionReference": "0x4004ab"}]}, "success": true, "seq": 6}Content-Length: 97 {"request_seq": 4, "type": "response", "command": "configurationDone", "success": true, "seq": 7}Content-Length: 92 {"type": "event", "event": "thread", "body": {"reason": "started", "threadId": 1}, "seq": 8}Content-Length: 303 {"type": "event", "event": "breakpoint", "body": {"reason": "changed", "breakpoint": {"id": 1, "verified": true, "source": {"name": "bt-main.c", "path": "/data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.dap/bt-main.c", "sourceReference": 0}, "line": 23, "instructionReference": "0x4004ab"}}, "seq": 9}Content-Length: 149 {"type": "event", "event": "stopped", "body": {"threadId": 1, "allThreadsStopped": true, "hitBreakpointIds": [1], "reason": "breakpoint"}, "seq": 10}Content-Length: 685 {"request_seq": 5, "type": "response", "command": "stackTrace", "body": {"stackFrames": [{"id": 0, "name": "function_breakpoint_here", "line": 23, "column": 0, "instructionPointerReference": "0x4004ab", "source": {"name": "bt-main.c", "path": "/data/vries/gdb/src/gdb/testsuite/gdb.dap/bt-main.c", "sourceReference": 0}}, {"id": 1, "name": "no_debug_info", "line": 0, "column": 0, "instructionPointerReference": "0x4004c7"}, {"id": 2, "name": "main", "line": 27, "column": 0, "instructionPointerReference": "0x4004b7", "source": {"name": "bt-main.c", "path": "/data/vries/gdb/src/gdb/testsuite/gdb.dap/bt-main.c", "sourceReference": 0}}], "totalFrames": 3}, "success": true, "seq": 11}Content-Length: 91 {"request_seq": 6, "type": "response", "command": "disconnect", "success": true, "seq": 12}$ ... As we can see the backtrace is now not empty. The WAIT_FOR_EVENTS bit ensures that we get a non-empty backtrace each time. Thanks, - Tom