Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2 2/2] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index
Date: Fri, 24 Feb 2017 15:34:00 -0000	[thread overview]
Message-ID: <86poi77gd0.fsf@gmail.com> (raw)
In-Reply-To: <1487870642-29926-3-git-send-email-palves@redhat.com> (Pedro	Alves's message of "Thu, 23 Feb 2017 17:24:02 +0000")

Pedro Alves <palves@redhat.com> writes:

> -  /* Find the symtab for SRCFILE (this loads it if it was not yet read
> -     in).  */
> -  s = lookup_symtab (srcfile);
> -  if (s == NULL)
> +  /* Go through symtabs for SRCFILE and check the externs and statics
> +     for symbols which match.  */
> +  iterate_over_symtabs (srcfile, [&] (symtab *s)
>      {
> -      /* Maybe they typed the file with leading directories, while the
> -	 symbol tables record only its basename.  */
> -      const char *tail = lbasename (srcfile);
> -
> -      if (tail > srcfile)
> -	s = lookup_symtab (tail);
> -    }
> -
> -  /* If we have no symtab for that file, return an empty list.  */
> -  if (s == NULL)
> -    return (return_val);

In the original code, lookup_symtab is called twice, and if we inline
lookup_symtab here, the change in this patch is more readable.

Let us inline lookup_symtab first, the code becomes,

  s = NULL;
  iterate_over_symtabs (srcfile, [&] (symtab *symtab)
    {
      s = symtab;

      add_symtab_completions (SYMTAB_COMPUNIT (s),
			      sym_text, sym_text_len,
			      text, word, TYPE_CODE_UNDEF);
      return true;
    });

  if (s == NULL)
    {
      /* Maybe they typed the file with leading directories, while the
	 symbol tables record only its basename.  */
      const char *tail = lbasename (srcfile);

      if (tail > srcfile)
	iterate_over_symtabs (tail, [&] (symtab *symtab)
			      {
				s = symtab;

				add_symtab_completions (SYMTAB_COMPUNIT (s),
							sym_text, sym_text_len,
							text, word, TYPE_CODE_UNDEF);
				return true;
			      });
    }


then, as you described in commit log, we have to iterate all symtabs
rather than stop on the first matched symtab.  We need to replace
"return true;" with "return false;" above.  Presumably, this replacement
will fix the fails in completion.exp.

Then, it turns out that the whole block "if (s == NULL) {...}" is
removed by this patch.  I'll dig deep to see this block is still needed
or not.

-- 
Yao (齐尧)


  reply	other threads:[~2017-02-24 15:34 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 14:50 [PATCH 0/3] Introduce gdb::function_view & fix completion bug Pedro Alves
2017-02-22 14:50 ` [PATCH 1/3] Introduce gdb::function_view Pedro Alves
2017-02-22 15:15   ` Simon Marchi
2017-02-22 17:40     ` Pedro Alves
2017-02-22 17:49       ` [PATCH v1.1 " Pedro Alves
2017-02-22 22:12         ` Yao Qi
2017-02-23 14:49           ` Pedro Alves
2017-02-23 15:11             ` Yao Qi
2017-02-23 15:20               ` Pedro Alves
2017-02-23 15:34                 ` Yao Qi
2017-02-22 22:23         ` Yao Qi
2017-02-23 14:50           ` [PATCH v1.2 " Pedro Alves
2017-02-23 14:58             ` Yao Qi
2017-02-23 14:59               ` Pedro Alves
2017-02-22 18:02       ` [PATCH " Simon Marchi
2017-02-22 14:50 ` [PATCH 3/3] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index Pedro Alves
2017-02-23 16:02   ` Yao Qi
2017-02-23 17:12     ` Pedro Alves
2017-02-23 17:24     ` [PATCH v2 0/2] " Pedro Alves
2017-02-23 17:24       ` [PATCH v2 1/2] symtab.c: Small refactor Pedro Alves
2017-02-23 21:45         ` Yao Qi
2017-02-24 17:45           ` Pedro Alves
2017-02-23 17:24       ` [PATCH v2 2/2] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index Pedro Alves
2017-02-24 15:34         ` Yao Qi [this message]
2017-02-24 17:15           ` Pedro Alves
2017-02-22 14:50 ` [PATCH 2/3] Use gdb::function_view in iterate_over_symtabs & co Pedro Alves
2017-02-22 22:40   ` Yao Qi

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=86poi77gd0.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.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