From patchwork Wed Aug 29 01:50:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 420TBy1DKSz9s1x for ; Wed, 29 Aug 2018 11:52:10 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X7TOX9vt"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 420TBx61ZFzF1Zs for ; Wed, 29 Aug 2018 11:52:09 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X7TOX9vt"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62e; helo=mail-pl1-x62e.google.com; envelope-from=rashmica.g@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X7TOX9vt"; dkim-atps=neutral Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 420TBQ1VCxzF13P for ; Wed, 29 Aug 2018 11:51:42 +1000 (AEST) Received: by mail-pl1-x62e.google.com with SMTP id 60-v6so1565792ple.0 for ; Tue, 28 Aug 2018 18:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Gq0M0pkRAcNtrkH0yiXQLpLoAabh6Wk6cV9b3RZbOF0=; b=X7TOX9vtPZGfIpJeH/XpijS22i8EuRziJSpGJ15/fvto7rYsNFUiYos9NhxvfrhJgf JNXTAr1fvvyexEelprMFiyWX6VSu0Cau3c/dHI7JE4ikJtW956/RTpaU5GNA0jEpxize 55n3ufiDvqlOyGLgP57EGn3iCy63eFoYTLk9zX2cbhkFdRUUxsbZ00Eqv+iPeKwzdwi2 fryUVWJ1PR5WDGHadAUcuMKdGRjNQfDH1uerpZW0UXQU/VbQJ4B+EyeYZkgKka4FkD/t i4b0NU5ib9E1ErFIELxRJquV1yVbKgHcdkLUPbVgfNau0JfPROvYHNbp8qdA8CU7wqZJ prHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Gq0M0pkRAcNtrkH0yiXQLpLoAabh6Wk6cV9b3RZbOF0=; b=eRQ1E8Fey/Vlv1jHkmvOSoL0eCa4iylx+M4lFy9UBfSnii6LVLdn81AjIWWvc+6sVN 8QdyxbYSUpbFl+cD5L9qSJNmCS+RlCdi5RGdBg7eUeXFBbMQzxR/2zWxL5TCYBAI1ONH XPJMa+sh8LHkRBCnpn8gSu6CODYp7Nh8r//27lPJlrQcGAvdzdLbVImXVCKTJk0YHr0M L5YO9qLVvl+oa1upHwVLLlgiceewol64rkyKH395Pf6NGkd9Z/gG23PvnP90wbAsN0bO DZioqijibUta7kZWR+w1JvuqRezIqYX3uezoJsPBNUZlUDb1Bw+TSnZpyX3xmPCpWjL5 nBSA== X-Gm-Message-State: APzg51DZnbLVb1W1plz1WjHWGVc5AlcGKJ6QJBLdIjeDQ7+iIP/MyYhV zqCwslN29l27ArfHnRRt6PmOkMAU X-Google-Smtp-Source: ANB0VdbIRLoEgvVH6fEP60VZ7ViI711M19klJZzplecJZno/9LPTHrhT4vtiQdYJJ8UEdy0nGnEgWA== X-Received: by 2002:a17:902:7587:: with SMTP id j7-v6mr3947962pll.256.1535507500341; Tue, 28 Aug 2018 18:51:40 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:39 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:45 +1000 Message-Id: <20180829015047.7355-18-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 17/19] pdbg/gdbserver: Detach from client X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/gdb_parser.rl | 5 ++++- src/pdbgproxy.c | 9 +++++++++ src/pdbgproxy.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gdb_parser.rl b/src/gdb_parser.rl index 18dfac7..6259b96 100644 --- a/src/gdb_parser.rl +++ b/src/gdb_parser.rl @@ -76,6 +76,9 @@ set_thread = ('H' any* @{cmd = SET_THREAD;}); + disconnect = ('D' @{cmd = DISCONNECT;} + xdigit+ $hex_digit %push); + # TODO: We don't actually listen to what's supported q_attached = ('qAttached:' xdigit* @{rsp = "1";}); q_C = ('qC' @{rsp = "QC1";}); @@ -91,7 +94,7 @@ commands = (get_mem | get_gprs | get_spr | stop_reason | set_thread | q_attached | q_C | q_supported | qf_threadinfo | q_C | - v_contq | v_contc | v_conts | put_mem ); + v_contq | v_contc | v_conts | put_mem | disconnect ); cmd = ((commands & ^'#'*) | ^'#'*) $crc ('#' xdigit{2} $hex_digit @end); diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index ac0b3ae..eb7c0ae 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -36,6 +36,8 @@ static int fd = -1; enum client_state {IDLE, SIGNAL_WAIT}; static enum client_state state = IDLE; +static void destroy_client(int dead_fd); + static uint8_t gdbcrc(char *data) { uint8_t crc = 0; @@ -80,6 +82,12 @@ static void stop_reason(uint64_t *stack, void *priv) send_response(fd, "S05"); } +static void disconnect(uint64_t *stack, void *priv) +{ + printf("Terminating connection with client. pid %16" PRIi64 "\n", stack[0]); + send_response(fd, "OK"); +} + /* 32 registers represented as 16 char hex numbers with null-termination */ #define REG_DATA_SIZE (32*16+1) static void get_gprs(uint64_t *stack, void *priv) @@ -413,6 +421,7 @@ command_cb callbacks[LAST_CMD + 1] = { v_conts, put_mem, interrupt, + disconnect, NULL}; int gdbserver_start(struct pdbg_target *target, uint16_t port) diff --git a/src/pdbgproxy.h b/src/pdbgproxy.h index bd12b5e..1fe67f2 100644 --- a/src/pdbgproxy.h +++ b/src/pdbgproxy.h @@ -3,7 +3,7 @@ enum gdb_command {NONE, GET_GPRS, GET_SPR, GET_MEM, STOP_REASON, SET_THREAD, V_CONTC, V_CONTS, - PUT_MEM, INTERRUPT, LAST_CMD}; + PUT_MEM, INTERRUPT, DISCONNECT, LAST_CMD}; typedef void (*command_cb)(uint64_t *stack, void *priv); void parser_init(command_cb *callbacks);