From patchwork Mon Mar 14 04:17:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1604890 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=WluAuvTb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KH3Dc2chjz9sG2 for ; Mon, 14 Mar 2022 15:18:08 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KH3Db2FMjz30KL for ; Mon, 14 Mar 2022 15:18:07 +1100 (AEDT) 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=WluAuvTb; 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::42b; helo=mail-pf1-x42b.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=WluAuvTb; dkim-atps=neutral Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (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 4KH3DH00lYz303H for ; Mon, 14 Mar 2022 15:17:50 +1100 (AEDT) Received: by mail-pf1-x42b.google.com with SMTP id t5so13188943pfg.4 for ; Sun, 13 Mar 2022 21:17:50 -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=wRVLl+/l6ZXs5FcOhBj7CBOZKbB46ydv7W/ZQvZinsI=; b=WluAuvTbX1/HWGdF59FK11125+YhXEj8QFmTB55xRg07rc7pNuMNr1gEvDzU8ymq2N WZm38ERHZ6XB+NKRtqTPQ7R+pUH4v+M4aEskCBLpu8qiMjSgNjCq+hjnz7ZMmdifyYv+ 4GRJKd4V4XBZ3mZAVvhzZNmtJUDKeY+rzjPMtW0kIyA03K/If31KMIpKkhXyQkU73HGY kRHOO4oa+gEG9NDYDV4RyKJaIlxzPTBZ5/tnxjaMMqrhVhYUtGc9TD4vx8MfHYSHH6nl J9SiR4OLdmdEA5bwTfUkn1K/awNGVIIP/D5f/xYHZkSjMK76vvXMMiwJfYGhhDBN2OxQ 1CFQ== 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=wRVLl+/l6ZXs5FcOhBj7CBOZKbB46ydv7W/ZQvZinsI=; b=S97vER7059tupi3bBjNxPloeiESE9qn1rrYG38uOekPpZkUtSW1RJSdcTBMLHdkjJl LriDn0bLrl8nfnZAiCDpA7/YDWFc462n+K8EqTId6Q88HlzgztUgsJgoOT5UH/o1M15R PDm60H7SGO7cf+MkbVLSj73RCIKQrm/H9MbWzK6fUc9cwbz+A5WCnlW1ITtkn5TSgveI p/BP+fHrxh+49o8PAWv63uspfFVbuSjIf2sO67J4f4UBe5Orw6le1eSRZXPVob3bWMiX WDH5G24v2J7YmDHqhMAyBH8kWlt5v4t8J4S7jG981uHbQ/dh/dYsgiO8IgylR2syXrRi OEKg== X-Gm-Message-State: AOAM532ZxUanWQjTDYL/wXjSOMhM42prEgmUC5jRWXdpa9uVsWfEBvM8 kck17VPch7UEOuD59+N1LULdQohRHv4= X-Google-Smtp-Source: ABdhPJxO2Bz82pOP+fFC9x1mCxsOwm0rZFVJTO8ZHtzPyzmdrtFeCZo86RLN+vlx3J5H4wlPaS7eXA== X-Received: by 2002:a65:5501:0:b0:380:c32f:23eb with SMTP id f1-20020a655501000000b00380c32f23ebmr18350029pgr.307.1647231468744; Sun, 13 Mar 2022 21:17:48 -0700 (PDT) Received: from bobo.ibm.com (110-175-148-108.static.tpgi.com.au. [110.175.148.108]) by smtp.gmail.com with ESMTPSA id d16-20020a056a00245000b004f771b48736sm14283018pfj.194.2022.03.13.21.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 21:17:48 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Mon, 14 Mar 2022 14:17:23 +1000 Message-Id: <20220314041735.542867-4-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220314041735.542867-1-npiggin@gmail.com> References: <20220314041735.542867-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 03/14] 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. Signed-off-by: Nicholas Piggin Reviewed-by: Joel Stanley --- src/pdbgproxy.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 3e27ba0..e32f518 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"); } } }