From patchwork Wed Apr 20 06:49:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1619333 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=D0j3NRwz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kjrsd5Kprz9sG0 for ; Wed, 20 Apr 2022 16:50:45 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Kjrsd4Dj4z2ymq for ; Wed, 20 Apr 2022 16:50:45 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=D0j3NRwz; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::430; helo=mail-pf1-x430.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=D0j3NRwz; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (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 lists.ozlabs.org (Postfix) with ESMTPS id 4KjrsZ1GBWz2yn2 for ; Wed, 20 Apr 2022 16:50:42 +1000 (AEST) Received: by mail-pf1-x430.google.com with SMTP id j17so1084781pfi.9 for ; Tue, 19 Apr 2022 23:50:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HUk5u7gPGnP2g2hjKna7df112Qsb10meN8u6/RnxvpI=; b=D0j3NRwzPSXcu0pZeLsLnLJP2tT/yQPLmhLQa+YdU7bNQjytTExocQxH+3wloe9s9X 2bba9+cUdgLbe+Abe3JgOSO6hqHjXhyMyPAgH9n7akNOtRRKj9+5ddAJdU8tSsKxXLy2 ELDuqZQWYMXhdKNo6imUS6D/vMymhl0ykjU53b8y2dWfugqK/8O3+tV9yhMlDlAI6G2G 9e50P/gH0WIBrryUhK5uao6upaFvd8psaeN1kHFyRVGMXe/ly5WxXYaReaoTvdhKGvdp /WLnQkOnuqEbdXt3pS1jqo91TyhryHIwYpc8E8v2MvDifTjxBEpmRRTK+3LQMDueUQay oiSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HUk5u7gPGnP2g2hjKna7df112Qsb10meN8u6/RnxvpI=; b=jW6+Iy4Ynqis456F09Za0HQIpbuDDzBSKAqqVEObvdTt9R4SxbadaxQAZtqsEyjmXV mCDhhoulxoTDVccZYjx2cmD0T+nT8KglLo2ncuPk+nfYazLLG+b3QeM8XNQVI0yv2m45 QhvGb0EdwQf8cGbngBAAOpivFskHMcfClWAs51wK/Y85/HQfi6cTLDsP2E8ctORey0RE OdLlmsYen6AAeWTfIyvtOoEmp4Bh2GjzLrxx8SNAPDgwQAJi24eWMDg31xnrEraX0uvo Z6azc3EyWJNtW2I5fN35roKtPlbFDsnMu6Ap8Up4RZiRvDkZxEY2sxyHlSD1nTQKV+39 fULw== X-Gm-Message-State: AOAM533xZAafAcNy7sJP5u3cKBp4SWXTF9jMCklG2UXcDuJBd0Oi/VI3 nMNTcuUX1hEfYv8DP8QKTmI/C+bOxnhVog== X-Google-Smtp-Source: ABdhPJxAIqodp/ktbljehzhqwc/DpUrOITj060lFsP8pKplrfHlNR/Q+wM/kdBmrOB6Iy5nTSMhvzg== X-Received: by 2002:a63:4f0b:0:b0:3a9:f4ad:6c30 with SMTP id d11-20020a634f0b000000b003a9f4ad6c30mr12431871pgb.88.1650437439436; Tue, 19 Apr 2022 23:50:39 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([203.221.203.144]) by smtp.gmail.com with ESMTPSA id x20-20020aa79574000000b005061f4782c5sm18481235pfq.183.2022.04.19.23.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 23:50:39 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Wed, 20 Apr 2022 16:49:41 +1000 Message-Id: <20220420065013.222816-8-npiggin@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220420065013.222816-1-npiggin@gmail.com> References: <20220420065013.222816-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 07/39] gdbserver: print some client/server info X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Rather than silently listening this gives some idea things are working. Reviewed-by: Joel Stanley Signed-off-by: Nicholas Piggin --- src/pdbgproxy.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 3e27ba02..e32f5184 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -448,6 +448,8 @@ int gdbserver_start(struct pdbg_target *thread, struct pdbg_target *adu, uint16_ return -1; } + printf("gdbserver: listening on port %d\n", port); + FD_ZERO(&active_fd_set); FD_SET(sock, &active_fd_set); @@ -463,17 +465,29 @@ int gdbserver_start(struct pdbg_target *thread, struct pdbg_target *adu, uint16_ for (i = 0; i < FD_SETSIZE; i++) { if (FD_ISSET(i, &read_fd_set)) { if (i == sock) { + char host[NI_MAXHOST]; + struct sockaddr saddr; + socklen_t slen; int new; - new = accept(sock, NULL, NULL); + + new = accept(sock, &saddr, &slen); if (new < 0) { perror(__FUNCTION__); return -1; } - if (fd > 0) + if (getnameinfo(&saddr, slen, + host, sizeof(host), + NULL, 0, + NI_NUMERICHOST) == 0) { + printf("gdbserver: connection from gdb client %s\n", host); + } + + if (fd > 0) { /* It only makes sense to accept a single client */ + printf("gdbserver: another client already connected\n"); close(new); - else { + } else { create_client(new); FD_SET(new, &active_fd_set); } @@ -481,6 +495,7 @@ int gdbserver_start(struct pdbg_target *thread, struct pdbg_target *adu, uint16_ if (read_from_client(i) < 0) { destroy_client(i); FD_CLR(i, &active_fd_set); + printf("gdbserver: ended connection with gdb client\n"); } } }