From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by sourceware.org (Postfix) with ESMTPS id 287583889051 for ; Thu, 8 Dec 2022 19:18:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 287583889051 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd2f.google.com with SMTP id r72so833257iod.5 for ; Thu, 08 Dec 2022 11:18:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=30g8RtRxs3tl4FW3/ioANBihsSAP+VJJjuioEo9P0fY=; b=Do73MDOqwPFocDF7hAHwcKdMZZHqi1iaNcTrPynlyaX9BVTw/symAy9UTgr4t3+Rne KBmdj/0XqDBS9b72FeIHzfdwtjnbm/YAwO384IkpcKW9AfNlDhlnfwqX3MmBRS3A43sQ FLWRGmP0rh5VqwB120GcZaZCwTo3cE6rBiVdH84PUtSEX/RICWAeUU+djkDX9zqmSp/6 tQ1OIGyFSjxEw6GGZecM/a6PqJeyMNjq56iPfOFIWN6pPJwp3OzFNBrCVWvUnpFT9RlO ZuPq3QlbWXIaTA/Bbrbvwfp9uGfo16foO7FTjbj8l+ATa49NdQXpHI9fT54rSXidP5mO K/NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=30g8RtRxs3tl4FW3/ioANBihsSAP+VJJjuioEo9P0fY=; b=sCZI5fMZM2qprQ3ABqcY1PtkYQHcIND+mGSRrtk940cdqjL3NiFKdIJhQV0BsIuw8w SZUEh9ZH/SHM/vsdv65zhraAjghF1d/cwDvX0wxo9dNenJ/IHVPqXr1uWl0P64tepYDW i+Cijbcezqod47LmnmtWDwkpfAk1UuHurKGMCbhICTzTtS/lFzno55+5Ahi9Y9z/uMko Fh0BsX+nMcteyOAY52LC4dOGmo3mOzz6FwrvxRurz9XU5FSkRa/mJihAl2LJcFKkI2vZ rr5TFMNoftdXxUgtQo06ScYTh0TMbDD7pvD+vTK4EBkX/DsYkgb0pmzOVedyG4Y/rALu gCQg== X-Gm-Message-State: ANoB5pkT74BqLignL+gbP3DFEaMxD4em6S3ouuJq1VNzYkMU3+jf/Lrw ywkGPkWn8a8JlTr0iNqAXVnraCKK/U46ClxF X-Google-Smtp-Source: AA0mqf5GYtH5Iwut4VfdWyt2hdUcsYZHrvY4GNyUeCS/QSjZSDHOz0DQgpqSKdQ2e7Q+/qGJx6o2Cw== X-Received: by 2002:a02:b691:0:b0:389:af9:4860 with SMTP id i17-20020a02b691000000b003890af94860mr30181877jam.164.1670527095450; Thu, 08 Dec 2022 11:18:15 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id a16-20020a027350000000b0038a08d5ac32sm8422462jae.31.2022.12.08.11.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 11:18:15 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/3] Fix latent bug in Python breakpoint creation Date: Thu, 8 Dec 2022 12:18:03 -0700 Message-Id: <20221208191804.3819129-3-tromey@adacore.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221208191804.3819129-1-tromey@adacore.com> References: <20221208191804.3819129-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: While working on the previous patch, I noticed that Python breakpoint creation does: - = (qualified != NULL && PyObject_IsTrue (qualified) PyObject_IsTrue can fail, so this is missing an error check. This patch adds the missing check. Note that this could probably be improved by using the "p" format in the call to gdb_PyArg_ParseTupleAndKeywords, but that was added in Python 3.3, and I think gdb still supports 3.2. --- gdb/python/py-breakpoint.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 917fd367d06..39d9bd5dff6 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -818,7 +818,7 @@ bppy_init_validate_args (const char *spec, char *source, static void bppy_create_breakpoint (enum bptype type, int access_type, int temporary_bp, int internal_bp, const char *spec, - PyObject *qualified, const char *source, + int qualified, const char *source, const char *function, const char *label, const char *line) { @@ -829,7 +829,7 @@ bppy_create_breakpoint (enum bptype type, int access_type, int temporary_bp, { location_spec_up locspec; symbol_name_match_type func_name_match_type - = (qualified != NULL && PyObject_IsTrue (qualified) + = (qualified ? symbol_name_match_type::FULL : symbol_name_match_type::WILD); @@ -916,14 +916,15 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) char *label = NULL; char *source = NULL; char *function = NULL; - PyObject * qualified = NULL; + PyObject *qualified_obj = nullptr; + int qualified = 0; if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|siiOOsssOO", keywords, &spec, &type, &access_type, &internal, &temporary, &source, &function, &label, &lineobj, - &qualified)) + &qualified_obj)) return -1; @@ -955,6 +956,13 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) return -1; } + if (qualified_obj != nullptr) + { + qualified = PyObject_IsTrue (qualified_obj); + if (qualified == -1) + return -1; + } + if (bppy_init_validate_args (spec, source, function, label, line.get (), type) == -1) return -1; -- 2.34.3