From patchwork Fri Feb 7 15:31:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 862990 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp385218wrt; Fri, 7 Feb 2025 07:37:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUFJFzy6Qmr42L5XtnNuUTeVnJ0Uhi2ei5CW0I5fzp0si1/X6ZnKMw0MrKLUUt5GIQDvlSA3A==@linaro.org X-Google-Smtp-Source: AGHT+IFXDcGcI74G26pHjm9GXQi5bd3ThWobYSjndHgq3e/HfX72jqOLHUFelr7UDE0UVE4S1IEt X-Received: by 2002:a05:6102:4414:b0:4ba:76e4:638c with SMTP id ada2fe7eead31-4ba85de0aeamr2868254137.9.1738942657731; Fri, 07 Feb 2025 07:37:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738942657; cv=none; d=google.com; s=arc-20240605; b=LQ66J2fstf7JM67pkTkpkSy96TFaTCOubgSDH2U5FjQNA27VO+Covd5/NL1DfGs2s3 uO0N2jBz8H373ysJp28vXWAYMZ4O0k1STY8cbTuGvOnSGKoGrGpG1rVS2SDuWzI92wWI GQFuuQQJUxaM3HCBD7ZrZy45REvx9G1X7/3Ya+yYNfOk3H0LG9EMangC5DdRDwX+1IYl Bshnp2P3hyjmKJgvYzIs/VjrNxX5IwKFtGi8l2CRT/aqVEBMYdNMgILHHQ1/aCmPSpTt tu+MvD4KzFANowIW6zpUSpXucMzS4PxyLg+hzZROf0IH6SmpvMLGWA2J+zVChUSY/rcD WOBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/577CdB1eWedE91Z4d0PM1VMtk8hOH9rwbGlAE6K9w8=; fh=Jdg4fLQw/+vV+BD6NiVJYsZoanjBKb4fl4V8sUUe9bg=; b=PzEWHwNk+aTB89uQBx/68KHrJV9UaP2EakyiP0kLjAyemcJIYr51YTzAp/Vaudd3Tg E+RAfB+370bkgEdCi958XI7+ebRlGQ6ym9JnVjtkDRmDl0e29fVjQThDJPOmv2wiVtk/ JlFo+daXVUX87uBvY/IEmh0APjw3K4h+3dzLHXuK8x7p/HWbx8pKpiJ1dvrOLrS15PLF 4WJEAab1hBlb6FUncSiUrC37q6PPsSYodtuZCMqDKjN6ZYYKkSHU29PAtBfyzOe6Je3+ AM3OVbVdQK0h86pqihuARX4Ew2ovDkzVVj/gN+V8/trMptEs26BYpm4wMKT9uwVhDPJL ypAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T6UsfFjK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4ba77920e61si830910137.634.2025.02.07.07.37.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Feb 2025 07:37:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T6UsfFjK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tgQLY-0001Fd-Uu; Fri, 07 Feb 2025 10:32:48 -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 1tgQKO-0008A8-1T for qemu-devel@nongnu.org; Fri, 07 Feb 2025 10:31:38 -0500 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tgQKB-00040x-0d for qemu-devel@nongnu.org; Fri, 07 Feb 2025 10:31:35 -0500 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-ab7157cf352so640858366b.0 for ; Fri, 07 Feb 2025 07:31:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738942281; x=1739547081; 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=/577CdB1eWedE91Z4d0PM1VMtk8hOH9rwbGlAE6K9w8=; b=T6UsfFjKKjJFChLvwUX2GPsQIuOe3s53L2+jyXysPHsKas9TR8sf5YtKQxRZnn9Eo9 BU7X6E8T75jU1Uv0LiJN/TbdyI2UiqSz0KcLTdid2QD2b+ttFUoZ/IVNZ57lpr+7+n4I LwKn7VS40/lK7kmcZUR8bIgq58j2dP2Y1Z9pCwIl6Utr3dRK8d/ns7KmkzF3wtg2PkVZ tYvAoXM+7D3mcYt5u37c4F9BhgfJf2cqFkdP8asIGphQHuYbjSON2HVuKe7wsW2f8ohL Jxe9Pqvkbhe+oyUCeYrh5ocaB4NM0W3/15qO3LmD2Vr3qEmXSLkMfKFtlfYIWRkYnoLF meJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738942281; x=1739547081; 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=/577CdB1eWedE91Z4d0PM1VMtk8hOH9rwbGlAE6K9w8=; b=iU0cWE8BH5UKqepxlI8vqBfWMjrHBc1MAOKg2GEEZ/viGO25MEiGzxtvxWRivR2dZ6 94OoRam6pPoPu8zHiiqvXL6hnm8KQLUTVT8X+26nnE2bWnu8P8uNZVM4YAR59XpwPQtZ xHMN3vv+X2Qn+VvlVdNbPyRGzPtUYnk8dcGPq/22D1FyfgAS38RfFN/8mD5dyvrkJuJt +DH3dQ1eQrsJAWLHEBYdUSaL4lWILApKAqpxJQ4ZX0lulb/rcHIGBKn60COzjkxROVUR qWYPNM28YLfVDxMwYq2sh4o3BoyoC+NfnUk5eP0x4Isum2qfY0MS3ZypUESjqRAr1Wkj mXHg== X-Gm-Message-State: AOJu0Yww/iFl8zZEqkyymutM1uyIEyymI+R0TB+n3j+dVXT54w6jP5v/ z8e2vw7TY72SVFsjIy2k8CbOW4M9HF4s/ohe8e53jQOO8V/YUql1M2V6//eypt8= X-Gm-Gg: ASbGncsvbDuVfbPczIyIfn56SaIYqUW8Vn3EIQFNgIv+szXgEvQn2jH9Tdj2f7L4SnC 9Ieb0SQaQ8VdZsqg5VpO3dkfCSjMHknN1oxRT7Hhsv/11Ow9K1Y9M7A++0L3NCNZT4UsabPlKpo pDzpfJbn4ZcGNsOAm/2jn/pzRa9HJpUek7rQzM57mkhwa9azi4bBzerMoYXlkbWA0CPKtKsYvoN JFRxa/hn9I92BY88VW3vqN0fvh22aMltceqCwHc/RrkhlP24ByiLZWqSJnMUoNCHeV5WUW/Mf9S vdtl0i8uJG9tQhmxgA== X-Received: by 2002:a17:907:d8a:b0:ab3:4d1e:4606 with SMTP id a640c23a62f3a-ab789a9a340mr333621766b.3.1738942280827; Fri, 07 Feb 2025 07:31:20 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab772f4870bsm286370366b.32.2025.02.07.07.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 07:31:18 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 4FB7C608B4; Fri, 7 Feb 2025 15:31:13 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Weiwei Li , qemu-arm@nongnu.org, Nicholas Piggin , Liu Zhiwei , Bin Meng , Tyrone Ting , Hao Wu , Kyle Evans , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Riku Voipio , Harsh Prateek Bora , Fabiano Rosas , Alexandre Iooss , Laurent Vivier , Daniel Henrique Barboza , Warner Losh , Pierrick Bouvier , Palmer Dabbelt , Mahmoud Mandour , qemu-ppc@nongnu.org, Paolo Bonzini , qemu-rust@nongnu.org, qemu-riscv@nongnu.org, Ilya Leoshkevich , Richard Henderson Subject: [PATCH v2 10/17] gdbstub: Allow the %d placeholder in the socket path Date: Fri, 7 Feb 2025 15:31:05 +0000 Message-Id: <20250207153112.3939799-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250207153112.3939799-1-alex.bennee@linaro.org> References: <20250207153112.3939799-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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=/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ée --- gdbstub/user.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) static int gdbserver_open_socket(const char *path) { + g_autoptr(GString) buf = g_string_new(""); struct sockaddr_un sockaddr = {}; + char *pid_placeholder; int fd, ret; + pid_placeholder = strstr(path, "%d"); + if (pid_placeholder != 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 = buf->str; + } + fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) { perror("create socket");