Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Phil Muldoon <pmuldoon@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>,
	Keith Seitz <keiths@redhat.com>,
	eliz@gnu.org,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [python] Allow explicit locations in breakpoints.
Date: Fri, 24 Nov 2017 14:07:00 -0000	[thread overview]
Message-ID: <688b8b82-b747-389a-50a8-8d45d0fc27eb@redhat.com> (raw)
In-Reply-To: <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


  reply	other threads:[~2017-11-24 14:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <04ccc2c4-7827-eedc-d8db-a83a0167acb6@redhat.com>
2017-08-23 17:51 ` Keith Seitz
2017-08-23 18:31   ` Phil Muldoon
2017-10-16 18:23     ` Simon Marchi
2017-10-16 18:33       ` Simon Marchi
2017-10-16 20:24       ` Phil Muldoon
2017-10-16 21:26         ` Simon Marchi
2017-10-16 22:01           ` Phil Muldoon
2017-10-16 22:26             ` Simon Marchi
2017-11-17 11:02               ` Phil Muldoon
2017-11-17 13:31                 ` Eli Zaretskii
2017-11-17 14:02                   ` Phil Muldoon
2017-11-23 22:17                 ` Simon Marchi
2017-11-24 14:07                   ` Phil Muldoon [this message]
2017-12-07 10:02                   ` Phil Muldoon
2017-12-07 12:16                     ` Phil Muldoon
2017-12-07 14:54                       ` Simon Marchi
2017-12-07 15:12                         ` Phil Muldoon
2017-12-07 16:41                           ` Simon Marchi
2017-12-08 13:50                     ` Eli Zaretskii
2017-09-12 10:03 ` Phil Muldoon
2017-10-02 15:18   ` Phil Muldoon
2017-10-16 11:14     ` Phil Muldoon
2017-10-16 18:31 ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=688b8b82-b747-389a-50a8-8d45d0fc27eb@redhat.com \
    --to=pmuldoon@redhat.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    --cc=simon.marchi@ericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox