public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Tom Tromey <tom@tromey.com>
Cc: Simon Marchi <simark@simark.ca>, <gdb-patches@sourceware.org>
Subject: Re: [RFA 1/2] Make line tables independent of progspace
Date: Tue, 27 Mar 2018 20:22:00 -0000	[thread overview]
Message-ID: <cbfd1765-be31-2e36-6bd7-c922c23fb5a4@ericsson.com> (raw)
In-Reply-To: <87vadiw24a.fsf@tromey.com>

On 2018-03-27 12:53 AM, Tom Tromey wrote:
> Tom> I've run the new patch through the buildbot.  I'll resubmit it soon, I
> Tom> just have to update the ChangeLog and rewrite the commit message.
> 
> Here it is.  Let me reiterate that this probably requires careful review
> as the buildbot may not test some of these paths.
> 
> Tom

Hi Tom,

I had a first quick look, enough to familiarize myself with the problem.
Conceptually, the approach looks ok to me, but I'd like to have a closer
look later (unless someone else reviews it in the mean time).

Here are two small comments I noted.

> @@ -517,10 +522,12 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch,
>    first_le = NULL;
>  
>    /* Skip all the preceding functions.  */
> -  for (i = 0; i < nlines && le[i].pc < low; i++)
> -    continue;
> +  for (i = 0;
> +       i < nlines - 1 && le[i].address (main_symtab) < low;

I don't understand why "i < nlines" becomes "i < nlines - 1" here.

> diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
> index 8c707aa8fe..880d87436e 100644
> --- a/gdb/xcoffread.c
> +++ b/gdb/xcoffread.c
> @@ -420,7 +420,11 @@ compare_lte (const void *lte1p, const void *lte2p)
>    struct linetable_entry *lte1 = (struct linetable_entry *) lte1p;
>    struct linetable_entry *lte2 = (struct linetable_entry *) lte2p;
>  
> -  return lte1->pc - lte2->pc;
> +  if (lte1->raw_address () < lte2->raw_address ())
> +    return -1;
> +  if (lte1->raw_address () > lte2->raw_address ())
> +    return -1;
> +  return 0;
>  }

Both branches return -1 here.

I don't mind the "left - right", I see that often.  Especially when you
want to sort by multiple fields, it's short and clear (IMO) to do

  if (left->foo != right->foo)
    return left->foo - right->foo;

  return left->bar - right->bar;

Simon

  reply	other threads:[~2018-03-27 20:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-21 17:18 [RFA 0/2] " Tom Tromey
2018-03-21 17:18 ` [RFA 2/2] Constify the line table Tom Tromey
2018-03-21 17:18 ` [RFA 1/2] Make line tables independent of progspace Tom Tromey
2018-03-24  3:40   ` Simon Marchi
2018-03-27  4:16     ` Tom Tromey
2018-03-27  4:53       ` Tom Tromey
2018-03-27 20:22         ` Simon Marchi [this message]
2018-03-28  4:53           ` Tom Tromey
2018-03-28 12:30             ` Simon Marchi
2018-03-28  3:34         ` Simon Marchi
2018-03-28  5:02           ` Tom Tromey
2018-03-28 12:32             ` Simon Marchi
2018-03-28 19:33           ` Maciej W. Rozycki
2018-03-29 15:04             ` Simon Marchi
2018-03-29 21:07               ` Maciej W. Rozycki
2018-04-26 21:30                 ` Tom Tromey
2018-05-03 23:17                   ` Maciej W. Rozycki
2018-05-14 23:54                     ` Maciej W. Rozycki

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=cbfd1765-be31-2e36-6bd7-c922c23fb5a4@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).