From nobody Sat Apr 5 01:10:07 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1739204625; cv=none; d=zohomail.com; s=zohoarc; b=fxYVYOytWoz/V9Tj5gZ84mrnes+mvqpUsM3aoxtwp5Hw9zi8eLFjDrDgL0kwl71hl3eoYHSOrNNeyNMP7P39366A8LbjKmiJJChTTdSzINtuq2oKcCanzmQR64IueIc5i6GedZdfajVfuH9r8qWAY/ESTO3KtTDpQMWIAxC85do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739204625; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=drUSqKJyol0KqcrQAykb+B2rcXTaSjubQI7HNVc4K6M=; b=TRJvsN/rp0X1SOMmithP8AU8tspaa/unGp10toZi3MToSRuN/qgqYaRR9s1ET9ykZDsL9askZvA1Whr9rtbtse4iNlXv5IRD46ImO0QmxqUo5SRq7KqIGcnHU6gDEY2zouCLfUjQbv+uuwqZnXUh9yV+RuvdcBr7JFK+kjpQXeA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1739204625236464.1240775982984; Mon, 10 Feb 2025 08:23:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWS9-0006gZ-Cb; Mon, 10 Feb 2025 11:16:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1thWR9-0004Kg-6h for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:09 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR5-0001WB-Eb for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:06 -0500 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-ab7d451f7c4so58244866b.0 for ; Mon, 10 Feb 2025 08:15:02 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7d243bb58sm81258066b.141.2025.02.10.08.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B0E9B60353; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204100; x=1739808900; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=drUSqKJyol0KqcrQAykb+B2rcXTaSjubQI7HNVc4K6M=; b=EQ3NXv5LhYDpbgICW+p5kJoUpzNKnG4NOhmp7gN7dduhwfTPo9HztwYOMjeN9h0Mst orrgJw9BCxq0/peQ20/QX1kOpOLFajpmd+cUHF5hlboTWAS54uOebJu4fOZAO3URiQlG 8GRsyjQ2/4yRysLBdWqwGX1OIEkXNe97SKlF3IZk/u59nzJVF+OXt/NQK6lQMuq68toV woTQ4CBqrWttAc4ebeGE6SvVKL+CMsrLvWYH1tI7IC7kMhqT4Lk38gDEfFRcbO1IVhcw XMZwOodhMpeeDGBRahd9eh8KPbMuUPG6MA00JOTRNGV4WpzwzNjGUyh8LIGn3pLPfQsF YRwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204100; x=1739808900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=drUSqKJyol0KqcrQAykb+B2rcXTaSjubQI7HNVc4K6M=; b=Qn8hd5j+mVxOcO3/xWPOZBhuZ8xaKjQnanTPQ9njE9LuC8EcToSIys/yM0SmaFC8fK qIgNJHcl3zyqe02c6VoqO1JAPy4S/e5R4HIftF1tjHerNeuZATlATKXGpAwGg+2wE9rk HpAyHlziMGUDMVLLz4E7JS1hcJo2E/zpj8fa6Q9V2g8noqDZm1i2hiaACGWSt+XcV3G4 Z8S5S2ueycNIIxSd+OK37lzuh3pQZjcs9fhlOdJL+C3+skO4NSG8b6Ze8O9ffWOEd0pv XJ9iHbPUM38CP50HnCVAsGV9AQ6+65yNYuYFxxzVDcdRxMIiHduKBOQ8vFSo6vXBVkt0 tmuA== X-Gm-Message-State: AOJu0Yzyr9MoTQabHqHew2Wszdg+XrvZW99QYDXmsGqpomeWx96RNgOz fMk/eiPdzmXrJKQ36FBujTuyfdWInFVt/J+DIn2k5WA51cxZacTAwKrrtbhNZT8= X-Gm-Gg: ASbGnctGFQN5aqYxKe5xZO+WkpN/SogxLt6NqAUMJzxHeB0v86cBPWgIludHs1ba81p YoeGniIVVfGEgnG7l/g4SZa3b4VqFRAdedsqWb6KL2UE+XCuHqrV7J4kzP18EluG4HR8s5P4AnS PHaly7R8sOYNmDiOAlJERolAtp15rHuQgH0kSMkQxRqowouZ7gpQnDItQCvk7i8YVBMb1EcEI+Y 0C7Ehi2Nczjs3+jjppFwoZy10tM8jVzjD67Z5AsgWXkXggsMog0P7VtwRbPOFyQMc6OFn3Ra5Dx 8wvq3zxUxOwmiM5F6w== X-Google-Smtp-Source: AGHT+IHb5RndRI06xl37JMWMbMARZvkmIYowTjDXqIdy4SANlVpPE0LB6SOC8VryYlW8/4iTdNv2TQ== X-Received: by 2002:a17:906:7955:b0:ab7:cedc:4b13 with SMTP id a640c23a62f3a-ab7cedc4c5bmr271617666b.34.1739204100593; Mon, 10 Feb 2025 08:15:00 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Warner Losh , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 10/17] gdbstub: Allow the %d placeholder in the socket path Date: Mon, 10 Feb 2025 16:14:44 +0000 Message-Id: <20250210161451.3273284-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x629.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1739204626447019100 From: Ilya Leoshkevich Just like for QEMU_LOG_FILENAME, replace %d with PID in the GDB socket path. This allows running multi-process applications with, e.g., export QEMU_GDB=3D/tmp/qemu-%d.sock. Currently this is not possible, since the first process will cause the subsequent ones to fail due to not being able to bind() the GDB socket. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich Message-Id: <20250117001542.8290-2-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20250207153112.3939799-11-alex.bennee@linaro.org> diff --git a/gdbstub/user.c b/gdbstub/user.c index c2bdfc3d49..fd29d595f4 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -317,9 +317,19 @@ static bool gdb_accept_socket(int gdb_fd) =20 static int gdbserver_open_socket(const char *path) { + g_autoptr(GString) buf =3D g_string_new(""); struct sockaddr_un sockaddr =3D {}; + char *pid_placeholder; int fd, ret; =20 + pid_placeholder =3D strstr(path, "%d"); + if (pid_placeholder !=3D NULL) { + g_string_append_len(buf, path, pid_placeholder - path); + g_string_append_printf(buf, "%d", qemu_get_thread_id()); + g_string_append(buf, pid_placeholder + 2); + path =3D buf->str; + } + fd =3D socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) { perror("create socket"); --=20 2.39.5