From patchwork Mon Oct 30 16:11:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 78766 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3D699385351E for ; Mon, 30 Oct 2023 16:11:41 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 8E643385C017 for ; Mon, 30 Oct 2023 16:11:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E643385C017 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8E643385C017 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698682285; cv=none; b=SESG/7SOicNc5+Q+1wm2nzwM1Hv6RrPaOcz6+KEKB5tBmbE64ShF7sFWvRhicaV73UzT5orfEmAERM9ozVdkQ6+qacqLp3nuQKuidE8zmHmB2Z6l1BCaStPivNXueZr+7sqPmFKbiw+3I2CNdGVPu89aOZa5+8vcHF2Pl4imgm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698682285; c=relaxed/simple; bh=va7ssJ0kEvn+m9idFlTk7Vn8Kpoi4vmmi8jamoCpwFE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=hCX4Ql85IMZCuAp5nZRRz8PmjBpEOKC2ElkOV8UGvEnZnBNuDwsiwSymhmNxxXl0ZuGCoqp4mIZN+Iq9Sth+gM50Ztby/I3IK84UTQancJvML4L0lZPynQqfwxgBdMFQB/5COShzq13lSIluFjI8ErNWjWQ5INWFolxSnbCQR/0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698682284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xo+1C2v2dQayaZWZWrjeIGjAY1JVIsCRvuAEwARM940=; b=PUU+6oLfuE5iLf7CA/vzq1Xl70FS4FNTEDE3bFGBpuiLnhtiGUaqk7MSP79nV/Oz7kDn0N NYhn62PwOPKmRAZbDaYuH4HpQwmk5MJAsDGoDkU+8Zcsrk5QRJ8eqJXOWZON/ZHloDYmTc hWdtr+SO+v60lGXh0fp4FO/LX38IGEw= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-327-guRmHOCzN2iZu0y7syZOZw-1; Mon, 30 Oct 2023 12:11:23 -0400 X-MC-Unique: guRmHOCzN2iZu0y7syZOZw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9c7558b838aso321544566b.2 for ; Mon, 30 Oct 2023 09:11:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698682282; x=1699287082; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xo+1C2v2dQayaZWZWrjeIGjAY1JVIsCRvuAEwARM940=; b=hLFgdvC7NQD0NZECVpCkVD0OAz40SR8A3zlJlg4YwL/FO+L7W+oZvuY3j50bIupYZB D8gdKe0XdNIWH9Z0QizjMA9IoT6lIm79lT6QbeZ0EZsqJOBAuMgfnNgQRyCJeJ1xc0xd s5NkjI0zGzs0N6BB37cUCYbTg37BxOCkDZfb8y1qkI6UfeO0qRjLjSGeBVND0rI3K2+y TdeBfCZsOOUZsC9IBUYJy6XFiOQhxHS0PHkCmBypgO5lk3AMKdDKJ7hszI11R48EKVDq qhjqCwSjIDUlOjPdH4YU5tyH4emS9T8TOdXzNWUu0k2T/TPyzJQ0hwLg4qU3zqlDX7Xv NM/w== X-Gm-Message-State: AOJu0YxtuGN2EnHJw+jfkKh0g6Q1qYEjNLaI5xgTVCWdRY0xtQz1Bf++ k3Iio/wPOpbaEVnzLS1iaTum5t64kyJyKpcXpcWsz/dmOPx0BCbB5Cxf6Coal+Lwhz0vpbhps6W 3S5o2M9YqN0pIeF4RLWGrdFgLv39viG5aAshagGuLEtfCgFw02bR9QYnp+8VVy+cEnyaJ7wRmwQ aWvdzrdg== X-Received: by 2002:a17:907:9484:b0:9a5:cbb2:3fab with SMTP id dm4-20020a170907948400b009a5cbb23fabmr9390006ejc.2.1698682281847; Mon, 30 Oct 2023 09:11:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+3D/7X6pch5kg8rnpW6bGuWeZTZ9zENYyRni3cU+kGH/pnYci7PX3utMgwAAPu/CpscQTFA== X-Received: by 2002:a17:907:9484:b0:9a5:cbb2:3fab with SMTP id dm4-20020a170907948400b009a5cbb23fabmr9389994ejc.2.1698682281602; Mon, 30 Oct 2023 09:11:21 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id l8-20020a170906a40800b009a168ab6ee2sm6098888ejz.164.2023.10.30.09.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 09:11:21 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv6 03/10] gdb: change 'if' to gdb_assert in update_dprintf_command_list Date: Mon, 30 Oct 2023 16:11:07 +0000 Message-Id: <08dc0143aa7c1729dddb8676e320e3acaac89611.1698682161.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org I noticed in update_dprintf_command_list that we handle the case where the bp_dprintf style breakpoint doesn't have a format and args string. However, I don't believe such a situation is possible. The obvious approach certainly already catches this case: (gdb) dprintf main Format string required If it is possible to create a dprintf breakpoint without a format and args string then I think we should be catching this case and handling it at creation time, rather than having GDB just ignore the situation later on. And so, I propose that we change the 'if' that ignores the case where the format/args string is empty, and instead assert that we do always have a format/args string. The original code, that handled an empty format/args string has existed since commit e7e0cddfb0d4, which is when dprintf support was added to GDB. If I'm correct and this situation can't ever happen then there should be no user visible changes after this commit. --- gdb/breakpoint.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index d87123cb2f1..f7279811e99 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8539,8 +8539,9 @@ update_dprintf_command_list (struct breakpoint *b) const char *dprintf_args = b->extra_string.get (); gdb::unique_xmalloc_ptr printf_line = nullptr; - if (!dprintf_args) - return; + /* Trying to create a dprintf breakpoint without a format and args + string should be detected at creation time. */ + gdb_assert (dprintf_args != nullptr); dprintf_args = skip_spaces (dprintf_args);