Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Simon Marchi (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: Christian Biesinger <cbiesinger@google.com>,	gdb-patches@sourceware.org
Subject: Change in binutils-gdb[master]: Change iterate_over_breakpoints to take a function_view
Date: Tue, 15 Oct 2019 03:11:00 -0000	[thread overview]
Message-ID: <20191015031124.19C9629ECF@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1570928756000.Ia9de4deecae562a70a40f5cd49f5a74d64570251@gnutoolchain-gerrit.osci.io>

Simon Marchi has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21
......................................................................


Patch Set 2: Code-Review-1

(6 comments)

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/breakpoint.c 
File gdb/breakpoint.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/breakpoint.c@15131 
PS2, Line 15131: iterate_over_breakpoints
               :   (gdb::function_view<bool (breakpoint *)> callback)
This would fit on a single line.


https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/dummy-frame.c 
File gdb/dummy-frame.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/dummy-frame.c@169 
PS2, Line 169:   iterate_over_breakpoints ([dummy] (breakpoint* bp)
Same comment about formatting as in py-finishbreakpoint.c.


https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/guile/scm-breakpoint.c 
File gdb/guile/scm-breakpoint.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/guile/scm-breakpoint.c@551 
PS2, Line 551: ([&] (breakpoint *bp) { return bpscm_build_bp_list(bp, &list); })
For readability, I'd like if you took that out of the "if".  Either:

  auto callback = [&] (breakpoint *bp)
    {
      return bpscm_build_bp_list(bp, &list);
    };
  if (iterate_over_breakpoints (callback) != NULL)
    return SCM_BOOL_F;

or

  breakpoint *bp_ret = iterate_over_breakpoints ([&] (breakpoint *bp)
    {
      return bpscm_build_bp_list(bp, &list);
    });

  if (bp_ret != NULL)
    return SCM_BOOL_F;

Oooooor, it seems to me like bpscm_build_bp_list can never return true, so iterate_over_breakpoints will never return a breakpoint.  So you could maybe get rid of this "if", that's indeed the case.


https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/python/py-breakpoint.c 
File gdb/python/py-breakpoint.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/python/py-breakpoint.c@909 
PS2, Line 909:       ([&] (breakpoint *bp) { return build_bp_list(bp, list.get ()); }) != NULL)
Same comment about formatting as in scm-breakpoint.o, except here the callback function can actually fail (in theory).


https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/python/py-finishbreakpoint.c 
File gdb/python/py-finishbreakpoint.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/python/py-finishbreakpoint.c@386 
PS2, Line 386: iterate_over_breakpoints ([&] (breakpoint *bp) {
             : 			    return bpfinishpy_detect_out_scope_cb
             : 			      (bp, bs == NULL ? NULL : bs->breakpoint_at); });
I was told before to place the curly braces of the lambda like this, to mimic how we format scopes:

  iterate_over_breakpoints ([&] (breakpoint *bp)
    {
      return bpfinishpy_detect_out_scope_cb
        (bp, bs == NULL ? NULL : bs->breakpoint_at);
    });

I'd suggest to use that, I think it's quite readable.


https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21/2/gdb/python/py-finishbreakpoint.c@399 
PS2, Line 399:   iterate_over_breakpoints ([&] (breakpoint *bp) {
Same.



-- 
To view, visit https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/21
To unsubscribe, or for help writing mail filters, visit https://gnutoolchain-gerrit.osci.io/r/settings


       reply	other threads:[~2019-10-15  3:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <gerrit.1570928756000.Ia9de4deecae562a70a40f5cd49f5a74d64570251@gnutoolchain-gerrit.osci.io>
2019-10-15  3:11 ` Simon Marchi (Code Review) [this message]
2019-10-15  8:43 ` Christian Biesinger (Code Review)
2019-10-15  8:43 ` Christian Biesinger (Code Review)
2019-10-15 12:57 ` Simon Marchi (Code Review)
2019-10-15 13:31 ` Sourceware to Gerrit sync (Code Review)
2019-10-15 13:31 ` Sourceware to Gerrit sync (Code Review)
2019-10-15 21:18 ` [review] " Simon Marchi (Code Review)
2019-10-15 21:32 ` Simon Marchi (Code Review)

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=20191015031124.19C9629ECF@gnutoolchain-gerrit.osci.io \
    --to=gerrit@gnutoolchain-gerrit.osci.io \
    --cc=cbiesinger@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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