mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
c9317f214b
A Rust enum is, essentially, a discriminated union. Currently the Rust language support handles Rust enums locally, in rust-lang.c. However, because I am changing the Rust compiler to use DW_TAG_variant* to represent enums, it seemed better to have a single internal representation for Rust enums in gdb. This patch implements this idea by moving the current Rust enum handling code to dwarf2read. This allows the simplification of some parts of rust-lang.c as well. 2018-02-26 Tom Tromey <tom@tromey.com> * rust-lang.h (rust_last_path_segment): Declare. * rust-lang.c (rust_last_path_segment): Now public. Change contract. (struct disr_info): Remove. (RUST_ENUM_PREFIX, RUST_ENCODED_ENUM_REAL) (RUST_ENCODED_ENUM_HIDDEN, rust_union_is_untagged) (rust_get_disr_info, rust_tuple_variant_type_p): Remove. (rust_enum_p, rust_enum_variant): New function. (rust_underscore_fields): Remove "offset" parameter. (rust_print_enum): New function. (rust_val_print) <TYPE_CODE_UNION>: Remove enum code. <TYPE_CODE_STRUCT>: Call rust_print_enum when appropriate. (rust_print_struct_def): Add "for_rust_enum" parameter. Handle enums. (rust_internal_print_type): New function, from rust_print_type. Remove enum code. (rust_print_type): Call rust_internal_print_type. (rust_evaluate_subexp) <STRUCTOP_ANONYMOUS, STRUCTOP_STRUCT>: Update enum handling. * dwarf2read.c (struct dwarf2_cu) <rust_unions>: New field. (rust_fully_qualify, alloc_discriminant_info, quirk_rust_enum) (rust_union_quirks): New functions. (process_full_comp_unit, process_full_type_unit): Call rust_union_quirks. (process_structure_scope): Update rust_unions if necessary. 2018-02-26 Tom Tromey <tom@tromey.com> * gdb.rust/simple.exp: Accept more possible results in enum test.
55 lines
2.0 KiB
C++
55 lines
2.0 KiB
C++
/* Rust language support definitions for GDB, the GNU debugger.
|
|
|
|
Copyright (C) 2016-2018 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef RUST_LANG_H
|
|
#define RUST_LANG_H
|
|
|
|
struct parser_state;
|
|
struct type;
|
|
|
|
/* The la_parser implementation for Rust. */
|
|
extern int rust_parse (struct parser_state *);
|
|
|
|
/* The la_error implementation for Rust. */
|
|
extern void rustyyerror (const char *);
|
|
|
|
/* Return true if TYPE is a tuple type; otherwise false. */
|
|
extern bool rust_tuple_type_p (struct type *type);
|
|
|
|
/* Return true if TYPE is a tuple struct type; otherwise false. */
|
|
extern bool rust_tuple_struct_type_p (struct type *type);
|
|
|
|
/* Given a block, find the name of the block's crate. Returns an empty
|
|
stringif no crate name can be found. */
|
|
extern std::string rust_crate_for_block (const struct block *block);
|
|
|
|
/* Returns the last segment of a Rust path like foo::bar::baz. Will
|
|
not handle cases where the last segment contains generics. */
|
|
|
|
extern const char *rust_last_path_segment (const char *path);
|
|
|
|
/* Create a new slice type. NAME is the name of the type. ELT_TYPE
|
|
is the type of the elements of the slice. USIZE_TYPE is the Rust
|
|
"usize" type to use. The new type is allocated whereever ELT_TYPE
|
|
is allocated. */
|
|
extern struct type *rust_slice_type (const char *name, struct type *elt_type,
|
|
struct type *usize_type);
|
|
|
|
#endif /* RUST_LANG_H */
|