From patchwork Mon Apr 30 12:37:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Muldoon X-Patchwork-Id: 27033 Received: (qmail 53617 invoked by alias); 30 Apr 2018 12:37:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 53606 invoked by uid 89); 30 Apr 2018 12:37:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=qualified, older X-HELO: mail-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Apr 2018 12:37:40 +0000 Received: by mail-wm0-f51.google.com with SMTP id f8so3450700wmc.4 for ; Mon, 30 Apr 2018 05:37:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=EnfTUT5bCsBJOfwjOPeXMwxMlEVCY8kWvOJOfn2gcuY=; b=X43W9I5hD2qJMRIy4ZyvIad+uc7YoeW4pejgX4YCM/c2kIq/mixY0co4zoLrLZ47fg 9NgzAbHd3Bkw0mFgxHbyEIX2V4ZuZe+O29Zds/dCGW4nM9mBERwE0Xa0/N8bhSMRQJ5M sqXivmYxU3gwTElFG5cMltKHPqNNe7Xu2HTBsoyOWygqgoHnntKXW8DdiQ978fP+b5rV 9zwSs6/uVqtmBaOe0+RSYYROIiQwrFxUe7H9/CM8o/tit/ko1L2DSMc9Bwo+E/ua+5NH v8W+x6QgGbAcFKRiTSGya6i+/KUWWCItmUNEoxwHV7aJjTk6DQxUOW1DIsVyjmvNYsrk jYSw== X-Gm-Message-State: ALQs6tALoiOYO2zR66tWKTWovPggafkxmfeDt8/E8Qd9Z306gDceVL63 s8ZaE+889+2Fbia1jMtyYcL/co9pgfs= X-Google-Smtp-Source: AB8JxZr4XlTGq6EhtecsJT6EIevRXxrUYvQuXzg585WLUeAvTmH1AYUkRzsuDn8wnNkT++cZlQtNcA== X-Received: by 10.28.35.72 with SMTP id j69mr7269990wmj.45.1525091857936; Mon, 30 Apr 2018 05:37:37 -0700 (PDT) Received: from ?IPv6:2a02:c7f:ae6a:ed00:4685:ff:fe66:9f4? ([2a02:c7f:ae6a:ed00:4685:ff:fe66:9f4]) by smtp.gmail.com with ESMTPSA id d9-v6sm1092978wrn.71.2018.04.30.05.37.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Apr 2018 05:37:37 -0700 (PDT) Subject: Re: [python][patch] PR python/19151 Hardware breakpoints in GDB Python. From: Phil Muldoon To: "gdb-patches@sourceware.org" References: <12c35b5f-aa8d-17b3-476d-2fbf4eb3587d@redhat.com> Message-ID: <68969e58-85d9-5cb7-d2a5-14930d08f799@redhat.com> Date: Mon, 30 Apr 2018 13:37:36 +0100 MIME-Version: 1.0 In-Reply-To: <12c35b5f-aa8d-17b3-476d-2fbf4eb3587d@redhat.com> X-IsSubscribed: yes On 30/04/18 12:46, Phil Muldoon wrote: > > This patch adds hardware breakpoint support for code based breakpoints > to the Python API. > > Cheers, My apologies but I mistakenly applied this patch to a much older version of GDB HEAD (I did not realize the git pull master had failed.) The following patch is the correct patch and has been re-flowed and adjusted to current HEAD. 2018-04-30 Phil Muldoon PR python/19151 * python/py-breakpoint.c: Add hardware breakpoint constant gdb.BP_HARDWARE_BREAKPOINT. (bppy_init): Add bp_hardware_breakpoint case. Use the enum bptype variable 2018-04-30 Phil Muldoon * gdb.python/py-breakpoint.exp: Call test_hardware_breakpoints. (test_hardware_breakpoints): New function. 2018-04-30 Phil Muldoon * python.texi (Breakpoints In Python): Mention gdb.BP_HARDWARE_BREAKPOINT. diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index ebd48fffe7..dd1fd101f1 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -4937,6 +4937,10 @@ module: @item gdb.BP_BREAKPOINT Normal code breakpoint. +@vindex BP_BREAKPOINT +@item gdb.BP_HARDWARE_BREAKPOINT +Hardware assisted code breakpoint. + @vindex BP_WATCHPOINT @item gdb.BP_WATCHPOINT Watchpoint breakpoint. diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index d654b92a8c..049d8d6d11 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -58,6 +58,7 @@ static struct pybp_code pybp_codes[] = { { "BP_NONE", bp_none}, { "BP_BREAKPOINT", bp_breakpoint}, + { "BP_HARDWARE_BREAKPOINT", bp_hardware_breakpoint}, { "BP_WATCHPOINT", bp_watchpoint}, { "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint}, { "BP_READ_WATCHPOINT", bp_read_watchpoint}, @@ -759,6 +760,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) switch (type) { case bp_breakpoint: + case bp_hardware_breakpoint: { event_location_up location; symbol_name_match_type func_name_match_type @@ -797,7 +799,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) create_breakpoint (python_gdbarch, location.get (), NULL, -1, NULL, 0, - temporary_bp, bp_breakpoint, + temporary_bp, type, 0, AUTO_BOOLEAN_TRUE, &bkpt_breakpoint_ops, @@ -972,6 +974,7 @@ gdbpy_breakpoint_created (struct breakpoint *bp) return; if (bp->type != bp_breakpoint + && bp->type != bp_hardware_breakpoint && bp->type != bp_watchpoint && bp->type != bp_hardware_watchpoint && bp->type != bp_read_watchpoint diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index 6e0ff88f87..156dcbfa9a 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -681,6 +681,33 @@ proc_with_prefix test_bkpt_qualified {} { "-q in spec string and qualified false" } +# Test hardware assisted breakpoints +proc_with_prefix test_hardware_breakpoints { } { + global srcfile testfile decimal + + # Start with a fresh gdb. + clean_restart ${testfile} + + if {[skip_hw_breakpoint_tests]} { + unsupported "Hardware breakpoints." + } + + if ![runto_main] then { + fail "cannot run to main." + return 0 + } + + set hardware_location [gdb_get_line_number "Break at multiply."] + gdb_test "python hbp = gdb.Breakpoint (\"$hardware_location\", type=gdb.BP_HARDWARE_BREAKPOINT)" \ + ".*Hardware assisted breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\." \ + "Set hardware breakpoint" + gdb_continue_to_breakpoint "Break at multiply." \ + ".*$srcfile:$hardware_location.*" + gdb_test "info breakpoints" \ + "2.*hw breakpoint.*$srcfile:$hardware_location.*" \ + "Check info breakpoints shows a hardware breakpoint" +} + test_bkpt_basic test_bkpt_deletion test_bkpt_cond_and_cmds @@ -694,3 +721,4 @@ test_bkpt_pending test_bkpt_events test_bkpt_explicit_loc test_bkpt_qualified +test_hardware_breakpoints