From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA] Make gdb.lookup_typename work for Rust types
Date: Fri, 14 Jul 2017 14:57:00 -0000 [thread overview]
Message-ID: <20170714145703.12318-1-tom@tromey.com> (raw)
PR rust/21763 points out that gdb.lookup_typename does not work properly
for (some) Rust types. I tracked this down to a missing case in
symbol_matches_domain.
Tested by the buildbot.
2017-07-14 Tom Tromey <tom@tromey.com>
PR rust/21763:
* symtab.c (symbol_matches_domain): Add language_rust to special
case.
* rust-exp.y (convert_ast_to_expression) <OP_VAR_VALUE>: Don't
treat LOC_TYPEDEF symbols as variables.
2017-07-14 Tom Tromey <tom@tromey.com>
* gdb.rust/simple.exp: Add regression test for PR rust/21763.
---
gdb/ChangeLog | 8 ++++++++
gdb/rust-exp.y | 12 +++++++++---
gdb/symtab.c | 3 ++-
gdb/testsuite/ChangeLog | 4 ++++
gdb/testsuite/gdb.rust/simple.exp | 8 ++++++++
5 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 550a7a8..5c36fb1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2017-07-14 Tom Tromey <tom@tromey.com>
+
+ PR rust/21763:
+ * symtab.c (symbol_matches_domain): Add language_rust to special
+ case.
+ * rust-exp.y (convert_ast_to_expression) <OP_VAR_VALUE>: Don't
+ treat LOC_TYPEDEF symbols as variables.
+
2017-07-14 Simon Marchi <simon.marchi@ericsson.com>
* ax-gdb.c (gen_aggregate_elt_ref): Remove operand_name and
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
index c7361bc..821abcd 100644
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -2316,7 +2316,7 @@ convert_ast_to_expression (struct parser_state *state,
varname = convert_name (state, operation);
sym = rust_lookup_symbol (varname, expression_context_block,
VAR_DOMAIN);
- if (sym.symbol != NULL)
+ if (sym.symbol != NULL && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
{
write_exp_elt_opcode (state, OP_VAR_VALUE);
write_exp_elt_block (state, sym.block);
@@ -2325,9 +2325,15 @@ convert_ast_to_expression (struct parser_state *state,
}
else
{
- struct type *type;
+ struct type *type = NULL;
- type = rust_lookup_type (varname, expression_context_block);
+ if (sym.symbol != NULL)
+ {
+ gdb_assert (SYMBOL_CLASS (sym.symbol) == LOC_TYPEDEF);
+ type = SYMBOL_TYPE (sym.symbol);
+ }
+ if (type == NULL)
+ type = rust_lookup_type (varname, expression_context_block);
if (type == NULL)
error (_("No symbol '%s' in current context"), varname);
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 497d520..89cc338 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2625,7 +2625,8 @@ symbol_matches_domain (enum language symbol_language,
Similarly, any Ada type declaration implicitly defines a typedef. */
if (symbol_language == language_cplus
|| symbol_language == language_d
- || symbol_language == language_ada)
+ || symbol_language == language_ada
+ || symbol_language == language_rust)
{
if ((domain == VAR_DOMAIN || domain == STRUCT_DOMAIN)
&& symbol_domain == STRUCT_DOMAIN)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c29f6e5..1807fb6 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2017-07-14 Tom Tromey <tom@tromey.com>
+
+ * gdb.rust/simple.exp: Add regression test for PR rust/21763.
+
2017-07-13 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.mi/mi-vla-fortran.exp: Correct even more parameter passing
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
index 872b22c..db23162 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -246,3 +246,11 @@ gdb_test "print parametrized.next.val" \
" = \\(simple::ParametrizedStruct<i32> \\*\\) $hex"
gdb_test "print parametrized" \
" = simple::ParametrizedStruct<i32> \\{next: simple::ParametrizedEnum<\[a-z:\]*Box<simple::ParametrizedStruct<i32>>>::Val\\{val: $hex\\}, value: 0\\}"
+
+
+load_lib gdb-python.exp
+if {[skip_python_tests]} {
+ continue
+}
+
+gdb_test "python print(gdb.lookup_type('simple::HiBob'))" "simple::HiBob"
--
2.9.4
next reply other threads:[~2017-07-14 14:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-14 14:57 Tom Tromey [this message]
2017-07-14 15:09 ` Pedro Alves
2017-07-14 16:22 ` Tom Tromey
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=20170714145703.12318-1-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/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