From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by sourceware.org (Postfix) with ESMTPS id ED59D3858002 for ; Mon, 2 Nov 2020 09:48:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ED59D3858002 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x442.google.com with SMTP id y12so13772393wrp.6 for ; Mon, 02 Nov 2020 01:48:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yFMADMgAIuRjpaWaHv2UndmS0R+b+BIZ2N9Js9Gzn5Y=; b=UcXp9JhuLNblmL9IXmLXmkIGCLBXVJHKoalb0roGQGeFYA/BtGqzVr9xm56JvBc8BB vdeBqf1yyw6ayUFOZ/Xe1c4XeAOrsf5mHzAasOEUZw5KiDEJHKr0ADpwbAFAupCjdgGA lxzb1JtCBR76jIj5JzvpkfbpnexVjSKxvz0+7CHb/bOTbafmr78C+E+lGQ7VkUhwCc9z T3Kk0/V7oqvMSvy8o1B8E3o1+lTWwgVTSN5J/E5hDQpyAsFXzAtwx+YqH5SkUnm7E31D zk0T4a/cHcZ9GflZDHBLD7Te1fIzl1cZtYlYLVAgW10RuoL8Qgg0rVQDLRrUkf7bw5jj MBEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yFMADMgAIuRjpaWaHv2UndmS0R+b+BIZ2N9Js9Gzn5Y=; b=AgT60IyOJelEXqogqO/11LPNfbbGqTWMXLAmA0fu1fEaB212bI4WemzoPYp53Rv8hf RE9aLUOhQ5zJ2fqDTRZxWA/3p5OK1881ZRuXBwjOHF6JWgXSI+USDVb23OflDCsE8OkE y974x3EcQQyk4uucs5nka1jtWIDRUL5QyoiCLUZMUfNcV2XpPSNIAeZgsHln9HPTX8Tw Mewft0zaV09s3Kf9YpcJOZe7+ex4AvZB1jY3vDwZONtvJb3ijDkTYJxyT0HkjFpXgynO YFuCg9zb318r0wQgrDImBMDcnhy3y8t+kDx4N3/yee2YfZEw57u7mbEPqfXrUZfYdwDC gqhw== X-Gm-Message-State: AOAM533x7P8qM7PwE4bfDdq/js6etBE7s2hlLxnGPcSlmV+cHywv+h+R G8mW7JkjcJsEaxal8vAIm/8ZOA== X-Google-Smtp-Source: ABdhPJwVLnc1X4G1qd5VL5St1ES0xg7M/9GJPperZEgcVlwCgCGAzOOYpo5daQsYG7mJj71MY+NfIA== X-Received: by 2002:adf:9d81:: with SMTP id p1mr18486234wre.13.1604310520057; Mon, 02 Nov 2020 01:48:40 -0800 (PST) Received: from localhost (host109-154-163-49.range109-154.btcentralplus.com. [109.154.163.49]) by smtp.gmail.com with ESMTPSA id w7sm22756753wre.9.2020.11.02.01.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 01:48:39 -0800 (PST) Date: Mon, 2 Nov 2020 09:48:38 +0000 From: Andrew Burgess To: "Aktemur, Tankut Baris" Cc: "gdb-patches@sourceware.org" , Tom Tromey Subject: Re: [PATCH 3/7] gdb: new function to wrap up executing command line scripts/commands Message-ID: <20201102094838.GE2729@embecosm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux/5.8.13-100.fc31.x86_64 (x86_64) X-Uptime: 09:45:34 up 8 days, 48 min, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Nov 2020 09:48:42 -0000 * Aktemur, Tankut Baris [2020-10-08 15:25:25 +0000]: > On Wednesday, October 7, 2020 10:05 PM, Andrew Burgess wrote: > > Small refactor to wrap up executing the scripts and commands passed > > using the -x, -ex, -ix, -iex command line flags. > > > > There should be no user visible changes after this commit. > > > > gdb/ChangeLog: > > > > * main.c (execute_cmdargs): New function. > > (captured_main_1): Make use of execute_cmdargs. > > --- > > gdb/ChangeLog | 5 +++++ > > gdb/main.c | 53 ++++++++++++++++++++------------------------------- > > 2 files changed, 26 insertions(+), 32 deletions(-) > > > > diff --git a/gdb/main.c b/gdb/main.c > > index f6377f2df28..f85b7dbfdaa 100644 > > --- a/gdb/main.c > > +++ b/gdb/main.c > > @@ -515,6 +515,25 @@ struct cmdarg > > char *string; > > }; > > > > +/* From CMDARG_VEC execute command files (matching FILE_TYPE) or commands > > + (matching CMD_TYPE). Update the value in *RET. */ > > Is there any particular reason to have the output parameter? The function could have > returned its result instead of writing it to *ret, right? > > > +static void > > +execute_cmdargs (const std::vector *cmdarg_vec, > > + cmdarg_kind file_type, cmdarg_kind cmd_type, > > + int *ret) > > +{ > > + for (const auto &cmdarg_p : *cmdarg_vec) > > + { > > + if (cmdarg_p.type == file_type) > > + *ret = catch_command_errors (source_script, cmdarg_p.string, > > + !batch_flag); > > + else if (cmdarg_p.type == cmd_type) > > + *ret = catch_command_errors (execute_command, cmdarg_p.string, > > + !batch_flag); > > + } > > Well, it's the original code that was doing it, but I found it a bit odd that > ret is being overwritten without checking the value until almost the very end > of captured_main_1. I find this odd too, but the last thing I wanted to do was combine a change in behaviour with a restructuring, so I left things as they were. I'll update the comment on the function to (hopefully) document the existing (odd) behaviour a little better. Thanks, Andrew