From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8B9363858C2F for ; Fri, 19 Jan 2024 11:57:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B9363858C2F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8B9363858C2F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705665427; cv=none; b=sFUeUtlwIEolSvlI98pKYLCqSAZLmKqQaJDMeXNX308mO5WkSdw4+pxUpG+e224LdDDUgmZZ9ZzYaxahT6d5t/btkiXOIXVaKP+SfmFhWcPw7Rz3aNP9xr1CCsrP6mOU/O1OCNIQl/dBrRyiFsY7x482/ZPMe31yvwnmH8bHAGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705665427; c=relaxed/simple; bh=fAWN94MpCwwbTKP/XXf8iqR8PHHL0fylFtzTqf+vNYc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MMh1oOkzBkkBkrdiV9VZiK8qZgrZefoLTd2vLMTCW+HINiUVmHC/EVHwbv3a/5DQnSOs/uW0acaOXD5mG2XydBQ7hk3e1Y48GTYaf1OU/z09fADwUaL1rmL+Vn27HZ6e7Met3uBfOu69srnscxlzl0GMggEsbe55b/EAcEZVBHA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705665424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AhWV1wmmdPdqwDLlU+RJZDj6Y8UNfkYTy6q8ZE8L3Zs=; b=IdmBeJsYIF4ZGbrFNH/CJJORezORwhe/9YBAnDe0yA5bIiuJJ9Ed/J/VQyaGxJr4ZGj5YQ 8Uoa9gQX7b++BTlOGRLFlb+6YU4Jhe4wZISLWfw3yb1qBNofR+iMA8ap9HE9De2DznavHJ 1J7fc5AhYkiJ00sNlfsUtA87HxjQRlY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-590-XVd6Lmy4PPqRG498Ig-6Cg-1; Fri, 19 Jan 2024 06:57:03 -0500 X-MC-Unique: XVd6Lmy4PPqRG498Ig-6Cg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB3CF881BC2 for ; Fri, 19 Jan 2024 11:57:02 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3645140C95AD for ; Fri, 19 Jan 2024 11:57:02 +0000 (UTC) From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= To: gdb-patches@sourceware.org Subject: [PATCH v2 0/6] Add vDefaultInferiorFd feature Date: Fri, 19 Jan 2024 12:56:23 +0100 Message-ID: <20240119115659.491195-1-ahajkova@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: Currently, when GDBserver is run locally using stdio, the inferior is unable to read from STDIN so we can't give it any input. The main motivation to address this issue is to use GDB together with Valgrind, using vgdb --multi feature which allows to run Valgrind from inside GDB. Valgrind then acts as a locally run GDBserver that uses stdio. Add a new DefaultInferiorFd feature and the corresponding packet. This feature allows GDB to send, to GDBserver, the file descriptor numbers of the terminal to which GDB is connected. The inferior is then started connected to the same terminal as GDB. This allows the inferior run by local GDBserver to read from GDB's STDIN and write its output to GDB's STOUT/ERR the same way as native target. v2: - [2/6]:- add an error handling in a case dup would fail - hoist the calls to mark_fd_no_cloexec near the dup()s [3/6] - improve documentation formatting - rephrase and extend the documentation - cosmetics - add a new target method so that gdbserver doesn't advertise this new feauture on platforms it does not work at [4/3] - cosmetics Alexandra Hájková (6): gdb.server/non-existing-program.exp: Use gdbserver_start. gdb/ser-pipe.c: Duplicate the file descriptors Add new vDefaultInferiorFd packet gdbserver/linux-low.cc: Connect the inferior to the terminal remote.c: Add terminal handling functions Add defaultinf.exp test to the testsuite gdb/doc/gdb.texinfo | 42 ++++++ gdb/remote.c | 83 +++++++++++ gdb/ser-pipe.c | 40 ++++++ gdb/serial.c | 4 + gdb/serial.h | 4 + gdb/testsuite/gdb.server/defaultinf.c | 39 +++++ gdb/testsuite/gdb.server/defaultinf.exp | 59 ++++++++ .../gdb.server/non-existing-program.exp | 54 ++----- gdb/testsuite/lib/gdbserver-support.exp | 62 +++++--- gdbserver/linux-low.cc | 38 ++++- gdbserver/linux-low.h | 2 + gdbserver/server.cc | 135 +++++++++++++++++- gdbserver/server.h | 12 ++ gdbserver/target.cc | 6 + gdbserver/target.h | 6 + 15 files changed, 524 insertions(+), 62 deletions(-) create mode 100644 gdb/testsuite/gdb.server/defaultinf.c create mode 100644 gdb/testsuite/gdb.server/defaultinf.exp -- 2.43.0