2016-04-27 09:38:08 +08:00
|
|
|
|
/* Rust language support routines for GDB, the GNU debugger.
|
|
|
|
|
|
2024-01-12 23:30:44 +08:00
|
|
|
|
Copyright (C) 2016-2024 Free Software Foundation, Inc.
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
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/>. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
|
|
#include "block.h"
|
|
|
|
|
#include "c-lang.h"
|
|
|
|
|
#include "charset.h"
|
|
|
|
|
#include "cp-support.h"
|
2016-05-27 05:04:07 +08:00
|
|
|
|
#include "demangle.h"
|
2024-04-23 21:22:59 +08:00
|
|
|
|
#include "event-top.h"
|
2016-04-27 09:38:08 +08:00
|
|
|
|
#include "gdbarch.h"
|
|
|
|
|
#include "infcall.h"
|
|
|
|
|
#include "objfiles.h"
|
|
|
|
|
#include "rust-lang.h"
|
2018-06-09 03:18:25 +08:00
|
|
|
|
#include "typeprint.h"
|
2016-04-27 09:38:08 +08:00
|
|
|
|
#include "valprint.h"
|
|
|
|
|
#include "varobj.h"
|
2018-06-09 03:18:25 +08:00
|
|
|
|
#include <algorithm>
|
2016-09-22 23:51:20 +08:00
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
Introduce metadata style
This introduces a new "metadata" style and changes many places in gdb
to use it. The idea here is to let the user distinguish gdb output
from output that (conceptually at least) comes directly from the
inferior. The newly-styled category includes text that gdb
traditionally surrounds in "<...>", like "<unavailable>".
I only added a single test for this. In many cases this output is
difficult to test. Also, while developing this errors in the
implementation of the new printf formats showed up as regressions.
gdb/ChangeLog
2019-10-01 Tom Tromey <tom@tromey.com>
* p-lang.c (pascal_printstr): Use metadata style.
* value.c (show_convenience): Use metadata style.
* valprint.c (valprint_check_validity, val_print_optimized_out)
(val_print_not_saved, val_print_unavailable)
(val_print_invalid_address, generic_val_print, val_print)
(value_check_printable, val_print_array_elements): Use metadata
style.
* ui-out.h (class ui_out) <field_fmt>: New overload.
<do_field_fmt>: Add style parameter.
* ui-out.c (ui_out::field_fmt): New overload.
* typeprint.c (type_print_unknown_return_type)
(val_print_not_allocated, val_print_not_associated): Use metadata
style.
* tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style
parameter.
* tui/tui-out.c (tui_ui_out::do_field_fmt): Update.
* tracepoint.c (tvariables_info_1): Use metadata style.
* stack.c (print_frame_arg, print_frame_info, print_frame)
(info_frame_command_core): Use metadata style.
* skip.c (info_skip_command): Use metadata style.
* rust-lang.c (rust_print_enum): Use metadata style.
* python/py-prettyprint.c (print_stack_unless_memory_error): Use
metadata style.
* python/py-framefilter.c (py_print_single_arg): Use metadata
style.
* printcmd.c (do_one_display, print_variable_and_value): Use
metadata style.
* p-valprint.c (pascal_val_print)
(pascal_object_print_value_fields): Use metadata style.
* p-typeprint.c (pascal_type_print_base): Use metadata style.
* mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style
parameter.
* mi/mi-out.c (mi_ui_out::do_field_fmt): Update.
* m2-valprint.c (m2_print_long_set): Use metadata style.
* m2-typeprint.c (m2_print_type): Use metadata style.
* infcmd.c (print_return_value_1): Use metadata style.
* gnu-v3-abi.c (print_one_vtable): Use metadata style.
* f-valprint.c (info_common_command_for_block): Use metadata
style.
* f-typeprint.c (f_type_print_base): Use metadata style.
* expprint.c (print_subexp_standard): Use metadata style.
* cp-valprint.c (cp_print_value_fields): Use metadata style.
* cli/cli-style.h (class cli_style_option): Add constructor.
(metadata_style): Declare.
* cli/cli-style.c (metadata_style): New global.
(_initialize_cli_style): Register metadata style.
* cli-out.h (class cli_ui_out) <do_field_fmt>: Add style
parameter.
* cli-out.c (cli_ui_out::do_field_fmt): Update.
* c-typeprint.c (c_type_print_base_struct_union)
(c_type_print_base_1): Use metadata style.
* breakpoint.c (watchpoint_value_print)
(print_one_breakpoint_location): Use metadata style.
* break-catch-syscall.c (print_one_catch_syscall): Use metadata
style.
* break-catch-sig.c (signal_catchpoint_print_one): Use metadata
style.
* ada-valprint.c (val_print_packed_array_elements, printstr)
(print_field_values, ada_val_print_ref, ada_val_print): Use
metadata style.
* ada-typeprint.c (print_array_type, ada_print_type): Use metadata
style.
* ada-tasks.c (print_ada_task_info, info_task): Use metadata
style.
* ada-lang.c (user_select_syms): Use metadata style.
gdb/testsuite/ChangeLog
2019-10-01 Tom Tromey <tom@tromey.com>
* lib/gdb-utils.exp (style): Handle "metadata" argument.
* gdb.base/style.exp: Add metadata style test.
2019-04-03 10:00:18 +08:00
|
|
|
|
#include "cli/cli-style.h"
|
2020-11-25 02:50:54 +08:00
|
|
|
|
#include "parser-defs.h"
|
2021-03-08 22:27:57 +08:00
|
|
|
|
#include "rust-exp.h"
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
/* See rust-lang.h. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
const char *
|
|
|
|
|
rust_last_path_segment (const char *path)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
const char *result = strrchr (path, ':');
|
|
|
|
|
|
|
|
|
|
if (result == NULL)
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
return path;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
return result + 1;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-03 11:58:12 +08:00
|
|
|
|
/* See rust-lang.h. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2017-02-03 11:58:12 +08:00
|
|
|
|
std::string
|
2016-04-27 09:38:08 +08:00
|
|
|
|
rust_crate_for_block (const struct block *block)
|
|
|
|
|
{
|
2023-01-17 08:39:55 +08:00
|
|
|
|
const char *scope = block->scope ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (scope[0] == '\0')
|
2017-02-03 11:58:12 +08:00
|
|
|
|
return std::string ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2017-02-03 11:58:12 +08:00
|
|
|
|
return std::string (scope, cp_find_first_component (scope));
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
/* Return true if TYPE, which must be a struct type, represents a Rust
|
|
|
|
|
enum. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2016-10-29 09:00:43 +08:00
|
|
|
|
static bool
|
2020-04-25 03:40:31 +08:00
|
|
|
|
rust_enum_p (struct type *type)
|
2016-10-29 09:00:43 +08:00
|
|
|
|
{
|
2020-04-25 03:40:31 +08:00
|
|
|
|
/* is_dynamic_type will return true if any field has a dynamic
|
|
|
|
|
attribute -- but we only want to check the top level. */
|
|
|
|
|
return TYPE_HAS_VARIANT_PARTS (type);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-25 03:40:31 +08:00
|
|
|
|
/* Return true if TYPE, which must be an already-resolved enum type,
|
|
|
|
|
has no variants. */
|
2018-09-12 05:28:04 +08:00
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
rust_empty_enum_p (const struct type *type)
|
|
|
|
|
{
|
2020-05-23 04:55:15 +08:00
|
|
|
|
return type->num_fields () == 0;
|
2018-09-12 05:28:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-25 03:40:31 +08:00
|
|
|
|
/* Given an already-resolved enum type and contents, find which
|
|
|
|
|
variant is active. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2020-04-25 03:40:31 +08:00
|
|
|
|
static int
|
|
|
|
|
rust_enum_variant (struct type *type)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2020-04-25 03:40:31 +08:00
|
|
|
|
/* The active variant is simply the first non-artificial field. */
|
2020-05-23 04:55:15 +08:00
|
|
|
|
for (int i = 0; i < type->num_fields (); ++i)
|
2023-08-31 23:46:24 +08:00
|
|
|
|
if (!type->field (i).is_artificial ())
|
2020-04-25 03:40:31 +08:00
|
|
|
|
return i;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2020-04-25 03:40:31 +08:00
|
|
|
|
/* Perhaps we could get here by trying to print an Ada variant
|
|
|
|
|
record in Rust mode. Unlikely, but an error is safer than an
|
|
|
|
|
assert. */
|
|
|
|
|
error (_("Could not find active enum variant"));
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See rust-lang.h. */
|
|
|
|
|
|
2017-02-03 12:21:19 +08:00
|
|
|
|
bool
|
2016-04-27 09:38:08 +08:00
|
|
|
|
rust_tuple_type_p (struct type *type)
|
|
|
|
|
{
|
|
|
|
|
/* The current implementation is a bit of a hack, but there's
|
|
|
|
|
nothing else in the debuginfo to distinguish a tuple from a
|
|
|
|
|
struct. */
|
2020-05-15 01:46:38 +08:00
|
|
|
|
return (type->code () == TYPE_CODE_STRUCT
|
2020-05-17 00:16:06 +08:00
|
|
|
|
&& type->name () != NULL
|
|
|
|
|
&& type->name ()[0] == '(');
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return true if all non-static fields of a structlike type are in a
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
sequence like __0, __1, __2. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2017-02-03 12:21:19 +08:00
|
|
|
|
static bool
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
rust_underscore_fields (struct type *type)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
int i, field_number;
|
|
|
|
|
|
|
|
|
|
field_number = 0;
|
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
|
if (type->code () != TYPE_CODE_STRUCT)
|
2017-02-03 12:21:19 +08:00
|
|
|
|
return false;
|
2020-05-23 04:55:15 +08:00
|
|
|
|
for (i = 0; i < type->num_fields (); ++i)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2023-04-23 02:41:43 +08:00
|
|
|
|
if (!type->field (i).is_static ())
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
char buf[20];
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
xsnprintf (buf, sizeof (buf), "__%d", field_number);
|
2021-08-30 23:49:49 +08:00
|
|
|
|
if (strcmp (buf, type->field (i).name ()) != 0)
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
return false;
|
|
|
|
|
field_number++;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-03 12:21:19 +08:00
|
|
|
|
return true;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See rust-lang.h. */
|
|
|
|
|
|
2017-02-03 12:21:19 +08:00
|
|
|
|
bool
|
2016-04-27 09:38:08 +08:00
|
|
|
|
rust_tuple_struct_type_p (struct type *type)
|
|
|
|
|
{
|
2016-07-12 05:02:10 +08:00
|
|
|
|
/* This is just an approximation until DWARF can represent Rust more
|
|
|
|
|
precisely. We exclude zero-length structs because they may not
|
|
|
|
|
be tuple structs, and there's no way to tell. */
|
2020-05-23 04:55:15 +08:00
|
|
|
|
return type->num_fields () > 0 && rust_underscore_fields (type);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-31 01:06:46 +08:00
|
|
|
|
/* Return true if TYPE is "slice-like"; false otherwise. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2024-01-31 01:06:46 +08:00
|
|
|
|
static bool
|
2023-08-05 03:46:44 +08:00
|
|
|
|
rust_slice_type_p (const struct type *type)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2022-03-26 03:36:53 +08:00
|
|
|
|
if (type->code () == TYPE_CODE_STRUCT
|
|
|
|
|
&& type->name () != NULL
|
|
|
|
|
&& type->num_fields () == 2)
|
|
|
|
|
{
|
|
|
|
|
/* The order of fields doesn't matter. While it would be nice
|
|
|
|
|
to check for artificiality here, the Rust compiler doesn't
|
|
|
|
|
emit this information. */
|
|
|
|
|
const char *n1 = type->field (0).name ();
|
|
|
|
|
const char *n2 = type->field (1).name ();
|
|
|
|
|
return ((streq (n1, "data_ptr") && streq (n2, "length"))
|
|
|
|
|
|| (streq (n2, "data_ptr") && streq (n1, "length")));
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return true if TYPE is a range type, otherwise false. */
|
|
|
|
|
|
2017-02-03 12:21:19 +08:00
|
|
|
|
static bool
|
2016-04-27 09:38:08 +08:00
|
|
|
|
rust_range_type_p (struct type *type)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
|
if (type->code () != TYPE_CODE_STRUCT
|
2020-05-23 04:55:15 +08:00
|
|
|
|
|| type->num_fields () > 2
|
2020-05-17 00:16:06 +08:00
|
|
|
|
|| type->name () == NULL
|
|
|
|
|
|| strstr (type->name (), "::Range") == NULL)
|
2017-02-03 12:21:19 +08:00
|
|
|
|
return false;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2020-05-23 04:55:15 +08:00
|
|
|
|
if (type->num_fields () == 0)
|
2017-02-03 12:21:19 +08:00
|
|
|
|
return true;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
i = 0;
|
2021-08-30 23:49:49 +08:00
|
|
|
|
if (strcmp (type->field (0).name (), "start") == 0)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2020-05-23 04:55:15 +08:00
|
|
|
|
if (type->num_fields () == 1)
|
2017-02-03 12:21:19 +08:00
|
|
|
|
return true;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
i = 1;
|
|
|
|
|
}
|
2020-05-23 04:55:15 +08:00
|
|
|
|
else if (type->num_fields () == 2)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
/* First field had to be "start". */
|
2017-02-03 12:21:19 +08:00
|
|
|
|
return false;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-30 23:49:49 +08:00
|
|
|
|
return strcmp (type->field (i).name (), "end") == 0;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-30 04:14:07 +08:00
|
|
|
|
/* Return true if TYPE is an inclusive range type, otherwise false.
|
|
|
|
|
This is only valid for types which are already known to be range
|
|
|
|
|
types. */
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
rust_inclusive_range_type_p (struct type *type)
|
|
|
|
|
{
|
2020-05-17 00:16:06 +08:00
|
|
|
|
return (strstr (type->name (), "::RangeInclusive") != NULL
|
|
|
|
|
|| strstr (type->name (), "::RangeToInclusive") != NULL);
|
2018-03-30 04:14:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-27 09:38:08 +08:00
|
|
|
|
/* Return true if TYPE seems to be the type "u8", otherwise false. */
|
|
|
|
|
|
2017-02-03 12:21:19 +08:00
|
|
|
|
static bool
|
2016-04-27 09:38:08 +08:00
|
|
|
|
rust_u8_type_p (struct type *type)
|
|
|
|
|
{
|
2020-05-15 01:46:38 +08:00
|
|
|
|
return (type->code () == TYPE_CODE_INT
|
2020-09-14 23:07:57 +08:00
|
|
|
|
&& type->is_unsigned ()
|
2022-09-21 23:05:21 +08:00
|
|
|
|
&& type->length () == 1);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return true if TYPE is a Rust character type. */
|
|
|
|
|
|
2017-02-03 12:21:19 +08:00
|
|
|
|
static bool
|
2016-04-27 09:38:08 +08:00
|
|
|
|
rust_chartype_p (struct type *type)
|
|
|
|
|
{
|
2020-05-15 01:46:38 +08:00
|
|
|
|
return (type->code () == TYPE_CODE_CHAR
|
2022-09-21 23:05:21 +08:00
|
|
|
|
&& type->length () == 4
|
2020-09-14 23:07:57 +08:00
|
|
|
|
&& type->is_unsigned ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
Handle dereferencing Rust trait objects
In Rust, virtual tables work a bit differently than they do in C++. In
C++, as you know, they are connected to a particular class hierarchy.
Rust, instead, can generate a virtual table for potentially any type --
in fact, one such virtual table for each trait (a trait is similar to an
abstract class or to a Java interface) that a type implements.
Objects that are referenced via a trait can't currently be inspected by
gdb. This patch implements the Rust equivalent of "set print object".
gdb relies heavily on the C++ ABI to decode virtual tables; primarily to
make "set print object" work; but also "info vtbl". However, Rust does
not currently have a specified ABI, so this approach seems unwise to
emulate.
Instead, I've changed the Rust compiler to emit some DWARF that
describes trait objects (previously their internal structure was
opaque), vtables (currently just a size -- but I hope to expand this in
the future), and the concrete type for which a vtable was emitted.
The concrete type is expressed as a DW_AT_containing_type on the
vtable's type. This is a small extension to DWARF.
This patch adds a new entry to quick_symbol_functions to return the
symtab that holds a data address. Previously there was no way in gdb to
look up a full (only minimal) non-text symbol by address. The psymbol
implementation of this method works by lazily filling in a map that is
added to the objfile. This avoids slowing down psymbol reading for a
feature that is likely to not be used too frequently.
I did not update .gdb_index. My thinking here is that the DWARF 5
indices will obsolete .gdb_index soon-ish, meaning that adding a new
feature to them is probably wasted work. If necessary I can update the
DWARF 5 index code when it lands in gdb.
Regression tested on x86-64 Fedora 25.
2017-11-17 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol) <is_rust_vtable>: New member.
(struct rust_vtable_symbol): New.
(find_symbol_at_address): Declare.
* symtab.c (find_symbol_at_address): New function.
* symfile.h (struct quick_symbol_functions)
<find_compunit_symtab_by_address>: New member.
* symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New
function.
(debug_sym_quick_functions): Link to
debug_qf_find_compunit_symtab_by_address.
* rust-lang.c (rust_get_trait_object_pointer): New function.
(rust_evaluate_subexp) <case UNOP_IND>: New case. Call
rust_get_trait_object_pointer.
* psymtab.c (psym_relocate): Clear psymbol_map.
(psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New
functions.
(psym_functions): Link to psym_find_compunit_symtab_by_address.
* objfiles.h (struct objfile) <psymbol_map>: New member.
* dwarf2read.c (dwarf2_gdb_index_functions): Update.
(process_die) <DW_TAG_variable>: New case. Call read_variable.
(rust_containing_type, read_variable): New functions.
2017-11-17 Tom Tromey <tom@tromey.com>
* gdb.rust/traits.rs: New file.
* gdb.rust/traits.exp: New file.
2017-07-06 20:44:38 +08:00
|
|
|
|
/* If VALUE represents a trait object pointer, return the underlying
|
|
|
|
|
pointer with the correct (i.e., runtime) type. Otherwise, return
|
|
|
|
|
NULL. */
|
|
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
|
rust_get_trait_object_pointer (struct value *value)
|
|
|
|
|
{
|
2023-01-31 22:52:09 +08:00
|
|
|
|
struct type *type = check_typedef (value->type ());
|
Handle dereferencing Rust trait objects
In Rust, virtual tables work a bit differently than they do in C++. In
C++, as you know, they are connected to a particular class hierarchy.
Rust, instead, can generate a virtual table for potentially any type --
in fact, one such virtual table for each trait (a trait is similar to an
abstract class or to a Java interface) that a type implements.
Objects that are referenced via a trait can't currently be inspected by
gdb. This patch implements the Rust equivalent of "set print object".
gdb relies heavily on the C++ ABI to decode virtual tables; primarily to
make "set print object" work; but also "info vtbl". However, Rust does
not currently have a specified ABI, so this approach seems unwise to
emulate.
Instead, I've changed the Rust compiler to emit some DWARF that
describes trait objects (previously their internal structure was
opaque), vtables (currently just a size -- but I hope to expand this in
the future), and the concrete type for which a vtable was emitted.
The concrete type is expressed as a DW_AT_containing_type on the
vtable's type. This is a small extension to DWARF.
This patch adds a new entry to quick_symbol_functions to return the
symtab that holds a data address. Previously there was no way in gdb to
look up a full (only minimal) non-text symbol by address. The psymbol
implementation of this method works by lazily filling in a map that is
added to the objfile. This avoids slowing down psymbol reading for a
feature that is likely to not be used too frequently.
I did not update .gdb_index. My thinking here is that the DWARF 5
indices will obsolete .gdb_index soon-ish, meaning that adding a new
feature to them is probably wasted work. If necessary I can update the
DWARF 5 index code when it lands in gdb.
Regression tested on x86-64 Fedora 25.
2017-11-17 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol) <is_rust_vtable>: New member.
(struct rust_vtable_symbol): New.
(find_symbol_at_address): Declare.
* symtab.c (find_symbol_at_address): New function.
* symfile.h (struct quick_symbol_functions)
<find_compunit_symtab_by_address>: New member.
* symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New
function.
(debug_sym_quick_functions): Link to
debug_qf_find_compunit_symtab_by_address.
* rust-lang.c (rust_get_trait_object_pointer): New function.
(rust_evaluate_subexp) <case UNOP_IND>: New case. Call
rust_get_trait_object_pointer.
* psymtab.c (psym_relocate): Clear psymbol_map.
(psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New
functions.
(psym_functions): Link to psym_find_compunit_symtab_by_address.
* objfiles.h (struct objfile) <psymbol_map>: New member.
* dwarf2read.c (dwarf2_gdb_index_functions): Update.
(process_die) <DW_TAG_variable>: New case. Call read_variable.
(rust_containing_type, read_variable): New functions.
2017-11-17 Tom Tromey <tom@tromey.com>
* gdb.rust/traits.rs: New file.
* gdb.rust/traits.exp: New file.
2017-07-06 20:44:38 +08:00
|
|
|
|
|
2020-05-23 04:55:15 +08:00
|
|
|
|
if (type->code () != TYPE_CODE_STRUCT || type->num_fields () != 2)
|
Handle dereferencing Rust trait objects
In Rust, virtual tables work a bit differently than they do in C++. In
C++, as you know, they are connected to a particular class hierarchy.
Rust, instead, can generate a virtual table for potentially any type --
in fact, one such virtual table for each trait (a trait is similar to an
abstract class or to a Java interface) that a type implements.
Objects that are referenced via a trait can't currently be inspected by
gdb. This patch implements the Rust equivalent of "set print object".
gdb relies heavily on the C++ ABI to decode virtual tables; primarily to
make "set print object" work; but also "info vtbl". However, Rust does
not currently have a specified ABI, so this approach seems unwise to
emulate.
Instead, I've changed the Rust compiler to emit some DWARF that
describes trait objects (previously their internal structure was
opaque), vtables (currently just a size -- but I hope to expand this in
the future), and the concrete type for which a vtable was emitted.
The concrete type is expressed as a DW_AT_containing_type on the
vtable's type. This is a small extension to DWARF.
This patch adds a new entry to quick_symbol_functions to return the
symtab that holds a data address. Previously there was no way in gdb to
look up a full (only minimal) non-text symbol by address. The psymbol
implementation of this method works by lazily filling in a map that is
added to the objfile. This avoids slowing down psymbol reading for a
feature that is likely to not be used too frequently.
I did not update .gdb_index. My thinking here is that the DWARF 5
indices will obsolete .gdb_index soon-ish, meaning that adding a new
feature to them is probably wasted work. If necessary I can update the
DWARF 5 index code when it lands in gdb.
Regression tested on x86-64 Fedora 25.
2017-11-17 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol) <is_rust_vtable>: New member.
(struct rust_vtable_symbol): New.
(find_symbol_at_address): Declare.
* symtab.c (find_symbol_at_address): New function.
* symfile.h (struct quick_symbol_functions)
<find_compunit_symtab_by_address>: New member.
* symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New
function.
(debug_sym_quick_functions): Link to
debug_qf_find_compunit_symtab_by_address.
* rust-lang.c (rust_get_trait_object_pointer): New function.
(rust_evaluate_subexp) <case UNOP_IND>: New case. Call
rust_get_trait_object_pointer.
* psymtab.c (psym_relocate): Clear psymbol_map.
(psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New
functions.
(psym_functions): Link to psym_find_compunit_symtab_by_address.
* objfiles.h (struct objfile) <psymbol_map>: New member.
* dwarf2read.c (dwarf2_gdb_index_functions): Update.
(process_die) <DW_TAG_variable>: New case. Call read_variable.
(rust_containing_type, read_variable): New functions.
2017-11-17 Tom Tromey <tom@tromey.com>
* gdb.rust/traits.rs: New file.
* gdb.rust/traits.exp: New file.
2017-07-06 20:44:38 +08:00
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Try to be a bit resilient if the ABI changes. */
|
|
|
|
|
int vtable_field = 0;
|
|
|
|
|
for (int i = 0; i < 2; ++i)
|
|
|
|
|
{
|
2021-08-30 23:49:49 +08:00
|
|
|
|
if (strcmp (type->field (i).name (), "vtable") == 0)
|
Handle dereferencing Rust trait objects
In Rust, virtual tables work a bit differently than they do in C++. In
C++, as you know, they are connected to a particular class hierarchy.
Rust, instead, can generate a virtual table for potentially any type --
in fact, one such virtual table for each trait (a trait is similar to an
abstract class or to a Java interface) that a type implements.
Objects that are referenced via a trait can't currently be inspected by
gdb. This patch implements the Rust equivalent of "set print object".
gdb relies heavily on the C++ ABI to decode virtual tables; primarily to
make "set print object" work; but also "info vtbl". However, Rust does
not currently have a specified ABI, so this approach seems unwise to
emulate.
Instead, I've changed the Rust compiler to emit some DWARF that
describes trait objects (previously their internal structure was
opaque), vtables (currently just a size -- but I hope to expand this in
the future), and the concrete type for which a vtable was emitted.
The concrete type is expressed as a DW_AT_containing_type on the
vtable's type. This is a small extension to DWARF.
This patch adds a new entry to quick_symbol_functions to return the
symtab that holds a data address. Previously there was no way in gdb to
look up a full (only minimal) non-text symbol by address. The psymbol
implementation of this method works by lazily filling in a map that is
added to the objfile. This avoids slowing down psymbol reading for a
feature that is likely to not be used too frequently.
I did not update .gdb_index. My thinking here is that the DWARF 5
indices will obsolete .gdb_index soon-ish, meaning that adding a new
feature to them is probably wasted work. If necessary I can update the
DWARF 5 index code when it lands in gdb.
Regression tested on x86-64 Fedora 25.
2017-11-17 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol) <is_rust_vtable>: New member.
(struct rust_vtable_symbol): New.
(find_symbol_at_address): Declare.
* symtab.c (find_symbol_at_address): New function.
* symfile.h (struct quick_symbol_functions)
<find_compunit_symtab_by_address>: New member.
* symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New
function.
(debug_sym_quick_functions): Link to
debug_qf_find_compunit_symtab_by_address.
* rust-lang.c (rust_get_trait_object_pointer): New function.
(rust_evaluate_subexp) <case UNOP_IND>: New case. Call
rust_get_trait_object_pointer.
* psymtab.c (psym_relocate): Clear psymbol_map.
(psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New
functions.
(psym_functions): Link to psym_find_compunit_symtab_by_address.
* objfiles.h (struct objfile) <psymbol_map>: New member.
* dwarf2read.c (dwarf2_gdb_index_functions): Update.
(process_die) <DW_TAG_variable>: New case. Call read_variable.
(rust_containing_type, read_variable): New functions.
2017-11-17 Tom Tromey <tom@tromey.com>
* gdb.rust/traits.rs: New file.
* gdb.rust/traits.exp: New file.
2017-07-06 20:44:38 +08:00
|
|
|
|
vtable_field = i;
|
2021-08-30 23:49:49 +08:00
|
|
|
|
else if (strcmp (type->field (i).name (), "pointer") != 0)
|
Handle dereferencing Rust trait objects
In Rust, virtual tables work a bit differently than they do in C++. In
C++, as you know, they are connected to a particular class hierarchy.
Rust, instead, can generate a virtual table for potentially any type --
in fact, one such virtual table for each trait (a trait is similar to an
abstract class or to a Java interface) that a type implements.
Objects that are referenced via a trait can't currently be inspected by
gdb. This patch implements the Rust equivalent of "set print object".
gdb relies heavily on the C++ ABI to decode virtual tables; primarily to
make "set print object" work; but also "info vtbl". However, Rust does
not currently have a specified ABI, so this approach seems unwise to
emulate.
Instead, I've changed the Rust compiler to emit some DWARF that
describes trait objects (previously their internal structure was
opaque), vtables (currently just a size -- but I hope to expand this in
the future), and the concrete type for which a vtable was emitted.
The concrete type is expressed as a DW_AT_containing_type on the
vtable's type. This is a small extension to DWARF.
This patch adds a new entry to quick_symbol_functions to return the
symtab that holds a data address. Previously there was no way in gdb to
look up a full (only minimal) non-text symbol by address. The psymbol
implementation of this method works by lazily filling in a map that is
added to the objfile. This avoids slowing down psymbol reading for a
feature that is likely to not be used too frequently.
I did not update .gdb_index. My thinking here is that the DWARF 5
indices will obsolete .gdb_index soon-ish, meaning that adding a new
feature to them is probably wasted work. If necessary I can update the
DWARF 5 index code when it lands in gdb.
Regression tested on x86-64 Fedora 25.
2017-11-17 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol) <is_rust_vtable>: New member.
(struct rust_vtable_symbol): New.
(find_symbol_at_address): Declare.
* symtab.c (find_symbol_at_address): New function.
* symfile.h (struct quick_symbol_functions)
<find_compunit_symtab_by_address>: New member.
* symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New
function.
(debug_sym_quick_functions): Link to
debug_qf_find_compunit_symtab_by_address.
* rust-lang.c (rust_get_trait_object_pointer): New function.
(rust_evaluate_subexp) <case UNOP_IND>: New case. Call
rust_get_trait_object_pointer.
* psymtab.c (psym_relocate): Clear psymbol_map.
(psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New
functions.
(psym_functions): Link to psym_find_compunit_symtab_by_address.
* objfiles.h (struct objfile) <psymbol_map>: New member.
* dwarf2read.c (dwarf2_gdb_index_functions): Update.
(process_die) <DW_TAG_variable>: New case. Call read_variable.
(rust_containing_type, read_variable): New functions.
2017-11-17 Tom Tromey <tom@tromey.com>
* gdb.rust/traits.rs: New file.
* gdb.rust/traits.exp: New file.
2017-07-06 20:44:38 +08:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CORE_ADDR vtable = value_as_address (value_field (value, vtable_field));
|
|
|
|
|
struct symbol *symbol = find_symbol_at_address (vtable);
|
2017-11-18 03:05:58 +08:00
|
|
|
|
if (symbol == NULL || symbol->subclass != SYMBOL_RUST_VTABLE)
|
Handle dereferencing Rust trait objects
In Rust, virtual tables work a bit differently than they do in C++. In
C++, as you know, they are connected to a particular class hierarchy.
Rust, instead, can generate a virtual table for potentially any type --
in fact, one such virtual table for each trait (a trait is similar to an
abstract class or to a Java interface) that a type implements.
Objects that are referenced via a trait can't currently be inspected by
gdb. This patch implements the Rust equivalent of "set print object".
gdb relies heavily on the C++ ABI to decode virtual tables; primarily to
make "set print object" work; but also "info vtbl". However, Rust does
not currently have a specified ABI, so this approach seems unwise to
emulate.
Instead, I've changed the Rust compiler to emit some DWARF that
describes trait objects (previously their internal structure was
opaque), vtables (currently just a size -- but I hope to expand this in
the future), and the concrete type for which a vtable was emitted.
The concrete type is expressed as a DW_AT_containing_type on the
vtable's type. This is a small extension to DWARF.
This patch adds a new entry to quick_symbol_functions to return the
symtab that holds a data address. Previously there was no way in gdb to
look up a full (only minimal) non-text symbol by address. The psymbol
implementation of this method works by lazily filling in a map that is
added to the objfile. This avoids slowing down psymbol reading for a
feature that is likely to not be used too frequently.
I did not update .gdb_index. My thinking here is that the DWARF 5
indices will obsolete .gdb_index soon-ish, meaning that adding a new
feature to them is probably wasted work. If necessary I can update the
DWARF 5 index code when it lands in gdb.
Regression tested on x86-64 Fedora 25.
2017-11-17 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol) <is_rust_vtable>: New member.
(struct rust_vtable_symbol): New.
(find_symbol_at_address): Declare.
* symtab.c (find_symbol_at_address): New function.
* symfile.h (struct quick_symbol_functions)
<find_compunit_symtab_by_address>: New member.
* symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New
function.
(debug_sym_quick_functions): Link to
debug_qf_find_compunit_symtab_by_address.
* rust-lang.c (rust_get_trait_object_pointer): New function.
(rust_evaluate_subexp) <case UNOP_IND>: New case. Call
rust_get_trait_object_pointer.
* psymtab.c (psym_relocate): Clear psymbol_map.
(psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New
functions.
(psym_functions): Link to psym_find_compunit_symtab_by_address.
* objfiles.h (struct objfile) <psymbol_map>: New member.
* dwarf2read.c (dwarf2_gdb_index_functions): Update.
(process_die) <DW_TAG_variable>: New case. Call read_variable.
(rust_containing_type, read_variable): New functions.
2017-11-17 Tom Tromey <tom@tromey.com>
* gdb.rust/traits.rs: New file.
* gdb.rust/traits.exp: New file.
2017-07-06 20:44:38 +08:00
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
struct rust_vtable_symbol *vtable_sym
|
|
|
|
|
= static_cast<struct rust_vtable_symbol *> (symbol);
|
|
|
|
|
struct type *pointer_type = lookup_pointer_type (vtable_sym->concrete_type);
|
|
|
|
|
return value_cast (pointer_type, value_field (value, 1 - vtable_field));
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-31 01:06:46 +08:00
|
|
|
|
/* Find and possibly rewrite the unsized part of a slice-like type.
|
|
|
|
|
|
|
|
|
|
This function has two modes. If the out parameters are both NULL,
|
|
|
|
|
it will return true if an unsized member of IN_TYPE is found.
|
|
|
|
|
|
|
|
|
|
If the out parameters are both non-NULL, it will do the same, but
|
|
|
|
|
will also rewrite the unsized member's type to be an array of the
|
|
|
|
|
appropriate type. BOUND is the upper bound of the new array.
|
|
|
|
|
|
|
|
|
|
See convert_slice to understand the different kinds of unsized type
|
|
|
|
|
and how they are represented.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
rewrite_slice_type (struct type *in_type, struct type **new_type,
|
|
|
|
|
LONGEST bound, ULONGEST *additional_length)
|
|
|
|
|
{
|
|
|
|
|
if (in_type->code () != TYPE_CODE_STRUCT)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
unsigned nfields = in_type->num_fields ();
|
|
|
|
|
if (nfields == 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
struct type *rewritten;
|
|
|
|
|
const field &field = in_type->field (nfields - 1);
|
|
|
|
|
struct type *field_type = field.type ();
|
|
|
|
|
if (field.loc_kind () == FIELD_LOC_KIND_BITPOS
|
|
|
|
|
&& field.loc_bitpos () == 8 * in_type->length ())
|
|
|
|
|
{
|
|
|
|
|
if (additional_length == nullptr)
|
|
|
|
|
return true;
|
|
|
|
|
rewritten = lookup_array_range_type (field_type, 0, bound);
|
|
|
|
|
*additional_length = rewritten->length ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!rewrite_slice_type (field_type, &rewritten, bound,
|
|
|
|
|
additional_length))
|
|
|
|
|
return false;
|
|
|
|
|
if (additional_length == nullptr)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct type *result = copy_type (in_type);
|
|
|
|
|
result->copy_fields (in_type);
|
|
|
|
|
result->field (nfields - 1).set_type (rewritten);
|
|
|
|
|
result->set_length (result->length () + *additional_length);
|
|
|
|
|
|
|
|
|
|
*new_type = result;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convert a Rust slice to its "true" representation.
|
|
|
|
|
|
|
|
|
|
The Rust compiler emits slices as "fat" pointers like:
|
|
|
|
|
|
|
|
|
|
struct { payload *data_ptr; usize length }
|
|
|
|
|
|
|
|
|
|
Any sort of unsized type is emitted this way.
|
|
|
|
|
|
|
|
|
|
If 'payload' is a struct type, then it must be searched to see if
|
|
|
|
|
the trailing field is unsized. This has to be done recursively (as
|
|
|
|
|
in, if the final field in the struct type itself has struct type,
|
|
|
|
|
then that type must be searched). In this scenario, the unsized
|
|
|
|
|
field can be recognized because it does not contribute to the
|
|
|
|
|
type's size.
|
|
|
|
|
|
|
|
|
|
If 'payload' does not have a trailing unsized type, or if it is not
|
|
|
|
|
of struct type, then this slice is "array-like". In this case
|
|
|
|
|
rewriting will return an array.
|
|
|
|
|
*/
|
|
|
|
|
static struct value *
|
|
|
|
|
convert_slice (struct value *val)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = check_typedef (val->type ());
|
|
|
|
|
/* This must have been checked by the caller. */
|
|
|
|
|
gdb_assert (rust_slice_type_p (type));
|
|
|
|
|
|
|
|
|
|
struct value *len = value_struct_elt (&val, {}, "length", nullptr,
|
|
|
|
|
"slice");
|
|
|
|
|
LONGEST llen = value_as_long (len);
|
|
|
|
|
|
|
|
|
|
struct value *ptr = value_struct_elt (&val, {}, "data_ptr", nullptr,
|
|
|
|
|
"slice");
|
|
|
|
|
struct type *original_type = ptr->type ()->target_type ();
|
|
|
|
|
ULONGEST new_length_storage = 0;
|
|
|
|
|
struct type *new_type = nullptr;
|
|
|
|
|
if (!rewrite_slice_type (original_type, &new_type, llen - 1,
|
|
|
|
|
&new_length_storage))
|
|
|
|
|
new_type = lookup_array_range_type (original_type, 0, llen - 1);
|
|
|
|
|
|
|
|
|
|
struct value *result = value::allocate_lazy (new_type);
|
|
|
|
|
result->set_lval (lval_memory);
|
|
|
|
|
result->set_address (value_as_address (ptr));
|
|
|
|
|
result->fetch_lazy ();
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If TYPE is an array-like slice, return the element type; otherwise
|
|
|
|
|
return NULL. */
|
|
|
|
|
static struct type *
|
|
|
|
|
rust_array_like_element_type (struct type *type)
|
|
|
|
|
{
|
|
|
|
|
/* Caller must check this. */
|
|
|
|
|
gdb_assert (rust_slice_type_p (type));
|
|
|
|
|
for (int i = 0; i < type->num_fields (); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (type->field (i).name (), "data_ptr") == 0)
|
|
|
|
|
{
|
|
|
|
|
struct type *base_type = type->field (i).type ()->target_type ();
|
|
|
|
|
if (rewrite_slice_type (base_type, nullptr, 0, nullptr))
|
|
|
|
|
return nullptr;
|
|
|
|
|
return base_type;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
/* See language.h. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
void
|
|
|
|
|
rust_language::printstr (struct ui_file *stream, struct type *type,
|
|
|
|
|
const gdb_byte *string, unsigned int length,
|
|
|
|
|
const char *user_encoding, int force_ellipses,
|
|
|
|
|
const struct value_print_options *options) const
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
/* Rust always uses UTF-8, but let the caller override this if need
|
|
|
|
|
be. */
|
|
|
|
|
const char *encoding = user_encoding;
|
|
|
|
|
if (user_encoding == NULL || !*user_encoding)
|
|
|
|
|
{
|
|
|
|
|
/* In Rust strings, characters are "u8". */
|
|
|
|
|
if (rust_u8_type_p (type))
|
|
|
|
|
encoding = "UTF-8";
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* This is probably some C string, so let's let C deal with
|
|
|
|
|
it. */
|
2022-02-12 09:14:17 +08:00
|
|
|
|
language_defn::printstr (stream, type, string, length,
|
|
|
|
|
user_encoding, force_ellipses,
|
|
|
|
|
options);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This is not ideal as it doesn't use our character printer. */
|
|
|
|
|
generic_printstr (stream, type, string, length, encoding, force_ellipses,
|
|
|
|
|
'"', 0, options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-26 03:36:53 +08:00
|
|
|
|
static const struct generic_val_print_decorations rust_decorations =
|
|
|
|
|
{
|
|
|
|
|
/* Complex isn't used in Rust, but we provide C-ish values just in
|
|
|
|
|
case. */
|
|
|
|
|
"",
|
|
|
|
|
" + ",
|
|
|
|
|
" * I",
|
|
|
|
|
"true",
|
|
|
|
|
"false",
|
|
|
|
|
"()",
|
|
|
|
|
"[",
|
|
|
|
|
"]"
|
|
|
|
|
};
|
|
|
|
|
|
2023-08-05 03:46:44 +08:00
|
|
|
|
/* See rust-lang.h. */
|
|
|
|
|
|
|
|
|
|
struct value *
|
|
|
|
|
rust_slice_to_array (struct value *val)
|
|
|
|
|
{
|
2024-01-31 01:06:46 +08:00
|
|
|
|
val = convert_slice (val);
|
|
|
|
|
if (val->type ()->code () != TYPE_CODE_ARRAY)
|
|
|
|
|
return nullptr;
|
|
|
|
|
return val;
|
2023-08-05 03:46:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-26 03:36:53 +08:00
|
|
|
|
/* Helper function to print a slice. */
|
2017-10-03 03:55:42 +08:00
|
|
|
|
|
2024-01-31 01:06:46 +08:00
|
|
|
|
void
|
|
|
|
|
rust_language::val_print_slice
|
|
|
|
|
(struct value *val, struct ui_file *stream, int recurse,
|
|
|
|
|
const struct value_print_options *options) const
|
2017-10-03 03:55:42 +08:00
|
|
|
|
{
|
2024-01-31 01:06:46 +08:00
|
|
|
|
struct type *orig_type = check_typedef (val->type ());
|
2017-10-03 03:55:42 +08:00
|
|
|
|
|
2024-01-31 01:06:46 +08:00
|
|
|
|
val = convert_slice (val);
|
2023-01-31 22:52:09 +08:00
|
|
|
|
struct type *type = check_typedef (val->type ());
|
2022-03-26 03:36:53 +08:00
|
|
|
|
|
2024-01-31 01:06:46 +08:00
|
|
|
|
/* &str is handled here; but for all other slice types it is fine to
|
|
|
|
|
simply print the contents. */
|
|
|
|
|
if (orig_type->name () != nullptr
|
|
|
|
|
&& strcmp (orig_type->name (), "&str") == 0)
|
|
|
|
|
{
|
|
|
|
|
LONGEST low_bound, high_bound;
|
|
|
|
|
if (get_array_bounds (type, &low_bound, &high_bound))
|
2022-03-26 03:36:53 +08:00
|
|
|
|
{
|
2024-01-31 01:06:46 +08:00
|
|
|
|
val_print_string (type->target_type (), "UTF-8",
|
|
|
|
|
val->address (), high_bound - low_bound + 1,
|
|
|
|
|
stream, options);
|
|
|
|
|
return;
|
2022-03-26 03:36:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-31 01:06:46 +08:00
|
|
|
|
|
2024-03-08 03:57:07 +08:00
|
|
|
|
/* Print the slice type here. This was gdb's historical behavior
|
|
|
|
|
(from before unsized types were generically handled) and helps
|
|
|
|
|
make it clear that the user is seeing a slice, not an array.
|
|
|
|
|
Only arrays must be handled as the other cases are handled by
|
|
|
|
|
value_print_inner. */
|
|
|
|
|
if (type->code () == TYPE_CODE_ARRAY)
|
|
|
|
|
{
|
|
|
|
|
type_print (orig_type, "", stream, -1);
|
|
|
|
|
gdb_printf (stream, " ");
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-31 01:06:46 +08:00
|
|
|
|
value_print_inner (val, stream, recurse, options);
|
2017-10-03 03:55:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
/* See rust-lang.h. */
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
void
|
|
|
|
|
rust_language::val_print_struct
|
|
|
|
|
(struct value *val, struct ui_file *stream, int recurse,
|
|
|
|
|
const struct value_print_options *options) const
|
2016-10-29 09:00:43 +08:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int first_field;
|
2023-01-31 22:52:09 +08:00
|
|
|
|
struct type *type = check_typedef (val->type ());
|
2017-10-03 03:55:42 +08:00
|
|
|
|
|
2022-03-26 03:36:53 +08:00
|
|
|
|
if (rust_slice_type_p (type))
|
2017-10-03 03:55:42 +08:00
|
|
|
|
{
|
2024-01-31 01:06:46 +08:00
|
|
|
|
val_print_slice (val, stream, recurse, options);
|
2017-10-03 03:55:42 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-03 12:21:19 +08:00
|
|
|
|
bool is_tuple = rust_tuple_type_p (type);
|
|
|
|
|
bool is_tuple_struct = !is_tuple && rust_tuple_struct_type_p (type);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
struct value_print_options opts;
|
|
|
|
|
|
|
|
|
|
if (!is_tuple)
|
|
|
|
|
{
|
2020-05-17 00:16:06 +08:00
|
|
|
|
if (type->name () != NULL)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "%s", type->name ());
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
2020-05-23 04:55:15 +08:00
|
|
|
|
if (type->num_fields () == 0)
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
|
return;
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
2020-05-17 00:16:06 +08:00
|
|
|
|
if (type->name () != NULL)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (" ", stream);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_tuple || is_tuple_struct)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("(", stream);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
else
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("{", stream);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
|
|
|
|
opts = *options;
|
2022-06-13 04:13:22 +08:00
|
|
|
|
opts.deref_ref = false;
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
|
|
|
|
first_field = 1;
|
2020-05-23 04:55:15 +08:00
|
|
|
|
for (i = 0; i < type->num_fields (); ++i)
|
2016-10-29 09:00:43 +08:00
|
|
|
|
{
|
2023-04-23 02:41:43 +08:00
|
|
|
|
if (type->field (i).is_static ())
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
|
continue;
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
|
|
|
|
if (!first_field)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (",", stream);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
|
|
|
|
if (options->prettyformat)
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
|
{
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("\n", stream);
|
2022-01-03 02:53:15 +08:00
|
|
|
|
print_spaces (2 + 2 * recurse, stream);
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
|
}
|
2016-10-29 09:00:43 +08:00
|
|
|
|
else if (!first_field)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (" ", stream);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
|
|
|
|
first_field = 0;
|
|
|
|
|
|
|
|
|
|
if (!is_tuple && !is_tuple_struct)
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
|
{
|
2021-08-30 23:49:49 +08:00
|
|
|
|
fputs_styled (type->field (i).name (),
|
2020-02-23 01:02:42 +08:00
|
|
|
|
variable_name_style.style (), stream);
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (": ", stream);
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
|
}
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
2021-05-15 09:54:35 +08:00
|
|
|
|
common_val_print (value_field (val, i), stream, recurse + 1, &opts,
|
|
|
|
|
this);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options->prettyformat)
|
|
|
|
|
{
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("\n", stream);
|
2022-01-03 02:53:15 +08:00
|
|
|
|
print_spaces (2 * recurse, stream);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_tuple || is_tuple_struct)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (")", stream);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
else
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("}", stream);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
/* See rust-lang.h. */
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
void
|
|
|
|
|
rust_language::print_enum (struct value *val, struct ui_file *stream,
|
|
|
|
|
int recurse,
|
|
|
|
|
const struct value_print_options *options) const
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
{
|
|
|
|
|
struct value_print_options opts = *options;
|
2023-01-31 22:52:09 +08:00
|
|
|
|
struct type *type = check_typedef (val->type ());
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
|
2022-06-13 04:13:22 +08:00
|
|
|
|
opts.deref_ref = false;
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
|
2020-04-25 03:40:31 +08:00
|
|
|
|
gdb_assert (rust_enum_p (type));
|
2021-10-05 08:47:06 +08:00
|
|
|
|
gdb::array_view<const gdb_byte> view
|
2023-02-01 05:38:30 +08:00
|
|
|
|
(val->contents_for_printing ().data (),
|
2023-01-31 22:52:09 +08:00
|
|
|
|
val->type ()->length ());
|
2023-02-01 03:27:30 +08:00
|
|
|
|
type = resolve_dynamic_type (type, view, val->address ());
|
2020-04-25 03:40:31 +08:00
|
|
|
|
|
2018-09-12 05:28:04 +08:00
|
|
|
|
if (rust_empty_enum_p (type))
|
|
|
|
|
{
|
|
|
|
|
/* Print the enum type name here to be more clear. */
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, _("%s {%p[<No data fields>%p]}"),
|
|
|
|
|
type->name (),
|
|
|
|
|
metadata_style.style ().ptr (), nullptr);
|
2018-09-12 05:28:04 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-25 03:40:31 +08:00
|
|
|
|
int variant_fieldno = rust_enum_variant (type);
|
2023-02-10 03:12:42 +08:00
|
|
|
|
val = val->primitive_field (0, variant_fieldno, type);
|
2020-06-09 03:26:20 +08:00
|
|
|
|
struct type *variant_type = type->field (variant_fieldno).type ();
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
|
2020-05-23 04:55:15 +08:00
|
|
|
|
int nfields = variant_type->num_fields ();
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
|
|
|
|
|
bool is_tuple = rust_tuple_struct_type_p (variant_type);
|
|
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "%s", variant_type->name ());
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
if (nfields == 0)
|
|
|
|
|
{
|
|
|
|
|
/* In case of a nullary variant like 'None', just output
|
|
|
|
|
the name. */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* In case of a non-nullary variant, we output 'Foo(x,y,z)'. */
|
|
|
|
|
if (is_tuple)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "(");
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* struct variant. */
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "{");
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool first_field = true;
|
2023-02-10 03:13:08 +08:00
|
|
|
|
for (int j = 0; j < nfields; j++)
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
{
|
|
|
|
|
if (!first_field)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (", ", stream);
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
first_field = false;
|
|
|
|
|
|
|
|
|
|
if (!is_tuple)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "%ps: ",
|
|
|
|
|
styled_string (variable_name_style.style (),
|
|
|
|
|
variant_type->field (j).name ()));
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
|
2021-05-15 09:54:35 +08:00
|
|
|
|
common_val_print (value_field (val, j), stream, recurse + 1, &opts,
|
|
|
|
|
this);
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_tuple)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (")", stream);
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
else
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("}", stream);
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
/* See language.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
rust_language::value_print_inner
|
|
|
|
|
(struct value *val, struct ui_file *stream, int recurse,
|
|
|
|
|
const struct value_print_options *options) const
|
2020-03-14 07:39:52 +08:00
|
|
|
|
{
|
|
|
|
|
struct value_print_options opts = *options;
|
2022-06-13 04:13:22 +08:00
|
|
|
|
opts.deref_ref = true;
|
2020-03-14 07:39:52 +08:00
|
|
|
|
|
|
|
|
|
if (opts.prettyformat == Val_prettyformat_default)
|
|
|
|
|
opts.prettyformat = (opts.prettyformat_structs
|
|
|
|
|
? Val_prettyformat : Val_no_prettyformat);
|
|
|
|
|
|
2023-01-31 22:52:09 +08:00
|
|
|
|
struct type *type = check_typedef (val->type ());
|
2020-05-15 01:46:38 +08:00
|
|
|
|
switch (type->code ())
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_PTR:
|
|
|
|
|
{
|
|
|
|
|
LONGEST low_bound, high_bound;
|
|
|
|
|
|
2022-07-31 10:43:54 +08:00
|
|
|
|
if (type->target_type ()->code () == TYPE_CODE_ARRAY
|
|
|
|
|
&& rust_u8_type_p (type->target_type ()->target_type ())
|
|
|
|
|
&& get_array_bounds (type->target_type (), &low_bound,
|
2020-03-14 07:39:52 +08:00
|
|
|
|
&high_bound))
|
|
|
|
|
{
|
|
|
|
|
/* We have a pointer to a byte string, so just print
|
|
|
|
|
that. */
|
2022-07-31 10:43:54 +08:00
|
|
|
|
struct type *elttype = check_typedef (type->target_type ());
|
2020-03-14 07:39:52 +08:00
|
|
|
|
CORE_ADDR addr = value_as_address (val);
|
2021-01-28 23:12:10 +08:00
|
|
|
|
struct gdbarch *arch = type->arch ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2020-03-14 07:39:52 +08:00
|
|
|
|
if (opts.addressprint)
|
|
|
|
|
{
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (paddress (arch, addr), stream);
|
|
|
|
|
gdb_puts (" ", stream);
|
2020-03-14 07:39:52 +08:00
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("b", stream);
|
2022-07-31 10:43:54 +08:00
|
|
|
|
val_print_string (elttype->target_type (), "ASCII", addr,
|
2020-03-14 07:39:52 +08:00
|
|
|
|
high_bound - low_bound + 1, stream,
|
|
|
|
|
&opts);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
2020-03-14 07:39:52 +08:00
|
|
|
|
goto generic_print;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
case TYPE_CODE_INT:
|
|
|
|
|
/* Recognize the unit type. */
|
2022-09-21 23:05:21 +08:00
|
|
|
|
if (type->is_unsigned () && type->length () == 0
|
2020-05-17 00:16:06 +08:00
|
|
|
|
&& type->name () != NULL && strcmp (type->name (), "()") == 0)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("()", stream);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
goto generic_print;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_STRING:
|
|
|
|
|
{
|
|
|
|
|
LONGEST low_bound, high_bound;
|
|
|
|
|
|
|
|
|
|
if (!get_array_bounds (type, &low_bound, &high_bound))
|
|
|
|
|
error (_("Could not determine the array bounds"));
|
|
|
|
|
|
|
|
|
|
/* If we see a plain TYPE_CODE_STRING, then we're printing a
|
|
|
|
|
byte string, hence the choice of "ASCII" as the
|
|
|
|
|
encoding. */
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("b", stream);
|
2022-07-31 10:43:54 +08:00
|
|
|
|
printstr (stream, type->target_type (),
|
2023-02-01 05:38:30 +08:00
|
|
|
|
val->contents_for_printing ().data (),
|
2020-10-30 23:09:35 +08:00
|
|
|
|
high_bound - low_bound + 1, "ASCII", 0, &opts);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
|
{
|
|
|
|
|
LONGEST low_bound, high_bound;
|
|
|
|
|
|
|
|
|
|
if (get_array_bounds (type, &low_bound, &high_bound)
|
|
|
|
|
&& high_bound - low_bound + 1 == 0)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("[]", stream);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else
|
|
|
|
|
goto generic_print;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_UNION:
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
/* Untagged unions are printed as if they are structs. Since
|
|
|
|
|
the field bit positions overlap in the debuginfo, the code
|
|
|
|
|
for printing a union is same as that for a struct, the only
|
|
|
|
|
difference is that the input type will have overlapping
|
|
|
|
|
fields. */
|
2020-03-14 07:39:52 +08:00
|
|
|
|
val_print_struct (val, stream, recurse, &opts);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
if (rust_enum_p (type))
|
2020-10-30 23:09:35 +08:00
|
|
|
|
print_enum (val, stream, recurse, &opts);
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
else
|
2020-03-14 07:39:52 +08:00
|
|
|
|
val_print_struct (val, stream, recurse, &opts);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
break;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2016-10-29 09:00:43 +08:00
|
|
|
|
default:
|
|
|
|
|
generic_print:
|
|
|
|
|
/* Nothing special yet. */
|
2020-03-14 07:39:52 +08:00
|
|
|
|
generic_value_print (val, stream, recurse, &opts, &rust_decorations);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2022-03-28 05:29:28 +08:00
|
|
|
|
/* See language.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
rust_language::value_print
|
|
|
|
|
(struct value *val, struct ui_file *stream,
|
|
|
|
|
const struct value_print_options *options) const
|
|
|
|
|
{
|
|
|
|
|
value_print_options opts = *options;
|
|
|
|
|
opts.deref_ref = true;
|
|
|
|
|
|
2023-01-31 22:52:09 +08:00
|
|
|
|
struct type *type = check_typedef (val->type ());
|
2022-03-28 05:29:28 +08:00
|
|
|
|
if (type->is_pointer_or_reference ())
|
|
|
|
|
{
|
|
|
|
|
gdb_printf (stream, "(");
|
2023-01-31 22:52:09 +08:00
|
|
|
|
type_print (val->type (), "", stream, -1);
|
2022-03-28 05:29:28 +08:00
|
|
|
|
gdb_printf (stream, ") ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return common_val_print (val, stream, 0, &opts, this);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2016-10-29 09:00:43 +08:00
|
|
|
|
static void
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
rust_internal_print_type (struct type *type, const char *varstring,
|
|
|
|
|
struct ui_file *stream, int show, int level,
|
|
|
|
|
const struct type_print_options *flags,
|
2018-06-09 03:18:25 +08:00
|
|
|
|
bool for_rust_enum, print_offset_data *podata);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
|
|
|
|
/* Print a struct or union typedef. */
|
|
|
|
|
static void
|
|
|
|
|
rust_print_struct_def (struct type *type, const char *varstring,
|
2017-02-03 12:01:11 +08:00
|
|
|
|
struct ui_file *stream, int show, int level,
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
const struct type_print_options *flags,
|
2018-06-09 03:18:25 +08:00
|
|
|
|
bool for_rust_enum, print_offset_data *podata)
|
2016-10-29 09:00:43 +08:00
|
|
|
|
{
|
2017-02-03 12:01:11 +08:00
|
|
|
|
/* Print a tuple type simply. */
|
|
|
|
|
if (rust_tuple_type_p (type))
|
|
|
|
|
{
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (type->name (), stream);
|
2017-02-03 12:01:11 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2017-02-03 12:01:11 +08:00
|
|
|
|
/* If we see a base class, delegate to C. */
|
|
|
|
|
if (TYPE_N_BASECLASSES (type) > 0)
|
Always pass an explicit language down to c_type_print
The next patch will want to do language->print_type(type, ...), to
print a type in a given language, avoiding a dependency on the current
language. That doesn't work correctly currently, however, because
most language implementations of language_defn::print_type call
c_print_type without passing down the language. There are two
overloads of c_print_type, one that takes a language, and one that
does not. The one that does not uses the current language, defeating
the point of calling language->print_type()...
This commit removes the c_print_type overload that does not take a
language, and adjusts the codebase throughout to always pass down a
language. In most places, there's already an enum language handy.
language_defn::print_type implementations naturally pass down
this->la_language. In a couple spots, like in ada-typeprint.c and
rust-lang.c there's no enum language handy, but the code is written
for a specific language, so we just hardcode the language.
In gnuv3_print_method_ptr, I wasn't sure whether we could hardcode C++
here, and we don't have an enum language handy, so I made it use the
current language, just like today. Can always be improved later.
Change-Id: Ib54fab4cf0fd307bfd55bf1dd5056830096a653b
2022-04-30 06:21:18 +08:00
|
|
|
|
c_print_type (type, varstring, stream, show, level, language_rust, flags);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2018-06-09 03:18:25 +08:00
|
|
|
|
if (flags->print_offsets)
|
|
|
|
|
{
|
|
|
|
|
/* Temporarily bump the level so that the output lines up
|
|
|
|
|
correctly. */
|
|
|
|
|
level += 2;
|
|
|
|
|
}
|
|
|
|
|
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
/* Compute properties of TYPE here because, in the enum case, the
|
|
|
|
|
rest of the code ends up looking only at the variant part. */
|
2020-05-17 00:16:06 +08:00
|
|
|
|
const char *tagname = type->name ();
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
bool is_tuple_struct = rust_tuple_struct_type_p (type);
|
|
|
|
|
bool is_tuple = rust_tuple_type_p (type);
|
|
|
|
|
bool is_enum = rust_enum_p (type);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
if (for_rust_enum)
|
|
|
|
|
{
|
|
|
|
|
/* Already printing an outer enum, so nothing to print here. */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* This code path is also used by unions and enums. */
|
|
|
|
|
if (is_enum)
|
|
|
|
|
{
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("enum ", stream);
|
2020-05-07 23:32:25 +08:00
|
|
|
|
dynamic_prop *prop = type->dyn_prop (DYN_PROP_VARIANT_PARTS);
|
gdb: add accessors to struct dynamic_prop
Add setters, to ensure that the kind and value of the property are
always kept in sync (a caller can't forget one or the other). Add
getters, such that we can assert that when a caller accesses a data bit
of the property, the property is indeed of the corresponding kind.
Note that because of the way `struct dynamic_prop` is allocated
currently, we can't make the `m_kind` and `m_data` fields private. That
would make the type non-default-constructible, and we would have to call
the constructor when allocating them. However, I still prefixed them
with `m_` to indicate that they should not be accessed from outside the
class (and also to be able to use the name `kind` for the method).
gdb/ChangeLog:
* gdbtypes.h (struct dynamic_prop) <kind, set_undefined,
const_val, set_const_val, baton, set_locexpr, set_loclist,
set_addr_offset, variant_parts, set_variant_parts,
original_type, set_original_type>: New methods.
<kind>: Rename to...
<m_kind>: ... this. Update all users to use the new methods
instead.
<data>: Rename to...
<m_data>: ... this. Update all users to use the new methods
instead.
Change-Id: Ib72a8eb440dfeb1a5421d0933334230d7f2478f9
2020-07-13 10:58:51 +08:00
|
|
|
|
if (prop != nullptr && prop->kind () == PROP_TYPE)
|
|
|
|
|
type = prop->original_type ();
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
}
|
2020-05-15 01:46:38 +08:00
|
|
|
|
else if (type->code () == TYPE_CODE_STRUCT)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("struct ", stream);
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
else
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("union ", stream);
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
if (tagname != NULL)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (tagname, stream);
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
}
|
2016-10-29 09:00:43 +08:00
|
|
|
|
|
2020-05-23 04:55:15 +08:00
|
|
|
|
if (type->num_fields () == 0 && !is_tuple)
|
2017-02-03 12:01:11 +08:00
|
|
|
|
return;
|
2018-06-09 03:18:25 +08:00
|
|
|
|
if (for_rust_enum && !flags->print_offsets)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (is_tuple_struct ? "(" : "{", stream);
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
else
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (is_tuple_struct ? " (\n" : " {\n", stream);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2018-06-09 03:18:25 +08:00
|
|
|
|
/* When printing offsets, we rearrange the fields into storage
|
|
|
|
|
order. This lets us show holes more clearly. We work using
|
|
|
|
|
field indices here because it simplifies calls to
|
|
|
|
|
print_offset_data::update below. */
|
|
|
|
|
std::vector<int> fields;
|
2020-05-23 04:55:15 +08:00
|
|
|
|
for (int i = 0; i < type->num_fields (); ++i)
|
2017-02-03 12:01:11 +08:00
|
|
|
|
{
|
2023-04-23 02:41:43 +08:00
|
|
|
|
if (type->field (i).is_static ())
|
2017-02-03 12:01:11 +08:00
|
|
|
|
continue;
|
2023-08-31 23:46:24 +08:00
|
|
|
|
if (is_enum && type->field (i).is_artificial ())
|
2018-06-09 03:18:25 +08:00
|
|
|
|
continue;
|
|
|
|
|
fields.push_back (i);
|
|
|
|
|
}
|
|
|
|
|
if (flags->print_offsets)
|
|
|
|
|
std::sort (fields.begin (), fields.end (),
|
|
|
|
|
[&] (int a, int b)
|
|
|
|
|
{
|
2021-09-27 04:36:15 +08:00
|
|
|
|
return (type->field (a).loc_bitpos ()
|
|
|
|
|
< type->field (b).loc_bitpos ());
|
2018-06-09 03:18:25 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (int i : fields)
|
|
|
|
|
{
|
|
|
|
|
QUIT;
|
|
|
|
|
|
2023-04-23 02:41:43 +08:00
|
|
|
|
gdb_assert (!type->field (i).is_static ());
|
2023-08-31 23:46:24 +08:00
|
|
|
|
gdb_assert (! (is_enum && type->field (i).is_artificial ()));
|
2018-06-09 03:18:25 +08:00
|
|
|
|
|
|
|
|
|
if (flags->print_offsets)
|
|
|
|
|
podata->update (type, i, stream);
|
2017-02-03 12:01:11 +08:00
|
|
|
|
|
|
|
|
|
/* We'd like to print "pub" here as needed, but rustc
|
|
|
|
|
doesn't emit the debuginfo, and our types don't have
|
|
|
|
|
cplus_struct_type attached. */
|
|
|
|
|
|
|
|
|
|
/* For a tuple struct we print the type but nothing
|
|
|
|
|
else. */
|
2018-06-09 03:18:25 +08:00
|
|
|
|
if (!for_rust_enum || flags->print_offsets)
|
2022-01-03 02:53:15 +08:00
|
|
|
|
print_spaces (level + 2, stream);
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
if (is_enum)
|
2021-08-30 23:49:49 +08:00
|
|
|
|
fputs_styled (type->field (i).name (), variable_name_style.style (),
|
2020-02-23 01:02:42 +08:00
|
|
|
|
stream);
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
else if (!is_tuple_struct)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "%ps: ",
|
|
|
|
|
styled_string (variable_name_style.style (),
|
|
|
|
|
type->field (i).name ()));
|
2017-02-03 12:01:11 +08:00
|
|
|
|
|
2020-06-09 03:26:20 +08:00
|
|
|
|
rust_internal_print_type (type->field (i).type (), NULL,
|
2018-03-30 02:08:32 +08:00
|
|
|
|
stream, (is_enum ? show : show - 1),
|
2018-06-09 03:18:25 +08:00
|
|
|
|
level + 2, flags, is_enum, podata);
|
|
|
|
|
if (!for_rust_enum || flags->print_offsets)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (",\n", stream);
|
2018-06-09 03:18:25 +08:00
|
|
|
|
/* Note that this check of "I" is ok because we only sorted the
|
|
|
|
|
fields by offset when print_offsets was set, so we won't take
|
|
|
|
|
this branch in that case. */
|
2020-05-23 04:55:15 +08:00
|
|
|
|
else if (i + 1 < type->num_fields ())
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (", ", stream);
|
2017-02-03 12:01:11 +08:00
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2018-06-09 03:18:25 +08:00
|
|
|
|
if (flags->print_offsets)
|
|
|
|
|
{
|
|
|
|
|
/* Undo the temporary level increase we did above. */
|
|
|
|
|
level -= 2;
|
|
|
|
|
podata->finish (type, level, stream);
|
2022-01-03 02:53:15 +08:00
|
|
|
|
print_spaces (print_offset_data::indentation, stream);
|
2018-06-09 03:18:25 +08:00
|
|
|
|
if (level == 0)
|
2022-01-03 02:53:15 +08:00
|
|
|
|
print_spaces (2, stream);
|
2018-06-09 03:18:25 +08:00
|
|
|
|
}
|
|
|
|
|
if (!for_rust_enum || flags->print_offsets)
|
2022-01-03 02:53:15 +08:00
|
|
|
|
print_spaces (level, stream);
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (is_tuple_struct ? ")" : "}", stream);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* la_print_type implementation for Rust. */
|
|
|
|
|
|
|
|
|
|
static void
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
rust_internal_print_type (struct type *type, const char *varstring,
|
|
|
|
|
struct ui_file *stream, int show, int level,
|
|
|
|
|
const struct type_print_options *flags,
|
2018-06-09 03:18:25 +08:00
|
|
|
|
bool for_rust_enum, print_offset_data *podata)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
QUIT;
|
|
|
|
|
if (show <= 0
|
2020-05-17 00:16:06 +08:00
|
|
|
|
&& type->name () != NULL)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2016-06-27 23:46:59 +08:00
|
|
|
|
/* Rust calls the unit type "void" in its debuginfo,
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
|
but we don't want to print it as that. */
|
2020-05-15 01:46:38 +08:00
|
|
|
|
if (type->code () == TYPE_CODE_VOID)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("()", stream);
|
2016-06-27 23:46:59 +08:00
|
|
|
|
else
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (type->name (), stream);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type = check_typedef (type);
|
2020-05-15 01:46:38 +08:00
|
|
|
|
switch (type->code ())
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2016-06-27 23:46:59 +08:00
|
|
|
|
case TYPE_CODE_VOID:
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
/* If we have an enum, we've already printed the type's
|
|
|
|
|
unqualified name, and there is nothing else to print
|
|
|
|
|
here. */
|
|
|
|
|
if (!for_rust_enum)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("()", stream);
|
2016-06-27 23:46:59 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2016-04-27 09:38:08 +08:00
|
|
|
|
case TYPE_CODE_FUNC:
|
|
|
|
|
/* Delegate varargs to the C printer. */
|
2020-09-14 23:08:02 +08:00
|
|
|
|
if (type->has_varargs ())
|
2016-04-27 09:38:08 +08:00
|
|
|
|
goto c_printer;
|
|
|
|
|
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("fn ", stream);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (varstring != NULL)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (varstring, stream);
|
|
|
|
|
gdb_puts ("(", stream);
|
2020-05-23 04:55:15 +08:00
|
|
|
|
for (int i = 0; i < type->num_fields (); ++i)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
QUIT;
|
|
|
|
|
if (i > 0)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (", ", stream);
|
2020-06-09 03:26:20 +08:00
|
|
|
|
rust_internal_print_type (type->field (i).type (), "", stream,
|
2018-06-09 03:18:25 +08:00
|
|
|
|
-1, 0, flags, false, podata);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (")", stream);
|
2016-06-27 23:46:59 +08:00
|
|
|
|
/* If it returns unit, we can omit the return type. */
|
2022-07-31 10:43:54 +08:00
|
|
|
|
if (type->target_type ()->code () != TYPE_CODE_VOID)
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
|
{
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (" -> ", stream);
|
2022-07-31 10:43:54 +08:00
|
|
|
|
rust_internal_print_type (type->target_type (), "", stream,
|
2018-06-09 03:18:25 +08:00
|
|
|
|
-1, 0, flags, false, podata);
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
|
{
|
|
|
|
|
LONGEST low_bound, high_bound;
|
|
|
|
|
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("[", stream);
|
2022-07-31 10:43:54 +08:00
|
|
|
|
rust_internal_print_type (type->target_type (), NULL,
|
2018-06-09 03:18:25 +08:00
|
|
|
|
stream, show - 1, level, flags, false,
|
|
|
|
|
podata);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2020-07-13 11:05:08 +08:00
|
|
|
|
if (type->bounds ()->high.kind () == PROP_LOCEXPR
|
|
|
|
|
|| type->bounds ()->high.kind () == PROP_LOCLIST)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "; variable length");
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else if (get_array_bounds (type, &low_bound, &high_bound))
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "; %s",
|
|
|
|
|
plongest (high_bound - low_bound + 1));
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("]", stream);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
case TYPE_CODE_UNION:
|
2016-04-27 09:38:08 +08:00
|
|
|
|
case TYPE_CODE_STRUCT:
|
Convert Rust to use discriminated unions
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.
2018-02-10 04:31:51 +08:00
|
|
|
|
rust_print_struct_def (type, varstring, stream, show, level, flags,
|
2018-06-09 03:18:25 +08:00
|
|
|
|
for_rust_enum, podata);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_ENUM:
|
|
|
|
|
{
|
2018-04-22 06:16:27 +08:00
|
|
|
|
int len = 0;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("enum ", stream);
|
2020-05-17 00:16:06 +08:00
|
|
|
|
if (type->name () != NULL)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (type->name (), stream);
|
|
|
|
|
gdb_puts (" ", stream);
|
2020-05-17 00:16:06 +08:00
|
|
|
|
len = strlen (type->name ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("{\n", stream);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2020-05-23 04:55:15 +08:00
|
|
|
|
for (int i = 0; i < type->num_fields (); ++i)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2021-08-30 23:49:49 +08:00
|
|
|
|
const char *name = type->field (i).name ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
QUIT;
|
|
|
|
|
|
|
|
|
|
if (len > 0
|
2020-05-17 00:16:06 +08:00
|
|
|
|
&& strncmp (name, type->name (), len) == 0
|
2016-04-27 09:38:08 +08:00
|
|
|
|
&& name[len] == ':'
|
|
|
|
|
&& name[len + 1] == ':')
|
|
|
|
|
name += len + 2;
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "%*s%ps,\n",
|
|
|
|
|
level + 2, "",
|
|
|
|
|
styled_string (variable_name_style.style (),
|
|
|
|
|
name));
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("}", stream);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
2018-11-17 06:30:35 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_PTR:
|
|
|
|
|
{
|
2020-05-17 00:16:06 +08:00
|
|
|
|
if (type->name () != nullptr)
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts (type->name (), stream);
|
2018-11-17 06:30:35 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We currently can't distinguish between pointers and
|
|
|
|
|
references. */
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("*mut ", stream);
|
2022-07-31 10:43:54 +08:00
|
|
|
|
type_print (type->target_type (), "", stream, 0);
|
2018-11-17 06:30:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
c_printer:
|
Always pass an explicit language down to c_type_print
The next patch will want to do language->print_type(type, ...), to
print a type in a given language, avoiding a dependency on the current
language. That doesn't work correctly currently, however, because
most language implementations of language_defn::print_type call
c_print_type without passing down the language. There are two
overloads of c_print_type, one that takes a language, and one that
does not. The one that does not uses the current language, defeating
the point of calling language->print_type()...
This commit removes the c_print_type overload that does not take a
language, and adjusts the codebase throughout to always pass down a
language. In most places, there's already an enum language handy.
language_defn::print_type implementations naturally pass down
this->la_language. In a couple spots, like in ada-typeprint.c and
rust-lang.c there's no enum language handy, but the code is written
for a specific language, so we just hardcode the language.
In gnuv3_print_method_ptr, I wasn't sure whether we could hardcode C++
here, and we don't have an enum language handy, so I made it use the
current language, just like today. Can always be improved later.
Change-Id: Ib54fab4cf0fd307bfd55bf1dd5056830096a653b
2022-04-30 06:21:18 +08:00
|
|
|
|
c_print_type (type, varstring, stream, show, level, language_rust,
|
|
|
|
|
flags);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Like arch_composite_type, but uses TYPE to decide how to allocate
|
|
|
|
|
-- either on an obstack or on a gdbarch. */
|
|
|
|
|
|
|
|
|
|
static struct type *
|
|
|
|
|
rust_composite_type (struct type *original,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *field1, struct type *type1,
|
|
|
|
|
const char *field2, struct type *type2)
|
|
|
|
|
{
|
2023-03-13 22:59:34 +08:00
|
|
|
|
struct type *result = type_allocator (original).new_type ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
int i, nfields, bitpos;
|
|
|
|
|
|
|
|
|
|
nfields = 0;
|
|
|
|
|
if (field1 != NULL)
|
|
|
|
|
++nfields;
|
|
|
|
|
if (field2 != NULL)
|
|
|
|
|
++nfields;
|
|
|
|
|
|
2020-05-15 01:45:40 +08:00
|
|
|
|
result->set_code (TYPE_CODE_STRUCT);
|
2020-05-17 00:15:54 +08:00
|
|
|
|
result->set_name (name);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
[gdb/symtab] Factor out type::{alloc_fields,copy_fields}
After finding this code in buildsym_compunit::finish_block_internal:
...
ftype->set_fields
((struct field *)
TYPE_ALLOC (ftype, nparams * sizeof (struct field)));
...
and fixing PR30810 by using TYPE_ZALLOC, I wondered if there were more
locations that needed fixing.
I decided to make things easier to spot by factoring out a new function
alloc_fields:
...
/* Allocate the fields array of this type, with NFIELDS elements. If INIT,
zero-initialize the allocated memory. */
void
type::alloc_fields (unsigned int nfields, bool init = true);
...
where:
- a regular use would be "alloc_fields (nfields)", and
- an exceptional use that needed no initialization would be
"alloc_fields (nfields, false)".
Pretty soon I discovered that most of the latter cases are due to
initialization by memcpy, so I added two variants of copy_fields as well.
After this rewrite there are 8 uses of set_fields left:
...
gdb/coffread.c: type->set_fields (nullptr);
gdb/coffread.c: type->set_fields (nullptr);
gdb/coffread.c: type->set_fields (nullptr);
gdb/eval.c: type->set_fields
gdb/gdbtypes.c: type->set_fields (args);
gdb/gdbtypes.c: t->set_fields (XRESIZEVEC (struct field, t->fields (),
gdb/dwarf2/read.c: type->set_fields (new_fields);
gdb/dwarf2/read.c: sub_type->set_fields (sub_type->fields () + 1);
...
These fall into the following categories:
- set to nullptr (coffread.c),
- type not owned by objfile or gdbarch (eval.c), and
- modifying an existing fields array, like adding an element at the end or
dropping an element at the start (the rest).
Tested on x86_64-linux.
2023-08-31 15:37:44 +08:00
|
|
|
|
result->alloc_fields (nfields);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
bitpos = 0;
|
|
|
|
|
if (field1 != NULL)
|
|
|
|
|
{
|
2020-05-24 05:39:54 +08:00
|
|
|
|
struct field *field = &result->field (i);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
gdb: add accessors for field (and call site) location
Add accessors for the various location values in struct field. This
lets us assert that when we get a location value of a certain kind (say,
bitpos), the field's location indeed contains a value of that kind.
Remove the SET_FIELD_* macros, instead use the new setters directly.
Update the FIELD_* macros used to access field locations to go through
the getters. They will be removed in a subsequent patch.
There are places where the FIELD_* macros are used on call_site_target
structures, because it contains members of the same name (loc_kind and
loc). For now, I have replicated the getters/setters in
call_site_target. But we could perhaps eventually factor them in a
"location" structure that can be used at both places.
Note that the field structure, being zero-initialized, defaults to a
bitpos location with value 0. While writing this patch, I tried to make
it default to an "unset" location, to catch places where we would miss
setting a field's location. However, I found that some places relied on
the default being "bitpos 0", so I left it as-is. This change could
always be done as follow-up work, making these places explicitly set the
"bitpos 0" location.
I found two issues to fix:
- I got some failures in the gdb.base/infcall-nested-structs-c++.exp
test. They were caused by two functions in amd64-tdep.c using
TYPE_FIELD_BITPOS before checking if the location is of the bitpos
kind, which they do indirectly through `field_is_static`. Simply
move getting the bitpos below the field_is_static call.
- I got a failure in gdb.xml/tdesc-regs.exp. It turns out that in
make_gdb_type_enum, we set enum field values using SET_FIELD_BITPOS,
and later access them through FIELD_ENUMVAL. Fix that by using
set_loc_enumval to set the value.
Change-Id: I53d3734916c46457576ba11dd77df4049d2fc1e8
2021-10-01 10:38:29 +08:00
|
|
|
|
field->set_loc_bitpos (bitpos);
|
2022-09-21 23:05:21 +08:00
|
|
|
|
bitpos += type1->length () * TARGET_CHAR_BIT;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2021-08-30 23:49:48 +08:00
|
|
|
|
field->set_name (field1);
|
2020-06-09 03:26:04 +08:00
|
|
|
|
field->set_type (type1);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
if (field2 != NULL)
|
|
|
|
|
{
|
2020-05-24 05:39:54 +08:00
|
|
|
|
struct field *field = &result->field (i);
|
2018-04-24 03:23:02 +08:00
|
|
|
|
unsigned align = type_align (type2);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (align != 0)
|
|
|
|
|
{
|
|
|
|
|
int delta;
|
|
|
|
|
|
|
|
|
|
align *= TARGET_CHAR_BIT;
|
|
|
|
|
delta = bitpos % align;
|
|
|
|
|
if (delta != 0)
|
|
|
|
|
bitpos += align - delta;
|
|
|
|
|
}
|
gdb: add accessors for field (and call site) location
Add accessors for the various location values in struct field. This
lets us assert that when we get a location value of a certain kind (say,
bitpos), the field's location indeed contains a value of that kind.
Remove the SET_FIELD_* macros, instead use the new setters directly.
Update the FIELD_* macros used to access field locations to go through
the getters. They will be removed in a subsequent patch.
There are places where the FIELD_* macros are used on call_site_target
structures, because it contains members of the same name (loc_kind and
loc). For now, I have replicated the getters/setters in
call_site_target. But we could perhaps eventually factor them in a
"location" structure that can be used at both places.
Note that the field structure, being zero-initialized, defaults to a
bitpos location with value 0. While writing this patch, I tried to make
it default to an "unset" location, to catch places where we would miss
setting a field's location. However, I found that some places relied on
the default being "bitpos 0", so I left it as-is. This change could
always be done as follow-up work, making these places explicitly set the
"bitpos 0" location.
I found two issues to fix:
- I got some failures in the gdb.base/infcall-nested-structs-c++.exp
test. They were caused by two functions in amd64-tdep.c using
TYPE_FIELD_BITPOS before checking if the location is of the bitpos
kind, which they do indirectly through `field_is_static`. Simply
move getting the bitpos below the field_is_static call.
- I got a failure in gdb.xml/tdesc-regs.exp. It turns out that in
make_gdb_type_enum, we set enum field values using SET_FIELD_BITPOS,
and later access them through FIELD_ENUMVAL. Fix that by using
set_loc_enumval to set the value.
Change-Id: I53d3734916c46457576ba11dd77df4049d2fc1e8
2021-10-01 10:38:29 +08:00
|
|
|
|
field->set_loc_bitpos (bitpos);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2021-08-30 23:49:48 +08:00
|
|
|
|
field->set_name (field2);
|
2020-06-09 03:26:04 +08:00
|
|
|
|
field->set_type (type2);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i > 0)
|
2022-07-31 00:01:12 +08:00
|
|
|
|
result->set_length (result->field (i - 1).loc_bitpos () / TARGET_CHAR_BIT
|
2022-09-21 23:05:21 +08:00
|
|
|
|
+ result->field (i - 1).type ()->length ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See rust-lang.h. */
|
|
|
|
|
|
|
|
|
|
struct type *
|
|
|
|
|
rust_slice_type (const char *name, struct type *elt_type,
|
|
|
|
|
struct type *usize_type)
|
|
|
|
|
{
|
|
|
|
|
struct type *type;
|
|
|
|
|
|
|
|
|
|
elt_type = lookup_pointer_type (elt_type);
|
|
|
|
|
type = rust_composite_type (elt_type, name,
|
|
|
|
|
"data_ptr", elt_type,
|
|
|
|
|
"length", usize_type);
|
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-28 00:28:56 +08:00
|
|
|
|
/* A helper for rust_evaluate_subexp that handles OP_RANGE. */
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *
|
2021-03-08 22:27:57 +08:00
|
|
|
|
rust_range (struct type *expect_type, struct expression *exp,
|
|
|
|
|
enum noside noside, enum range_flag kind,
|
|
|
|
|
struct value *low, struct value *high)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
struct value *addrval, *result;
|
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
struct type *range_type;
|
|
|
|
|
struct type *index_type;
|
|
|
|
|
struct type *temp_type;
|
|
|
|
|
const char *name;
|
|
|
|
|
|
2020-05-05 23:03:53 +08:00
|
|
|
|
bool inclusive = !(kind & RANGE_HIGH_BOUND_EXCLUSIVE);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
if (low == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (high == NULL)
|
|
|
|
|
{
|
|
|
|
|
index_type = NULL;
|
|
|
|
|
name = "std::ops::RangeFull";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-01-31 22:52:09 +08:00
|
|
|
|
index_type = high->type ();
|
2018-03-30 04:14:07 +08:00
|
|
|
|
name = (inclusive
|
|
|
|
|
? "std::ops::RangeToInclusive" : "std::ops::RangeTo");
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (high == NULL)
|
|
|
|
|
{
|
2023-01-31 22:52:09 +08:00
|
|
|
|
index_type = low->type ();
|
2016-04-27 09:38:08 +08:00
|
|
|
|
name = "std::ops::RangeFrom";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-01-31 22:52:09 +08:00
|
|
|
|
if (!types_equal (low->type (), high->type ()))
|
2016-04-27 09:38:08 +08:00
|
|
|
|
error (_("Range expression with different types"));
|
2023-01-31 22:52:09 +08:00
|
|
|
|
index_type = low->type ();
|
2018-03-30 04:14:07 +08:00
|
|
|
|
name = inclusive ? "std::ops::RangeInclusive" : "std::ops::Range";
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If we don't have an index type, just allocate this on the
|
|
|
|
|
arch. Here any type will do. */
|
|
|
|
|
temp_type = (index_type == NULL
|
|
|
|
|
? language_bool_type (exp->language_defn, exp->gdbarch)
|
|
|
|
|
: index_type);
|
|
|
|
|
/* It would be nicer to cache the range type. */
|
|
|
|
|
range_type = rust_composite_type (temp_type, name,
|
|
|
|
|
low == NULL ? NULL : "start", index_type,
|
|
|
|
|
high == NULL ? NULL : "end", index_type);
|
|
|
|
|
|
|
|
|
|
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
2023-02-01 04:41:35 +08:00
|
|
|
|
return value::zero (range_type, lval_memory);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2022-09-21 23:05:21 +08:00
|
|
|
|
addrval = value_allocate_space_in_inferior (range_type->length ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
addr = value_as_long (addrval);
|
|
|
|
|
result = value_at_lazy (range_type, addr);
|
|
|
|
|
|
|
|
|
|
if (low != NULL)
|
|
|
|
|
{
|
2021-06-23 02:27:53 +08:00
|
|
|
|
struct value *start = value_struct_elt (&result, {}, "start", NULL,
|
2016-04-27 09:38:08 +08:00
|
|
|
|
"range");
|
|
|
|
|
|
|
|
|
|
value_assign (start, low);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (high != NULL)
|
|
|
|
|
{
|
2021-06-23 02:27:53 +08:00
|
|
|
|
struct value *end = value_struct_elt (&result, {}, "end", NULL,
|
2016-04-27 09:38:08 +08:00
|
|
|
|
"range");
|
|
|
|
|
|
|
|
|
|
value_assign (end, high);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = value_at_lazy (range_type, addr);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A helper function to compute the range and kind given a range
|
|
|
|
|
value. TYPE is the type of the range value. RANGE is the range
|
|
|
|
|
value. LOW, HIGH, and KIND are out parameters. The LOW and HIGH
|
|
|
|
|
parameters might be filled in, or might not be, depending on the
|
|
|
|
|
kind of range this is. KIND will always be set to the appropriate
|
|
|
|
|
value describing the kind of range, and this can be used to
|
|
|
|
|
determine whether LOW or HIGH are valid. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
rust_compute_range (struct type *type, struct value *range,
|
|
|
|
|
LONGEST *low, LONGEST *high,
|
2020-09-26 07:09:25 +08:00
|
|
|
|
range_flags *kind)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
*low = 0;
|
|
|
|
|
*high = 0;
|
2020-05-05 23:03:53 +08:00
|
|
|
|
*kind = RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2020-05-23 04:55:15 +08:00
|
|
|
|
if (type->num_fields () == 0)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
i = 0;
|
2021-08-30 23:49:49 +08:00
|
|
|
|
if (strcmp (type->field (0).name (), "start") == 0)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2020-05-05 23:03:53 +08:00
|
|
|
|
*kind = RANGE_HIGH_BOUND_DEFAULT;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
*low = value_as_long (value_field (range, 0));
|
|
|
|
|
++i;
|
|
|
|
|
}
|
2020-05-23 04:55:15 +08:00
|
|
|
|
if (type->num_fields () > i
|
2021-08-30 23:49:49 +08:00
|
|
|
|
&& strcmp (type->field (i).name (), "end") == 0)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2020-05-05 23:03:53 +08:00
|
|
|
|
*kind = (*kind == (RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT)
|
|
|
|
|
? RANGE_LOW_BOUND_DEFAULT : RANGE_STANDARD);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
*high = value_as_long (value_field (range, i));
|
2018-03-30 04:14:07 +08:00
|
|
|
|
|
|
|
|
|
if (rust_inclusive_range_type_p (type))
|
|
|
|
|
++*high;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A helper for rust_evaluate_subexp that handles BINOP_SUBSCRIPT. */
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *
|
2021-03-08 22:27:57 +08:00
|
|
|
|
rust_subscript (struct type *expect_type, struct expression *exp,
|
|
|
|
|
enum noside noside, bool for_addr,
|
|
|
|
|
struct value *lhs, struct value *rhs)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *result;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
struct type *rhstype;
|
2016-05-19 00:48:41 +08:00
|
|
|
|
LONGEST low, high_bound;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
/* Initialized to appease the compiler. */
|
2020-09-26 07:09:25 +08:00
|
|
|
|
range_flags kind = RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT;
|
2016-05-19 00:48:41 +08:00
|
|
|
|
LONGEST high = 0;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
int want_slice = 0;
|
|
|
|
|
|
2023-01-31 22:52:09 +08:00
|
|
|
|
rhstype = check_typedef (rhs->type ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (rust_range_type_p (rhstype))
|
|
|
|
|
{
|
|
|
|
|
if (!for_addr)
|
|
|
|
|
error (_("Can't take slice of array without '&'"));
|
|
|
|
|
rust_compute_range (rhstype, rhs, &low, &high, &kind);
|
|
|
|
|
want_slice = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
low = value_as_long (rhs);
|
|
|
|
|
|
2023-01-31 22:52:09 +08:00
|
|
|
|
struct type *type = check_typedef (lhs->type ());
|
2024-01-31 01:06:46 +08:00
|
|
|
|
struct type *orig_type = type;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
|
|
|
|
{
|
2017-10-03 03:47:15 +08:00
|
|
|
|
struct type *base_type = nullptr;
|
2020-05-15 01:46:38 +08:00
|
|
|
|
if (type->code () == TYPE_CODE_ARRAY)
|
2022-07-31 10:43:54 +08:00
|
|
|
|
base_type = type->target_type ();
|
2017-10-03 03:47:15 +08:00
|
|
|
|
else if (rust_slice_type_p (type))
|
|
|
|
|
{
|
2024-01-31 01:06:46 +08:00
|
|
|
|
base_type = rust_array_like_element_type (type);
|
2017-10-03 03:47:15 +08:00
|
|
|
|
if (base_type == nullptr)
|
2024-01-31 01:06:46 +08:00
|
|
|
|
error (_("Cannot subscript non-array-like slice"));
|
2017-10-03 03:47:15 +08:00
|
|
|
|
}
|
2020-05-15 01:46:38 +08:00
|
|
|
|
else if (type->code () == TYPE_CODE_PTR)
|
2022-07-31 10:43:54 +08:00
|
|
|
|
base_type = type->target_type ();
|
2017-10-03 03:47:15 +08:00
|
|
|
|
else
|
|
|
|
|
error (_("Cannot subscript non-array type"));
|
|
|
|
|
|
|
|
|
|
struct type *new_type;
|
|
|
|
|
if (want_slice)
|
|
|
|
|
{
|
|
|
|
|
if (rust_slice_type_p (type))
|
|
|
|
|
new_type = type;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
struct type *usize
|
|
|
|
|
= language_lookup_primitive_type (exp->language_defn,
|
|
|
|
|
exp->gdbarch,
|
|
|
|
|
"usize");
|
|
|
|
|
new_type = rust_slice_type ("&[*gdb*]", base_type, usize);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
new_type = base_type;
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2023-02-09 21:55:48 +08:00
|
|
|
|
return value::zero (new_type, lhs->lval ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LONGEST low_bound;
|
|
|
|
|
struct value *base;
|
|
|
|
|
|
2024-01-31 01:06:46 +08:00
|
|
|
|
if (rust_slice_type_p (type))
|
|
|
|
|
{
|
|
|
|
|
lhs = convert_slice (lhs);
|
|
|
|
|
type = check_typedef (lhs->type ());
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
|
if (type->code () == TYPE_CODE_ARRAY)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
{
|
|
|
|
|
base = lhs;
|
|
|
|
|
if (!get_array_bounds (type, &low_bound, &high_bound))
|
|
|
|
|
error (_("Can't compute array bounds"));
|
|
|
|
|
if (low_bound != 0)
|
|
|
|
|
error (_("Found array with non-zero lower bound"));
|
|
|
|
|
++high_bound;
|
|
|
|
|
}
|
2020-05-15 01:46:38 +08:00
|
|
|
|
else if (type->code () == TYPE_CODE_PTR)
|
2016-07-06 13:25:10 +08:00
|
|
|
|
{
|
|
|
|
|
base = lhs;
|
|
|
|
|
low_bound = 0;
|
|
|
|
|
high_bound = LONGEST_MAX;
|
|
|
|
|
}
|
2016-04-27 09:38:08 +08:00
|
|
|
|
else
|
|
|
|
|
error (_("Cannot subscript non-array type"));
|
|
|
|
|
|
2020-05-05 23:03:53 +08:00
|
|
|
|
if (want_slice && (kind & RANGE_LOW_BOUND_DEFAULT))
|
2016-04-27 09:38:08 +08:00
|
|
|
|
low = low_bound;
|
|
|
|
|
if (low < 0)
|
|
|
|
|
error (_("Index less than zero"));
|
|
|
|
|
if (low > high_bound)
|
|
|
|
|
error (_("Index greater than length"));
|
|
|
|
|
|
|
|
|
|
result = value_subscript (base, low);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (for_addr)
|
|
|
|
|
{
|
|
|
|
|
if (want_slice)
|
|
|
|
|
{
|
|
|
|
|
struct type *usize, *slice;
|
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
struct value *addrval, *tem;
|
|
|
|
|
|
2020-05-05 23:03:53 +08:00
|
|
|
|
if (kind & RANGE_HIGH_BOUND_DEFAULT)
|
2016-04-27 09:38:08 +08:00
|
|
|
|
high = high_bound;
|
|
|
|
|
if (high < 0)
|
|
|
|
|
error (_("High index less than zero"));
|
|
|
|
|
if (low > high)
|
|
|
|
|
error (_("Low index greater than high index"));
|
|
|
|
|
if (high > high_bound)
|
|
|
|
|
error (_("High index greater than length"));
|
|
|
|
|
|
|
|
|
|
usize = language_lookup_primitive_type (exp->language_defn,
|
|
|
|
|
exp->gdbarch,
|
|
|
|
|
"usize");
|
2024-01-31 01:06:46 +08:00
|
|
|
|
/* Preserve the name for slice-of-slice; this lets
|
|
|
|
|
string-printing work a bit more nicely. */
|
|
|
|
|
const char *new_name = ((orig_type != nullptr
|
|
|
|
|
&& rust_slice_type_p (orig_type))
|
|
|
|
|
? orig_type->name () : "&[*gdb*]");
|
2017-10-03 03:55:42 +08:00
|
|
|
|
|
2023-01-31 22:52:09 +08:00
|
|
|
|
slice = rust_slice_type (new_name, result->type (), usize);
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
2022-09-21 23:05:21 +08:00
|
|
|
|
addrval = value_allocate_space_in_inferior (slice->length ());
|
2016-04-27 09:38:08 +08:00
|
|
|
|
addr = value_as_long (addrval);
|
|
|
|
|
tem = value_at_lazy (slice, addr);
|
|
|
|
|
|
|
|
|
|
value_assign (value_field (tem, 0), value_addr (result));
|
|
|
|
|
value_assign (value_field (tem, 1),
|
|
|
|
|
value_from_longest (usize, high - low));
|
|
|
|
|
|
|
|
|
|
result = value_at_lazy (slice, addr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
result = value_addr (result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-24 03:48:38 +08:00
|
|
|
|
namespace expr
|
|
|
|
|
{
|
2021-03-08 22:27:57 +08:00
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *
|
2022-01-24 03:48:38 +08:00
|
|
|
|
rust_unop_ind_operation::evaluate (struct type *expect_type,
|
|
|
|
|
struct expression *exp,
|
|
|
|
|
enum noside noside)
|
2021-03-08 22:27:57 +08:00
|
|
|
|
{
|
2022-01-24 03:48:38 +08:00
|
|
|
|
if (noside != EVAL_NORMAL)
|
|
|
|
|
return unop_ind_operation::evaluate (expect_type, exp, noside);
|
|
|
|
|
|
|
|
|
|
struct value *value = std::get<0> (m_storage)->evaluate (nullptr, exp,
|
|
|
|
|
noside);
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *trait_ptr = rust_get_trait_object_pointer (value);
|
|
|
|
|
if (trait_ptr != NULL)
|
|
|
|
|
value = trait_ptr;
|
|
|
|
|
|
|
|
|
|
return value_ind (value);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-24 03:48:38 +08:00
|
|
|
|
} /* namespace expr */
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
/* A helper function for UNOP_COMPLEMENT. */
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *
|
2021-03-08 22:27:57 +08:00
|
|
|
|
eval_op_rust_complement (struct type *expect_type, struct expression *exp,
|
|
|
|
|
enum noside noside,
|
2021-03-08 22:27:57 +08:00
|
|
|
|
enum exp_opcode opcode,
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *value)
|
|
|
|
|
{
|
2023-01-31 22:52:09 +08:00
|
|
|
|
if (value->type ()->code () == TYPE_CODE_BOOL)
|
|
|
|
|
return value_from_longest (value->type (), value_logical_not (value));
|
2021-03-08 22:27:57 +08:00
|
|
|
|
return value_complement (value);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
/* A helper function for OP_ARRAY. */
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *
|
2021-03-08 22:27:57 +08:00
|
|
|
|
eval_op_rust_array (struct type *expect_type, struct expression *exp,
|
|
|
|
|
enum noside noside,
|
2021-03-08 22:27:57 +08:00
|
|
|
|
enum exp_opcode opcode,
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *elt, struct value *ncopies)
|
|
|
|
|
{
|
|
|
|
|
int copies = value_as_long (ncopies);
|
|
|
|
|
if (copies < 0)
|
|
|
|
|
error (_("Array with negative number of elements"));
|
|
|
|
|
|
|
|
|
|
if (noside == EVAL_NORMAL)
|
2023-08-30 23:21:20 +08:00
|
|
|
|
return value_array (0, std::vector<value *> (copies, elt));
|
2021-03-08 22:27:57 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
struct type *arraytype
|
2023-01-31 22:52:09 +08:00
|
|
|
|
= lookup_array_range_type (elt->type (), 0, copies - 1);
|
2023-02-01 04:25:17 +08:00
|
|
|
|
return value::allocate (arraytype);
|
2021-03-08 22:27:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-24 03:48:38 +08:00
|
|
|
|
namespace expr
|
|
|
|
|
{
|
2021-03-08 22:27:57 +08:00
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *
|
2022-01-24 03:48:38 +08:00
|
|
|
|
rust_struct_anon::evaluate (struct type *expect_type,
|
|
|
|
|
struct expression *exp,
|
|
|
|
|
enum noside noside)
|
2021-03-08 22:27:57 +08:00
|
|
|
|
{
|
2022-01-24 03:48:38 +08:00
|
|
|
|
value *lhs = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
|
|
|
|
|
int field_number = std::get<0> (m_storage);
|
|
|
|
|
|
2023-01-31 22:52:09 +08:00
|
|
|
|
struct type *type = lhs->type ();
|
2021-03-08 22:27:57 +08:00
|
|
|
|
|
|
|
|
|
if (type->code () == TYPE_CODE_STRUCT)
|
|
|
|
|
{
|
|
|
|
|
struct type *outer_type = NULL;
|
|
|
|
|
|
|
|
|
|
if (rust_enum_p (type))
|
|
|
|
|
{
|
2023-02-01 05:38:30 +08:00
|
|
|
|
type = resolve_dynamic_type (type, lhs->contents (),
|
2023-02-01 03:27:30 +08:00
|
|
|
|
lhs->address ());
|
2021-03-08 22:27:57 +08:00
|
|
|
|
|
|
|
|
|
if (rust_empty_enum_p (type))
|
|
|
|
|
error (_("Cannot access field %d of empty enum %s"),
|
|
|
|
|
field_number, type->name ());
|
|
|
|
|
|
|
|
|
|
int fieldno = rust_enum_variant (type);
|
2023-02-01 22:27:50 +08:00
|
|
|
|
lhs = lhs->primitive_field (0, fieldno, type);
|
2021-03-08 22:27:57 +08:00
|
|
|
|
outer_type = type;
|
2023-01-31 22:52:09 +08:00
|
|
|
|
type = lhs->type ();
|
2021-03-08 22:27:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Tuples and tuple structs */
|
|
|
|
|
int nfields = type->num_fields ();
|
|
|
|
|
|
|
|
|
|
if (field_number >= nfields || field_number < 0)
|
|
|
|
|
{
|
|
|
|
|
if (outer_type != NULL)
|
|
|
|
|
error(_("Cannot access field %d of variant %s::%s, "
|
|
|
|
|
"there are only %d fields"),
|
|
|
|
|
field_number, outer_type->name (),
|
|
|
|
|
rust_last_path_segment (type->name ()),
|
|
|
|
|
nfields);
|
|
|
|
|
else
|
|
|
|
|
error(_("Cannot access field %d of %s, "
|
|
|
|
|
"there are only %d fields"),
|
|
|
|
|
field_number, type->name (), nfields);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Tuples are tuple structs too. */
|
|
|
|
|
if (!rust_tuple_struct_type_p (type))
|
|
|
|
|
{
|
|
|
|
|
if (outer_type != NULL)
|
|
|
|
|
error(_("Variant %s::%s is not a tuple variant"),
|
|
|
|
|
outer_type->name (),
|
|
|
|
|
rust_last_path_segment (type->name ()));
|
|
|
|
|
else
|
|
|
|
|
error(_("Attempting to access anonymous field %d "
|
|
|
|
|
"of %s, which is not a tuple, tuple struct, or "
|
|
|
|
|
"tuple-like variant"),
|
|
|
|
|
field_number, type->name ());
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-01 22:27:50 +08:00
|
|
|
|
return lhs->primitive_field (0, field_number, type);
|
2021-03-08 22:27:57 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
error(_("Anonymous field access is only allowed on tuples, \
|
|
|
|
|
tuple structs, and tuple-like enum variants"));
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *
|
2022-01-24 03:48:38 +08:00
|
|
|
|
rust_structop::evaluate (struct type *expect_type,
|
|
|
|
|
struct expression *exp,
|
|
|
|
|
enum noside noside)
|
2021-03-08 22:27:57 +08:00
|
|
|
|
{
|
2022-01-24 03:48:38 +08:00
|
|
|
|
value *lhs = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
|
|
|
|
|
const char *field_name = std::get<1> (m_storage).c_str ();
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
struct value *result;
|
2023-01-31 22:52:09 +08:00
|
|
|
|
struct type *type = lhs->type ();
|
2021-03-08 22:27:57 +08:00
|
|
|
|
if (type->code () == TYPE_CODE_STRUCT && rust_enum_p (type))
|
|
|
|
|
{
|
2023-02-01 05:38:30 +08:00
|
|
|
|
type = resolve_dynamic_type (type, lhs->contents (),
|
2023-02-01 03:27:30 +08:00
|
|
|
|
lhs->address ());
|
2021-03-08 22:27:57 +08:00
|
|
|
|
|
|
|
|
|
if (rust_empty_enum_p (type))
|
|
|
|
|
error (_("Cannot access field %s of empty enum %s"),
|
|
|
|
|
field_name, type->name ());
|
|
|
|
|
|
|
|
|
|
int fieldno = rust_enum_variant (type);
|
2023-02-01 22:27:50 +08:00
|
|
|
|
lhs = lhs->primitive_field (0, fieldno, type);
|
2021-03-08 22:27:57 +08:00
|
|
|
|
|
|
|
|
|
struct type *outer_type = type;
|
2023-01-31 22:52:09 +08:00
|
|
|
|
type = lhs->type ();
|
2021-03-08 22:27:57 +08:00
|
|
|
|
if (rust_tuple_type_p (type) || rust_tuple_struct_type_p (type))
|
|
|
|
|
error (_("Attempting to access named field %s of tuple "
|
|
|
|
|
"variant %s::%s, which has only anonymous fields"),
|
|
|
|
|
field_name, outer_type->name (),
|
|
|
|
|
rust_last_path_segment (type->name ()));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-06-23 02:27:53 +08:00
|
|
|
|
result = value_struct_elt (&lhs, {}, field_name,
|
2021-03-08 22:27:57 +08:00
|
|
|
|
NULL, "structure");
|
|
|
|
|
}
|
|
|
|
|
catch (const gdb_exception_error &except)
|
|
|
|
|
{
|
|
|
|
|
error (_("Could not find field %s of struct variant %s::%s"),
|
|
|
|
|
field_name, outer_type->name (),
|
|
|
|
|
rust_last_path_segment (type->name ()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2024-01-31 01:06:46 +08:00
|
|
|
|
{
|
|
|
|
|
if (rust_slice_type_p (type))
|
|
|
|
|
lhs = convert_slice (lhs);
|
|
|
|
|
result = value_struct_elt (&lhs, {}, field_name, NULL, "structure");
|
|
|
|
|
}
|
2021-03-08 22:27:57 +08:00
|
|
|
|
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
2023-02-09 21:55:48 +08:00
|
|
|
|
result = value::zero (result->type (), result->lval ());
|
2021-03-08 22:27:57 +08:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
value *
|
|
|
|
|
rust_aggregate_operation::evaluate (struct type *expect_type,
|
|
|
|
|
struct expression *exp,
|
|
|
|
|
enum noside noside)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = std::get<0> (m_storage);
|
|
|
|
|
CORE_ADDR addr = 0;
|
|
|
|
|
struct value *addrval = NULL;
|
|
|
|
|
value *result;
|
|
|
|
|
|
|
|
|
|
if (noside == EVAL_NORMAL)
|
|
|
|
|
{
|
2022-09-21 23:05:21 +08:00
|
|
|
|
addrval = value_allocate_space_in_inferior (type->length ());
|
2021-03-08 22:27:57 +08:00
|
|
|
|
addr = value_as_long (addrval);
|
|
|
|
|
result = value_at_lazy (type, addr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (std::get<1> (m_storage) != nullptr)
|
|
|
|
|
{
|
|
|
|
|
struct value *init = std::get<1> (m_storage)->evaluate (nullptr, exp,
|
|
|
|
|
noside);
|
|
|
|
|
|
|
|
|
|
if (noside == EVAL_NORMAL)
|
|
|
|
|
{
|
|
|
|
|
/* This isn't quite right but will do for the time
|
|
|
|
|
being, seeing that we can't implement the Copy
|
|
|
|
|
trait anyway. */
|
|
|
|
|
value_assign (result, init);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const auto &item : std::get<2> (m_storage))
|
|
|
|
|
{
|
|
|
|
|
value *val = item.second->evaluate (nullptr, exp, noside);
|
|
|
|
|
if (noside == EVAL_NORMAL)
|
|
|
|
|
{
|
|
|
|
|
const char *fieldname = item.first.c_str ();
|
2021-06-23 02:27:53 +08:00
|
|
|
|
value *field = value_struct_elt (&result, {}, fieldname,
|
2021-03-08 22:27:57 +08:00
|
|
|
|
nullptr, "structure");
|
|
|
|
|
value_assign (field, val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
2023-02-01 04:25:17 +08:00
|
|
|
|
result = value::allocate (type);
|
2021-03-08 22:27:57 +08:00
|
|
|
|
else
|
|
|
|
|
result = value_at_lazy (type, addr);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
value *
|
|
|
|
|
rust_structop::evaluate_funcall (struct type *expect_type,
|
|
|
|
|
struct expression *exp,
|
|
|
|
|
enum noside noside,
|
|
|
|
|
const std::vector<operation_up> &ops)
|
|
|
|
|
{
|
|
|
|
|
std::vector<struct value *> args (ops.size () + 1);
|
|
|
|
|
|
|
|
|
|
/* Evaluate the argument to STRUCTOP_STRUCT, then find its
|
|
|
|
|
type in order to look up the method. */
|
|
|
|
|
args[0] = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
|
|
|
|
|
/* We don't yet implement real Deref semantics. */
|
2023-01-31 22:52:09 +08:00
|
|
|
|
while (args[0]->type ()->code () == TYPE_CODE_PTR)
|
2021-03-08 22:27:57 +08:00
|
|
|
|
args[0] = value_ind (args[0]);
|
|
|
|
|
|
2023-01-31 22:52:09 +08:00
|
|
|
|
struct type *type = args[0]->type ();
|
2021-03-08 22:27:57 +08:00
|
|
|
|
if ((type->code () != TYPE_CODE_STRUCT
|
|
|
|
|
&& type->code () != TYPE_CODE_UNION
|
|
|
|
|
&& type->code () != TYPE_CODE_ENUM)
|
|
|
|
|
|| rust_tuple_type_p (type))
|
|
|
|
|
error (_("Method calls only supported on struct or enum types"));
|
|
|
|
|
if (type->name () == NULL)
|
|
|
|
|
error (_("Method call on nameless type"));
|
|
|
|
|
|
|
|
|
|
std::string name = (std::string (type->name ()) + "::"
|
|
|
|
|
+ std::get<1> (m_storage));
|
|
|
|
|
|
|
|
|
|
const struct block *block = get_selected_block (0);
|
|
|
|
|
struct block_symbol sym = lookup_symbol (name.c_str (), block,
|
2023-09-20 07:50:17 +08:00
|
|
|
|
SEARCH_FUNCTION_DOMAIN,
|
2023-03-31 13:00:26 +08:00
|
|
|
|
nullptr);
|
2021-03-08 22:27:57 +08:00
|
|
|
|
if (sym.symbol == NULL)
|
|
|
|
|
error (_("Could not find function named '%s'"), name.c_str ());
|
|
|
|
|
|
2022-01-28 11:16:41 +08:00
|
|
|
|
struct type *fn_type = sym.symbol->type ();
|
2021-03-08 22:27:57 +08:00
|
|
|
|
if (fn_type->num_fields () == 0)
|
|
|
|
|
error (_("Function '%s' takes no arguments"), name.c_str ());
|
|
|
|
|
|
|
|
|
|
if (fn_type->field (0).type ()->code () == TYPE_CODE_PTR)
|
|
|
|
|
args[0] = value_addr (args[0]);
|
|
|
|
|
|
|
|
|
|
value *function = address_of_variable (sym.symbol, block);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ops.size (); ++i)
|
|
|
|
|
args[i + 1] = ops[i]->evaluate (nullptr, exp, noside);
|
|
|
|
|
|
|
|
|
|
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
2023-02-01 04:41:35 +08:00
|
|
|
|
return value::zero (fn_type->target_type (), not_lval);
|
2021-03-08 22:27:57 +08:00
|
|
|
|
return call_function_by_hand (function, NULL, args);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 22:27:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-27 09:38:08 +08:00
|
|
|
|
|
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
/* See language.h. */
|
gdb: Represent all languages as sub-classes of language_defn
This commit converts all languages to sub-classes of a language_defn
base class.
The motivation for this change is to make it easier to add new methods
onto languages without having to update all of the individual language
structures. In the future it might be possible to move more things,
like expression parsing, into the language class(es) for better
encapsulation, however I have no plans to tackle this in the short
term.
This commit sets up a strategy for transitioning from the current
language system, where each language is an instance of the
language_defn structure, to the class hierarchy system.
The plan is to rename the existing language_defn into language_data,
and make this a base class for the new language_defn class, something
like this:
struct language_data
{
... old language_defn fields here ...
};
struct language_defn : public language_data
{
language_defn (const language_data d)
: language_data (d)
{ .... }
};
Then each existing language, for example ada_language_defn can be
converted into an instance of language_data, and passed into the
constructor of a new language class, something like this:
language_data ada_language_data =
{
... old ada_language_defn values here ...
};
struct ada_language : public language_defn
{
ada_language (ada_language_data)
{ .... }
};
What this means is that immediately after the conversion nothing much
changes. Every language is now its own class, but all the old
language fields still exist and can be accessed in the same way.
In later commits I will convert function pointers from the old
language_defn structure into real class methods on language_defn, with
overrides on sub-classes where needed.
At this point I imagine that those fields of the old language_defn
structure that contained only data will probably remain as data fields
within the new language_data base structure, it is only the methods
that I plan to change initially.
I tweaked how we manage the list of languages a bit, each language is
now registered as it is created, and this resulted in a small number
of changes in language.c.
Most of the changes in the *-lang.c files are identical.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* gdb/ada-lang.c (ada_language_defn): Convert to...
(ada_language_data): ...this.
(class ada_language): New class.
(ada_language_defn): New static global.
* gdb/c-lang.c (c_language_defn): Convert to...
(c_language_data): ...this.
(class c_language): New class.
(c_language_defn): New static global.
(cplus_language_defn): Convert to...
(cplus_language_data): ...this.
(class cplus_language): New class.
(cplus_language_defn): New static global.
(asm_language_defn): Convert to...
(asm_language_data): ...this.
(class asm_language): New class.
(asm_language_defn): New static global.
(minimal_language_defn): Convert to...
(minimal_language_data): ...this.
(class minimal_language): New class.
(minimal_language_defn): New static global.
* gdb/d-lang.c (d_language_defn): Convert to...
(d_language_data): ...this.
(class d_language): New class.
(d_language_defn): New static global.
* gdb/f-lang.c (f_language_defn): Convert to...
(f_language_data): ...this.
(class f_language): New class.
(f_language_defn): New static global.
* gdb/go-lang.c (go_language_defn): Convert to...
(go_language_data): ...this.
(class go_language): New class.
(go_language_defn): New static global.
* gdb/language.c (unknown_language_defn): Remove declaration.
(current_language): Initialize to nullptr, real initialization is
moved to _initialize_language.
(languages): Delete global.
(language_defn::languages): Define.
(set_language_command): Use language_defn::languages.
(set_language): Likewise.
(range_error): Likewise.
(language_enum): Likewise.
(language_def): Likewise.
(add_set_language_command): Use language_def::languages for the
language list, and language_def to lookup language pointers.
(skip_language_trampoline): Use language_defn::languages.
(unknown_language_defn): Convert to...
(unknown_language_data): ...this.
(class unknown_language): New class.
(unknown_language_defn): New static global.
(auto_language_defn): Convert to...
(auto_language_data): ...this.
(class auto_language): New class.
(auto_language_defn): New static global.
(language_gdbarch_post_init): Use language_defn::languages.
(_initialize_language): Initialize current_language.
* gdb/language.h (struct language_defn): Rename to...
(struct language_data): ...this.
(struct language_defn): New.
(auto_language_defn): Delete.
(unknown_language_defn): Delete.
(minimal_language_defn): Delete.
(ada_language_defn): Delete.
(asm_language_defn): Delete.
(c_language_defn): Delete.
(cplus_language_defn): Delete.
(d_language_defn): Delete.
(f_language_defn): Delete.
(go_language_defn): Delete.
(m2_language_defn): Delete.
(objc_language_defn): Delete.
(opencl_language_defn): Delete.
(pascal_language_defn): Delete.
(rust_language_defn): Delete.
* gdb/m2-lang.c (m2_language_defn): Convert to...
(m2_language_data): ...this.
(class m2_language): New class.
(m2_language_defn): New static global.
* gdb/objc-lang.c (objc_language_defn): Convert to...
(objc_language_data): ...this.
(class objc_language): New class.
(objc_language_defn): New static global.
* gdb/opencl-lang.c (opencl_language_defn): Convert to...
(opencl_language_data): ...this.
(class opencl_language): New class.
(opencl_language_defn): New static global.
* gdb/p-lang.c (pascal_language_defn): Convert to...
(pascal_language_data): ...this.
(class pascal_language): New class.
(pascal_language_defn): New static global.
* gdb/rust-exp.y (rust_lex_tests): Use language_def to find
language pointer, update comment format.
* gdb/rust-lang.c (rust_language_defn): Convert to...
(rust_language_data): ...this.
(class rust_language): New class.
(rust_language_defn): New static global.
2020-05-01 19:16:58 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
void
|
|
|
|
|
rust_language::language_arch_info (struct gdbarch *gdbarch,
|
|
|
|
|
struct language_arch_info *lai) const
|
gdb: Represent all languages as sub-classes of language_defn
This commit converts all languages to sub-classes of a language_defn
base class.
The motivation for this change is to make it easier to add new methods
onto languages without having to update all of the individual language
structures. In the future it might be possible to move more things,
like expression parsing, into the language class(es) for better
encapsulation, however I have no plans to tackle this in the short
term.
This commit sets up a strategy for transitioning from the current
language system, where each language is an instance of the
language_defn structure, to the class hierarchy system.
The plan is to rename the existing language_defn into language_data,
and make this a base class for the new language_defn class, something
like this:
struct language_data
{
... old language_defn fields here ...
};
struct language_defn : public language_data
{
language_defn (const language_data d)
: language_data (d)
{ .... }
};
Then each existing language, for example ada_language_defn can be
converted into an instance of language_data, and passed into the
constructor of a new language class, something like this:
language_data ada_language_data =
{
... old ada_language_defn values here ...
};
struct ada_language : public language_defn
{
ada_language (ada_language_data)
{ .... }
};
What this means is that immediately after the conversion nothing much
changes. Every language is now its own class, but all the old
language fields still exist and can be accessed in the same way.
In later commits I will convert function pointers from the old
language_defn structure into real class methods on language_defn, with
overrides on sub-classes where needed.
At this point I imagine that those fields of the old language_defn
structure that contained only data will probably remain as data fields
within the new language_data base structure, it is only the methods
that I plan to change initially.
I tweaked how we manage the list of languages a bit, each language is
now registered as it is created, and this resulted in a small number
of changes in language.c.
Most of the changes in the *-lang.c files are identical.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* gdb/ada-lang.c (ada_language_defn): Convert to...
(ada_language_data): ...this.
(class ada_language): New class.
(ada_language_defn): New static global.
* gdb/c-lang.c (c_language_defn): Convert to...
(c_language_data): ...this.
(class c_language): New class.
(c_language_defn): New static global.
(cplus_language_defn): Convert to...
(cplus_language_data): ...this.
(class cplus_language): New class.
(cplus_language_defn): New static global.
(asm_language_defn): Convert to...
(asm_language_data): ...this.
(class asm_language): New class.
(asm_language_defn): New static global.
(minimal_language_defn): Convert to...
(minimal_language_data): ...this.
(class minimal_language): New class.
(minimal_language_defn): New static global.
* gdb/d-lang.c (d_language_defn): Convert to...
(d_language_data): ...this.
(class d_language): New class.
(d_language_defn): New static global.
* gdb/f-lang.c (f_language_defn): Convert to...
(f_language_data): ...this.
(class f_language): New class.
(f_language_defn): New static global.
* gdb/go-lang.c (go_language_defn): Convert to...
(go_language_data): ...this.
(class go_language): New class.
(go_language_defn): New static global.
* gdb/language.c (unknown_language_defn): Remove declaration.
(current_language): Initialize to nullptr, real initialization is
moved to _initialize_language.
(languages): Delete global.
(language_defn::languages): Define.
(set_language_command): Use language_defn::languages.
(set_language): Likewise.
(range_error): Likewise.
(language_enum): Likewise.
(language_def): Likewise.
(add_set_language_command): Use language_def::languages for the
language list, and language_def to lookup language pointers.
(skip_language_trampoline): Use language_defn::languages.
(unknown_language_defn): Convert to...
(unknown_language_data): ...this.
(class unknown_language): New class.
(unknown_language_defn): New static global.
(auto_language_defn): Convert to...
(auto_language_data): ...this.
(class auto_language): New class.
(auto_language_defn): New static global.
(language_gdbarch_post_init): Use language_defn::languages.
(_initialize_language): Initialize current_language.
* gdb/language.h (struct language_defn): Rename to...
(struct language_data): ...this.
(struct language_defn): New.
(auto_language_defn): Delete.
(unknown_language_defn): Delete.
(minimal_language_defn): Delete.
(ada_language_defn): Delete.
(asm_language_defn): Delete.
(c_language_defn): Delete.
(cplus_language_defn): Delete.
(d_language_defn): Delete.
(f_language_defn): Delete.
(go_language_defn): Delete.
(m2_language_defn): Delete.
(objc_language_defn): Delete.
(opencl_language_defn): Delete.
(pascal_language_defn): Delete.
(rust_language_defn): Delete.
* gdb/m2-lang.c (m2_language_defn): Convert to...
(m2_language_data): ...this.
(class m2_language): New class.
(m2_language_defn): New static global.
* gdb/objc-lang.c (objc_language_defn): Convert to...
(objc_language_data): ...this.
(class objc_language): New class.
(objc_language_defn): New static global.
* gdb/opencl-lang.c (opencl_language_defn): Convert to...
(opencl_language_data): ...this.
(class opencl_language): New class.
(opencl_language_defn): New static global.
* gdb/p-lang.c (pascal_language_defn): Convert to...
(pascal_language_data): ...this.
(class pascal_language): New class.
(pascal_language_defn): New static global.
* gdb/rust-exp.y (rust_lex_tests): Use language_def to find
language pointer, update comment format.
* gdb/rust-lang.c (rust_language_defn): Convert to...
(rust_language_data): ...this.
(class rust_language): New class.
(rust_language_defn): New static global.
2020-05-01 19:16:58 +08:00
|
|
|
|
{
|
2020-10-30 23:09:35 +08:00
|
|
|
|
const struct builtin_type *builtin = builtin_type (gdbarch);
|
2020-06-02 21:48:04 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
/* Helper function to allow shorter lines below. */
|
|
|
|
|
auto add = [&] (struct type * t) -> struct type *
|
2020-06-02 21:48:04 +08:00
|
|
|
|
{
|
2020-10-30 23:09:35 +08:00
|
|
|
|
lai->add_primitive_type (t);
|
|
|
|
|
return t;
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-14 00:31:06 +08:00
|
|
|
|
type_allocator alloc (gdbarch);
|
2020-10-30 23:09:35 +08:00
|
|
|
|
struct type *bool_type
|
2023-03-14 01:09:08 +08:00
|
|
|
|
= add (init_boolean_type (alloc, 8, 1, "bool"));
|
2023-03-14 00:57:56 +08:00
|
|
|
|
add (init_character_type (alloc, 32, 1, "char"));
|
2023-03-14 00:31:06 +08:00
|
|
|
|
add (init_integer_type (alloc, 8, 0, "i8"));
|
2020-10-30 23:09:35 +08:00
|
|
|
|
struct type *u8_type
|
2023-03-14 00:31:06 +08:00
|
|
|
|
= add (init_integer_type (alloc, 8, 1, "u8"));
|
|
|
|
|
add (init_integer_type (alloc, 16, 0, "i16"));
|
|
|
|
|
add (init_integer_type (alloc, 16, 1, "u16"));
|
|
|
|
|
add (init_integer_type (alloc, 32, 0, "i32"));
|
|
|
|
|
add (init_integer_type (alloc, 32, 1, "u32"));
|
|
|
|
|
add (init_integer_type (alloc, 64, 0, "i64"));
|
|
|
|
|
add (init_integer_type (alloc, 64, 1, "u64"));
|
2023-03-28 03:05:03 +08:00
|
|
|
|
add (init_integer_type (alloc, 128, 0, "i128"));
|
|
|
|
|
add (init_integer_type (alloc, 128, 1, "u128"));
|
2020-10-30 23:09:35 +08:00
|
|
|
|
|
2022-09-21 23:05:21 +08:00
|
|
|
|
unsigned int length = 8 * builtin->builtin_data_ptr->length ();
|
2023-03-14 00:31:06 +08:00
|
|
|
|
add (init_integer_type (alloc, length, 0, "isize"));
|
2020-10-30 23:09:35 +08:00
|
|
|
|
struct type *usize_type
|
2023-03-14 00:31:06 +08:00
|
|
|
|
= add (init_integer_type (alloc, length, 1, "usize"));
|
2020-10-30 23:09:35 +08:00
|
|
|
|
|
2023-03-14 01:30:08 +08:00
|
|
|
|
add (init_float_type (alloc, 32, "f32", floatformats_ieee_single));
|
|
|
|
|
add (init_float_type (alloc, 64, "f64", floatformats_ieee_double));
|
2023-03-14 00:31:06 +08:00
|
|
|
|
add (init_integer_type (alloc, 0, 1, "()"));
|
2020-10-30 23:09:35 +08:00
|
|
|
|
|
|
|
|
|
struct type *tem = make_cv_type (1, 0, u8_type, NULL);
|
|
|
|
|
add (rust_slice_type ("&str", tem, usize_type));
|
|
|
|
|
|
|
|
|
|
lai->set_bool_type (bool_type);
|
|
|
|
|
lai->set_string_char_type (u8_type);
|
|
|
|
|
}
|
gdb: Convert language la_is_string_type_p field to a method
This commit changes the language_data::la_is_string_type_p function
pointer member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_is_string_type_p
initializer.
(ada_language::is_string_type_p): New member function.
* c-lang.c (c_language_data): Delete la_is_string_type_p
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_is_string_type_p): Delete function, implementation
moved to f_language::is_string_type_p.
(f_language_data): Delete la_is_string_type_p initializer.
(f_language::is_string_type_p): New member function,
implementation from f_is_string_type_p.
* go-lang.c (go_is_string_type_p): Delete function, implementation
moved to go_language::is_string_type_p.
(go_language_data): Delete la_is_string_type_p initializer.
(go_language::is_string_type_p): New member function,
implementation from go_is_string_type_p.
* language.c (language_defn::is_string_type_p): Define new member
function.
(default_is_string_type_p): Make static, add comment copied from
header file.
(unknown_language_data): Delete la_is_string_type_p initializer.
(unknown_language::is_string_type_p): New member function.
(auto_language_data): Delete la_is_string_type_p initializer.
(auto_language::is_string_type_p): New member function.
* language.h (language_data): Delete la_is_string_type_p field.
(language_defn::is_string_type_p): Declare new function.
(default_is_string_type_p): Delete desclaration, move comment to
definition.
* m2-lang.c (m2_is_string_type_p): Delete function, implementation
moved to m2_language::is_string_type_p.
(m2_language_data): Delete la_is_string_type_p initializer.
(m2_language::is_string_type_p): New member function,
implementation from m2_is_string_type_p.
* objc-lang.c (objc_language_data): Delete la_is_string_type_p
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_is_string_type_p): Delete function,
implementation moved to pascal_language::is_string_type_p.
(pascal_language_data): Delete la_is_string_type_p initializer.
(pascal_language::is_string_type_p): New member function,
implementation from pascal_is_string_type_p.
* rust-lang.c (rust_is_string_type_p): Delete function,
implementation moved to rust_language::is_string_type_p.
(rust_language_data): Delete la_is_string_type_p initializer.
(rust_language::is_string_type_p): New member function,
implementation from rust_is_string_type_p.
* valprint.c (val_print_scalar_or_string_type_p): Update call to
is_string_type_p.
2020-06-19 05:01:33 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
/* See language.h. */
|
2020-07-12 17:15:32 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
void
|
|
|
|
|
rust_language::print_type (struct type *type, const char *varstring,
|
|
|
|
|
struct ui_file *stream, int show, int level,
|
|
|
|
|
const struct type_print_options *flags) const
|
|
|
|
|
{
|
2021-04-17 19:10:23 +08:00
|
|
|
|
print_offset_data podata (flags);
|
2020-10-30 23:09:35 +08:00
|
|
|
|
rust_internal_print_type (type, varstring, stream, show, level,
|
|
|
|
|
flags, false, &podata);
|
|
|
|
|
}
|
2020-07-12 17:15:32 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
/* See language.h. */
|
2020-08-04 23:31:56 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
void
|
|
|
|
|
rust_language::emitchar (int ch, struct type *chtype,
|
|
|
|
|
struct ui_file *stream, int quoter) const
|
|
|
|
|
{
|
|
|
|
|
if (!rust_chartype_p (chtype))
|
|
|
|
|
generic_emit_char (ch, chtype, stream, quoter,
|
2021-01-28 23:12:10 +08:00
|
|
|
|
target_charset (chtype->arch ()));
|
2020-10-30 23:09:35 +08:00
|
|
|
|
else if (ch == '\\' || ch == quoter)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "\\%c", ch);
|
2020-10-30 23:09:35 +08:00
|
|
|
|
else if (ch == '\n')
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("\\n", stream);
|
2020-10-30 23:09:35 +08:00
|
|
|
|
else if (ch == '\r')
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("\\r", stream);
|
2020-10-30 23:09:35 +08:00
|
|
|
|
else if (ch == '\t')
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("\\t", stream);
|
2020-10-30 23:09:35 +08:00
|
|
|
|
else if (ch == '\0')
|
2022-01-03 02:36:44 +08:00
|
|
|
|
gdb_puts ("\\0", stream);
|
2020-10-30 23:09:35 +08:00
|
|
|
|
else if (ch >= 32 && ch <= 127 && isprint (ch))
|
2022-01-03 02:42:07 +08:00
|
|
|
|
gdb_putc (ch, stream);
|
2020-10-30 23:09:35 +08:00
|
|
|
|
else if (ch <= 255)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "\\x%02x", ch);
|
2020-10-30 23:09:35 +08:00
|
|
|
|
else
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (stream, "\\u{%06x}", ch);
|
2020-10-30 23:09:35 +08:00
|
|
|
|
}
|
2020-08-04 23:31:56 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
/* See language.h. */
|
2020-08-05 00:07:59 +08:00
|
|
|
|
|
2024-01-31 01:06:46 +08:00
|
|
|
|
bool
|
|
|
|
|
rust_language::is_array_like (struct type *type) const
|
|
|
|
|
{
|
|
|
|
|
if (!rust_slice_type_p (type))
|
|
|
|
|
return false;
|
|
|
|
|
return rust_array_like_element_type (type) != nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See language.h. */
|
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
bool
|
|
|
|
|
rust_language::is_string_type_p (struct type *type) const
|
|
|
|
|
{
|
|
|
|
|
LONGEST low_bound, high_bound;
|
2020-08-05 00:07:59 +08:00
|
|
|
|
|
2020-10-30 23:09:35 +08:00
|
|
|
|
type = check_typedef (type);
|
|
|
|
|
return ((type->code () == TYPE_CODE_STRING)
|
|
|
|
|
|| (type->code () == TYPE_CODE_PTR
|
2022-07-31 10:43:54 +08:00
|
|
|
|
&& (type->target_type ()->code () == TYPE_CODE_ARRAY
|
|
|
|
|
&& rust_u8_type_p (type->target_type ()->target_type ())
|
|
|
|
|
&& get_array_bounds (type->target_type (), &low_bound,
|
2020-10-30 23:09:35 +08:00
|
|
|
|
&high_bound)))
|
|
|
|
|
|| (type->code () == TYPE_CODE_STRUCT
|
|
|
|
|
&& !rust_enum_p (type)
|
|
|
|
|
&& rust_slice_type_p (type)
|
|
|
|
|
&& strcmp (type->name (), "&str") == 0));
|
|
|
|
|
}
|
gdb: Represent all languages as sub-classes of language_defn
This commit converts all languages to sub-classes of a language_defn
base class.
The motivation for this change is to make it easier to add new methods
onto languages without having to update all of the individual language
structures. In the future it might be possible to move more things,
like expression parsing, into the language class(es) for better
encapsulation, however I have no plans to tackle this in the short
term.
This commit sets up a strategy for transitioning from the current
language system, where each language is an instance of the
language_defn structure, to the class hierarchy system.
The plan is to rename the existing language_defn into language_data,
and make this a base class for the new language_defn class, something
like this:
struct language_data
{
... old language_defn fields here ...
};
struct language_defn : public language_data
{
language_defn (const language_data d)
: language_data (d)
{ .... }
};
Then each existing language, for example ada_language_defn can be
converted into an instance of language_data, and passed into the
constructor of a new language class, something like this:
language_data ada_language_data =
{
... old ada_language_defn values here ...
};
struct ada_language : public language_defn
{
ada_language (ada_language_data)
{ .... }
};
What this means is that immediately after the conversion nothing much
changes. Every language is now its own class, but all the old
language fields still exist and can be accessed in the same way.
In later commits I will convert function pointers from the old
language_defn structure into real class methods on language_defn, with
overrides on sub-classes where needed.
At this point I imagine that those fields of the old language_defn
structure that contained only data will probably remain as data fields
within the new language_data base structure, it is only the methods
that I plan to change initially.
I tweaked how we manage the list of languages a bit, each language is
now registered as it is created, and this resulted in a small number
of changes in language.c.
Most of the changes in the *-lang.c files are identical.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* gdb/ada-lang.c (ada_language_defn): Convert to...
(ada_language_data): ...this.
(class ada_language): New class.
(ada_language_defn): New static global.
* gdb/c-lang.c (c_language_defn): Convert to...
(c_language_data): ...this.
(class c_language): New class.
(c_language_defn): New static global.
(cplus_language_defn): Convert to...
(cplus_language_data): ...this.
(class cplus_language): New class.
(cplus_language_defn): New static global.
(asm_language_defn): Convert to...
(asm_language_data): ...this.
(class asm_language): New class.
(asm_language_defn): New static global.
(minimal_language_defn): Convert to...
(minimal_language_data): ...this.
(class minimal_language): New class.
(minimal_language_defn): New static global.
* gdb/d-lang.c (d_language_defn): Convert to...
(d_language_data): ...this.
(class d_language): New class.
(d_language_defn): New static global.
* gdb/f-lang.c (f_language_defn): Convert to...
(f_language_data): ...this.
(class f_language): New class.
(f_language_defn): New static global.
* gdb/go-lang.c (go_language_defn): Convert to...
(go_language_data): ...this.
(class go_language): New class.
(go_language_defn): New static global.
* gdb/language.c (unknown_language_defn): Remove declaration.
(current_language): Initialize to nullptr, real initialization is
moved to _initialize_language.
(languages): Delete global.
(language_defn::languages): Define.
(set_language_command): Use language_defn::languages.
(set_language): Likewise.
(range_error): Likewise.
(language_enum): Likewise.
(language_def): Likewise.
(add_set_language_command): Use language_def::languages for the
language list, and language_def to lookup language pointers.
(skip_language_trampoline): Use language_defn::languages.
(unknown_language_defn): Convert to...
(unknown_language_data): ...this.
(class unknown_language): New class.
(unknown_language_defn): New static global.
(auto_language_defn): Convert to...
(auto_language_data): ...this.
(class auto_language): New class.
(auto_language_defn): New static global.
(language_gdbarch_post_init): Use language_defn::languages.
(_initialize_language): Initialize current_language.
* gdb/language.h (struct language_defn): Rename to...
(struct language_data): ...this.
(struct language_defn): New.
(auto_language_defn): Delete.
(unknown_language_defn): Delete.
(minimal_language_defn): Delete.
(ada_language_defn): Delete.
(asm_language_defn): Delete.
(c_language_defn): Delete.
(cplus_language_defn): Delete.
(d_language_defn): Delete.
(f_language_defn): Delete.
(go_language_defn): Delete.
(m2_language_defn): Delete.
(objc_language_defn): Delete.
(opencl_language_defn): Delete.
(pascal_language_defn): Delete.
(rust_language_defn): Delete.
* gdb/m2-lang.c (m2_language_defn): Convert to...
(m2_language_data): ...this.
(class m2_language): New class.
(m2_language_defn): New static global.
* gdb/objc-lang.c (objc_language_defn): Convert to...
(objc_language_data): ...this.
(class objc_language): New class.
(objc_language_defn): New static global.
* gdb/opencl-lang.c (opencl_language_defn): Convert to...
(opencl_language_data): ...this.
(class opencl_language): New class.
(opencl_language_defn): New static global.
* gdb/p-lang.c (pascal_language_defn): Convert to...
(pascal_language_data): ...this.
(class pascal_language): New class.
(pascal_language_defn): New static global.
* gdb/rust-exp.y (rust_lex_tests): Use language_def to find
language pointer, update comment format.
* gdb/rust-lang.c (rust_language_defn): Convert to...
(rust_language_data): ...this.
(class rust_language): New class.
(rust_language_defn): New static global.
2020-05-01 19:16:58 +08:00
|
|
|
|
|
2023-08-05 04:00:33 +08:00
|
|
|
|
/* See language.h. */
|
|
|
|
|
|
|
|
|
|
struct block_symbol
|
|
|
|
|
rust_language::lookup_symbol_nonlocal
|
|
|
|
|
(const char *name, const struct block *block,
|
2023-03-31 13:00:26 +08:00
|
|
|
|
const domain_search_flags domain) const
|
2023-08-05 04:00:33 +08:00
|
|
|
|
{
|
|
|
|
|
struct block_symbol result = {};
|
|
|
|
|
|
|
|
|
|
const char *scope = block == nullptr ? "" : block->scope ();
|
|
|
|
|
symbol_lookup_debug_printf
|
|
|
|
|
("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)",
|
|
|
|
|
name, host_address_to_string (block), scope,
|
2023-03-31 13:00:26 +08:00
|
|
|
|
domain_name (domain).c_str ());
|
2023-08-05 04:00:33 +08:00
|
|
|
|
|
|
|
|
|
/* Look up bare names in the block's scope. */
|
|
|
|
|
std::string scopedname;
|
|
|
|
|
if (name[cp_find_first_component (name)] == '\0')
|
|
|
|
|
{
|
|
|
|
|
if (scope[0] != '\0')
|
|
|
|
|
{
|
|
|
|
|
scopedname = std::string (scope) + "::" + name;
|
|
|
|
|
name = scopedname.c_str ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
name = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (name != NULL)
|
|
|
|
|
{
|
|
|
|
|
result = lookup_symbol_in_static_block (name, block, domain);
|
|
|
|
|
if (result.symbol == NULL)
|
|
|
|
|
result = lookup_global_symbol (name, block, domain);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
gdb: Represent all languages as sub-classes of language_defn
This commit converts all languages to sub-classes of a language_defn
base class.
The motivation for this change is to make it easier to add new methods
onto languages without having to update all of the individual language
structures. In the future it might be possible to move more things,
like expression parsing, into the language class(es) for better
encapsulation, however I have no plans to tackle this in the short
term.
This commit sets up a strategy for transitioning from the current
language system, where each language is an instance of the
language_defn structure, to the class hierarchy system.
The plan is to rename the existing language_defn into language_data,
and make this a base class for the new language_defn class, something
like this:
struct language_data
{
... old language_defn fields here ...
};
struct language_defn : public language_data
{
language_defn (const language_data d)
: language_data (d)
{ .... }
};
Then each existing language, for example ada_language_defn can be
converted into an instance of language_data, and passed into the
constructor of a new language class, something like this:
language_data ada_language_data =
{
... old ada_language_defn values here ...
};
struct ada_language : public language_defn
{
ada_language (ada_language_data)
{ .... }
};
What this means is that immediately after the conversion nothing much
changes. Every language is now its own class, but all the old
language fields still exist and can be accessed in the same way.
In later commits I will convert function pointers from the old
language_defn structure into real class methods on language_defn, with
overrides on sub-classes where needed.
At this point I imagine that those fields of the old language_defn
structure that contained only data will probably remain as data fields
within the new language_data base structure, it is only the methods
that I plan to change initially.
I tweaked how we manage the list of languages a bit, each language is
now registered as it is created, and this resulted in a small number
of changes in language.c.
Most of the changes in the *-lang.c files are identical.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* gdb/ada-lang.c (ada_language_defn): Convert to...
(ada_language_data): ...this.
(class ada_language): New class.
(ada_language_defn): New static global.
* gdb/c-lang.c (c_language_defn): Convert to...
(c_language_data): ...this.
(class c_language): New class.
(c_language_defn): New static global.
(cplus_language_defn): Convert to...
(cplus_language_data): ...this.
(class cplus_language): New class.
(cplus_language_defn): New static global.
(asm_language_defn): Convert to...
(asm_language_data): ...this.
(class asm_language): New class.
(asm_language_defn): New static global.
(minimal_language_defn): Convert to...
(minimal_language_data): ...this.
(class minimal_language): New class.
(minimal_language_defn): New static global.
* gdb/d-lang.c (d_language_defn): Convert to...
(d_language_data): ...this.
(class d_language): New class.
(d_language_defn): New static global.
* gdb/f-lang.c (f_language_defn): Convert to...
(f_language_data): ...this.
(class f_language): New class.
(f_language_defn): New static global.
* gdb/go-lang.c (go_language_defn): Convert to...
(go_language_data): ...this.
(class go_language): New class.
(go_language_defn): New static global.
* gdb/language.c (unknown_language_defn): Remove declaration.
(current_language): Initialize to nullptr, real initialization is
moved to _initialize_language.
(languages): Delete global.
(language_defn::languages): Define.
(set_language_command): Use language_defn::languages.
(set_language): Likewise.
(range_error): Likewise.
(language_enum): Likewise.
(language_def): Likewise.
(add_set_language_command): Use language_def::languages for the
language list, and language_def to lookup language pointers.
(skip_language_trampoline): Use language_defn::languages.
(unknown_language_defn): Convert to...
(unknown_language_data): ...this.
(class unknown_language): New class.
(unknown_language_defn): New static global.
(auto_language_defn): Convert to...
(auto_language_data): ...this.
(class auto_language): New class.
(auto_language_defn): New static global.
(language_gdbarch_post_init): Use language_defn::languages.
(_initialize_language): Initialize current_language.
* gdb/language.h (struct language_defn): Rename to...
(struct language_data): ...this.
(struct language_defn): New.
(auto_language_defn): Delete.
(unknown_language_defn): Delete.
(minimal_language_defn): Delete.
(ada_language_defn): Delete.
(asm_language_defn): Delete.
(c_language_defn): Delete.
(cplus_language_defn): Delete.
(d_language_defn): Delete.
(f_language_defn): Delete.
(go_language_defn): Delete.
(m2_language_defn): Delete.
(objc_language_defn): Delete.
(opencl_language_defn): Delete.
(pascal_language_defn): Delete.
(rust_language_defn): Delete.
* gdb/m2-lang.c (m2_language_defn): Convert to...
(m2_language_data): ...this.
(class m2_language): New class.
(m2_language_defn): New static global.
* gdb/objc-lang.c (objc_language_defn): Convert to...
(objc_language_data): ...this.
(class objc_language): New class.
(objc_language_defn): New static global.
* gdb/opencl-lang.c (opencl_language_defn): Convert to...
(opencl_language_data): ...this.
(class opencl_language): New class.
(opencl_language_defn): New static global.
* gdb/p-lang.c (pascal_language_defn): Convert to...
(pascal_language_data): ...this.
(class pascal_language): New class.
(pascal_language_defn): New static global.
* gdb/rust-exp.y (rust_lex_tests): Use language_def to find
language pointer, update comment format.
* gdb/rust-lang.c (rust_language_defn): Convert to...
(rust_language_data): ...this.
(class rust_language): New class.
(rust_language_defn): New static global.
2020-05-01 19:16:58 +08:00
|
|
|
|
/* Single instance of the Rust language class. */
|
|
|
|
|
|
|
|
|
|
static rust_language rust_language_defn;
|