This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [python] Allow explicit locations in breakpoints.
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>, Keith Seitz <keiths at redhat dot com>, eliz at gnu dot org, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Fri, 24 Nov 2017 14:06:59 +0000
- Subject: Re: [python] Allow explicit locations in breakpoints.
- Authentication-results: sourceware.org; auth=none
- References: <04ccc2c4-7827-eedc-d8db-a83a0167acb6@redhat.com> <d1899991-db61-b663-7601-86dfa38449a2@redhat.com> <58311250-9ab1-39d1-99b6-07478bc8c2ab@redhat.com> <4768c7ad-cc3d-5702-fa93-40e9760d4ee8@ericsson.com> <c6934b14-6025-5638-6922-2cc3d1ef3a9c@redhat.com> <81f2b22a-ba79-cc7c-ee85-95d2d433a90e@ericsson.com> <1765bb88-8ab0-bdcd-8551-69f8dff3bcb9@redhat.com> <31ad8fb7-0e20-13a5-45d1-c9fa67b76e27@ericsson.com> <a793a568-37a9-26f5-e3ae-37820cb7ddf7@redhat.com> <9e817c74-170d-b7ee-e49b-0287215eab26@ericsson.com>
On 23/11/17 22:17, Simon Marchi wrote:
> On 2017-11-17 06:02 AM, Phil Muldoon wrote:
>
> I would suggest putting the argument validation code in its own function (e.g.
> bppy_init_validate_args), to keep bppy_init of a reasonnable size.
Okay, will do.
> For convenience, I think it would be nice to accept integers for line. So perhaps
> something like this:
>
> From d0e3122bca8b4fcb2d6f303bdc66f68929bdc14f Mon Sep 17 00:00:00 2001
> From: Simon Marchi <simon.marchi@ericsson.com>
> Date: Thu, 23 Nov 2017 16:58:35 -0500
> Subject: [PATCH] suggestion
Yeah good idea. I remember we talked about this, but I must have
forgotten about it. I'll add your patch in.
>> diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
>> index bd138ac3d2..d91e5deb50 100644
>> --- a/gdb/testsuite/gdb.python/py-breakpoint.exp
>> +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
>> @@ -547,6 +547,74 @@ proc test_bkpt_events {} {
>> check_last_event breakpoint_deleted
>> }
>>
>> +proc test_bkpt_explicit_loc {} {
>> + global srcfile testfile
>> +
>> + with_test_prefix test_bkpt_invisible {
>> + # Start with a fresh gdb.
>> + clean_restart ${testfile}
>> +
>> + if ![runto_main] then {
>> + fail "cannot run to main."
>> + return 0
>> + }
>> +
>> + delete_breakpoints
>> +
>> + set bp_location1 [gdb_get_line_number "Break at multiply."]
>> + set bp_location2 [gdb_get_line_number "Break at add."]
>> +
>> + gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (line=\"$bp_location1\")" \
>> + "set explicit breakpoint by line" 0
>> + gdb_continue_to_breakpoint "Break at multiply" \
>> + ".*Break at multiply.*"
>> +
>> + gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (line=\"+1\")" \
>> + "set explicit breakpoint by relative line" 0
>> + gdb_continue_to_breakpoint "Break at add" \
>> + ".*Break at add.*"
>> +
>> + delete_breakpoints
>> + gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (line=\"-1\")" \
>> + "set explicit breakpoint by relative negative line" 0
>> + gdb_continue_to_breakpoint "Break at multiply" \
>> + ".*Break at multiply.*"
>> +
>> + delete_breakpoints
>> + gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (function=\"add\")" \
>> + "set explicit breakpoint by function" 0
>> + gdb_continue_to_breakpoint "Break at function add" \
>> + ".*Break at function add.*"
>> +
>> + delete_breakpoints
>> + gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (source=\"$srcfile\", function=\"add\")" \
>> + "set explicit breakpoint by source file and function" 0
>> + gdb_continue_to_breakpoint "Break at function add" \
>> + ".*Break at function add.*"
>> +
>> + delete_breakpoints
>> + gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (source=\"$srcfile\", line=\"$bp_location2\")" \
>> + "set explicit breakpoint by source file and line number" 0
>> + gdb_continue_to_breakpoint "Break at add" \
>> + ".*Break at add.*"
>> +
>> + delete_breakpoints
>> + gdb_test "python bp1 = gdb.Breakpoint (source=\"$srcfile\")" \
>> + "RuntimeError: Specifying a source must also include a line, label or function.*" \
>> + "set invalid explicit breakpoint by source only"
>> +
>> + gdb_test "python bp1 = gdb.Breakpoint (source=\"foo.c\", line=\"5\")" \
>> + "No source file named foo.*" \
>> + "set invalid explicit breakpoint by missing source and line"
>> + gdb_test "python bp1 = gdb.Breakpoint (source=\"$srcfile\", line=\"900\")" \
>> + "No line 900 in file \"$srcfile\".*" \
>> + "set invalid explicit breakpoint by source and invalid line"
>> + gdb_test "python bp1 = gdb.Breakpoint (function=\"blah\")" \
>> + "Function \"blah\" not defined.*" \
>> + "set invalid explicit breakpoint by missing function"
>> + }
>
> The test names should start with a lower case letter:
>
> https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Follow_the_test_name_convention
>
> Also make sure that test names are not duplicated. You can use this command to quickly
> find duplicated names in gdb.sum:
>
> $ cat testsuite/gdb.sum | grep -e PASS -e FAIL | sort | uniq -c | sort -n
I thought they all were. Regardless, I'll check again before resubmitting.
> Would it be good to test that explicit breakpoint locations through the spec
> argument work as well? Things like
>
> gdb.Breakpoint('-line 5')
Yeah, good idea. They all originally were but I converted them to the
keywords without thinking of the spec case
Cheers
Phil