From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id BCC06383580D for ; Wed, 12 May 2021 13:05:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BCC06383580D 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-x435.google.com with SMTP id t18so23561124wry.1 for ; Wed, 12 May 2021 06:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5dnhQxXNv+KMd3hrHMjIc9MfxZcVszL6ttJlj2KQH7E=; b=NNAI5EGdvBvZEMrE9ljiC5N6feumjlZ1t8VJUBU5Tk+2gFla6Nd61Rvf3mQoLsmkHf 2WvOoZK6arf1xpPoZHGvJXzyittXg472WbQbgZR9KNqLW0QRn00HroJeDeShKLusan+u SFSQHeFYNMRLH0Fmh8iC4txpW3g+2oXd1N9id/39bGW3hKL+ZkcgOURsuqbKier0a+Yc 2urr8Ls1NPvH/wbMZSpMRlAMmR1ChisTuxTddBDgyUTRuqCoIS1GmILddtG0lwCo9zSc 0OQpNFrNI/6g3gB4M+NQLyOXt1tAI5YzXZmq4+jNwAbKVql2c3+dw7l1W8a2OWecgdV4 THUg== 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:mime-version:content-transfer-encoding; bh=5dnhQxXNv+KMd3hrHMjIc9MfxZcVszL6ttJlj2KQH7E=; b=NWUfiePXhYBshVHcNR13V5baY6KTnfSxeom1zWo0cbCmJoJGa7pm9Ql3C9X7sONvgd ZLxy1hHkwMt954AALjDlQXyAyFt6oFUcX3G/Ejt0mkL61p6SplX4s26fuhTTEsNM4dr0 SVeRxqhO8QMmIbB0Yix2UoqM99t83bxfKFm9Xc2ljtCw7LrtXn5FfE4xjaGnjJC3LlOH aYPSmsPVE5Jx3OlA5RQpV1htcHO0ksGOK3wXwEAjdzoyHI4ZKoXvVbQPFUgMeY7s2JRl FKPv/GRKp2261TM/q3YC6yO5SJvy0J8OEz3NjE5WUhKshTwAGq4Fn1cSGsNK8pOALHAp Zc4g== X-Gm-Message-State: AOAM533TaJe5tPuaj5sKSpm5x7cWv8Avkls0GN4wc+l2j3mQlZkcGVpt CREGkAjjuAK6Kwc17CHAHD/A8r+VxdS8SQ== X-Google-Smtp-Source: ABdhPJyrmDnpJC5CAHFFv73EL1PPDM6B13/LKxs3tQIFhjfLZYjycKPDlM2IclGxSB3ZXJPVjSbfKw== X-Received: by 2002:adf:e404:: with SMTP id g4mr45226029wrm.240.1620824704279; Wed, 12 May 2021 06:05:04 -0700 (PDT) Received: from localhost (host109-151-46-70.range109-151.btcentralplus.com. [109.151.46.70]) by smtp.gmail.com with ESMTPSA id a15sm29713923wrr.53.2021.05.12.06.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 06:05:03 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PATCH 1/3] gdb/guile: improve the errors when creating breakpoints Date: Wed, 12 May 2021 14:04:58 +0100 Message-Id: <02e07191078f56dee2c817ba2c9073a84eb83098.1620824610.git.andrew.burgess@embecosm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 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: Wed, 12 May 2021 13:05:08 -0000 When creating a breakpoint using the guile API, if an invalid breakpoint type number was used then the error would report the wrong argument position, like this: (gdb) guile (define wp2 (make-breakpoint "result" #:wp-class WP_WRITE #:type 999)) ERROR: In procedure make-breakpoint: ERROR: In procedure gdbscm_make_breakpoint: Out of range: invalid breakpoint type in position 3: 999 Error while executing Scheme code. (gdb) The 'position 3' here is actually pointing at WP_WRITE, when it should say 'position 5' and point to the 999. This commit fixes this. However, you also get errors like this: (gdb) guile (define wp2 (make-breakpoint "result" #:wp-class WP_WRITE #:type BP_NONE)) ERROR: In procedure make-breakpoint: ERROR: In procedure gdbscm_make_breakpoint: Out of range: invalid breakpoint type in position 3: 0 Error while executing Scheme code. The BP_NONE is a valid breakpoint type, it's just not valid for creating breakpoints through the 'make-breakpoint' API. The use of '0' in the error message (which is the value of BP_NONE) is not great. This commit changes the error in this case to: (gdb) guile (define wp2 (make-breakpoint "result" #:wp-class WP_WRITE #:type BP_NONE)) ERROR: In procedure make-breakpoint: ERROR: In procedure gdbscm_make_breakpoint: unsupported breakpoint type in position 5: "BP_NONE" Error while executing Scheme code. Which seems better; we now use the name of the type, and report that this type is unsupported. gdb/ChangeLog: * guile/scm-breakpoint.c (gdbscm_make_breakpoint): Split the error for invalid breakpoint numbers, and unsupported breakpoint numbers. gdb/testsuite/ChangeLog: * gdb.guile/scm-breakpoint.exp (test_watchpoints): Add new tests. --- gdb/ChangeLog | 6 ++++++ gdb/guile/scm-breakpoint.c | 13 ++++++++++++- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.guile/scm-breakpoint.exp | 7 +++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c index 826dfa9b0a3..cf613775e44 100644 --- a/gdb/guile/scm-breakpoint.c +++ b/gdb/guile/scm-breakpoint.c @@ -387,8 +387,19 @@ gdbscm_make_breakpoint (SCM location_scm, SCM rest) _("invalid watchpoint class")); } break; + case bp_none: + case bp_hardware_watchpoint: + case bp_read_watchpoint: + case bp_access_watchpoint: + { + const char *type_name = bpscm_type_to_string (type); + gdbscm_misc_error (FUNC_NAME, type_arg_pos, + gdbscm_scm_from_c_string (type_name), + _("unsupported breakpoint type")); + } + break; default: - gdbscm_out_of_range_error (FUNC_NAME, access_type_arg_pos, + gdbscm_out_of_range_error (FUNC_NAME, type_arg_pos, scm_from_int (type), _("invalid breakpoint type")); } diff --git a/gdb/testsuite/gdb.guile/scm-breakpoint.exp b/gdb/testsuite/gdb.guile/scm-breakpoint.exp index 56058942e64..0e9e64ed4ae 100644 --- a/gdb/testsuite/gdb.guile/scm-breakpoint.exp +++ b/gdb/testsuite/gdb.guile/scm-breakpoint.exp @@ -258,6 +258,13 @@ proc_with_prefix test_watchpoints { } { gdb_test "continue" \ ".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*main.*" \ "test watchpoint write" + + gdb_test "guile (define wp2 (make-breakpoint \"result\" #:wp-class WP_WRITE #:type 999))" \ + "ERROR: In procedure gdbscm_make_breakpoint: Out of range: invalid breakpoint type in position 5: 999\r\n.*" \ + "create a breakpoint with an invalid type number" + gdb_test "guile (define wp2 (make-breakpoint \"result\" #:wp-class WP_WRITE #:type BP_NONE))" \ + "ERROR: In procedure gdbscm_make_breakpoint: unsupported breakpoint type in position 5: \"BP_NONE\"\r\n.*" \ + "create a breakpoint with an unsupported type" } proc_with_prefix test_bkpt_internal { } { -- 2.25.4