This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Print void types correctly in Rust
- From: Tom Tromey <tom at tromey dot com>
- To: Tom Tromey <tom at tromey dot com>
- Cc: Manish Goregaokar <manish at mozilla dot com>, gdb-patches at sourceware dot org
- Date: Mon, 27 Jun 2016 10:26:13 -0600
- Subject: Re: [PATCH] Print void types correctly in Rust
- Authentication-results: sourceware.org; auth=none
- References: <CAFOnWk=UXb+EkAB6P=a2T4xNn_k5FveoVKv7ZsGN7-yUh7o8_w at mail dot gmail dot com> <8760suk3qg dot fsf at tromey dot com>
Tom> ... I wonder if that is something that changed after 1.8, or if it's the
Tom> case that the unit type can be represented in multiple ways. (Or maybe
Tom> this only handles the unit type constructed by rust_language_arch_info?)
[...]
Manish> +// Empty function, should not have "void"
Manish> +// or "()" in its return type
Manish> +fn empty() {
Tom> I'm curious what happens if it does say "-> ()"?
I did the experiment myself and I think I see what's going on now.
For an explicit "()", like "let y = ()", we'll end up with a zero-sized
integer type:
<1><98>: Abbrev Number: 7 (DW_TAG_base_type)
<99> DW_AT_name : (indirect string, offset: 0x88): ()
<9d> DW_AT_encoding : 7 (unsigned)
<9e> DW_AT_byte_size : 0
However, "fn empty()" (or in my experiment also "fn empty()->()"), the
type is left unspecified in the DWARF, which gdb turns into
TYPE_CODE_VOID (see dwarf2read.c:read_unspecified_type).
I think both have to be handled. However I think it's fine to do some
cleanup in a follow-up patch, which I'm happy to do.
So your patch is OK with the ChangeLog entry and the indentation fixed.
Tom