* [PATCH] Add Python support for hardware breakpoints
[not found] <20210102131345.231-1-ssbssa.ref@yahoo.de>
@ 2021-01-02 13:13 ` Hannes Domani
2021-01-02 13:32 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Hannes Domani @ 2021-01-02 13:13 UTC (permalink / raw)
To: gdb-patches
This allows the creation of hardware breakpoints in Python with
gdb.Breakpoint(type=gdb.BP_HARDWARE_BREAKPOINT)
And they are included in the sequence returned by gdb.breakpoints().
gdb/ChangeLog:
2021-01-02 Hannes Domani <ssbssa@yahoo.de>
* python/py-breakpoint.c (bppy_get_location): Handle
bp_hardware_breakpoint.
(bppy_init): Likewise.
(gdbpy_breakpoint_created): Likewise.
gdb/doc/ChangeLog:
2021-01-02 Hannes Domani <ssbssa@yahoo.de>
* python.texi (Breakpoints In Python): Document
gdb.BP_HARDWARE_BREAKPOINT.
gdb/testsuite/ChangeLog:
2021-01-02 Hannes Domani <ssbssa@yahoo.de>
* gdb.python/py-breakpoint.exp: Add tests for hardware breakpoints.
---
gdb/doc/python.texi | 4 ++++
gdb/python/py-breakpoint.c | 8 ++++++--
gdb/testsuite/gdb.python/py-breakpoint.exp | 24 ++++++++++++++++++++++
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index afa9c9c0c88..862e248cb4a 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -5406,6 +5406,10 @@ module:
@item gdb.BP_BREAKPOINT
Normal code breakpoint.
+@vindex BP_HARDWARE_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 9f6ae96266f..3fbb1c633ff 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},
@@ -383,7 +384,8 @@ bppy_get_location (PyObject *self, void *closure)
BPPY_REQUIRE_VALID (obj);
- if (obj->bp->type != bp_breakpoint)
+ if (obj->bp->type != bp_breakpoint
+ && obj->bp->type != bp_hardware_breakpoint)
Py_RETURN_NONE;
const char *str = event_location_to_string (obj->bp->location.get ());
@@ -793,6 +795,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
@@ -834,7 +837,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,
ops,
@@ -1008,6 +1011,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 3c06a89856e..64a70abb126 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -252,6 +252,29 @@ proc_with_prefix test_bkpt_invisible { } {
"Check maint info breakpoints shows invisible breakpoints"
}
+proc_with_prefix test_hardware_breakpoints { } {
+ global srcfile testfile hex decimal
+
+ # Start with a fresh gdb.
+ clean_restart ${testfile}
+
+ if ![runto_main] then {
+ fail "cannot run to main."
+ return 0
+ }
+
+ delete_breakpoints
+
+ gdb_test "python hbp1 = gdb.Breakpoint(\"add\", type=gdb.BP_HARDWARE_BREAKPOINT)" \
+ ".*Hardware assisted breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\." \
+ "Set hardware breakpoint"
+ gdb_test "python print (gdb.breakpoints()\[0\].type == gdb.BP_HARDWARE_BREAKPOINT)" \
+ "True" "Check hardware breakpoint type"
+ gdb_test "continue" \
+ ".*Breakpoint ($decimal)+, add.*" \
+ "Test hardware breakpoint stop"
+}
+
proc_with_prefix test_watchpoints { } {
global srcfile testfile hex decimal
@@ -718,6 +741,7 @@ test_bkpt_basic
test_bkpt_deletion
test_bkpt_cond_and_cmds
test_bkpt_invisible
+test_hardware_breakpoints
test_watchpoints
test_bkpt_internal
test_bkpt_eval_funcs
--
2.29.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add Python support for hardware breakpoints
2021-01-02 13:13 ` [PATCH] Add Python support for hardware breakpoints Hannes Domani
@ 2021-01-02 13:32 ` Eli Zaretskii
2021-01-16 15:05 ` Hannes Domani
2021-01-20 18:58 ` Tom Tromey
2 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2021-01-02 13:32 UTC (permalink / raw)
To: Hannes Domani; +Cc: gdb-patches
> Date: Sat, 2 Jan 2021 14:13:45 +0100
> From: Hannes Domani via Gdb-patches <gdb-patches@sourceware.org>
>
> This allows the creation of hardware breakpoints in Python with
> gdb.Breakpoint(type=gdb.BP_HARDWARE_BREAKPOINT)
> And they are included in the sequence returned by gdb.breakpoints().
>
> gdb/ChangeLog:
>
> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
>
> * python/py-breakpoint.c (bppy_get_location): Handle
> bp_hardware_breakpoint.
> (bppy_init): Likewise.
> (gdbpy_breakpoint_created): Likewise.
>
> gdb/doc/ChangeLog:
>
> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
>
> * python.texi (Breakpoints In Python): Document
> gdb.BP_HARDWARE_BREAKPOINT.
>
> gdb/testsuite/ChangeLog:
>
> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
>
> * gdb.python/py-breakpoint.exp: Add tests for hardware breakpoints.
Thanks, the documentation part is OK.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add Python support for hardware breakpoints
2021-01-02 13:13 ` [PATCH] Add Python support for hardware breakpoints Hannes Domani
2021-01-02 13:32 ` Eli Zaretskii
@ 2021-01-16 15:05 ` Hannes Domani
2021-01-20 18:58 ` Tom Tromey
2 siblings, 0 replies; 5+ messages in thread
From: Hannes Domani @ 2021-01-16 15:05 UTC (permalink / raw)
To: gdb-patches
Ping.
Also, I've found that a PR exists for this:
https://sourceware.org/bugzilla/show_bug.cgi?id=19151
So I've locally added it to the ChangeLog entries:
2021-01-02 Hannes Domani <ssbssa@yahoo.de>
PR python/19151
* python/py-breakpoint.c (bppy_get_location): Handle
bp_hardware_breakpoint.
(bppy_init): Likewise.
(gdbpy_breakpoint_created): Likewise.
gdb/doc/ChangeLog:
2021-01-02 Hannes Domani <ssbssa@yahoo.de>
PR python/19151
* python.texi (Breakpoints In Python): Document
gdb.BP_HARDWARE_BREAKPOINT.
gdb/testsuite/ChangeLog:
2021-01-02 Hannes Domani <ssbssa@yahoo.de>
PR python/19151
* gdb.python/py-breakpoint.exp: Add tests for hardware breakpoints.
Am Samstag, 2. Januar 2021, 14:14:27 MEZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> This allows the creation of hardware breakpoints in Python with
> gdb.Breakpoint(type=gdb.BP_HARDWARE_BREAKPOINT)
> And they are included in the sequence returned by gdb.breakpoints().
>
> gdb/ChangeLog:
>
> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
>
> * python/py-breakpoint.c (bppy_get_location): Handle
> bp_hardware_breakpoint.
> (bppy_init): Likewise.
> (gdbpy_breakpoint_created): Likewise.
>
> gdb/doc/ChangeLog:
>
> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
>
> * python.texi (Breakpoints In Python): Document
> gdb.BP_HARDWARE_BREAKPOINT.
>
> gdb/testsuite/ChangeLog:
>
> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
>
> * gdb.python/py-breakpoint.exp: Add tests for hardware breakpoints.
> ---
> gdb/doc/python.texi | 4 ++++
> gdb/python/py-breakpoint.c | 8 ++++++--
> gdb/testsuite/gdb.python/py-breakpoint.exp | 24 ++++++++++++++++++++++
> 3 files changed, 34 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> index afa9c9c0c88..862e248cb4a 100644
> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -5406,6 +5406,10 @@ module:
> @item gdb.BP_BREAKPOINT
> Normal code breakpoint.
>
> +@vindex BP_HARDWARE_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 9f6ae96266f..3fbb1c633ff 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},
> @@ -383,7 +384,8 @@ bppy_get_location (PyObject *self, void *closure)
>
> BPPY_REQUIRE_VALID (obj);
>
> - if (obj->bp->type != bp_breakpoint)
> + if (obj->bp->type != bp_breakpoint
> + && obj->bp->type != bp_hardware_breakpoint)
> Py_RETURN_NONE;
>
> const char *str = event_location_to_string (obj->bp->location.get ());
> @@ -793,6 +795,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
> @@ -834,7 +837,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,
> ops,
> @@ -1008,6 +1011,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 3c06a89856e..64a70abb126 100644
> --- a/gdb/testsuite/gdb.python/py-breakpoint.exp
> +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
> @@ -252,6 +252,29 @@ proc_with_prefix test_bkpt_invisible { } {
> "Check maint info breakpoints shows invisible breakpoints"
> }
>
> +proc_with_prefix test_hardware_breakpoints { } {
> + global srcfile testfile hex decimal
> +
> + # Start with a fresh gdb.
> + clean_restart ${testfile}
> +
> + if ![runto_main] then {
> + fail "cannot run to main."
> + return 0
> + }
> +
> + delete_breakpoints
> +
> + gdb_test "python hbp1 = gdb.Breakpoint(\"add\", type=gdb.BP_HARDWARE_BREAKPOINT)" \
> + ".*Hardware assisted breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\." \
> + "Set hardware breakpoint"
> + gdb_test "python print (gdb.breakpoints()\[0\].type == gdb.BP_HARDWARE_BREAKPOINT)" \
> + "True" "Check hardware breakpoint type"
> + gdb_test "continue" \
> + ".*Breakpoint ($decimal)+, add.*" \
> + "Test hardware breakpoint stop"
> +}
> +
> proc_with_prefix test_watchpoints { } {
> global srcfile testfile hex decimal
>
> @@ -718,6 +741,7 @@ test_bkpt_basic
> test_bkpt_deletion
> test_bkpt_cond_and_cmds
> test_bkpt_invisible
> +test_hardware_breakpoints
> test_watchpoints
> test_bkpt_internal
> test_bkpt_eval_funcs
> --
> 2.29.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add Python support for hardware breakpoints
2021-01-02 13:13 ` [PATCH] Add Python support for hardware breakpoints Hannes Domani
2021-01-02 13:32 ` Eli Zaretskii
2021-01-16 15:05 ` Hannes Domani
@ 2021-01-20 18:58 ` Tom Tromey
2021-01-21 17:58 ` Hannes Domani
2 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2021-01-20 18:58 UTC (permalink / raw)
To: Hannes Domani via Gdb-patches
>>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:
Hannes> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
Hannes> * python/py-breakpoint.c (bppy_get_location): Handle
Hannes> bp_hardware_breakpoint.
Hannes> (bppy_init): Likewise.
Hannes> (gdbpy_breakpoint_created): Likewise.
Hannes> gdb/doc/ChangeLog:
Hannes> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
Hannes> * python.texi (Breakpoints In Python): Document
Hannes> gdb.BP_HARDWARE_BREAKPOINT.
Hannes> gdb/testsuite/ChangeLog:
Hannes> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
Hannes> * gdb.python/py-breakpoint.exp: Add tests for hardware breakpoints.
Thank you for the patch.
This is ok.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add Python support for hardware breakpoints
2021-01-20 18:58 ` Tom Tromey
@ 2021-01-21 17:58 ` Hannes Domani
0 siblings, 0 replies; 5+ messages in thread
From: Hannes Domani @ 2021-01-21 17:58 UTC (permalink / raw)
To: Hannes Domani via Gdb-patches, Tom Tromey
Am Mittwoch, 20. Januar 2021, 19:58:32 MEZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben:
> >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Hannes> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
>
> Hannes> * python/py-breakpoint.c (bppy_get_location): Handle
> Hannes> bp_hardware_breakpoint.
> Hannes> (bppy_init): Likewise.
> Hannes> (gdbpy_breakpoint_created): Likewise.
>
> Hannes> gdb/doc/ChangeLog:
>
> Hannes> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
>
> Hannes> * python.texi (Breakpoints In Python): Document
> Hannes> gdb.BP_HARDWARE_BREAKPOINT.
>
> Hannes> gdb/testsuite/ChangeLog:
>
> Hannes> 2021-01-02 Hannes Domani <ssbssa@yahoo.de>
>
> Hannes> * gdb.python/py-breakpoint.exp: Add tests for hardware breakpoints.
>
> Thank you for the patch.
> This is ok.
Pushed, thanks.
Hannes
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-21 17:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20210102131345.231-1-ssbssa.ref@yahoo.de>
2021-01-02 13:13 ` [PATCH] Add Python support for hardware breakpoints Hannes Domani
2021-01-02 13:32 ` Eli Zaretskii
2021-01-16 15:05 ` Hannes Domani
2021-01-20 18:58 ` Tom Tromey
2021-01-21 17:58 ` Hannes Domani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).