From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id BGNqEduzLGF2aAAAWB0awg (envelope-from ) for ; Mon, 30 Aug 2021 06:32:59 -0400 Received: by simark.ca (Postfix, from userid 112) id 1B22D1EE1C; Mon, 30 Aug 2021 06:32:59 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 simark.ca (Postfix) with ESMTPS id 266E11E813 for ; Mon, 30 Aug 2021 06:32:56 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B02DD385743B for ; Mon, 30 Aug 2021 10:32:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B02DD385743B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1630319575; bh=+CghYbcYA47O3Z7BDMYUPt0Eb0Gnr5YOWIFCiHJMbjU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=XUV7V5HtTN8FiPTKXCmuQtWHkKrv7we5FzeHoKVal6WS5e9RCmFK6XA27EyV6UD9R pd1s0XO9HKUS87RFFbu5CWUvkE4R0jY25SQnMk8AVVExKcHRpgtd6f059fBGHdCPVo wn/ETwHOZCBYeOMaxlzhT9qVsW6o8zo/5jMZ4u04= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id D47B43858D35 for ; Mon, 30 Aug 2021 10:32:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D47B43858D35 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1C79521BAC for ; Mon, 30 Aug 2021 10:32:27 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 0B72A1365C for ; Mon, 30 Aug 2021 10:32:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id lPLPAbuzLGEYRwAAGKfGzw (envelope-from ) for ; Mon, 30 Aug 2021 10:32:27 +0000 Date: Mon, 30 Aug 2021 12:32:25 +0200 To: gdb-patches@sourceware.org Subject: [PATCH, master + 11][gdb/cli] Don't assert on empty string for core-file Message-ID: <20210830103223.GA1126@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, With current gdb we run into: ... $ gdb -batch '' '' : No such file or directory. pathstuff.cc:132: internal-error: \ gdb::unique_xmalloc_ptr gdb_abspath(const char*): \ Assertion `path != NULL && path[0] != '\0'' failed. ... Fix this by skipping the call to gdb_abspath in core_target_open in the empty-string case, such that we have instead: ... $ gdb -batch '' '' : No such file or directory. : No such file or directory. $ ... Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/cli] Don't assert on empty string for core-file gdb/ChangeLog: 2021-08-30 Tom de Vries PR cli/28290 * gdb/corelow.c (core_target_open): Skip call to gdb_abspath in the empty-string case. gdb/testsuite/ChangeLog: 2021-08-30 Tom de Vries PR cli/28290 * gdb.base/batch-exit-status.exp: Add gdb '' and gdb '' '' tests. --- gdb/corelow.c | 3 ++- gdb/testsuite/gdb.base/batch-exit-status.exp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/corelow.c b/gdb/corelow.c index eb785a08633..711e86c4cd4 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -428,7 +428,8 @@ core_target_open (const char *arg, int from_tty) } gdb::unique_xmalloc_ptr filename (tilde_expand (arg)); - if (!IS_ABSOLUTE_PATH (filename.get ())) + if (strlen (filename.get ()) != 0 + && !IS_ABSOLUTE_PATH (filename.get ())) filename = gdb_abspath (filename.get ()); flags = O_BINARY | O_LARGEFILE; diff --git a/gdb/testsuite/gdb.base/batch-exit-status.exp b/gdb/testsuite/gdb.base/batch-exit-status.exp index 085dfc6ad56..9a080196bd6 100644 --- a/gdb/testsuite/gdb.base/batch-exit-status.exp +++ b/gdb/testsuite/gdb.base/batch-exit-status.exp @@ -76,3 +76,7 @@ test_exit_status 1 "-batch -x $good_commands -x $bad_commands" \ "-batch -x good-commands -x bad-commands" test_exit_status 1 "-batch -x $good_commands -ex \"set not-a-thing 4\"" \ "-batch -x good-commands -ex \"set not-a-thing 4\"" + +set no_such_re ": No such file or directory\\." +test_exit_status 1 "-batch \"\"" $no_such_re +test_exit_status 1 "-batch \"\" \"\"" [multi_line $no_such_re $no_such_re]