This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v1] Fix of default lookup for "this" symbol.
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Walfred Tedeschi <walfred dot tedeschi at intel dot com>
- Cc: palves at redhat dot com, brobecker at adacore dot com, gdb-patches at sourceware dot org
- Date: Tue, 05 Apr 2016 12:32:24 +0100
- Subject: Re: [PATCH v1] Fix of default lookup for "this" symbol.
- Authentication-results: sourceware.org; auth=none
- References: <1457533925-22168-1-git-send-email-walfred dot tedeschi at intel dot com>
Walfred Tedeschi <walfred.tedeschi@intel.com> writes:
> 2016-03-09 Walfred Tedeschi <walfred.tedeschi@intel.com>
>
> gdb/ChangeLog:
>
> * cp_lookup_bare_symbol (cp_lookup_bare_symbol): Add check for the
* cp-namespace.c (cp_lookup_bare_symbol):
> name_of_this in order to return a null symbol when looking up
> for "this".
>
>
> ---
> gdb/cp-namespace.c | 7 ++++++
> gdb/testsuite/gdb.fortran/derived-type.exp | 35 ++++++++++++++++++++++++++++--
> gdb/testsuite/gdb.fortran/derived-type.f90 | 7 +++++-
> 3 files changed, 46 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
> index 72002d6..b9d7dbe 100644
> --- a/gdb/cp-namespace.c
> +++ b/gdb/cp-namespace.c
> @@ -210,6 +210,13 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
> if (lang_this.symbol == NULL)
> return null_block_symbol;
>
> + /* This whole routine is also the default path for several languages.
> + In some languages "this" is not a special symbol,
> + i.e. LA_NAME_OF_THIS is NULL.
> + For those cases we should return a null_block_symbol. */
> + if (langdef != NULL && langdef->la_name_of_this == NULL)
> + return null_block_symbol;
> +
The better fix would be pass "langdef" to lookup_language_this rather
than language_def (language_cplus). The patch is like this:
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -206,7 +206,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
struct block_symbol lang_this;
struct type *type;
- lang_this = lookup_language_this (language_def (language_cplus), block);
+ lang_this = lookup_language_this (langdef, block);
if (lang_this.symbol == NULL)
return null_block_symbol;
> type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this.symbol)));
> /* If TYPE_NAME is NULL, abandon trying to find this symbol.
> This can happen for lambda functions compiled with clang++,
> diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
> index f650352..acccf3b 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type.exp
> @@ -74,14 +74,45 @@ gdb_test_multiple $test $test {
> gdb_test "print q%x%c" "\\$\[0-9\]+ = 1"
> gdb_test "print q%x%d" "\\$\[0-9\]+ = 2\\.375"
>
> +set result_line "= \\( a = 3.125, x = \\( c = 1, d = 2\\.375 \\),\
> +b = 'abcdefg' \\)\r\n$gdb_prompt $"
> +
> +# Used in case compiler generates an array of characters.
> +set result_line_2 " = \\( a = 3.125, x = \\( 1, 2\\.375 \\),\
> +b = \\('abcdefg'\\) \\)\r\n$gdb_prompt $"
> +
> set test "print q"
> gdb_test_multiple $test $test {
> - -re "\\$\[0-9\]+ = \\( a = 3.125, x = \\( c = 1, d = 2\\.375 \\), b = 'abcdefg' \\)\r\n$gdb_prompt $" {
Your patch can't be applied cleanly, because the pattern in mainline is
"\\$\[0-9\]+ = \\( 3.125, \\( 1, 2\\.375 \\), 'abcdefg' \\)\r\n$gdb_prompt $",
it doesn't have " a =" or "x = " things.
> + -re $result_line {
> pass $test
> }
> - -re "\\$\[0-9\]+ = \\( a = 3.125, x = \\( 1, 2\\.375 \\), b = \\('abcdefg'\\) \\)\r\n$gdb_prompt $" {
> + -re $result_line_2 {
> # Compiler should produce string, not an array of characters.
> setup_xfail "*-*-*"
> fail $test
> }
> }
> +
--
Yao (éå)