2013-10-09 22:28:22 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Internal type definitions for GDB.
|
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* ax-gdb.c, c-valprint.c, charset.c, corefile.c: Update copyright.
* demangle.c, disasm.c, dwarf2cfi.c, dwarfread.c: Update copyright.
* elfread.c, eval.c, expprint.c, expression.h: Update copyright.
* f-typeprint.c, findvar.c, gcore.c, gdb_mbuild.sh: Update copyright.
* gdbtypes.h, gnu-v2-abi.c, inferior.h, inftarg.c: Update copyright.
* language.c, language.h, m32r-tdep.c: Update copyright.
* mn10200-tdep.c, scm-lang.c, scm-lang.h: Update copyright.
* somsolib.c, somsolib.h, symfile.c, symtab.h: Update copyright.
* thread-db.c, typeprint.c, utils.c, valarith.c: Update copyright.
* values.c, win32-nat.c, x86-64-linux-nat.c: Update copyright.
* x86-64-linux-tdep.c, z8k-tdep.c: Update copyright.
* cli/cli-decode.h, config/h8500/tm-h8500.h: Update copyright.
Index: mi/ChangeLog
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* mi-cmd-env.c: Update copyright.
2003-01-14 08:49:06 +08:00
|
|
|
|
2023-01-01 20:49:04 +08:00
|
|
|
Copyright (C) 1992-2023 Free Software Foundation, Inc.
|
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* ax-gdb.c, c-valprint.c, charset.c, corefile.c: Update copyright.
* demangle.c, disasm.c, dwarf2cfi.c, dwarfread.c: Update copyright.
* elfread.c, eval.c, expprint.c, expression.h: Update copyright.
* f-typeprint.c, findvar.c, gcore.c, gdb_mbuild.sh: Update copyright.
* gdbtypes.h, gnu-v2-abi.c, inferior.h, inftarg.c: Update copyright.
* language.c, language.h, m32r-tdep.c: Update copyright.
* mn10200-tdep.c, scm-lang.c, scm-lang.h: Update copyright.
* somsolib.c, somsolib.h, symfile.c, symtab.h: Update copyright.
* thread-db.c, typeprint.c, utils.c, valarith.c: Update copyright.
* values.c, win32-nat.c, x86-64-linux-nat.c: Update copyright.
* x86-64-linux-tdep.c, z8k-tdep.c: Update copyright.
* cli/cli-decode.h, config/h8500/tm-h8500.h: Update copyright.
Index: mi/ChangeLog
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* mi-cmd-env.c: Update copyright.
2003-01-14 08:49:06 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
Contributed by Cygnus Support, using pieces from other GDB modules.
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
This file is part of GDB.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
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
|
2007-08-24 02:08:50 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-08 04:19:36 +08:00
|
|
|
(at your option) any later version.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
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.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 02:08:50 +08:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
#if !defined (GDBTYPES_H)
|
|
|
|
#define GDBTYPES_H 1
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * \page gdbtypes GDB Types
|
|
|
|
|
|
|
|
GDB represents all the different kinds of types in programming
|
|
|
|
languages using a common representation defined in gdbtypes.h.
|
|
|
|
|
|
|
|
The main data structure is main_type; it consists of a code (such
|
2014-03-13 14:07:26 +08:00
|
|
|
as #TYPE_CODE_ENUM for enumeration types), a number of
|
2014-03-13 10:36:45 +08:00
|
|
|
generally-useful fields such as the printable name, and finally a
|
2014-03-13 14:07:26 +08:00
|
|
|
field main_type::type_specific that is a union of info specific to
|
|
|
|
particular languages or other special cases (such as calling
|
|
|
|
convention).
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2014-03-13 14:07:26 +08:00
|
|
|
The available type codes are defined in enum #type_code. The enum
|
2014-03-13 10:36:45 +08:00
|
|
|
includes codes both for types that are common across a variety
|
|
|
|
of languages, and for types that are language-specific.
|
|
|
|
|
2014-03-13 14:07:26 +08:00
|
|
|
Most accesses to type fields go through macros such as
|
|
|
|
#TYPE_CODE(thistype) and #TYPE_FN_FIELD_CONST(thisfn, n). These are
|
|
|
|
written such that they can be used as both rvalues and lvalues.
|
2014-03-13 10:36:45 +08:00
|
|
|
*/
|
|
|
|
|
gdb/
* Makefile.in (gdbtypes_h, gdbtypes.o, utils.o): Update.
* defs.h (hashtab_obstack_allocate, dummy_obstack_deallocate): Add
prototypes.
* dwarf2read.c (read_subroutine_type): Use TYPE_ZALLOC.
(hashtab_obstack_allocate, dummy_obstack_deallocate): Moved to...
* utils.c (hashtab_obstack_allocate, dummy_obstack_deallocate):
...here.
* gdbtypes.c: Include "hashtab.h".
(build_gdbtypes): Remove extra prototype.
(struct type_pair, type_pair_hash, type_pair_eq)
(create_copied_types_hash, copy_type_recursive): New.
* gdbtypes.h: Include "hashtab.h".
(TYPE_ZALLOC): New.
(create_copied_types_hash, copy_type_recursive): New prototypes.
* objfiles.c (free_objfile): Call preserve_values.
* symfile.c (reread_symbols): Likewise.
(clear_symtab_users): Remove calls to clear_value_history and
clear_internalvars.
* value.c (clear_value_history, clear_internalvars): Removed.
(preserve_one_value, preserve_values): New functions.
* value.h (clear_value_history, clear_internalvars): Removed.
(preserve_values): New prototype.
* tracepoint.c (_initialize_tracepoint): Do not initialize convenience
variables here.
gdb/doc/
* gdb.texinfo (Files): Remove obsolete bits from the description
of "symbol-file".
2006-02-02 07:14:11 +08:00
|
|
|
#include "hashtab.h"
|
Rename common to gdbsupport
This is the next patch in the ongoing series to move gdbsever to the
top level.
This patch just renames the "common" directory. The idea is to do
this move in two parts: first rename the directory (this patch), then
move the directory to the top. This approach makes the patches a bit
more tractable.
I chose the name "gdbsupport" for the directory. However, as this
patch was largely written by sed, we could pick a new name without too
much difficulty.
Tested by the buildbot.
gdb/ChangeLog
2019-07-09 Tom Tromey <tom@tromey.com>
* contrib/ari/gdb_ari.sh: Change common to gdbsupport.
* configure: Rebuild.
* configure.ac: Change common to gdbsupport.
* gdbsupport: Rename from common.
* acinclude.m4: Change common to gdbsupport.
* Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES)
(HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to
gdbsupport.
* aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c,
amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c,
amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c,
amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c,
amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c,
arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c,
arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c,
arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c,
arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c,
auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h,
btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c,
charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c,
cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c,
coff-pe-read.c, command.h, compile/compile-c-support.c,
compile/compile-c.h, compile/compile-cplus-symbols.c,
compile/compile-cplus-types.c, compile/compile-cplus.h,
compile/compile-loc2c.c, compile/compile.c, completer.c,
completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c,
cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c,
darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c,
disasm.h, dtrace-probe.c, dwarf-index-cache.c,
dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c,
dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c,
event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c,
features/aarch64-core.c, features/aarch64-fpu.c,
features/aarch64-pauth.c, features/aarch64-sve.c,
features/i386/32bit-avx.c, features/i386/32bit-avx512.c,
features/i386/32bit-core.c, features/i386/32bit-linux.c,
features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c,
features/i386/32bit-segments.c, features/i386/32bit-sse.c,
features/i386/64bit-avx.c, features/i386/64bit-avx512.c,
features/i386/64bit-core.c, features/i386/64bit-linux.c,
features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c,
features/i386/64bit-segments.c, features/i386/64bit-sse.c,
features/i386/x32-core.c, features/riscv/32bit-cpu.c,
features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c,
features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c,
features/riscv/64bit-fpu.c, features/tic6x-c6xp.c,
features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h,
findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h,
gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c,
gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c,
go32-nat.c, guile/guile.c, guile/scm-ports.c,
guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c,
i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c,
i386-linux-tdep.c, i386-tdep.c, i387-tdep.c,
ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c,
inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h,
inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h,
inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, location.c, machoread.c,
macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h,
mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c,
mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h,
minsyms.c, mips-linux-tdep.c, namespace.h,
nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h,
nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c,
nat/amd64-linux-siginfo.c, nat/fork-inferior.c,
nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c,
nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c,
nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h,
nat/linux-waitpid.c, nat/mips-linux-watch.c,
nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c,
nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c,
nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h,
obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c,
parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c,
procfs.c, producer.c, progspace.h, psymtab.h,
python/py-framefilter.c, python/py-inferior.c, python/py-ref.h,
python/py-type.c, python/python.c, record-btrace.c, record-full.c,
record.c, record.h, regcache-dump.c, regcache.c, regcache.h,
remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c,
riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c,
selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c,
ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c,
source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c,
stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h,
symtab.c, symtab.h, target-descriptions.c, target-descriptions.h,
target-memory.c, target.c, target.h, target/waitstatus.c,
target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c,
top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c,
tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h,
unittests/array-view-selftests.c,
unittests/child-path-selftests.c, unittests/cli-utils-selftests.c,
unittests/common-utils-selftests.c,
unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c,
unittests/format_pieces-selftests.c,
unittests/function-view-selftests.c,
unittests/lookup_name_info-selftests.c,
unittests/memory-map-selftests.c, unittests/memrange-selftests.c,
unittests/mkdir-recursive-selftests.c,
unittests/observable-selftests.c,
unittests/offset-type-selftests.c, unittests/optional-selftests.c,
unittests/parse-connection-spec-selftests.c,
unittests/ptid-selftests.c, unittests/rsp-low-selftests.c,
unittests/scoped_fd-selftests.c,
unittests/scoped_mmap-selftests.c,
unittests/scoped_restore-selftests.c,
unittests/string_view-selftests.c, unittests/style-selftests.c,
unittests/tracepoint-selftests.c, unittests/unpack-selftests.c,
unittests/utils-selftests.c, unittests/xml-utils-selftests.c,
utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c,
value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c,
xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c,
xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport.
gdb/gdbserver/ChangeLog
2019-07-09 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
* configure.ac: Change common to gdbsupport.
* acinclude.m4: Change common to gdbsupport.
* Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS)
(version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change
common to gdbsupport.
* ax.c, event-loop.c, fork-child.c, gdb_proc_service.h,
gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c,
inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c,
linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c,
linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c,
linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h,
nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c,
server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h,
thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change
common to gdbsupport.
2019-05-06 10:29:24 +08:00
|
|
|
#include "gdbsupport/array-view.h"
|
2021-12-22 07:48:38 +08:00
|
|
|
#include "gdbsupport/gdb-hashtab.h"
|
2020-12-10 02:51:45 +08:00
|
|
|
#include "gdbsupport/gdb_optional.h"
|
Rename common to gdbsupport
This is the next patch in the ongoing series to move gdbsever to the
top level.
This patch just renames the "common" directory. The idea is to do
this move in two parts: first rename the directory (this patch), then
move the directory to the top. This approach makes the patches a bit
more tractable.
I chose the name "gdbsupport" for the directory. However, as this
patch was largely written by sed, we could pick a new name without too
much difficulty.
Tested by the buildbot.
gdb/ChangeLog
2019-07-09 Tom Tromey <tom@tromey.com>
* contrib/ari/gdb_ari.sh: Change common to gdbsupport.
* configure: Rebuild.
* configure.ac: Change common to gdbsupport.
* gdbsupport: Rename from common.
* acinclude.m4: Change common to gdbsupport.
* Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES)
(HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to
gdbsupport.
* aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c,
amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c,
amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c,
amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c,
amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c,
arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c,
arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c,
arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c,
arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c,
auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h,
btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c,
charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c,
cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c,
coff-pe-read.c, command.h, compile/compile-c-support.c,
compile/compile-c.h, compile/compile-cplus-symbols.c,
compile/compile-cplus-types.c, compile/compile-cplus.h,
compile/compile-loc2c.c, compile/compile.c, completer.c,
completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c,
cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c,
darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c,
disasm.h, dtrace-probe.c, dwarf-index-cache.c,
dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c,
dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c,
event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c,
features/aarch64-core.c, features/aarch64-fpu.c,
features/aarch64-pauth.c, features/aarch64-sve.c,
features/i386/32bit-avx.c, features/i386/32bit-avx512.c,
features/i386/32bit-core.c, features/i386/32bit-linux.c,
features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c,
features/i386/32bit-segments.c, features/i386/32bit-sse.c,
features/i386/64bit-avx.c, features/i386/64bit-avx512.c,
features/i386/64bit-core.c, features/i386/64bit-linux.c,
features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c,
features/i386/64bit-segments.c, features/i386/64bit-sse.c,
features/i386/x32-core.c, features/riscv/32bit-cpu.c,
features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c,
features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c,
features/riscv/64bit-fpu.c, features/tic6x-c6xp.c,
features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h,
findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h,
gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c,
gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c,
go32-nat.c, guile/guile.c, guile/scm-ports.c,
guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c,
i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c,
i386-linux-tdep.c, i386-tdep.c, i387-tdep.c,
ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c,
inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h,
inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h,
inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, location.c, machoread.c,
macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h,
mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c,
mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h,
minsyms.c, mips-linux-tdep.c, namespace.h,
nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h,
nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c,
nat/amd64-linux-siginfo.c, nat/fork-inferior.c,
nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c,
nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c,
nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h,
nat/linux-waitpid.c, nat/mips-linux-watch.c,
nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c,
nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c,
nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h,
obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c,
parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c,
procfs.c, producer.c, progspace.h, psymtab.h,
python/py-framefilter.c, python/py-inferior.c, python/py-ref.h,
python/py-type.c, python/python.c, record-btrace.c, record-full.c,
record.c, record.h, regcache-dump.c, regcache.c, regcache.h,
remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c,
riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c,
selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c,
ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c,
source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c,
stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h,
symtab.c, symtab.h, target-descriptions.c, target-descriptions.h,
target-memory.c, target.c, target.h, target/waitstatus.c,
target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c,
top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c,
tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h,
unittests/array-view-selftests.c,
unittests/child-path-selftests.c, unittests/cli-utils-selftests.c,
unittests/common-utils-selftests.c,
unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c,
unittests/format_pieces-selftests.c,
unittests/function-view-selftests.c,
unittests/lookup_name_info-selftests.c,
unittests/memory-map-selftests.c, unittests/memrange-selftests.c,
unittests/mkdir-recursive-selftests.c,
unittests/observable-selftests.c,
unittests/offset-type-selftests.c, unittests/optional-selftests.c,
unittests/parse-connection-spec-selftests.c,
unittests/ptid-selftests.c, unittests/rsp-low-selftests.c,
unittests/scoped_fd-selftests.c,
unittests/scoped_mmap-selftests.c,
unittests/scoped_restore-selftests.c,
unittests/string_view-selftests.c, unittests/style-selftests.c,
unittests/tracepoint-selftests.c, unittests/unpack-selftests.c,
unittests/utils-selftests.c, unittests/xml-utils-selftests.c,
utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c,
value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c,
xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c,
xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport.
gdb/gdbserver/ChangeLog
2019-07-09 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
* configure.ac: Change common to gdbsupport.
* acinclude.m4: Change common to gdbsupport.
* Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS)
(version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change
common to gdbsupport.
* ax.c, event-loop.c, fork-child.c, gdb_proc_service.h,
gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c,
inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c,
linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c,
linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c,
linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h,
nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c,
server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h,
thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change
common to gdbsupport.
2019-05-06 10:29:24 +08:00
|
|
|
#include "gdbsupport/offset-type.h"
|
|
|
|
#include "gdbsupport/enum-flags.h"
|
|
|
|
#include "gdbsupport/underlying.h"
|
|
|
|
#include "gdbsupport/print-utils.h"
|
2021-11-20 00:28:51 +08:00
|
|
|
#include "gdbsupport/function-view.h"
|
2019-12-21 00:43:06 +08:00
|
|
|
#include "dwarf2.h"
|
2021-12-22 07:38:32 +08:00
|
|
|
#include "gdbsupport/gdb_obstack.h"
|
Add support for printing value of DWARF-based fixed-point type objects
This commit introduces a new kind of type, meant to describe
fixed-point types, using a new code added specifically for
this purpose (TYPE_CODE_FIXED_POINT).
It then adds handling of fixed-point base types in the DWARF reader.
And finally, as a first step, this commit adds support for printing
the value of fixed-point type objects.
Note that this commit has a known issue: Trying to print the value
of a fixed-point object with a format letter (e.g. "print /x NAME")
causes the wrong value to be printed because the scaling factor
is not applied. Since the fix for this issue is isolated, and
this is not a regression, the fix will be made in a pach of its own.
This is meant to simplify review and archeology.
Also, other functionalities related to fixed-point type handling
(ptype, arithmetics, etc), will be added piecemeal as well, for
the same reasons (faciliate reviews and archeology). Related to this,
the testcase gdb.ada/fixed_cmp.exp is adjusted to compile the test
program with -fgnat-encodings=all, so as to force the use of GNAT
encodings, rather than rely on the compiler's default to use them.
The intent is to enhance this testcase to also test the pure DWARF
approach using -fgnat-encodings=minimal as soon as the corresponding
suport gets added in. Thus, the modification to the testcase is made
in a way that it prepares this testcase to be tested in both modes.
gdb/ChangeLog:
* ada-valprint.c (ada_value_print_1): Add fixed-point type handling.
* dwarf2/read.c (get_dwarf2_rational_constant)
(get_dwarf2_unsigned_rational_constant, finish_fixed_point_type)
(has_zero_over_zero_small_attribute): New functions.
read_base_type, set_die_type): Add fixed-point type handling.
* gdb-gdb.py.in: Add fixed-point type handling.
* gdbtypes.c: #include "gmp-utils.h".
(create_range_type, set_type_code): Add fixed-point type handling.
(init_fixed_point_type): New function.
(is_integral_type, is_scalar_type): Add fixed-point type handling.
(print_fixed_point_type_info): New function.
(recursive_dump_type, copy_type_recursive): Add fixed-point type
handling.
(fixed_point_type_storage): New typedef.
(fixed_point_objfile_key): New static global.
(allocate_fixed_point_type_info, is_fixed_point_type): New functions.
(fixed_point_type_base_type, fixed_point_scaling_factor): New
functions.
* gdbtypes.h: #include "gmp-utils.h".
(enum type_code) <TYPE_SPECIFIC_FIXED_POINT>: New enum.
(union type_specific) <fixed_point_info>: New field.
(struct fixed_point_type_info): New struct.
(INIT_FIXED_POINT_SPECIFIC, TYPE_FIXED_POINT_INFO): New macros.
(init_fixed_point_type, is_fixed_point_type)
(fixed_point_type_base_type, fixed_point_scaling_factor)
(allocate_fixed_point_type_info): Add declarations.
* valprint.c (generic_val_print_fixed_point): New function.
(generic_value_print): Add fixed-point type handling.
* value.c (value_as_address, unpack_long): Add fixed-point type
handling.
gdb/testsuite/ChangeLog:
* gdb.ada/fixed_cmp.exp: Force compilation to use -fgnat-encodings=all.
* gdb.ada/fixed_points.exp: Add fixed-point variables printing tests.
* gdb.ada/fixed_points/pck.ads, gdb.ada/fixed_points/pck.adb:
New files.
* gdb.ada/fixed_points/fixed_points.adb: Add use of package Pck.
* gdb.dwarf2/dw2-fixed-point.c, gdb.dwarf2/dw2-fixed-point.exp:
New files.
2020-11-15 16:12:52 +08:00
|
|
|
#include "gmp-utils.h"
|
gdb/
* Makefile.in (gdbtypes_h, gdbtypes.o, utils.o): Update.
* defs.h (hashtab_obstack_allocate, dummy_obstack_deallocate): Add
prototypes.
* dwarf2read.c (read_subroutine_type): Use TYPE_ZALLOC.
(hashtab_obstack_allocate, dummy_obstack_deallocate): Moved to...
* utils.c (hashtab_obstack_allocate, dummy_obstack_deallocate):
...here.
* gdbtypes.c: Include "hashtab.h".
(build_gdbtypes): Remove extra prototype.
(struct type_pair, type_pair_hash, type_pair_eq)
(create_copied_types_hash, copy_type_recursive): New.
* gdbtypes.h: Include "hashtab.h".
(TYPE_ZALLOC): New.
(create_copied_types_hash, copy_type_recursive): New prototypes.
* objfiles.c (free_objfile): Call preserve_values.
* symfile.c (reread_symbols): Likewise.
(clear_symtab_users): Remove calls to clear_value_history and
clear_internalvars.
* value.c (clear_value_history, clear_internalvars): Removed.
(preserve_one_value, preserve_values): New functions.
* value.h (clear_value_history, clear_internalvars): Removed.
(preserve_values): New prototype.
* tracepoint.c (_initialize_tracepoint): Do not initialize convenience
variables here.
gdb/doc/
* gdb.texinfo (Files): Remove obsolete bits from the description
of "symbol-file".
2006-02-02 07:14:11 +08:00
|
|
|
|
2001-09-08 18:16:57 +08:00
|
|
|
/* Forward declarations for prototypes. */
|
2003-04-12 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh: Add missing opaque declarations.
* gdbarch.h: Regnerate.
* symtab.h: Add missing opaque declarations.
* value.h, target.h, symfile.h, stabsread.h: Ditto.
* x86-64-tdep.h, xmodem.h, monitor.h, typeprint.h: Ditto.
* srec.h, solib-svr4.h, source.h, inferior.h: Ditto.
* ser-unix.h, serial.h, remote-utils.h, gdbcore.h: Ditto.
* ppc-tdep.h, ocd.h, mips-tdep.h, gdbtypes.h: Ditto.
* buildsym.h, builtin-regs.h, linespec.h, language.h: Ditto.
* i387-tdep.h, gdbthread.h, event-top.h, gdb.h: Ditto.
* dwarf2cfi.h, doublest.h, disasm.h, cp-abi.h: Ditto.
* cli-out.h, c-lang.h, ax-gdb.h, arch-utils.h: Ditto.
* ada-lang.h, config/nm-lynx.h, config/nm-linux.h: Ditto.
* config/sparc/tm-sp64.h, config/rs6000/tm-rs6000.h: Ditto.
* config/pa/tm-hppah.h, config/m68k/tm-delta68.h: Ditto.
* cli/cli-setshow.h, cli/cli-script.h: Ditto.
2003-04-13 01:41:26 +08:00
|
|
|
struct field;
|
2001-09-08 18:16:57 +08:00
|
|
|
struct block;
|
gdb
* varobj.c (value_get_print_value): Include valprint.h.
(value_get_print_value): Use get_formatted_print_options.
* value.h (struct value_print_options): Declare.
(value_print, val_print, common_val_print, val_print_string):
Update.
* value.c: Include valprint.h.
(show_values): Use get_user_print_options.
(show_convenience): Likewise.
* valprint.h (prettyprint_arrays, prettyprint_structs): Don't
declare.
(struct value_print_options): New type.
(vtblprint, unionprint, addressprint, objectprint, print_max,
inspect_it, repeat_count_threshold, output_format,
stop_print_at_null): Don't declare.
(user_print_options, get_user_print_options,
get_raw_print_options, get_formatted_print_options): Declare.
(print_array_indexes_p): Don't declare.
(maybe_print_array_index, val_print_array_elements): Update.
* valprint.c (print_max): Remove.
(user_print_options): New global.
(get_user_print_options, get_raw_print_options,
get_formatted_print_options): New functions.
(print_array_indexes, repeat_count_threshold, stop_print_at_null,
prettyprint_structs, prettyprint_arrays, unionprint,
addressprint): Remove.
(val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(common_val_print): Likewise.
(print_array_indexes_p): Remove.
(maybe_print_array_index): Remove format, pretty arguments; add
options. Update.
(val_print_array_elements): Remove format, deref_ref, pretty
arguments; add options. Update.
(val_print_string): Add options argument. Update.
(_initialize_valprint): Use user_print_options.
(output_format): Remove.
(set_output_radix_1): Use user_print_options.
* typeprint.c: Include valprint.h.
(objectprint): Don't declare.
(whatis_exp): Use get_user_print_options.
* tui/tui-regs.c: Include valprint.h.
(tui_register_format): Use get_formatted_print_options.
* tracepoint.c: Include valprint.h.
(addressprint): Don't declare.
(trace_mention): Use get_user_print_options.
(tracepoints_info): Likewise.
* stack.c (print_frame_args): Use get_raw_print_options.
(print_frame_info): Use get_user_print_options.
(print_frame): Likewise.
* sh64-tdep.c: Include valprint.h
(sh64_do_register): Use get_formatted_print_options.
* scm-valprint.c (scm_inferior_print): Remove format, deref_ref,
pretty arguments; add options.
(scm_scmlist_print): Likewise. Update.
(scm_scmval_print): Likewise.
(scm_val_print): Likewise.
(scm_value_print): Remove format, pretty arguments; add options.
Update.
* scm-lang.h (scm_value_print, scm_val_print, scm_scmval_print):
Update.
* scm-lang.c (scm_printstr): Add options argument.
* python/python-value.c: Include valprint.h.
(valpy_str): Use get_user_print_options.
* printcmd.c: Include valprint.h.
(addressprint): Don't declare.
(inspect_it): Remove.
(print_formatted): Remove format option; add options. Update.
(print_scalar_formatted): Likewise.
(print_address_demangle): Use get_user_print_options.
(do_examine): Use get_formatted_print_options.
(print_command_1): Likewise.
(output_command): Use get_formatted_print_options.
(do_one_display): Likewise.
(print_variable_value): Use get_user_print_options.
* p-valprint.c (pascal_val_print): Remove format, deref_ref,
pretty arguments; add options. Update.
(pascal_value_print): Remove format, pretty arguments; add
options. Update.
(vtblprint, objectprint): Don't declare.
(pascal_static_field_print): Remove.
(pascal_object_print_value_fields): Remove format, pretty
arguments; add options. Update.
(pascal_object_print_static_field): Likewise.
(_initialize_pascal_valprint): Use user_print_options. Update.
* p-lang.h (pascal_val_print, pascal_value_print,
pascal_printstr, pascal_object_print_value_fields): Update.
(vtblprint, static_field_print): Don't declare.
* p-lang.c (pascal_printstr): Add options argument. Update.
* objc-lang.c (objc_printstr): Add options argument. Update.
* mt-tdep.c: Include valprint.h.
(mt_registers_info): Use get_raw_print_options.
* mips-tdep.c: Include valprint.h.
(mips_print_fp_register): Use get_formatted_print_options.
(mips_print_register): Likewise.
* mi/mi-main.c: Include valprint.h.
(get_register): Use get_user_print_options.
(mi_cmd_data_evaluate_expression): Likewise.
(mi_cmd_data_read_memory): Use get_formatted_print_options.
* mi/mi-cmd-stack.c: Include valprint.h.
(list_args_or_locals): Use get_raw_print_options.
* m2-valprint.c (print_function_pointer_address): Add addressprint
argument.
(m2_print_long_set): Remove format, pretty arguments.
(m2_print_unbounded_array): Remove format, deref_ref, pretty
arguments; add options. Update.
(print_unpacked_pointer): Remove format argument; add options.
Now static. Update.
(print_variable_at_address): Remove format, deref_ref, pretty
arguments; add options. Update.
(m2_print_array_contents): Likewise.
(m2_val_print): Likewise.
* m2-lang.h (m2_val_print): Update.
* m2-lang.c (m2_printstr): Add options argument. Update.
* language.h (struct value_print_options): Declare.
(struct language_defn) <la_printstr>: Add options argument.
<la_val_print>: Remove format, deref_ref, pretty argument; add
options.
<la_value_print>: Remove format, pretty arguments; add options.
<la_print_array_index>: Likewise.
(LA_VAL_PRINT, LA_VALUE_PRINT, LA_PRINT_STRING,
LA_PRINT_ARRAY_INDEX): Update.
(default_print_array_index): Update.
* language.c (default_print_array_index): Remove format, pretty
arguments; add options. Update.
(unk_lang_printstr): Add options argument.
(unk_lang_val_print): Remove format, deref_ref, pretty arguments;
add options.
(unk_lang_value_print): Remove format, pretty arguments; add
options.
* jv-valprint.c (java_value_print): Remove format, pretty
arguments; add options. Update.
(java_print_value_fields): Likewise.
(java_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
* jv-lang.h (java_val_print, java_value_print): Declare.
* infcmd.c: Include valprint.h.
(print_return_value): Use get_raw_print_options.
(default_print_registers_info): Use get_user_print_options,
get_formatted_print_options.
(registers_info): Use get_formatted_print_options.
* gdbtypes.h (struct value_print_options): Declare.
(print_scalar_formatted): Update.
* f-valprint.c (f77_print_array_1): Remove format, deref_ref,
pretty arguments; add options. Update.
(f77_print_array): Likewise.
(f_val_print): Likewise.
* f-lang.h (f_val_print): Update.
* f-lang.c (f_printstr): Add options argument. Update.
(c_value_print): Update declaration.
* expprint.c: Include valprint.h.
(print_subexp_standard): Use get_raw_print_options,
get_user_print_options.
* eval.c: Include valprint.h.
(objectprint): Don't declare.
(evaluate_subexp_standard): Use get_user_print_options.
* cp-valprint.c (vtblprint, objectprint, static_field_print):
Remove.
(cp_print_value_fields): Remove format, pretty arguments; add
options. Update.
(cp_print_value): Likewise.
(cp_print_static_field): Likewise.
(_initialize_cp_valprint): Use user_print_options. Update.
* c-valprint.c (print_function_pointer_address): Add addressprint
argument.
(c_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(c_value_print): Add options argument. Update.
* c-lang.h (c_val_print, c_value_print, c_printstr): Update.
(vtblprint, static_field_print): Don't declare.
(cp_print_value_fields): Update.
* c-lang.c (c_printstr): Add options argument. Update.
* breakpoint.c: Include valprint.h.
(addressprint): Don't declare.
(watchpoint_value_print): Use get_user_print_options.
(print_one_breakpoint_location): Likewise.
(breakpoint_1, print_it_catch_fork, print_it_catch_vfork, mention,
print_exception_catchpoint): Likewise.
* auxv.c (fprint_target_auxv): Don't declare addressprint. Use
get_user_print_options.
* ada-valprint.c (struct ada_val_print_args): Remove format,
deref_ref, and pretty; add options.
(print_optional_low_bound): Add options argument.
(val_print_packed_array_elements): Remove format and pretty
arguments; add options. Update.
(printstr): Add options argument. Update.
(ada_printstr): Likewise.
(ada_val_print): Remove format, deref_ref, pretty arguments; add
options argument. Update.
(ada_val_print_stub): Update.
(ada_val_print_array): Remove format, deref_ref, pretty arguments;
add options. Update.
(ada_val_print_1): Likewise.
(print_variant_part): Likewise.
(ada_value_print): Remove format, pretty arguments; add options.
Update.
(print_record): Likewise.
(print_field_values): Likewise.
* ada-lang.h (ada_val_print, ada_value_print, ada_printstr):
Update.
* ada-lang.c (ada_print_array_index): Add options argument; remove
format and pretty arguments.
(print_one_exception): Use get_user_print_options.
gdb/testsuite
* gdb.base/exprs.exp (test_expr): Add enum formatting tests.
2008-10-29 01:19:58 +08:00
|
|
|
struct value_print_options;
|
2009-06-18 02:46:26 +08:00
|
|
|
struct language_defn;
|
2020-05-27 23:14:04 +08:00
|
|
|
struct dwarf2_per_cu_data;
|
|
|
|
struct dwarf2_per_objfile;
|
2023-03-01 22:59:44 +08:00
|
|
|
struct dwarf2_property_baton;
|
2001-09-08 18:16:57 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Some macros for char-based bitfields. */
|
|
|
|
|
|
|
|
#define B_SET(a,x) ((a)[(x)>>3] |= (1 << ((x)&7)))
|
|
|
|
#define B_CLR(a,x) ((a)[(x)>>3] &= ~(1 << ((x)&7)))
|
|
|
|
#define B_TST(a,x) ((a)[(x)>>3] & (1 << ((x)&7)))
|
|
|
|
#define B_TYPE unsigned char
|
|
|
|
#define B_BYTES(x) ( 1 + ((x)>>3) )
|
|
|
|
#define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x))
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Different kinds of data types are distinguished by the `code'
|
|
|
|
field. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
enum type_code
|
1999-07-08 04:19:36 +08:00
|
|
|
{
|
2014-03-13 10:36:45 +08:00
|
|
|
TYPE_CODE_UNDEF = 0, /**< Not used; catches errors */
|
2004-08-25 23:41:54 +08:00
|
|
|
|
2022-10-12 22:40:34 +08:00
|
|
|
#define OP(X) X,
|
|
|
|
#include "type-codes.def"
|
|
|
|
#undef OP
|
2004-08-25 23:41:54 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
};
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Some bits for the type's instance_flags word. See the macros
|
2016-09-06 23:29:15 +08:00
|
|
|
below for documentation on each bit. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2018-07-27 09:52:47 +08:00
|
|
|
enum type_instance_flag_value : unsigned
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
{
|
|
|
|
TYPE_INSTANCE_FLAG_CONST = (1 << 0),
|
|
|
|
TYPE_INSTANCE_FLAG_VOLATILE = (1 << 1),
|
|
|
|
TYPE_INSTANCE_FLAG_CODE_SPACE = (1 << 2),
|
|
|
|
TYPE_INSTANCE_FLAG_DATA_SPACE = (1 << 3),
|
|
|
|
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 = (1 << 4),
|
2010-10-06 16:44:15 +08:00
|
|
|
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2 = (1 << 5),
|
|
|
|
TYPE_INSTANCE_FLAG_NOTTEXT = (1 << 6),
|
2015-02-09 21:58:25 +08:00
|
|
|
TYPE_INSTANCE_FLAG_RESTRICT = (1 << 7),
|
|
|
|
TYPE_INSTANCE_FLAG_ATOMIC = (1 << 8)
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
};
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Make "p S::method() const::static_var" work too
Trying to print a function local static variable of a const-qualified
method still doesn't work after the previous fixes:
(gdb) p 'S::method() const'::static_var
$1 = {i1 = 1, i2 = 2, i3 = 3}
(gdb) p S::method() const::static_var
No symbol "static_var" in specified context.
The reason is that the expression parser/evaluator loses the "const",
and the above unquoted case is just like trying to print a variable of
the non-const overload, if it exists, even. As if the above unquoted
case had been written as:
(gdb) p S::method()::static_var
No symbol "static_var" in specified context.
We can see the problem without static vars in the picture. With:
struct S
{
void method ();
void method () const;
};
Compare:
(gdb) print 'S::method(void) const'
$1 = {void (const S * const)} 0x400606 <S::method() const>
(gdb) print S::method(void) const
$2 = {void (S * const)} 0x4005d8 <S::method()> # wrong method!
That's what we need to fix. If we fix that, the function local static
case starts working.
The grammar production for function/method types is this one:
exp: exp '(' parameter_typelist ')' const_or_volatile
This results in a TYPE_INSTANCE expression evaluator operator. For
the example above, we get something like this ("set debug expression 1"):
...
0 TYPE_INSTANCE 1 TypeInstance: Type @0x560fda958be0 (void)
5 OP_SCOPE Type @0x560fdaa544d8 (S) Field name: `method'
...
While evaluating TYPE_INSTANCE, we end up in
value_struct_elt_for_reference, trying to find the method named
"method" that has the prototype recorded in TYPE_INSTANCE. In this
case, TYPE_INSTANCE says that we're looking for a method that has
"(void)" as parameters (that's what "1 TypeInstance: Type
@0x560fda958be0 (void)" above means. The trouble is that nowhere in
this mechanism do we communicate to value_struct_elt_for_reference
that we're looking for the _const_ overload.
value_struct_elt_for_reference only compared parameters, and the
non-const "method()" overload has matching parameters, so it's
considered the right match...
Conveniently, the "const_or_volatile" production in the grammar
already records "const" and "volatile" info in the type stack. The
type stack is not used in this code path, but we can borrow the
information. The patch converts the info in the type stack to an
"instance flags" enum, and adds that as another element in
TYPE_INSTANCE operators. This type instance flags is then applied to
the temporary type that is passed to value_struct_elt_for_reference
for matching.
The other side of the problem is that methods in the debug info aren't
marked const/volatile, so with that in place, the matching never finds
const/volatile-qualified methods.
The problem is that in the DWARF, there's no indication at all whether
a method is const/volatile qualified... For example (c++filt applied
to the linkage name for convenience):
<2><d3>: Abbrev Number: 6 (DW_TAG_subprogram)
<d4> DW_AT_external : 1
<d4> DW_AT_name : (indirect string, offset: 0x3df): method
<d8> DW_AT_decl_file : 1
<d9> DW_AT_decl_line : 58
<da> DW_AT_linkage_name: (indirect string, offset: 0x5b2): S::method() const
<de> DW_AT_declaration : 1
<de> DW_AT_object_pointer: <0xe6>
<e2> DW_AT_sibling : <0xec>
I see the same with both GCC and Clang. The patch works around this
by extracting the cv qualification from the "const" and "volatile" in
the demangled name. This will need further tweaking for "&" and
"const &" overloads, but we don't support them in the parser yet,
anyway.
The TYPE_CONST changes were necessary otherwise the comparisons in valops.c:
if (TYPE_CONST (intype) != TYPE_FN_FIELD_CONST (f, j))
continue;
would fail, because when both TYPE_CONST() TYPE_FN_FIELD_CONST() were
true, their values were different.
BTW, I'm recording the const/volatile-ness of methods in the
TYPE_FN_FIELD info because #1 - I'm not sure it's kosher to change the
method's type directly (vs having to call make_cv_type to create a new
type), and #2 it's what stabsread.c does:
...
case 'A': /* Normal functions. */
new_sublist->fn_field.is_const = 0;
new_sublist->fn_field.is_volatile = 0;
(*pp)++;
break;
case 'B': /* `const' member functions. */
new_sublist->fn_field.is_const = 1;
new_sublist->fn_field.is_volatile = 0;
...
After all this, this finally all works:
print S::method(void) const
$1 = {void (const S * const)} 0x400606 <S::method() const>
(gdb) p S::method() const::static_var
$2 = {i1 = 1, i2 = 2, i3 = 3}
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* c-exp.y (function_method, function_method_void): Add current
instance flags to TYPE_INSTANCE.
* dwarf2read.c (check_modifier): New.
(compute_delayed_physnames): Assert that only C++ adds delayed
physnames. Mark fn_fields as const/volatile depending on
physname.
* eval.c (make_params): New type_instance_flags parameter. Use
it as the new type's instance flags.
(evaluate_subexp_standard) <TYPE_INSTANCE>: Extract the instance
flags element and pass it to make_params.
* expprint.c (print_subexp_standard) <TYPE_INSTANCE>: Handle
instance flags element.
(dump_subexp_body_standard) <TYPE_INSTANCE>: Likewise.
* gdbtypes.h: Include "enum-flags.h".
(type_instance_flags): New enum-flags type.
(TYPE_CONST, TYPE_VOLATILE, TYPE_RESTRICT, TYPE_ATOMIC)
(TYPE_CODE_SPACE, TYPE_DATA_SPACE): Return boolean.
* parse.c (operator_length_standard) <TYPE_INSTANCE>: Adjust.
(follow_type_instance_flags): New function.
(operator_check_standard) <TYPE_INSTANCE>: Adjust.
* parser-defs.h (follow_type_instance_flags): Declare.
* valops.c (value_struct_elt_for_reference): const/volatile must
match too.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/func-static.c (S::method const, S::method volatile)
(S::method volatile const): New methods.
(c_s, v_s, cv_s): New instances.
(main): Call method() on them.
* gdb.base/func-static.exp (syntax_re, cannot_resolve_re): New variables.
(cannot_resolve): New procedure.
(cxx_scopes_list): Test cv methods. Add print-scope-quote and
print-quote-unquoted columns.
(do_test): Test printing each scope too.
2017-09-05 03:21:16 +08:00
|
|
|
DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Not textual. By default, GDB treats all single byte integers as
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
characters (or elements of strings) unless this flag is set. */
|
|
|
|
|
2020-09-15 10:22:33 +08:00
|
|
|
#define TYPE_NOTTEXT(t) (((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_NOTTEXT)
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Constant type. If this is set, the corresponding type has a
|
2011-01-08 03:36:19 +08:00
|
|
|
const modifier. */
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
|
2020-09-15 10:22:33 +08:00
|
|
|
#define TYPE_CONST(t) ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CONST) != 0)
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Volatile type. If this is set, the corresponding type has a
|
2011-01-08 03:36:19 +08:00
|
|
|
volatile modifier. */
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
|
2011-01-06 06:22:53 +08:00
|
|
|
#define TYPE_VOLATILE(t) \
|
2020-09-15 10:22:33 +08:00
|
|
|
((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_VOLATILE) != 0)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Restrict type. If this is set, the corresponding type has a
|
2013-01-15 04:59:27 +08:00
|
|
|
restrict modifier. */
|
|
|
|
|
|
|
|
#define TYPE_RESTRICT(t) \
|
2020-09-15 10:22:33 +08:00
|
|
|
((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_RESTRICT) != 0)
|
2013-01-15 04:59:27 +08:00
|
|
|
|
2015-02-09 21:58:25 +08:00
|
|
|
/* * Atomic type. If this is set, the corresponding type has an
|
|
|
|
_Atomic modifier. */
|
|
|
|
|
|
|
|
#define TYPE_ATOMIC(t) \
|
2020-09-15 10:22:33 +08:00
|
|
|
((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_ATOMIC) != 0)
|
2015-02-09 21:58:25 +08:00
|
|
|
|
2017-03-21 04:47:30 +08:00
|
|
|
/* * True if this type represents either an lvalue or lvalue reference type. */
|
|
|
|
|
|
|
|
#define TYPE_IS_REFERENCE(t) \
|
2020-05-15 01:46:38 +08:00
|
|
|
((t)->code () == TYPE_CODE_REF || (t)->code () == TYPE_CODE_RVALUE_REF)
|
2017-03-21 04:47:30 +08:00
|
|
|
|
2019-03-08 00:53:54 +08:00
|
|
|
/* * True if this type is allocatable. */
|
|
|
|
#define TYPE_IS_ALLOCATABLE(t) \
|
2020-05-07 23:32:25 +08:00
|
|
|
((t)->dyn_prop (DYN_PROP_ALLOCATED) != NULL)
|
2019-03-08 00:53:54 +08:00
|
|
|
|
Add new variant part code
This patch adds the infrastructure for the new variant part code. At
this point, nothing uses this code. This is done in a separate patch
to make it simpler to review.
I examined a few possible approaches to handling variant parts. In
particular, I considered having a DWARF variant part be a union
(similar to how the Rust code works now); and I considered having type
fields have a flag indicating that they are variants.
Having separate types seemed bad conceptually, because these variants
aren't truly separate -- they rely on the "parent" type. And,
changing how fields worked seemed excessively invasive.
So, in the end I thought the approach taken in this patch was both
simple to implement and understand, without losing generality. The
idea in this patch is that all the fields of a type with variant parts
will be stored in a single field array, just as if they'd all been
listed directly. Then, the variants are attached as a dynamic
property. These control which fields end up in the type that's
constructed during dynamic type resolution.
gdb/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
* gdbtypes.c (is_dynamic_type_internal): Check for variant parts.
(variant::matches, compute_variant_fields_recurse)
(compute_variant_fields_inner, compute_variant_fields): New
functions.
(resolve_dynamic_struct): Check for DYN_PROP_VARIANT_PARTS.
Use resolved_type after type is made.
(operator==): Add new cases.
* gdbtypes.h (TYPE_HAS_VARIANT_PARTS): New macro.
(struct discriminant_range, struct variant, struct variant_part):
New.
(union dynamic_prop_data) <variant_parts, original_type>: New
members.
(enum dynamic_prop_node_kind) <DYN_PROP_VARIANT_PARTS>: New constant.
(enum dynamic_prop_kind) <PROP_TYPE, PROP_VARIANT_PARTS>: New
constants.
* value.c (unpack_bits_as_long): Now public.
* value.h (unpack_bits_as_long): Declare.
2020-04-25 03:40:31 +08:00
|
|
|
/* * True if this type has variant parts. */
|
|
|
|
#define TYPE_HAS_VARIANT_PARTS(t) \
|
2020-05-07 23:32:25 +08:00
|
|
|
((t)->dyn_prop (DYN_PROP_VARIANT_PARTS) != nullptr)
|
Add new variant part code
This patch adds the infrastructure for the new variant part code. At
this point, nothing uses this code. This is done in a separate patch
to make it simpler to review.
I examined a few possible approaches to handling variant parts. In
particular, I considered having a DWARF variant part be a union
(similar to how the Rust code works now); and I considered having type
fields have a flag indicating that they are variants.
Having separate types seemed bad conceptually, because these variants
aren't truly separate -- they rely on the "parent" type. And,
changing how fields worked seemed excessively invasive.
So, in the end I thought the approach taken in this patch was both
simple to implement and understand, without losing generality. The
idea in this patch is that all the fields of a type with variant parts
will be stored in a single field array, just as if they'd all been
listed directly. Then, the variants are attached as a dynamic
property. These control which fields end up in the type that's
constructed during dynamic type resolution.
gdb/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
* gdbtypes.c (is_dynamic_type_internal): Check for variant parts.
(variant::matches, compute_variant_fields_recurse)
(compute_variant_fields_inner, compute_variant_fields): New
functions.
(resolve_dynamic_struct): Check for DYN_PROP_VARIANT_PARTS.
Use resolved_type after type is made.
(operator==): Add new cases.
* gdbtypes.h (TYPE_HAS_VARIANT_PARTS): New macro.
(struct discriminant_range, struct variant, struct variant_part):
New.
(union dynamic_prop_data) <variant_parts, original_type>: New
members.
(enum dynamic_prop_node_kind) <DYN_PROP_VARIANT_PARTS>: New constant.
(enum dynamic_prop_kind) <PROP_TYPE, PROP_VARIANT_PARTS>: New
constants.
* value.c (unpack_bits_as_long): Now public.
* value.h (unpack_bits_as_long): Declare.
2020-04-25 03:40:31 +08:00
|
|
|
|
2020-04-25 03:40:31 +08:00
|
|
|
/* * True if this type has a dynamic length. */
|
|
|
|
#define TYPE_HAS_DYNAMIC_LENGTH(t) \
|
2020-05-07 23:32:25 +08:00
|
|
|
((t)->dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr)
|
2020-04-25 03:40:31 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Instruction-space delimited type. This is for Harvard architectures
|
2001-11-15 09:55:59 +08:00
|
|
|
which have separate instruction and data address spaces (and perhaps
|
|
|
|
others).
|
|
|
|
|
|
|
|
GDB usually defines a flat address space that is a superset of the
|
|
|
|
architecture's two (or more) address spaces, but this is an extension
|
|
|
|
of the architecture's model.
|
|
|
|
|
2016-09-06 23:29:15 +08:00
|
|
|
If TYPE_INSTANCE_FLAG_CODE_SPACE is set, an object of the corresponding type
|
2001-11-15 09:55:59 +08:00
|
|
|
resides in instruction memory, even if its address (in the extended
|
|
|
|
flat address space) does not reflect this.
|
|
|
|
|
2016-09-06 23:29:15 +08:00
|
|
|
Similarly, if TYPE_INSTANCE_FLAG_DATA_SPACE is set, then an object of the
|
2001-11-15 09:55:59 +08:00
|
|
|
corresponding type resides in the data memory space, even if
|
|
|
|
this is not indicated by its (flat address space) address.
|
|
|
|
|
|
|
|
If neither flag is set, the default space for functions / methods
|
|
|
|
is instruction space, and for data objects is data memory. */
|
|
|
|
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
#define TYPE_CODE_SPACE(t) \
|
2020-09-15 10:22:33 +08:00
|
|
|
((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CODE_SPACE) != 0)
|
2001-11-15 09:55:59 +08:00
|
|
|
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
#define TYPE_DATA_SPACE(t) \
|
2020-09-15 10:22:33 +08:00
|
|
|
((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_DATA_SPACE) != 0)
|
2002-04-27 04:08:19 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Address class flags. Some environments provide for pointers
|
|
|
|
whose size is different from that of a normal pointer or address
|
|
|
|
types where the bits are interpreted differently than normal
|
2016-09-06 23:29:15 +08:00
|
|
|
addresses. The TYPE_INSTANCE_FLAG_ADDRESS_CLASS_n flags may be used in
|
2014-03-13 10:36:45 +08:00
|
|
|
target specific ways to represent these different types of address
|
|
|
|
classes. */
|
|
|
|
|
2020-09-15 10:22:33 +08:00
|
|
|
#define TYPE_ADDRESS_CLASS_1(t) (((t)->instance_flags ()) \
|
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
|
|
|
& TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
|
2020-09-15 10:22:33 +08:00
|
|
|
#define TYPE_ADDRESS_CLASS_2(t) (((t)->instance_flags ()) \
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
& TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
|
|
|
|
#define TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL \
|
|
|
|
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
|
2020-09-15 10:22:33 +08:00
|
|
|
#define TYPE_ADDRESS_CLASS_ALL(t) (((t)->instance_flags ()) \
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
& TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
|
2007-04-12 00:04:23 +08:00
|
|
|
|
Add new variant part code
This patch adds the infrastructure for the new variant part code. At
this point, nothing uses this code. This is done in a separate patch
to make it simpler to review.
I examined a few possible approaches to handling variant parts. In
particular, I considered having a DWARF variant part be a union
(similar to how the Rust code works now); and I considered having type
fields have a flag indicating that they are variants.
Having separate types seemed bad conceptually, because these variants
aren't truly separate -- they rely on the "parent" type. And,
changing how fields worked seemed excessively invasive.
So, in the end I thought the approach taken in this patch was both
simple to implement and understand, without losing generality. The
idea in this patch is that all the fields of a type with variant parts
will be stored in a single field array, just as if they'd all been
listed directly. Then, the variants are attached as a dynamic
property. These control which fields end up in the type that's
constructed during dynamic type resolution.
gdb/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
* gdbtypes.c (is_dynamic_type_internal): Check for variant parts.
(variant::matches, compute_variant_fields_recurse)
(compute_variant_fields_inner, compute_variant_fields): New
functions.
(resolve_dynamic_struct): Check for DYN_PROP_VARIANT_PARTS.
Use resolved_type after type is made.
(operator==): Add new cases.
* gdbtypes.h (TYPE_HAS_VARIANT_PARTS): New macro.
(struct discriminant_range, struct variant, struct variant_part):
New.
(union dynamic_prop_data) <variant_parts, original_type>: New
members.
(enum dynamic_prop_node_kind) <DYN_PROP_VARIANT_PARTS>: New constant.
(enum dynamic_prop_kind) <PROP_TYPE, PROP_VARIANT_PARTS>: New
constants.
* value.c (unpack_bits_as_long): Now public.
* value.h (unpack_bits_as_long): Declare.
2020-04-25 03:40:31 +08:00
|
|
|
/* * Information about a single discriminant. */
|
|
|
|
|
|
|
|
struct discriminant_range
|
|
|
|
{
|
|
|
|
/* * The range of values for the variant. This is an inclusive
|
|
|
|
range. */
|
|
|
|
ULONGEST low, high;
|
|
|
|
|
|
|
|
/* * Return true if VALUE is contained in this range. IS_UNSIGNED
|
|
|
|
is true if this should be an unsigned comparison; false for
|
|
|
|
signed. */
|
|
|
|
bool contains (ULONGEST value, bool is_unsigned) const
|
|
|
|
{
|
|
|
|
if (is_unsigned)
|
|
|
|
return value >= low && value <= high;
|
|
|
|
LONGEST valuel = (LONGEST) value;
|
|
|
|
return valuel >= (LONGEST) low && valuel <= (LONGEST) high;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct variant_part;
|
|
|
|
|
|
|
|
/* * A single variant. A variant has a list of discriminant values.
|
|
|
|
When the discriminator matches one of these, the variant is
|
|
|
|
enabled. Each variant controls zero or more fields; and may also
|
|
|
|
control other variant parts as well. This struct corresponds to
|
|
|
|
DW_TAG_variant in DWARF. */
|
|
|
|
|
|
|
|
struct variant : allocate_on_obstack
|
|
|
|
{
|
|
|
|
/* * The discriminant ranges for this variant. */
|
|
|
|
gdb::array_view<discriminant_range> discriminants;
|
|
|
|
|
|
|
|
/* * The fields controlled by this variant. This is inclusive on
|
|
|
|
the low end and exclusive on the high end. A variant may not
|
|
|
|
control any fields, in which case the two values will be equal.
|
|
|
|
These are indexes into the type's array of fields. */
|
|
|
|
int first_field;
|
|
|
|
int last_field;
|
|
|
|
|
|
|
|
/* * Variant parts controlled by this variant. */
|
|
|
|
gdb::array_view<variant_part> parts;
|
|
|
|
|
|
|
|
/* * Return true if this is the default variant. The default
|
|
|
|
variant can be recognized because it has no associated
|
|
|
|
discriminants. */
|
|
|
|
bool is_default () const
|
|
|
|
{
|
|
|
|
return discriminants.empty ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* * Return true if this variant matches VALUE. IS_UNSIGNED is true
|
|
|
|
if this should be an unsigned comparison; false for signed. */
|
|
|
|
bool matches (ULONGEST value, bool is_unsigned) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* * A variant part. Each variant part has an optional discriminant
|
|
|
|
and holds an array of variants. This struct corresponds to
|
|
|
|
DW_TAG_variant_part in DWARF. */
|
|
|
|
|
|
|
|
struct variant_part : allocate_on_obstack
|
|
|
|
{
|
|
|
|
/* * The index of the discriminant field in the outer type. This is
|
|
|
|
an index into the type's array of fields. If this is -1, there
|
|
|
|
is no discriminant, and only the default variant can be
|
|
|
|
considered to be selected. */
|
|
|
|
int discriminant_index;
|
|
|
|
|
|
|
|
/* * True if this discriminant is unsigned; false if signed. This
|
|
|
|
comes from the type of the discriminant. */
|
|
|
|
bool is_unsigned;
|
|
|
|
|
|
|
|
/* * The variants that are controlled by this variant part. Note
|
|
|
|
that these will always be sorted by field number. */
|
|
|
|
gdb::array_view<variant> variants;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
enum dynamic_prop_kind
|
|
|
|
{
|
|
|
|
PROP_UNDEFINED, /* Not defined. */
|
|
|
|
PROP_CONST, /* Constant. */
|
|
|
|
PROP_ADDR_OFFSET, /* Address offset. */
|
|
|
|
PROP_LOCEXPR, /* Location expression. */
|
Add new variant part code
This patch adds the infrastructure for the new variant part code. At
this point, nothing uses this code. This is done in a separate patch
to make it simpler to review.
I examined a few possible approaches to handling variant parts. In
particular, I considered having a DWARF variant part be a union
(similar to how the Rust code works now); and I considered having type
fields have a flag indicating that they are variants.
Having separate types seemed bad conceptually, because these variants
aren't truly separate -- they rely on the "parent" type. And,
changing how fields worked seemed excessively invasive.
So, in the end I thought the approach taken in this patch was both
simple to implement and understand, without losing generality. The
idea in this patch is that all the fields of a type with variant parts
will be stored in a single field array, just as if they'd all been
listed directly. Then, the variants are attached as a dynamic
property. These control which fields end up in the type that's
constructed during dynamic type resolution.
gdb/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
* gdbtypes.c (is_dynamic_type_internal): Check for variant parts.
(variant::matches, compute_variant_fields_recurse)
(compute_variant_fields_inner, compute_variant_fields): New
functions.
(resolve_dynamic_struct): Check for DYN_PROP_VARIANT_PARTS.
Use resolved_type after type is made.
(operator==): Add new cases.
* gdbtypes.h (TYPE_HAS_VARIANT_PARTS): New macro.
(struct discriminant_range, struct variant, struct variant_part):
New.
(union dynamic_prop_data) <variant_parts, original_type>: New
members.
(enum dynamic_prop_node_kind) <DYN_PROP_VARIANT_PARTS>: New constant.
(enum dynamic_prop_kind) <PROP_TYPE, PROP_VARIANT_PARTS>: New
constants.
* value.c (unpack_bits_as_long): Now public.
* value.h (unpack_bits_as_long): Declare.
2020-04-25 03:40:31 +08:00
|
|
|
PROP_LOCLIST, /* Location list. */
|
|
|
|
PROP_VARIANT_PARTS, /* Variant parts. */
|
|
|
|
PROP_TYPE, /* Type. */
|
2021-06-05 03:51:23 +08:00
|
|
|
PROP_VARIABLE_NAME, /* Variable name. */
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
union dynamic_prop_data
|
|
|
|
{
|
|
|
|
/* Storage for constant property. */
|
|
|
|
|
|
|
|
LONGEST const_val;
|
|
|
|
|
|
|
|
/* Storage for dynamic property. */
|
|
|
|
|
2023-03-01 23:03:49 +08:00
|
|
|
const dwarf2_property_baton *baton;
|
Add new variant part code
This patch adds the infrastructure for the new variant part code. At
this point, nothing uses this code. This is done in a separate patch
to make it simpler to review.
I examined a few possible approaches to handling variant parts. In
particular, I considered having a DWARF variant part be a union
(similar to how the Rust code works now); and I considered having type
fields have a flag indicating that they are variants.
Having separate types seemed bad conceptually, because these variants
aren't truly separate -- they rely on the "parent" type. And,
changing how fields worked seemed excessively invasive.
So, in the end I thought the approach taken in this patch was both
simple to implement and understand, without losing generality. The
idea in this patch is that all the fields of a type with variant parts
will be stored in a single field array, just as if they'd all been
listed directly. Then, the variants are attached as a dynamic
property. These control which fields end up in the type that's
constructed during dynamic type resolution.
gdb/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
* gdbtypes.c (is_dynamic_type_internal): Check for variant parts.
(variant::matches, compute_variant_fields_recurse)
(compute_variant_fields_inner, compute_variant_fields): New
functions.
(resolve_dynamic_struct): Check for DYN_PROP_VARIANT_PARTS.
Use resolved_type after type is made.
(operator==): Add new cases.
* gdbtypes.h (TYPE_HAS_VARIANT_PARTS): New macro.
(struct discriminant_range, struct variant, struct variant_part):
New.
(union dynamic_prop_data) <variant_parts, original_type>: New
members.
(enum dynamic_prop_node_kind) <DYN_PROP_VARIANT_PARTS>: New constant.
(enum dynamic_prop_kind) <PROP_TYPE, PROP_VARIANT_PARTS>: New
constants.
* value.c (unpack_bits_as_long): Now public.
* value.h (unpack_bits_as_long): Declare.
2020-04-25 03:40:31 +08:00
|
|
|
|
|
|
|
/* Storage of variant parts for a type. A type with variant parts
|
|
|
|
has all its fields "linearized" -- stored in a single field
|
|
|
|
array, just as if they had all been declared that way. The
|
|
|
|
variant parts are attached via a dynamic property, and then are
|
|
|
|
used to control which fields end up in the final type during
|
|
|
|
dynamic type resolution. */
|
|
|
|
|
|
|
|
const gdb::array_view<variant_part> *variant_parts;
|
|
|
|
|
|
|
|
/* Once a variant type is resolved, we may want to be able to go
|
|
|
|
from the resolved type to the original type. In this case we
|
|
|
|
rewrite the property's kind and set this field. */
|
|
|
|
|
|
|
|
struct type *original_type;
|
2021-06-05 03:51:23 +08:00
|
|
|
|
|
|
|
/* Name of a variable to look up; the variable holds the value of
|
|
|
|
this property. */
|
|
|
|
|
|
|
|
const char *variable_name;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
};
|
|
|
|
|
2013-10-08 22:04:49 +08:00
|
|
|
/* * Used to store a dynamic property. */
|
|
|
|
|
|
|
|
struct dynamic_prop
|
|
|
|
{
|
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
|
|
|
dynamic_prop_kind kind () const
|
|
|
|
{
|
|
|
|
return m_kind;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_undefined ()
|
|
|
|
{
|
|
|
|
m_kind = PROP_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
LONGEST const_val () const
|
|
|
|
{
|
|
|
|
gdb_assert (m_kind == PROP_CONST);
|
|
|
|
|
|
|
|
return m_data.const_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_const_val (LONGEST const_val)
|
|
|
|
{
|
|
|
|
m_kind = PROP_CONST;
|
|
|
|
m_data.const_val = const_val;
|
|
|
|
}
|
|
|
|
|
2023-04-19 23:40:20 +08:00
|
|
|
/* Return true if this property has a constant value, false
|
|
|
|
otherwise. */
|
|
|
|
bool is_constant () const
|
|
|
|
{ return m_kind == PROP_CONST; }
|
|
|
|
|
2023-03-01 23:03:49 +08:00
|
|
|
const dwarf2_property_baton *baton () const
|
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
|
|
|
{
|
|
|
|
gdb_assert (m_kind == PROP_LOCEXPR
|
|
|
|
|| m_kind == PROP_LOCLIST
|
|
|
|
|| m_kind == PROP_ADDR_OFFSET);
|
|
|
|
|
|
|
|
return m_data.baton;
|
|
|
|
}
|
|
|
|
|
2023-03-01 23:03:49 +08:00
|
|
|
void set_locexpr (const dwarf2_property_baton *baton)
|
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
|
|
|
{
|
|
|
|
m_kind = PROP_LOCEXPR;
|
|
|
|
m_data.baton = baton;
|
|
|
|
}
|
|
|
|
|
2023-03-01 23:03:49 +08:00
|
|
|
void set_loclist (const dwarf2_property_baton *baton)
|
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
|
|
|
{
|
|
|
|
m_kind = PROP_LOCLIST;
|
|
|
|
m_data.baton = baton;
|
|
|
|
}
|
|
|
|
|
2023-03-01 23:03:49 +08:00
|
|
|
void set_addr_offset (const dwarf2_property_baton *baton)
|
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
|
|
|
{
|
|
|
|
m_kind = PROP_ADDR_OFFSET;
|
|
|
|
m_data.baton = baton;
|
|
|
|
}
|
|
|
|
|
|
|
|
const gdb::array_view<variant_part> *variant_parts () const
|
|
|
|
{
|
|
|
|
gdb_assert (m_kind == PROP_VARIANT_PARTS);
|
|
|
|
|
|
|
|
return m_data.variant_parts;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_variant_parts (gdb::array_view<variant_part> *variant_parts)
|
|
|
|
{
|
|
|
|
m_kind = PROP_VARIANT_PARTS;
|
|
|
|
m_data.variant_parts = variant_parts;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct type *original_type () const
|
|
|
|
{
|
|
|
|
gdb_assert (m_kind == PROP_TYPE);
|
|
|
|
|
|
|
|
return m_data.original_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_original_type (struct type *original_type)
|
|
|
|
{
|
|
|
|
m_kind = PROP_TYPE;
|
|
|
|
m_data.original_type = original_type;
|
|
|
|
}
|
|
|
|
|
2021-06-05 03:51:23 +08:00
|
|
|
/* Return the name of the variable that holds this property's value.
|
|
|
|
Only valid for PROP_VARIABLE_NAME. */
|
|
|
|
const char *variable_name () const
|
|
|
|
{
|
|
|
|
gdb_assert (m_kind == PROP_VARIABLE_NAME);
|
|
|
|
return m_data.variable_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the name of the variable that holds this property's value,
|
|
|
|
and set this property to be of kind PROP_VARIABLE_NAME. */
|
|
|
|
void set_variable_name (const char *name)
|
|
|
|
{
|
|
|
|
m_kind = PROP_VARIABLE_NAME;
|
|
|
|
m_data.variable_name = name;
|
|
|
|
}
|
|
|
|
|
2013-10-08 22:04:49 +08:00
|
|
|
/* Determine which field of the union dynamic_prop.data is used. */
|
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
|
|
|
enum dynamic_prop_kind m_kind;
|
2013-10-08 22:04:49 +08:00
|
|
|
|
|
|
|
/* Storage for dynamic or static value. */
|
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
|
|
|
union dynamic_prop_data m_data;
|
2013-10-08 22:04:49 +08:00
|
|
|
};
|
|
|
|
|
Fix GCC PR83906 - [8 Regression] Random FAIL: libstdc++-prettyprinters/80276.cc whatis p4
GCC PR83906 [1] is about a GCC/libstdc++ GDB/Python type printer
testcase failing randomly, as shown by running (in libstdc++'s
testsuite):
make check RUNTESTFLAGS=prettyprinters.exp=80276.cc
in a loop. Sometimes you get this:
FAIL: libstdc++-prettyprinters/80276.cc whatis p4
I.e., this:
type = std::unique_ptr<std::vector<std::unique_ptr<std::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >>[]>>[99]>
instead of this:
type = std::unique_ptr<std::vector<std::unique_ptr<std::list<std::string>[]>>[99]>
Jonathan Wakely tracked it on the printer side to this bit in
libstdc++'s type printer:
if self.type_obj == type_obj:
return strip_inline_namespaces(self.name)
This assumes the two types resolve to the same gdb.Type but some times
the comparison unexpectedly fails.
Running the testcase manually under Valgrind finds the problem in GDB:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==6118== Conditional jump or move depends on uninitialised value(s)
==6118== at 0x4C35CB0: bcmp (vg_replace_strmem.c:1100)
==6118== by 0x6F773A: check_types_equal(type*, type*, VEC_type_equality_entry_d**) (gdbtypes.c:3515)
==6118== by 0x6F7B00: check_types_worklist(VEC_type_equality_entry_d**, bcache*) (gdbtypes.c:3618)
==6118== by 0x6F7C03: types_deeply_equal(type*, type*) (gdbtypes.c:3655)
==6118== by 0x4D5B06: typy_richcompare(_object*, _object*, int) (py-type.c:1007)
==6118== by 0x63D7E6C: PyObject_RichCompare (object.c:961)
==6118== by 0x646EAEC: PyEval_EvalFrameEx (ceval.c:4960)
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
That "bcmp" call is really a memcmp call in check_types_equal. The
problem is that gdb is memcmp'ing two objects that are equal in value:
(top-gdb) p *TYPE_RANGE_DATA (type1)
$1 = {low = {kind = PROP_CONST, data = {const_val = 0, baton = 0x0}}, high = {kind = PROP_CONST, data = {const_val = 15, baton = 0xf}}, flag_upper_bound_is_count = 0,
flag_bound_evaluated = 0}
(top-gdb) p *TYPE_RANGE_DATA (type2)
$2 = {low = {kind = PROP_CONST, data = {const_val = 0, baton = 0x0}}, high = {kind = PROP_CONST, data = {const_val = 15, baton = 0xf}}, flag_upper_bound_is_count = 0,
flag_bound_evaluated = 0}
but differ in padding. Notice the 4-byte hole:
(top-gdb) ptype /o range_bounds
/* offset | size */ type = struct range_bounds {
/* 0 | 16 */ struct dynamic_prop {
/* 0 | 4 */ dynamic_prop_kind kind;
/* XXX 4-byte hole */
/* 8 | 8 */ union dynamic_prop_data {
/* 8 */ LONGEST const_val;
/* 8 */ void *baton;
/* total size (bytes): 8 */
} data;
which is filled with garbage:
(top-gdb) x /40bx TYPE_RANGE_DATA (type1)
0x2fa7ea0: 0x01 0x00 0x00 0x00 0x43 0x01 0x00 0x00
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0x2fa7ea8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x2fa7eb0: 0x01 0x00 0x00 0x00 0xfe 0x7f 0x00 0x00
0x2fa7eb8: 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x2fa7ec0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
(top-gdb) x /40bx TYPE_RANGE_DATA (type2)
0x20379b0: 0x01 0x00 0x00 0x00 0xfe 0x7f 0x00 0x00
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0x20379b8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x20379c0: 0x01 0x00 0x00 0x00 0xfe 0x7f 0x00 0x00
0x20379c8: 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x20379d0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
(top-gdb) p memcmp (TYPE_RANGE_DATA (type1), TYPE_RANGE_DATA (type2), sizeof (*TYPE_RANGE_DATA (type1)))
$3 = -187
In some cases objects of type range_bounds are memset when allocated,
but then their dynamic_prop low/high fields are copied over from some
template dynamic_prop object that wasn't memset. E.g.,
create_static_range_type's low/high locals are left with garbage in
the padding, and then that padding is copied over to the range_bounds
object's low/high fields.
At first, I considered making sure to always memset range_bounds
objects, thinking that maybe type objects are being put in some bcache
instance somewhere. But then I hacked bcache/bcache_full to poison
non-pod types, and made dynamic_prop a non-pod, and GDB still
compiled.
So given that, it seems safest to not assume padding will always be
memset, and instead treat them as regular value types, implementing
(in)equality operators and using those instead of memcmp.
This fixes the random FAILs in GCC's testcase.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83906
gdb/ChangeLog:
2018-01-24 Pedro Alves <palves@redhat.com>
GCC PR libstdc++/83906
* gdbtypes.c (operator==(const dynamic_prop &,
const dynamic_prop &)): New.
(operator==(const range_bounds &, const range_bounds &)): New.
(check_types_equal): Use them instead of memcmp.
* gdbtypes.h (operator==(const dynamic_prop &,
const dynamic_prop &)): Declare.
(operator!=(const dynamic_prop &, const dynamic_prop &)): Declare.
(operator==(const range_bounds &, const range_bounds &)): Declare.
(operator!=(const range_bounds &, const range_bounds &)): Declare.
2018-01-25 01:22:05 +08:00
|
|
|
/* Compare two dynamic_prop objects for equality. dynamic_prop
|
|
|
|
instances are equal iff they have the same type and storage. */
|
|
|
|
extern bool operator== (const dynamic_prop &l, const dynamic_prop &r);
|
|
|
|
|
|
|
|
/* Compare two dynamic_prop objects for inequality. */
|
|
|
|
static inline bool operator!= (const dynamic_prop &l, const dynamic_prop &r)
|
|
|
|
{
|
|
|
|
return !(l == r);
|
|
|
|
}
|
|
|
|
|
2015-03-21 05:45:20 +08:00
|
|
|
/* * Define a type's dynamic property node kind. */
|
|
|
|
enum dynamic_prop_node_kind
|
|
|
|
{
|
|
|
|
/* A property providing a type's data location.
|
|
|
|
Evaluating this field yields to the location of an object's data. */
|
2015-03-25 02:03:21 +08:00
|
|
|
DYN_PROP_DATA_LOCATION,
|
2015-10-22 03:32:30 +08:00
|
|
|
|
|
|
|
/* A property representing DW_AT_allocated. The presence of this attribute
|
|
|
|
indicates that the object of the type can be allocated/deallocated. */
|
|
|
|
DYN_PROP_ALLOCATED,
|
|
|
|
|
2020-05-01 20:50:08 +08:00
|
|
|
/* A property representing DW_AT_associated. The presence of this attribute
|
2015-10-22 03:32:30 +08:00
|
|
|
indicated that the object of the type can be associated. */
|
|
|
|
DYN_PROP_ASSOCIATED,
|
Add support for dynamic DW_AT_byte_stride.
This patch adds support for DW_AT_byte_stride, using Ada as one
example of where this would be useful. However, the implementation
is language-agnostic.
Consider the following Ada code:
procedure Nested (L, U : Integer) is
subtype Small_Type is Integer range L .. U;
type Record_Type (I : Small_Type := L) is record
S : String (1 .. I);
end record;
type Array_Type is array (Integer range <>) of Record_Type;
A1 : Array_Type :=
(1 => (I => 0, S => <>),
2 => (I => 1, S => "A"),
3 => (I => 2, S => "AB"));
procedure Discard (R : Record_Type) is
begin
null;
end Discard;
begin
Discard (A1 (1)); -- STOP
end;
It defines an array A1 of Record_Type, which is a variant record
type whose maximum size actually depends on the value of the
parameters passed when calling Nested. As a result, the stride
of the array A1 cannot be known statically, which leads the compiler
to generate a dynamic DW_AT_byte_stride attribute for our type.
Here is what the debugging info looks like with GNAT:
.uleb128 0x10 # (DIE (0x14e) DW_TAG_array_type)
.long .LASF17 # DW_AT_name: "foo__nested__T18b"
.long 0x141 # DW_AT_byte_stride
.long 0xdc # DW_AT_type
.uleb128 0x11 # (DIE (0x15f) DW_TAG_subrange_type)
.long 0x166 # DW_AT_type
.byte 0x3 # DW_AT_upper_bound
.byte 0 # end of children of DIE 0x14e
There DW_AT_byte_stride is a reference to a local (internal)
variable:
.uleb128 0x9 # (DIE (0x141) DW_TAG_variable)
.long .LASF6 # DW_AT_name: "foo__nested__T18b___PAD___XVZ"
This patch enhances GDB to handle this dynamic byte stride attribute
by first adding a new dynamic_prop_node_kind (DYN_PROP_BYTE_STRIDE)
to store the array dynamic stride info (when dynamic). It then enhances
the dynamic type resolver to handle this dynamic property.
Before applying this patch, trying to print the value of some of
A1's elements after having stopped at the "STOP" comment does not
work. For instance:
(gdb) p a1(2)
Cannot access memory at address 0x80000268dec0
With this patch applied, GDB now prints the value of all 3 elements
correctly:
(gdb) print A1(1)
$1 = (i => 0, s => "")
(gdb) print A1(2)
$2 = (i => 1, s => "A")
(gdb) print A1(3)
$3 = (i => 2, s => "AB")
gdb/ChangeLog:
* gdbtypes.h (enum dynamic_prop_node_kind) <DYN_PROP_BYTE_STRIDE>:
New enum value.
(create_array_type_with_stride): Add byte_stride_prop parameter.
* gdbtypes.c (create_array_type_with_stride) <byte_stride_prop>:
New parameter. Update all callers in this file.
(array_type_has_dynamic_stride): New function.
(is_dynamic_type_internal, resolve_dynamic_array): Add handling
of arrays with dynamic byte strides.
* dwarf2read.c (read_array_type): Add support for dynamic
DW_AT_byte_stride attributes.
gdb/testsuite/ChangeLog:
* gdb.ada/dyn_stride: New testcase.
Tested on x86_64-linux.
2018-01-02 11:47:18 +08:00
|
|
|
|
|
|
|
/* A property providing an array's byte stride. */
|
|
|
|
DYN_PROP_BYTE_STRIDE,
|
2018-02-10 04:31:42 +08:00
|
|
|
|
Add new variant part code
This patch adds the infrastructure for the new variant part code. At
this point, nothing uses this code. This is done in a separate patch
to make it simpler to review.
I examined a few possible approaches to handling variant parts. In
particular, I considered having a DWARF variant part be a union
(similar to how the Rust code works now); and I considered having type
fields have a flag indicating that they are variants.
Having separate types seemed bad conceptually, because these variants
aren't truly separate -- they rely on the "parent" type. And,
changing how fields worked seemed excessively invasive.
So, in the end I thought the approach taken in this patch was both
simple to implement and understand, without losing generality. The
idea in this patch is that all the fields of a type with variant parts
will be stored in a single field array, just as if they'd all been
listed directly. Then, the variants are attached as a dynamic
property. These control which fields end up in the type that's
constructed during dynamic type resolution.
gdb/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
* gdbtypes.c (is_dynamic_type_internal): Check for variant parts.
(variant::matches, compute_variant_fields_recurse)
(compute_variant_fields_inner, compute_variant_fields): New
functions.
(resolve_dynamic_struct): Check for DYN_PROP_VARIANT_PARTS.
Use resolved_type after type is made.
(operator==): Add new cases.
* gdbtypes.h (TYPE_HAS_VARIANT_PARTS): New macro.
(struct discriminant_range, struct variant, struct variant_part):
New.
(union dynamic_prop_data) <variant_parts, original_type>: New
members.
(enum dynamic_prop_node_kind) <DYN_PROP_VARIANT_PARTS>: New constant.
(enum dynamic_prop_kind) <PROP_TYPE, PROP_VARIANT_PARTS>: New
constants.
* value.c (unpack_bits_as_long): Now public.
* value.h (unpack_bits_as_long): Declare.
2020-04-25 03:40:31 +08:00
|
|
|
/* A property holding variant parts. */
|
|
|
|
DYN_PROP_VARIANT_PARTS,
|
2020-04-25 03:40:31 +08:00
|
|
|
|
gdb: add support for Fortran's ASSUMED RANK arrays
This patch adds a new dynamic property DYN_PROP_RANK, this property is
read from the DW_AT_rank attribute and stored within the type just
like other dynamic properties.
As arrays with dynamic ranks make use of a single
DW_TAG_generic_subrange to represent all ranks of the array, support
for this tag has been added to dwarf2/read.c.
The final piece of this puzzle is to add support in gdbtypes.c so that
we can resolve an array type with dynamic rank. To do this the
existing resolve_dynamic_array_or_string function is split into two,
there's a new resolve_dynamic_array_or_string_1 core that is
responsible for resolving each rank of the array, while the now outer
resolve_dynamic_array_or_string is responsible for figuring out the
array rank (which might require resolving a dynamic property) and then
calling the inner core.
The resolve_dynamic_range function now takes a rank, which is passed
on to the dwarf expression evaluator. This rank will only be used in
the case where the array itself has dynamic rank, but we now pass the
rank in all cases, this should be harmless if the rank is not needed.
The only small nit is that resolve_dynamic_type_internal actually
handles resolving dynamic ranges itself, which now obviously requires
us to pass a rank value. But what rank value to use? In the end I
just passed '1' through here as a sane default, my thinking is that if
we are in resolve_dynamic_type_internal to resolve a range, then the
range isn't part of an array with dynamic rank, and so the range
should actually be using the rank value at all.
An alternative approach would be to make the rank value a
gdb::optional, however, this ends up adding a bunch of complexity to
the code (e.g. having to conditionally build the array to pass to
dwarf2_evaluate_property, and handling the 'rank - 1' in
resolve_dynamic_array_or_string_1) so I haven't done that, but could,
if people think that would be a better approach.
Finally, support for assumed rank arrays was only fixed very recently
in gcc, so you'll need the latest gcc in order to run the tests for
this.
Here's an example test program:
PROGRAM arank
REAL :: a1(10)
CALL sub1(a1)
CONTAINS
SUBROUTINE sub1(a)
REAL :: a(..)
PRINT *, RANK(a)
END SUBROUTINE sub1
END PROGRAM arank
Compiler Version:
gcc (GCC) 12.0.0 20211122 (experimental)
Compilation command:
gfortran assumedrank.f90 -gdwarf-5 -o assumedrank
Without Patch:
gdb -q assumedrank
Reading symbols from assumedrank...
(gdb) break sub1
Breakpoint 1 at 0x4006ff: file assumedrank.f90, line 10.
(gdb) run
Starting program: /home/rupesh/STAGING-BUILD-2787/bin/assumedrank
Breakpoint 1, arank::sub1 (a=<unknown type in /home/rupesh/STAGING-BUILD-2787
/bin/assumedrank, CU 0x0, DIE 0xd5>) at assumedrank.f90:10
10 PRINT *, RANK(a)
(gdb) print RANK(a)
'a' has unknown type; cast it to its declared type
With patch:
gdb -q assumedrank
Reading symbols from assumedrank...
(gdb) break sub1
Breakpoint 1 at 0x4006ff: file assumedrank.f90, line 10.
(gdb) run
Starting program: /home/rupesh/STAGING-BUILD-2787/bin/assumedrank
Breakpoint 1, arank::sub1 (a=...) at assumedrank.f90:10
10 PRINT *, RANK(a)
(gdb) print RANK(a)
$1 = 1
(gdb) ptype a
type = real(kind=4) (10)
(gdb)
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
2022-03-18 02:56:23 +08:00
|
|
|
/* A property representing DW_AT_rank. The presence of this attribute
|
|
|
|
indicates that the object is of assumed rank array type. */
|
|
|
|
DYN_PROP_RANK,
|
|
|
|
|
2020-04-25 03:40:31 +08:00
|
|
|
/* A property holding the size of the type. */
|
|
|
|
DYN_PROP_BYTE_SIZE,
|
2015-03-21 05:45:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* * List for dynamic type attributes. */
|
|
|
|
struct dynamic_prop_list
|
|
|
|
{
|
|
|
|
/* The kind of dynamic prop in this node. */
|
|
|
|
enum dynamic_prop_node_kind prop_kind;
|
|
|
|
|
|
|
|
/* The dynamic property itself. */
|
2015-03-25 02:14:13 +08:00
|
|
|
struct dynamic_prop prop;
|
2015-03-21 05:45:20 +08:00
|
|
|
|
|
|
|
/* A pointer to the next dynamic property. */
|
|
|
|
struct dynamic_prop_list *next;
|
|
|
|
};
|
2013-10-08 22:04:49 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Determine which field of the union main_type.fields[x].loc is
|
|
|
|
used. */
|
Convert static_kind into loc_kind enum.
* gdbtypes.h (enum field_loc_kind): New.
(union field_location): New field dwarf_block.
(struct field): Rename static_kind as loc_kind.
(FIELD_STATIC_KIND): Rename to ...
(FIELD_LOC_KIND): ... here.
(TYPE_FIELD_STATIC_KIND): Rename to ...
(TYPE_FIELD_LOC_KIND): ... here and use there now new FIELD_LOC_KIND.
(TYPE_FIELD_STATIC_HAS_ADDR): Remove.
(TYPE_FIELD_STATIC): Remove.
(TYPE_FIELD_BITPOS): Reformat.
(SET_FIELD_BITPOS): New.
(FIELD_PHYSADDR): Rename to ...
(FIELD_STATIC_PHYSADDR): ... here.
(TYPE_FIELD_STATIC_PHYSADDR): Follow the FIELD_PHYSADDR rename.
(SET_FIELD_PHYSADDR): Use new FIELD_LOC_KIND.
(FIELD_PHYSNAME): Rename to ...
(FIELD_STATIC_PHYSNAME): ... here.
(TYPE_FIELD_STATIC_PHYSNAME): Follow the FIELD_PHYSNAME rename.
(SET_FIELD_PHYSNAME): Use new FIELD_LOC_KIND.
(FIELD_DWARF_BLOCK, TYPE_FIELD_DWARF_BLOCK, SET_FIELD_DWARF_BLOCK): New.
(field_is_static): New declaration.
* gdbtypes.c (field_is_static): New function.
(copy_type_recursive): Update throughout.
* amd64-tdep.c, c-typeprint.c, coffread.c, cp-valprint.c, dwarf2read.c,
eval.c, jv-typeprint.c, jv-valprint.c, mdebugread.c, p-typeprint.c,
p-valprint.c, valops.c, value.c, varobj.c: Update throughout.
2008-10-08 20:49:13 +08:00
|
|
|
|
|
|
|
enum field_loc_kind
|
|
|
|
{
|
2014-03-13 10:36:45 +08:00
|
|
|
FIELD_LOC_KIND_BITPOS, /**< bitpos */
|
|
|
|
FIELD_LOC_KIND_ENUMVAL, /**< enumval */
|
|
|
|
FIELD_LOC_KIND_PHYSADDR, /**< physaddr */
|
|
|
|
FIELD_LOC_KIND_PHYSNAME, /**< physname */
|
|
|
|
FIELD_LOC_KIND_DWARF_BLOCK /**< dwarf_block */
|
Convert static_kind into loc_kind enum.
* gdbtypes.h (enum field_loc_kind): New.
(union field_location): New field dwarf_block.
(struct field): Rename static_kind as loc_kind.
(FIELD_STATIC_KIND): Rename to ...
(FIELD_LOC_KIND): ... here.
(TYPE_FIELD_STATIC_KIND): Rename to ...
(TYPE_FIELD_LOC_KIND): ... here and use there now new FIELD_LOC_KIND.
(TYPE_FIELD_STATIC_HAS_ADDR): Remove.
(TYPE_FIELD_STATIC): Remove.
(TYPE_FIELD_BITPOS): Reformat.
(SET_FIELD_BITPOS): New.
(FIELD_PHYSADDR): Rename to ...
(FIELD_STATIC_PHYSADDR): ... here.
(TYPE_FIELD_STATIC_PHYSADDR): Follow the FIELD_PHYSADDR rename.
(SET_FIELD_PHYSADDR): Use new FIELD_LOC_KIND.
(FIELD_PHYSNAME): Rename to ...
(FIELD_STATIC_PHYSNAME): ... here.
(TYPE_FIELD_STATIC_PHYSNAME): Follow the FIELD_PHYSNAME rename.
(SET_FIELD_PHYSNAME): Use new FIELD_LOC_KIND.
(FIELD_DWARF_BLOCK, TYPE_FIELD_DWARF_BLOCK, SET_FIELD_DWARF_BLOCK): New.
(field_is_static): New declaration.
* gdbtypes.c (field_is_static): New function.
(copy_type_recursive): Update throughout.
* amd64-tdep.c, c-typeprint.c, coffread.c, cp-valprint.c, dwarf2read.c,
eval.c, jv-typeprint.c, jv-valprint.c, mdebugread.c, p-typeprint.c,
p-valprint.c, valops.c, value.c, varobj.c: Update throughout.
2008-10-08 20:49:13 +08:00
|
|
|
};
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * A discriminant to determine which field in the
|
|
|
|
main_type.type_specific union is being used, if any.
|
2010-01-12 13:49:00 +08:00
|
|
|
|
Move TYPE_SELF_TYPE into new field type_specific.
This patch moves TYPE_SELF_TYPE into new field type_specific.self_type
for MEMBERPTR,METHODPTR types, and into type_specific.func_stuff
for METHODs, and then updates everything to use that.
TYPE_CODE_METHOD could share some things with TYPE_CODE_FUNC
(e.g. TYPE_NO_RETURN) and it seemed simplest to keep them together.
Moving TYPE_SELF_TYPE into type_specific.func_stuff for TYPE_CODE_METHOD
is also nice because when we allocate space for function types we assume
they're TYPE_CODE_FUNCs. If TYPE_CODE_METHODs don't need or use that
space then that space would be wasted, and cleaning that up would involve
more invasive changes.
In order to catch errant uses I've added accessor functions
that do some checking.
One can no longer assign to TYPE_SELF_TYPE like this:
TYPE_SELF_TYPE (foo) = bar;
One instead has to do:
set_type_self_type (foo, bar);
But I've left reading of the type to the macro:
bar = TYPE_SELF_TYPE (foo);
In order to discourage bypassing the TYPE_SELF_TYPE macro
I've named the underlying function that implements it
internal_type_self_type.
While testing this I found the stabs reader leaving methods
as TYPE_CODE_FUNCs, hitting my newly added asserts.
Since the dwarf reader smashes functions to methods (via
smash_to_method) I've done a similar thing for stabs.
gdb/ChangeLog:
* cp-valprint.c (cp_find_class_member): Rename parameter domain_p
to self_p.
(cp_print_class_member): Rename local domain to self_type.
* dwarf2read.c (quirk_gcc_member_function_pointer): Rename local
domain_type to self_type.
(set_die_type) <need_gnat_info>: Handle
TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, TYPE_CODE_METHOD.
* gdb-gdb.py (StructMainTypePrettyPrinter): Handle
TYPE_SPECIFIC_SELF_TYPE.
* gdbtypes.c (internal_type_self_type): New function.
(set_type_self_type): New function.
(smash_to_memberptr_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(smash_to_methodptr_type): Update setting of TYPE_SELF_TYPE.
(smash_to_method_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(check_stub_method): Call smash_to_method_type.
(recursive_dump_type): Handle TYPE_SPECIFIC_SELF_TYPE.
(copy_type_recursive): Ditto.
* gdbtypes.h (enum type_specific_kind): New value
TYPE_SPECIFIC_SELF_TYPE.
(struct main_type) <type_specific>: New member self_type.
(struct cplus_struct_type) <fn_field.type>: Update comment.
(TYPE_SELF_TYPE): Rewrite.
(internal_type_self_type, set_type_self_type): Declare.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Rename local domain to
self_type.
(gnuv3_method_ptr_to_value): Rename local domain_type to self_type.
* m2-typeprint.c (m2_range): Replace TYPE_SELF_TYPE with
TYPE_TARGET_TYPE.
* stabsread.c (read_member_functions): Mark methods with
TYPE_CODE_METHOD, not TYPE_CODE_FUNC. Update setting of
TYPE_SELF_TYPE.
2015-02-01 13:21:01 +08:00
|
|
|
For types such as TYPE_CODE_FLT, the use of this
|
2010-01-12 13:49:00 +08:00
|
|
|
discriminant is really redundant, as we know from the type code
|
|
|
|
which field is going to be used. As such, it would be possible to
|
|
|
|
reduce the size of this enum in order to save a bit or two for
|
|
|
|
other fields of struct main_type. But, since we still have extra
|
|
|
|
room , and for the sake of clarity and consistency, we treat all fields
|
|
|
|
of the union the same way. */
|
|
|
|
|
|
|
|
enum type_specific_kind
|
|
|
|
{
|
|
|
|
TYPE_SPECIFIC_NONE,
|
|
|
|
TYPE_SPECIFIC_CPLUS_STUFF,
|
|
|
|
TYPE_SPECIFIC_GNAT_STUFF,
|
|
|
|
TYPE_SPECIFIC_FLOATFORMAT,
|
Move TYPE_SELF_TYPE into new field type_specific.
This patch moves TYPE_SELF_TYPE into new field type_specific.self_type
for MEMBERPTR,METHODPTR types, and into type_specific.func_stuff
for METHODs, and then updates everything to use that.
TYPE_CODE_METHOD could share some things with TYPE_CODE_FUNC
(e.g. TYPE_NO_RETURN) and it seemed simplest to keep them together.
Moving TYPE_SELF_TYPE into type_specific.func_stuff for TYPE_CODE_METHOD
is also nice because when we allocate space for function types we assume
they're TYPE_CODE_FUNCs. If TYPE_CODE_METHODs don't need or use that
space then that space would be wasted, and cleaning that up would involve
more invasive changes.
In order to catch errant uses I've added accessor functions
that do some checking.
One can no longer assign to TYPE_SELF_TYPE like this:
TYPE_SELF_TYPE (foo) = bar;
One instead has to do:
set_type_self_type (foo, bar);
But I've left reading of the type to the macro:
bar = TYPE_SELF_TYPE (foo);
In order to discourage bypassing the TYPE_SELF_TYPE macro
I've named the underlying function that implements it
internal_type_self_type.
While testing this I found the stabs reader leaving methods
as TYPE_CODE_FUNCs, hitting my newly added asserts.
Since the dwarf reader smashes functions to methods (via
smash_to_method) I've done a similar thing for stabs.
gdb/ChangeLog:
* cp-valprint.c (cp_find_class_member): Rename parameter domain_p
to self_p.
(cp_print_class_member): Rename local domain to self_type.
* dwarf2read.c (quirk_gcc_member_function_pointer): Rename local
domain_type to self_type.
(set_die_type) <need_gnat_info>: Handle
TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, TYPE_CODE_METHOD.
* gdb-gdb.py (StructMainTypePrettyPrinter): Handle
TYPE_SPECIFIC_SELF_TYPE.
* gdbtypes.c (internal_type_self_type): New function.
(set_type_self_type): New function.
(smash_to_memberptr_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(smash_to_methodptr_type): Update setting of TYPE_SELF_TYPE.
(smash_to_method_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(check_stub_method): Call smash_to_method_type.
(recursive_dump_type): Handle TYPE_SPECIFIC_SELF_TYPE.
(copy_type_recursive): Ditto.
* gdbtypes.h (enum type_specific_kind): New value
TYPE_SPECIFIC_SELF_TYPE.
(struct main_type) <type_specific>: New member self_type.
(struct cplus_struct_type) <fn_field.type>: Update comment.
(TYPE_SELF_TYPE): Rewrite.
(internal_type_self_type, set_type_self_type): Declare.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Rename local domain to
self_type.
(gnuv3_method_ptr_to_value): Rename local domain_type to self_type.
* m2-typeprint.c (m2_range): Replace TYPE_SELF_TYPE with
TYPE_TARGET_TYPE.
* stabsread.c (read_member_functions): Mark methods with
TYPE_CODE_METHOD, not TYPE_CODE_FUNC. Update setting of
TYPE_SELF_TYPE.
2015-02-01 13:21:01 +08:00
|
|
|
/* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
|
|
|
|
TYPE_SPECIFIC_FUNC,
|
Handle bit offset and bit size in base types
PR symtab/25470 points out that the Zig programming language allows
integers of various bit sizes (including zero), not just sizes that
are a multiple of 8.
This is supported in DWARF by applying both a byte size and a
DW_AT_bit_size.
This patch adds support for this feature to integer and boolean types.
Other base types are not handled -- for floating-point types, this
didn't seem to make sense, and for character types I didn't see much
need. (These can be added later if desired.)
I've also added support for DW_AT_data_bit_offset at the same time. I
don't know whether the Zig compiler requires this, but it was
described in the same section in the DWARF standard and was easy to
add.
A new test case is supplied, using the DWARF assembler.
gdb/ChangeLog
2020-09-23 Tom Tromey <tom@tromey.com>
PR symtab/25470:
* value.c (unpack_long, pack_long, pack_unsigned_long): Handle bit
offset and bit size.
* printcmd.c (print_scalar_formatted): Handle zero-length
integer.
(print_scalar_formatted): Use bit_size_differs_p.
* gdbtypes.h (enum type_specific_kind) <TYPE_SPECIFIC_INT>: New
constant.
(union type_specific): <int_stuff>: New member.
(struct type) <bit_size_differs_p, bit_size, bit_offset>: New
methods.
* gdbtypes.c (init_integer_type, init_boolean_type): Initialize
TYPE_SPECIFIC_FIELD.
(recursive_dump_type, copy_type_recursive): Update.
* dwarf2/read.c (read_base_type): Handle DW_AT_bit_size and
DW_AT_data_bit_offset.
gdb/testsuite/ChangeLog
2020-09-23 Tom Tromey <tom@tromey.com>
* gdb.dwarf2/intbits.exp: New file.
* gdb.dwarf2/intbits.c: New file.
2020-09-23 23:39:24 +08:00
|
|
|
TYPE_SPECIFIC_SELF_TYPE,
|
Add support for printing value of DWARF-based fixed-point type objects
This commit introduces a new kind of type, meant to describe
fixed-point types, using a new code added specifically for
this purpose (TYPE_CODE_FIXED_POINT).
It then adds handling of fixed-point base types in the DWARF reader.
And finally, as a first step, this commit adds support for printing
the value of fixed-point type objects.
Note that this commit has a known issue: Trying to print the value
of a fixed-point object with a format letter (e.g. "print /x NAME")
causes the wrong value to be printed because the scaling factor
is not applied. Since the fix for this issue is isolated, and
this is not a regression, the fix will be made in a pach of its own.
This is meant to simplify review and archeology.
Also, other functionalities related to fixed-point type handling
(ptype, arithmetics, etc), will be added piecemeal as well, for
the same reasons (faciliate reviews and archeology). Related to this,
the testcase gdb.ada/fixed_cmp.exp is adjusted to compile the test
program with -fgnat-encodings=all, so as to force the use of GNAT
encodings, rather than rely on the compiler's default to use them.
The intent is to enhance this testcase to also test the pure DWARF
approach using -fgnat-encodings=minimal as soon as the corresponding
suport gets added in. Thus, the modification to the testcase is made
in a way that it prepares this testcase to be tested in both modes.
gdb/ChangeLog:
* ada-valprint.c (ada_value_print_1): Add fixed-point type handling.
* dwarf2/read.c (get_dwarf2_rational_constant)
(get_dwarf2_unsigned_rational_constant, finish_fixed_point_type)
(has_zero_over_zero_small_attribute): New functions.
read_base_type, set_die_type): Add fixed-point type handling.
* gdb-gdb.py.in: Add fixed-point type handling.
* gdbtypes.c: #include "gmp-utils.h".
(create_range_type, set_type_code): Add fixed-point type handling.
(init_fixed_point_type): New function.
(is_integral_type, is_scalar_type): Add fixed-point type handling.
(print_fixed_point_type_info): New function.
(recursive_dump_type, copy_type_recursive): Add fixed-point type
handling.
(fixed_point_type_storage): New typedef.
(fixed_point_objfile_key): New static global.
(allocate_fixed_point_type_info, is_fixed_point_type): New functions.
(fixed_point_type_base_type, fixed_point_scaling_factor): New
functions.
* gdbtypes.h: #include "gmp-utils.h".
(enum type_code) <TYPE_SPECIFIC_FIXED_POINT>: New enum.
(union type_specific) <fixed_point_info>: New field.
(struct fixed_point_type_info): New struct.
(INIT_FIXED_POINT_SPECIFIC, TYPE_FIXED_POINT_INFO): New macros.
(init_fixed_point_type, is_fixed_point_type)
(fixed_point_type_base_type, fixed_point_scaling_factor)
(allocate_fixed_point_type_info): Add declarations.
* valprint.c (generic_val_print_fixed_point): New function.
(generic_value_print): Add fixed-point type handling.
* value.c (value_as_address, unpack_long): Add fixed-point type
handling.
gdb/testsuite/ChangeLog:
* gdb.ada/fixed_cmp.exp: Force compilation to use -fgnat-encodings=all.
* gdb.ada/fixed_points.exp: Add fixed-point variables printing tests.
* gdb.ada/fixed_points/pck.ads, gdb.ada/fixed_points/pck.adb:
New files.
* gdb.ada/fixed_points/fixed_points.adb: Add use of package Pck.
* gdb.dwarf2/dw2-fixed-point.c, gdb.dwarf2/dw2-fixed-point.exp:
New files.
2020-11-15 16:12:52 +08:00
|
|
|
TYPE_SPECIFIC_INT,
|
|
|
|
TYPE_SPECIFIC_FIXED_POINT,
|
2010-01-12 13:49:00 +08:00
|
|
|
};
|
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
union type_owner
|
|
|
|
{
|
|
|
|
struct objfile *objfile;
|
|
|
|
struct gdbarch *gdbarch;
|
|
|
|
};
|
|
|
|
|
|
|
|
union field_location
|
|
|
|
{
|
|
|
|
/* * Position of this field, counting in bits from start of
|
2019-11-26 03:31:02 +08:00
|
|
|
containing structure. For big-endian targets, it is the bit
|
|
|
|
offset to the MSB. For little-endian targets, it is the bit
|
|
|
|
offset to the LSB. */
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
|
2016-04-13 03:02:57 +08:00
|
|
|
LONGEST bitpos;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
|
|
|
|
/* * Enum value. */
|
|
|
|
LONGEST enumval;
|
|
|
|
|
|
|
|
/* * For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then
|
|
|
|
physaddr is the location (in the target) of the static
|
|
|
|
field. Otherwise, physname is the mangled label of the
|
|
|
|
static field. */
|
|
|
|
|
|
|
|
CORE_ADDR physaddr;
|
|
|
|
const char *physname;
|
|
|
|
|
|
|
|
/* * The field location can be computed by evaluating the
|
|
|
|
following DWARF block. Its DATA is allocated on
|
|
|
|
objfile_obstack - no CU load is needed to access it. */
|
|
|
|
|
|
|
|
struct dwarf2_locexpr_baton *dwarf_block;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct field
|
|
|
|
{
|
2020-06-09 03:26:04 +08:00
|
|
|
struct type *type () const
|
|
|
|
{
|
|
|
|
return this->m_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_type (struct type *type)
|
|
|
|
{
|
|
|
|
this->m_type = type;
|
|
|
|
}
|
|
|
|
|
2021-08-30 23:49:48 +08:00
|
|
|
const char *name () const
|
|
|
|
{
|
|
|
|
return m_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_name (const char *name)
|
|
|
|
{
|
|
|
|
m_name = name;
|
|
|
|
}
|
|
|
|
|
2023-04-23 02:41:43 +08:00
|
|
|
/* Return true if this field is static; false if not. */
|
|
|
|
bool is_static () const
|
|
|
|
{
|
|
|
|
/* "static" fields are the fields whose location is not relative
|
|
|
|
to the address of the enclosing struct. It would be nice to
|
|
|
|
have a dedicated flag that would be set for static fields when
|
|
|
|
the type is being created. But in practice, checking the field
|
|
|
|
loc_kind should give us an accurate answer. */
|
|
|
|
return (m_loc_kind == FIELD_LOC_KIND_PHYSNAME
|
|
|
|
|| m_loc_kind == FIELD_LOC_KIND_PHYSADDR);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* Location getters / setters. */
|
|
|
|
|
|
|
|
field_loc_kind loc_kind () const
|
|
|
|
{
|
|
|
|
return m_loc_kind;
|
|
|
|
}
|
|
|
|
|
|
|
|
LONGEST loc_bitpos () const
|
|
|
|
{
|
|
|
|
gdb_assert (m_loc_kind == FIELD_LOC_KIND_BITPOS);
|
|
|
|
return m_loc.bitpos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_loc_bitpos (LONGEST bitpos)
|
|
|
|
{
|
|
|
|
m_loc_kind = FIELD_LOC_KIND_BITPOS;
|
|
|
|
m_loc.bitpos = bitpos;
|
|
|
|
}
|
|
|
|
|
|
|
|
LONGEST loc_enumval () const
|
|
|
|
{
|
|
|
|
gdb_assert (m_loc_kind == FIELD_LOC_KIND_ENUMVAL);
|
|
|
|
return m_loc.enumval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_loc_enumval (LONGEST enumval)
|
|
|
|
{
|
|
|
|
m_loc_kind = FIELD_LOC_KIND_ENUMVAL;
|
|
|
|
m_loc.enumval = enumval;
|
|
|
|
}
|
|
|
|
|
|
|
|
CORE_ADDR loc_physaddr () const
|
|
|
|
{
|
|
|
|
gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSADDR);
|
|
|
|
return m_loc.physaddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_loc_physaddr (CORE_ADDR physaddr)
|
|
|
|
{
|
|
|
|
m_loc_kind = FIELD_LOC_KIND_PHYSADDR;
|
|
|
|
m_loc.physaddr = physaddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *loc_physname () const
|
|
|
|
{
|
|
|
|
gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSNAME);
|
|
|
|
return m_loc.physname;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_loc_physname (const char *physname)
|
|
|
|
{
|
|
|
|
m_loc_kind = FIELD_LOC_KIND_PHYSNAME;
|
|
|
|
m_loc.physname = physname;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwarf2_locexpr_baton *loc_dwarf_block () const
|
|
|
|
{
|
|
|
|
gdb_assert (m_loc_kind == FIELD_LOC_KIND_DWARF_BLOCK);
|
|
|
|
return m_loc.dwarf_block;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_loc_dwarf_block (dwarf2_locexpr_baton *dwarf_block)
|
|
|
|
{
|
|
|
|
m_loc_kind = FIELD_LOC_KIND_DWARF_BLOCK;
|
|
|
|
m_loc.dwarf_block = dwarf_block;
|
|
|
|
}
|
|
|
|
|
|
|
|
union field_location m_loc;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
|
|
|
|
/* * For a function or member type, this is 1 if the argument is
|
|
|
|
marked artificial. Artificial arguments should not be shown
|
|
|
|
to the user. For TYPE_CODE_RANGE it is set if the specific
|
|
|
|
bound is not defined. */
|
|
|
|
|
|
|
|
unsigned int artificial : 1;
|
|
|
|
|
|
|
|
/* * Discriminant for union field_location. */
|
|
|
|
|
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
|
|
|
ENUM_BITFIELD(field_loc_kind) m_loc_kind : 3;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
|
|
|
|
/* * Size of this field, in bits, or zero if not packed.
|
|
|
|
If non-zero in an array type, indicates the element size in
|
|
|
|
bits (used only in Ada at the moment).
|
|
|
|
For an unpacked field, the field's type's length
|
|
|
|
says how many bytes the field occupies. */
|
|
|
|
|
|
|
|
unsigned int bitsize : 28;
|
|
|
|
|
|
|
|
/* * In a struct or union type, type of this field.
|
|
|
|
- In a function or member type, type of this argument.
|
|
|
|
- In an array type, the domain-type of the array. */
|
|
|
|
|
2020-06-09 03:26:04 +08:00
|
|
|
struct type *m_type;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
|
|
|
|
/* * Name of field, value or argument.
|
|
|
|
NULL for range bounds, array domains, and member function
|
|
|
|
arguments. */
|
|
|
|
|
2021-08-30 23:49:48 +08:00
|
|
|
const char *m_name;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct range_bounds
|
|
|
|
{
|
2020-07-13 10:58:53 +08:00
|
|
|
ULONGEST bit_stride () const
|
|
|
|
{
|
|
|
|
if (this->flag_is_byte_stride)
|
|
|
|
return this->stride.const_val () * 8;
|
|
|
|
else
|
|
|
|
return this->stride.const_val ();
|
|
|
|
}
|
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
/* * Low bound of range. */
|
|
|
|
|
|
|
|
struct dynamic_prop low;
|
|
|
|
|
|
|
|
/* * High bound of range. */
|
|
|
|
|
|
|
|
struct dynamic_prop high;
|
|
|
|
|
gdb/fortran: array stride support
Currently GDB supports a byte or bit stride on arrays, in DWARF this
would be DW_AT_bit_stride or DW_AT_byte_stride on DW_TAG_array_type.
However, DWARF can also support DW_AT_byte_stride or DW_AT_bit_stride
on DW_TAG_subrange_type, the tag used to describe each dimension of an
array.
Strides on subranges are used by gFortran to represent Fortran arrays,
and this commit adds support for this to GDB.
I've extended the range_bounds struct to include the stride
information. The name is possibly a little inaccurate now, but this
still sort of makes sense, the structure represents information about
the bounds of the range, and also how to move from the lower to the
upper bound (the stride).
I've added initial support for bit strides, but I've never actually
seen an example of this being generated. Further, I don't really see
right now how GDB would currently handle a bit stride that was not a
multiple of the byte size as the code in, for example,
valarith.c:value_subscripted_rvalue seems geared around byte
addressing. As a consequence if we see a bit stride that is not a
multiple of 8 then GDB will give an error.
gdb/ChangeLog:
* dwarf2read.c (read_subrange_type): Read bit and byte stride and
create a range with stride where appropriate.
* f-valprint.c: Include 'gdbarch.h'.
(f77_print_array_1): Take the stride into account when walking the
array. Also convert the stride into addressable units.
* gdbtypes.c (create_range_type): Initialise the stride to
constant zero.
(create_range_type_with_stride): New function, initialise the
range as normal, and then setup the stride.
(has_static_range): Include the stride here. Also change the
return type to bool.
(create_array_type_with_stride): Consider the range stride if the
array isn't given its own stride.
(resolve_dynamic_range): Resolve the stride if needed.
* gdbtypes.h (struct range_bounds) <stride>: New member variable.
(struct range_bounds) <flag_is_byte_stride>: New member variable.
(TYPE_BIT_STRIDE): Define.
(TYPE_ARRAY_BIT_STRIDE): Define.
(create_range_type_with_stride): Declare.
* valarith.c (value_subscripted_rvalue): Take range stride into
account when walking the array.
gdb/testsuite/ChangeLog:
* gdb.fortran/derived-type-striding.exp: New file.
* gdb.fortran/derived-type-striding.f90: New file.
* gdb.fortran/array-slices.exp: New file.
* gdb.fortran/array-slices.f90: New file.
Change-Id: I9af2bcd1f2d4c56f76f5f3f9f89d8f06bef10d9a
2019-10-24 18:12:11 +08:00
|
|
|
/* The stride value for this range. This can be stored in bits or bytes
|
|
|
|
based on the value of BYTE_STRIDE_P. It is optional to have a stride
|
|
|
|
value, if this range has no stride value defined then this will be set
|
|
|
|
to the constant zero. */
|
|
|
|
|
|
|
|
struct dynamic_prop stride;
|
|
|
|
|
2019-05-14 03:21:48 +08:00
|
|
|
/* * The bias. Sometimes a range value is biased before storage.
|
|
|
|
The bias is added to the stored bits to form the true value. */
|
|
|
|
|
|
|
|
LONGEST bias;
|
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
/* True if HIGH range bound contains the number of elements in the
|
2019-05-30 22:50:22 +08:00
|
|
|
subrange. This affects how the final high bound is computed. */
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
|
2019-11-28 11:42:57 +08:00
|
|
|
unsigned int flag_upper_bound_is_count : 1;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
|
|
|
|
/* True if LOW or/and HIGH are resolved into a static bound from
|
|
|
|
a dynamic one. */
|
|
|
|
|
2019-11-28 11:42:57 +08:00
|
|
|
unsigned int flag_bound_evaluated : 1;
|
gdb/fortran: array stride support
Currently GDB supports a byte or bit stride on arrays, in DWARF this
would be DW_AT_bit_stride or DW_AT_byte_stride on DW_TAG_array_type.
However, DWARF can also support DW_AT_byte_stride or DW_AT_bit_stride
on DW_TAG_subrange_type, the tag used to describe each dimension of an
array.
Strides on subranges are used by gFortran to represent Fortran arrays,
and this commit adds support for this to GDB.
I've extended the range_bounds struct to include the stride
information. The name is possibly a little inaccurate now, but this
still sort of makes sense, the structure represents information about
the bounds of the range, and also how to move from the lower to the
upper bound (the stride).
I've added initial support for bit strides, but I've never actually
seen an example of this being generated. Further, I don't really see
right now how GDB would currently handle a bit stride that was not a
multiple of the byte size as the code in, for example,
valarith.c:value_subscripted_rvalue seems geared around byte
addressing. As a consequence if we see a bit stride that is not a
multiple of 8 then GDB will give an error.
gdb/ChangeLog:
* dwarf2read.c (read_subrange_type): Read bit and byte stride and
create a range with stride where appropriate.
* f-valprint.c: Include 'gdbarch.h'.
(f77_print_array_1): Take the stride into account when walking the
array. Also convert the stride into addressable units.
* gdbtypes.c (create_range_type): Initialise the stride to
constant zero.
(create_range_type_with_stride): New function, initialise the
range as normal, and then setup the stride.
(has_static_range): Include the stride here. Also change the
return type to bool.
(create_array_type_with_stride): Consider the range stride if the
array isn't given its own stride.
(resolve_dynamic_range): Resolve the stride if needed.
* gdbtypes.h (struct range_bounds) <stride>: New member variable.
(struct range_bounds) <flag_is_byte_stride>: New member variable.
(TYPE_BIT_STRIDE): Define.
(TYPE_ARRAY_BIT_STRIDE): Define.
(create_range_type_with_stride): Declare.
* valarith.c (value_subscripted_rvalue): Take range stride into
account when walking the array.
gdb/testsuite/ChangeLog:
* gdb.fortran/derived-type-striding.exp: New file.
* gdb.fortran/derived-type-striding.f90: New file.
* gdb.fortran/array-slices.exp: New file.
* gdb.fortran/array-slices.f90: New file.
Change-Id: I9af2bcd1f2d4c56f76f5f3f9f89d8f06bef10d9a
2019-10-24 18:12:11 +08:00
|
|
|
|
|
|
|
/* If this is true this STRIDE is in bytes, otherwise STRIDE is in bits. */
|
|
|
|
|
|
|
|
unsigned int flag_is_byte_stride : 1;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
};
|
|
|
|
|
Fix GCC PR83906 - [8 Regression] Random FAIL: libstdc++-prettyprinters/80276.cc whatis p4
GCC PR83906 [1] is about a GCC/libstdc++ GDB/Python type printer
testcase failing randomly, as shown by running (in libstdc++'s
testsuite):
make check RUNTESTFLAGS=prettyprinters.exp=80276.cc
in a loop. Sometimes you get this:
FAIL: libstdc++-prettyprinters/80276.cc whatis p4
I.e., this:
type = std::unique_ptr<std::vector<std::unique_ptr<std::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >>[]>>[99]>
instead of this:
type = std::unique_ptr<std::vector<std::unique_ptr<std::list<std::string>[]>>[99]>
Jonathan Wakely tracked it on the printer side to this bit in
libstdc++'s type printer:
if self.type_obj == type_obj:
return strip_inline_namespaces(self.name)
This assumes the two types resolve to the same gdb.Type but some times
the comparison unexpectedly fails.
Running the testcase manually under Valgrind finds the problem in GDB:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==6118== Conditional jump or move depends on uninitialised value(s)
==6118== at 0x4C35CB0: bcmp (vg_replace_strmem.c:1100)
==6118== by 0x6F773A: check_types_equal(type*, type*, VEC_type_equality_entry_d**) (gdbtypes.c:3515)
==6118== by 0x6F7B00: check_types_worklist(VEC_type_equality_entry_d**, bcache*) (gdbtypes.c:3618)
==6118== by 0x6F7C03: types_deeply_equal(type*, type*) (gdbtypes.c:3655)
==6118== by 0x4D5B06: typy_richcompare(_object*, _object*, int) (py-type.c:1007)
==6118== by 0x63D7E6C: PyObject_RichCompare (object.c:961)
==6118== by 0x646EAEC: PyEval_EvalFrameEx (ceval.c:4960)
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
That "bcmp" call is really a memcmp call in check_types_equal. The
problem is that gdb is memcmp'ing two objects that are equal in value:
(top-gdb) p *TYPE_RANGE_DATA (type1)
$1 = {low = {kind = PROP_CONST, data = {const_val = 0, baton = 0x0}}, high = {kind = PROP_CONST, data = {const_val = 15, baton = 0xf}}, flag_upper_bound_is_count = 0,
flag_bound_evaluated = 0}
(top-gdb) p *TYPE_RANGE_DATA (type2)
$2 = {low = {kind = PROP_CONST, data = {const_val = 0, baton = 0x0}}, high = {kind = PROP_CONST, data = {const_val = 15, baton = 0xf}}, flag_upper_bound_is_count = 0,
flag_bound_evaluated = 0}
but differ in padding. Notice the 4-byte hole:
(top-gdb) ptype /o range_bounds
/* offset | size */ type = struct range_bounds {
/* 0 | 16 */ struct dynamic_prop {
/* 0 | 4 */ dynamic_prop_kind kind;
/* XXX 4-byte hole */
/* 8 | 8 */ union dynamic_prop_data {
/* 8 */ LONGEST const_val;
/* 8 */ void *baton;
/* total size (bytes): 8 */
} data;
which is filled with garbage:
(top-gdb) x /40bx TYPE_RANGE_DATA (type1)
0x2fa7ea0: 0x01 0x00 0x00 0x00 0x43 0x01 0x00 0x00
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0x2fa7ea8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x2fa7eb0: 0x01 0x00 0x00 0x00 0xfe 0x7f 0x00 0x00
0x2fa7eb8: 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x2fa7ec0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
(top-gdb) x /40bx TYPE_RANGE_DATA (type2)
0x20379b0: 0x01 0x00 0x00 0x00 0xfe 0x7f 0x00 0x00
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0x20379b8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x20379c0: 0x01 0x00 0x00 0x00 0xfe 0x7f 0x00 0x00
0x20379c8: 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x20379d0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
(top-gdb) p memcmp (TYPE_RANGE_DATA (type1), TYPE_RANGE_DATA (type2), sizeof (*TYPE_RANGE_DATA (type1)))
$3 = -187
In some cases objects of type range_bounds are memset when allocated,
but then their dynamic_prop low/high fields are copied over from some
template dynamic_prop object that wasn't memset. E.g.,
create_static_range_type's low/high locals are left with garbage in
the padding, and then that padding is copied over to the range_bounds
object's low/high fields.
At first, I considered making sure to always memset range_bounds
objects, thinking that maybe type objects are being put in some bcache
instance somewhere. But then I hacked bcache/bcache_full to poison
non-pod types, and made dynamic_prop a non-pod, and GDB still
compiled.
So given that, it seems safest to not assume padding will always be
memset, and instead treat them as regular value types, implementing
(in)equality operators and using those instead of memcmp.
This fixes the random FAILs in GCC's testcase.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83906
gdb/ChangeLog:
2018-01-24 Pedro Alves <palves@redhat.com>
GCC PR libstdc++/83906
* gdbtypes.c (operator==(const dynamic_prop &,
const dynamic_prop &)): New.
(operator==(const range_bounds &, const range_bounds &)): New.
(check_types_equal): Use them instead of memcmp.
* gdbtypes.h (operator==(const dynamic_prop &,
const dynamic_prop &)): Declare.
(operator!=(const dynamic_prop &, const dynamic_prop &)): Declare.
(operator==(const range_bounds &, const range_bounds &)): Declare.
(operator!=(const range_bounds &, const range_bounds &)): Declare.
2018-01-25 01:22:05 +08:00
|
|
|
/* Compare two range_bounds objects for equality. Simply does
|
|
|
|
memberwise comparison. */
|
|
|
|
extern bool operator== (const range_bounds &l, const range_bounds &r);
|
|
|
|
|
|
|
|
/* Compare two range_bounds objects for inequality. */
|
|
|
|
static inline bool operator!= (const range_bounds &l, const range_bounds &r)
|
|
|
|
{
|
|
|
|
return !(l == r);
|
|
|
|
}
|
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
union type_specific
|
|
|
|
{
|
|
|
|
/* * CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to
|
|
|
|
point to cplus_struct_default, a default static instance of a
|
|
|
|
struct cplus_struct_type. */
|
|
|
|
|
|
|
|
struct cplus_struct_type *cplus_stuff;
|
|
|
|
|
|
|
|
/* * GNAT_STUFF is for types for which the GNAT Ada compiler
|
|
|
|
provides additional information. */
|
|
|
|
|
|
|
|
struct gnat_aux_type *gnat_stuff;
|
|
|
|
|
Simplify floatformat_from_type
For historical reasons, the TYPE_FLOATFORMAT element is still set to hold
an array of two floatformat structs, one for big-endian and the other for
little-endian. When accessing the element via floatformat_from_type,
the code would check the type's byte order and return the appropriate
floatformat.
However, these days this is quite unnecessary, since the type's byte order
is already known at the time the type is allocated and the floatformat is
installed into TYPE_FLOATFORMAT. Therefore, we can just install the correct
version here.
Also, moves the (now trivially simple) floatformat_from_type accessor to
gdbtypes.{c,h}, since it doesn't really need to be in doublest.c now.
gdb/ChangeLog
2017-09-27 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.h (floatformat_from_type): Move to gdbtypes.h.
* doublest.c (floatformat_from_type): Move to gdbtypes.c.
* gdbtypes.h (union type_specific): Make field floatformat hold
just a single struct floatformat, not an array.
(floatformat_from_type): Move here.
* gdbtypes.c (floatformat_from_type): Move here. Update to
changed TYPE_FLOATFORMAT definition.
(verify_floatformat): Update to changed TYPE_FLOATFORMAT.
(recursive_dump_type): Likewise.
(init_float_type): Install correct floatformat for byte order.
(arch_float_type): Likewise.
2017-09-28 01:03:36 +08:00
|
|
|
/* * FLOATFORMAT is for TYPE_CODE_FLT. It is a pointer to a
|
|
|
|
floatformat object that describes the floating-point value
|
|
|
|
that resides within the type. */
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
|
Simplify floatformat_from_type
For historical reasons, the TYPE_FLOATFORMAT element is still set to hold
an array of two floatformat structs, one for big-endian and the other for
little-endian. When accessing the element via floatformat_from_type,
the code would check the type's byte order and return the appropriate
floatformat.
However, these days this is quite unnecessary, since the type's byte order
is already known at the time the type is allocated and the floatformat is
installed into TYPE_FLOATFORMAT. Therefore, we can just install the correct
version here.
Also, moves the (now trivially simple) floatformat_from_type accessor to
gdbtypes.{c,h}, since it doesn't really need to be in doublest.c now.
gdb/ChangeLog
2017-09-27 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.h (floatformat_from_type): Move to gdbtypes.h.
* doublest.c (floatformat_from_type): Move to gdbtypes.c.
* gdbtypes.h (union type_specific): Make field floatformat hold
just a single struct floatformat, not an array.
(floatformat_from_type): Move here.
* gdbtypes.c (floatformat_from_type): Move here. Update to
changed TYPE_FLOATFORMAT definition.
(verify_floatformat): Update to changed TYPE_FLOATFORMAT.
(recursive_dump_type): Likewise.
(init_float_type): Install correct floatformat for byte order.
(arch_float_type): Likewise.
2017-09-28 01:03:36 +08:00
|
|
|
const struct floatformat *floatformat;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
|
|
|
|
/* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
|
|
|
|
|
|
|
|
struct func_type *func_stuff;
|
|
|
|
|
|
|
|
/* * For types that are pointer to member types (TYPE_CODE_METHODPTR,
|
|
|
|
TYPE_CODE_MEMBERPTR), SELF_TYPE is the type that this pointer
|
|
|
|
is a member of. */
|
|
|
|
|
|
|
|
struct type *self_type;
|
Handle bit offset and bit size in base types
PR symtab/25470 points out that the Zig programming language allows
integers of various bit sizes (including zero), not just sizes that
are a multiple of 8.
This is supported in DWARF by applying both a byte size and a
DW_AT_bit_size.
This patch adds support for this feature to integer and boolean types.
Other base types are not handled -- for floating-point types, this
didn't seem to make sense, and for character types I didn't see much
need. (These can be added later if desired.)
I've also added support for DW_AT_data_bit_offset at the same time. I
don't know whether the Zig compiler requires this, but it was
described in the same section in the DWARF standard and was easy to
add.
A new test case is supplied, using the DWARF assembler.
gdb/ChangeLog
2020-09-23 Tom Tromey <tom@tromey.com>
PR symtab/25470:
* value.c (unpack_long, pack_long, pack_unsigned_long): Handle bit
offset and bit size.
* printcmd.c (print_scalar_formatted): Handle zero-length
integer.
(print_scalar_formatted): Use bit_size_differs_p.
* gdbtypes.h (enum type_specific_kind) <TYPE_SPECIFIC_INT>: New
constant.
(union type_specific): <int_stuff>: New member.
(struct type) <bit_size_differs_p, bit_size, bit_offset>: New
methods.
* gdbtypes.c (init_integer_type, init_boolean_type): Initialize
TYPE_SPECIFIC_FIELD.
(recursive_dump_type, copy_type_recursive): Update.
* dwarf2/read.c (read_base_type): Handle DW_AT_bit_size and
DW_AT_data_bit_offset.
gdb/testsuite/ChangeLog
2020-09-23 Tom Tromey <tom@tromey.com>
* gdb.dwarf2/intbits.exp: New file.
* gdb.dwarf2/intbits.c: New file.
2020-09-23 23:39:24 +08:00
|
|
|
|
Add support for printing value of DWARF-based fixed-point type objects
This commit introduces a new kind of type, meant to describe
fixed-point types, using a new code added specifically for
this purpose (TYPE_CODE_FIXED_POINT).
It then adds handling of fixed-point base types in the DWARF reader.
And finally, as a first step, this commit adds support for printing
the value of fixed-point type objects.
Note that this commit has a known issue: Trying to print the value
of a fixed-point object with a format letter (e.g. "print /x NAME")
causes the wrong value to be printed because the scaling factor
is not applied. Since the fix for this issue is isolated, and
this is not a regression, the fix will be made in a pach of its own.
This is meant to simplify review and archeology.
Also, other functionalities related to fixed-point type handling
(ptype, arithmetics, etc), will be added piecemeal as well, for
the same reasons (faciliate reviews and archeology). Related to this,
the testcase gdb.ada/fixed_cmp.exp is adjusted to compile the test
program with -fgnat-encodings=all, so as to force the use of GNAT
encodings, rather than rely on the compiler's default to use them.
The intent is to enhance this testcase to also test the pure DWARF
approach using -fgnat-encodings=minimal as soon as the corresponding
suport gets added in. Thus, the modification to the testcase is made
in a way that it prepares this testcase to be tested in both modes.
gdb/ChangeLog:
* ada-valprint.c (ada_value_print_1): Add fixed-point type handling.
* dwarf2/read.c (get_dwarf2_rational_constant)
(get_dwarf2_unsigned_rational_constant, finish_fixed_point_type)
(has_zero_over_zero_small_attribute): New functions.
read_base_type, set_die_type): Add fixed-point type handling.
* gdb-gdb.py.in: Add fixed-point type handling.
* gdbtypes.c: #include "gmp-utils.h".
(create_range_type, set_type_code): Add fixed-point type handling.
(init_fixed_point_type): New function.
(is_integral_type, is_scalar_type): Add fixed-point type handling.
(print_fixed_point_type_info): New function.
(recursive_dump_type, copy_type_recursive): Add fixed-point type
handling.
(fixed_point_type_storage): New typedef.
(fixed_point_objfile_key): New static global.
(allocate_fixed_point_type_info, is_fixed_point_type): New functions.
(fixed_point_type_base_type, fixed_point_scaling_factor): New
functions.
* gdbtypes.h: #include "gmp-utils.h".
(enum type_code) <TYPE_SPECIFIC_FIXED_POINT>: New enum.
(union type_specific) <fixed_point_info>: New field.
(struct fixed_point_type_info): New struct.
(INIT_FIXED_POINT_SPECIFIC, TYPE_FIXED_POINT_INFO): New macros.
(init_fixed_point_type, is_fixed_point_type)
(fixed_point_type_base_type, fixed_point_scaling_factor)
(allocate_fixed_point_type_info): Add declarations.
* valprint.c (generic_val_print_fixed_point): New function.
(generic_value_print): Add fixed-point type handling.
* value.c (value_as_address, unpack_long): Add fixed-point type
handling.
gdb/testsuite/ChangeLog:
* gdb.ada/fixed_cmp.exp: Force compilation to use -fgnat-encodings=all.
* gdb.ada/fixed_points.exp: Add fixed-point variables printing tests.
* gdb.ada/fixed_points/pck.ads, gdb.ada/fixed_points/pck.adb:
New files.
* gdb.ada/fixed_points/fixed_points.adb: Add use of package Pck.
* gdb.dwarf2/dw2-fixed-point.c, gdb.dwarf2/dw2-fixed-point.exp:
New files.
2020-11-15 16:12:52 +08:00
|
|
|
/* * For TYPE_CODE_FIXED_POINT types, the info necessary to decode
|
|
|
|
values of that type. */
|
|
|
|
struct fixed_point_type_info *fixed_point_info;
|
|
|
|
|
Handle bit offset and bit size in base types
PR symtab/25470 points out that the Zig programming language allows
integers of various bit sizes (including zero), not just sizes that
are a multiple of 8.
This is supported in DWARF by applying both a byte size and a
DW_AT_bit_size.
This patch adds support for this feature to integer and boolean types.
Other base types are not handled -- for floating-point types, this
didn't seem to make sense, and for character types I didn't see much
need. (These can be added later if desired.)
I've also added support for DW_AT_data_bit_offset at the same time. I
don't know whether the Zig compiler requires this, but it was
described in the same section in the DWARF standard and was easy to
add.
A new test case is supplied, using the DWARF assembler.
gdb/ChangeLog
2020-09-23 Tom Tromey <tom@tromey.com>
PR symtab/25470:
* value.c (unpack_long, pack_long, pack_unsigned_long): Handle bit
offset and bit size.
* printcmd.c (print_scalar_formatted): Handle zero-length
integer.
(print_scalar_formatted): Use bit_size_differs_p.
* gdbtypes.h (enum type_specific_kind) <TYPE_SPECIFIC_INT>: New
constant.
(union type_specific): <int_stuff>: New member.
(struct type) <bit_size_differs_p, bit_size, bit_offset>: New
methods.
* gdbtypes.c (init_integer_type, init_boolean_type): Initialize
TYPE_SPECIFIC_FIELD.
(recursive_dump_type, copy_type_recursive): Update.
* dwarf2/read.c (read_base_type): Handle DW_AT_bit_size and
DW_AT_data_bit_offset.
gdb/testsuite/ChangeLog
2020-09-23 Tom Tromey <tom@tromey.com>
* gdb.dwarf2/intbits.exp: New file.
* gdb.dwarf2/intbits.c: New file.
2020-09-23 23:39:24 +08:00
|
|
|
/* * An integer-like scalar type may be stored in just part of its
|
|
|
|
enclosing storage bytes. This structure describes this
|
|
|
|
situation. */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
/* * The bit size of the integer. This can be 0. For integers
|
|
|
|
that fill their storage (the ordinary case), this field holds
|
|
|
|
the byte size times 8. */
|
|
|
|
unsigned short bit_size;
|
|
|
|
/* * The bit offset of the integer. This is ordinarily 0, and can
|
|
|
|
only be non-zero if the bit size is less than the storage
|
|
|
|
size. */
|
|
|
|
unsigned short bit_offset;
|
|
|
|
} int_stuff;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
};
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Main structure representing a type in GDB.
|
|
|
|
|
|
|
|
This structure is space-critical. Its layout has been tweaked to
|
|
|
|
reduce the space used. */
|
2003-08-21 07:00:06 +08:00
|
|
|
|
2002-05-15 02:30:53 +08:00
|
|
|
struct main_type
|
|
|
|
{
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Code for kind of type. */
|
2002-05-15 02:30:53 +08:00
|
|
|
|
2003-08-21 07:00:06 +08:00
|
|
|
ENUM_BITFIELD(type_code) code : 8;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Flags about this type. These fields appear at this location
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
because they packs nicely here. See the TYPE_* macros for
|
|
|
|
documentation about these fields. */
|
|
|
|
|
2020-09-14 23:07:56 +08:00
|
|
|
unsigned int m_flag_unsigned : 1;
|
2020-09-14 23:07:57 +08:00
|
|
|
unsigned int m_flag_nosign : 1;
|
2020-09-14 23:07:58 +08:00
|
|
|
unsigned int m_flag_stub : 1;
|
2020-09-14 23:07:59 +08:00
|
|
|
unsigned int m_flag_target_stub : 1;
|
2020-09-14 23:08:00 +08:00
|
|
|
unsigned int m_flag_prototyped : 1;
|
2020-09-14 23:08:01 +08:00
|
|
|
unsigned int m_flag_varargs : 1;
|
2020-09-14 23:08:02 +08:00
|
|
|
unsigned int m_flag_vector : 1;
|
2020-09-14 23:08:03 +08:00
|
|
|
unsigned int m_flag_stub_supported : 1;
|
2020-09-14 23:08:05 +08:00
|
|
|
unsigned int m_flag_gnu_ifunc : 1;
|
2020-09-14 23:08:06 +08:00
|
|
|
unsigned int m_flag_fixed_instance : 1;
|
2021-01-23 01:21:09 +08:00
|
|
|
unsigned int m_flag_objfile_owned : 1;
|
2020-09-14 23:08:07 +08:00
|
|
|
unsigned int m_flag_endianity_not_default : 1;
|
2014-03-13 10:36:45 +08:00
|
|
|
|
|
|
|
/* * True if this type was declared with "class" rather than
|
2010-02-03 00:47:14 +08:00
|
|
|
"struct". */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2021-04-02 09:10:08 +08:00
|
|
|
unsigned int m_flag_declared_class : 1;
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * True if this is an enum type with disjoint values. This
|
|
|
|
affects how the enum is printed. */
|
2012-01-17 03:44:16 +08:00
|
|
|
|
2021-04-02 09:10:09 +08:00
|
|
|
unsigned int m_flag_flag_enum : 1;
|
2012-01-17 03:44:16 +08:00
|
|
|
|
2022-09-20 22:39:09 +08:00
|
|
|
/* * For TYPE_CODE_ARRAY, this is true if this type is part of a
|
|
|
|
multi-dimensional array. Multi-dimensional arrays are
|
|
|
|
represented internally as arrays of arrays, and this flag lets
|
|
|
|
gdb distinguish between multiple dimensions and an ordinary array
|
|
|
|
of arrays. The flag is set on each inner dimension, but not the
|
|
|
|
outermost dimension. */
|
|
|
|
|
|
|
|
unsigned int m_multi_dimensional : 1;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * A discriminant telling us which field of the type_specific
|
|
|
|
union is being used for this type, if any. */
|
|
|
|
|
2010-01-12 13:49:00 +08:00
|
|
|
ENUM_BITFIELD(type_specific_kind) type_specific_field : 3;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Number of fields described for this type. This field appears
|
|
|
|
at this location because it packs nicely here. */
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
|
Increase size of main_type::nfields
main_type::nfields is a 'short', and has been for many years. PR
c++/29985 points out that 'short' is too narrow for an enum that
contains more than 2^15 constants.
This patch bumps the size of 'nfields'. To verify that the field
isn't directly used, it is also renamed. Note that this does not
affect the size of main_type on x86-64 Fedora 36. And, if it does
have a negative effect somewhere, it's worth considering that types
could be shrunk more drastically by using subclasses for the different
codes.
This is v2 of this patch, which has these changes:
* I changed nfields to 'unsigned', per Simon's request. I looked at
changing all the uses, but this quickly fans out into a very large
patch. (One additional tweak was needed, though.)
* I wrote a test case. I discovered that GCC cannot compile a large
enough C test case, so I resorted to using the DWARF assembler.
This test doesn't reproduce the crash, but it does fail without the
patch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29985
2023-01-12 03:42:40 +08:00
|
|
|
unsigned int m_nfields;
|
gdb:
* xml-tdesc.c (tdesc_end_union): Update.
* stabsread.c (define_symbol): Update.
(read_type): Update.
(read_struct_type): Update.
(read_enum_type): Update.
* spu-tdep.c (spu_builtin_type_vec128): Update.
* sh-tdep.c (sh_push_dummy_call_fpu): Update.
(sh_push_dummy_call_nofpu): Update.
* mdebugread.c (parse_symbol): Update.
(parse_symbol): Update.
(parse_symbol): Update.
(upgrade_type): Update.
* jv-lang.c (java_lookup_class): Update.
* iq2000-tdep.c (iq2000_pointer_to_address): Update.
* i386-tdep.c (i386_mmx_type): Update.
(i386_sse_type): Update.
* gdbtypes.h (enum type_flag_value): New enum.
(enum type_instance_flag_value): New enum.
(TYPE_FLAG_UNSIGNED, TYPE_FLAG_NOSIGN, TYPE_FLAG_STUB,
TYPE_FLAG_TARGET_STUB, TYPE_FLAG_STATIC, TYPE_FLAG_PROTOTYPED,
TYPE_FLAG_INCOMPLETE, TYPE_FLAG_VARARGS, TYPE_FLAG_VECTOR,
TYPE_FLAG_FIXED_INSTANCE, TYPE_FLAG_STUB_SUPPORTED,
TYPE_FLAG_NOTTEXT): Now enum constants.
(TYPE_FLAG_CONST, TYPE_FLAG_VOLATILE, TYPE_FLAG_CODE_SPACE,
TYPE_FLAG_DATA_SPACE, TYPE_FLAG_ADDRESS_CLASS_1,
TYPE_FLAG_ADDRESS_CLASS_2): Remove.
(TYPE_INSTANCE_FLAG_CONST, TYPE_INSTANCE_FLAG_VOLATILE,
TYPE_INSTANCE_FLAG_CODE_SPACE, TYPE_INSTANCE_FLAG_DATA_SPACE,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1,
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2): New constants.
(TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB, TYPE_TARGET_STUB,
TYPE_STATIC, TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_VARARGS,
TYPE_VECTOR, TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED,
TYPE_NOTTEXT): Update.
(TYPE_FLAG_ADDRESS_CLASS_ALL): Remove.
(TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): New define.
(TYPE_VOLATILE, TYPE_CODE_SPACE, TYPE_DATA_SPACE,
TYPE_ADDRESS_CLASS_1, TYPE_ADDRESS_CLASS_2,
TYPE_ADDRESS_CLASS_ALL): Update.
(struct main_type) <flags>: Remove.
<flag_unsigned, flag_nosign, flag_stub, flag_target_stub,
flag_static, flag_prototyped, flag_incomplete, flag_varargs,
flag_vector, flag_stub_supported, flag_nottext,
flag_fixed_instance>: New fields.
<nfields, vptr_fieldno>: Move earlier.
(TYPE_FLAGS): Remove.
* gdbtypes.c (make_pointer_type): Update.
(address_space_name_to_int): Update.
(address_space_int_to_name): Update.
(make_type_with_address_space): Update.
(make_cv_type): Update.
(create_range_type): Update.
(get_discrete_bounds): Update.
(create_set_type): Update.
(make_vector_type): Update.
(smash_to_method_type): Update.
(check_typedef): Update.
(check_stub_method): Update.
(init_type): Individually assign flag fields.
(recursive_dump_type): Don't print entire TYPE_FLAGS field. Do
print TYPE_FIXED_INSTANCE, TYPE_STUB_SUPPORTED, and TYPE_NOTTEXT.
(copy_type_recursive): Copy the entire main type. Don't use
TYPE_FLAGS.
* features/rs6000/powerpc-altivec64l.c
(initialize_tdesc_powerpc_altivec64l): Update.
* features/rs6000/powerpc-altivec64.c
(initialize_tdesc_powerpc_altivec64): Update.
* features/rs6000/powerpc-altivec32l.c
(initialize_tdesc_powerpc_altivec32l): Update.
* features/rs6000/powerpc-altivec32.c
(initialize_tdesc_powerpc_altivec32): Update.
* features/rs6000/powerpc-7400.c (initialize_tdesc_powerpc_7400):
Update.
* features/arm-with-iwmmxt.c (initialize_tdesc_arm_with_iwmmxt):
Update.
* dwarf2read.c (read_structure_type): Update.
(read_enumeration_type): Likewise.
(process_enumeration_scope): Likewise.
(read_tag_pointer_type): Likewise.
(read_subroutine_type): Likewise.
(read_subroutine_type): Likewise.
(read_base_type): Likewise.
* coffread.c (coff_read_enum_type): Update.
* ada-valprint.c (adjust_type_signedness): Update.
* ada-typeprint.c (print_record_field_types): Update.
* ada-lang.c (packed_array_type): Update.
(empty_record): Don't reset TYPE_FLAGS.
(ada_template_to_fixed_record_type_1): Update.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_record_type): Likewise.
(to_fixed_array_type): Likewise.
(to_static_fixed_type): Likewise.
gdb/testsuite:
* gdb.base/maint.exp: Update "maint print type".
2008-08-25 00:39:57 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Name of this type, or NULL if none.
|
2002-05-15 02:30:53 +08:00
|
|
|
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-18 03:51:24 +08:00
|
|
|
This is used for printing only. For looking up a name, look for
|
|
|
|
a symbol in the VAR_DOMAIN. This is generally allocated in the
|
|
|
|
objfile's obstack. However coffread.c uses malloc. */
|
2002-05-15 02:30:53 +08:00
|
|
|
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 12:48:23 +08:00
|
|
|
const char *name;
|
2002-05-15 02:30:53 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Every type is now associated with a particular objfile, and the
|
|
|
|
type is allocated on the objfile_obstack for that objfile. One
|
|
|
|
problem however, is that there are times when gdb allocates new
|
|
|
|
types while it is not in the process of reading symbols from a
|
|
|
|
particular objfile. Fortunately, these happen when the type
|
|
|
|
being created is a derived type of an existing type, such as in
|
|
|
|
lookup_pointer_type(). So we can just allocate the new type
|
|
|
|
using the same objfile as the existing type, but to do this we
|
|
|
|
need a backpointer to the objfile from the existing type. Yes
|
|
|
|
this is somewhat ugly, but without major overhaul of the internal
|
|
|
|
type system, it can't be avoided for now. */
|
2002-05-15 02:30:53 +08:00
|
|
|
|
2021-01-23 01:21:09 +08:00
|
|
|
union type_owner m_owner;
|
2002-05-15 02:30:53 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * For a pointer type, describes the type of object pointed to.
|
|
|
|
- For an array type, describes the type of the elements.
|
|
|
|
- For a function or method type, describes the type of the return value.
|
|
|
|
- For a range type, describes the type of the full range.
|
|
|
|
- For a complex type, describes the type of each coordinate.
|
|
|
|
- For a special record or union type encoding a dynamic-sized type
|
2010-04-28 05:01:45 +08:00
|
|
|
in GNAT, a memoized pointer to a corresponding static version of
|
|
|
|
the type.
|
2014-03-13 10:36:45 +08:00
|
|
|
- Unused otherwise. */
|
2002-05-15 02:30:53 +08:00
|
|
|
|
2022-07-31 00:07:39 +08:00
|
|
|
struct type *m_target_type;
|
2002-05-15 02:30:53 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * For structure and union types, a description of each field.
|
2002-05-15 02:30:53 +08:00
|
|
|
For set and pascal array types, there is one "field",
|
|
|
|
whose type is the domain type of the set or array.
|
|
|
|
For range types, there are two "fields",
|
|
|
|
the minimum and maximum values (both inclusive).
|
|
|
|
For enum types, each possible value is described by one "field".
|
2002-06-14 22:34:26 +08:00
|
|
|
For a function or method type, a "field" for each parameter.
|
2002-05-15 02:30:53 +08:00
|
|
|
For C++ classes, there is one field for each base class (if it is
|
|
|
|
a derived class) plus one field for each class data member. Member
|
|
|
|
functions are recorded elsewhere.
|
|
|
|
|
|
|
|
Using a pointer to a separate array of fields
|
|
|
|
allows all types to have the same size, which is useful
|
|
|
|
because we can allocate the space for a type before
|
|
|
|
we know what to put in it. */
|
|
|
|
|
* dwarf2read.c (struct attribute): Increase sizes of unsnd and snd
fields to allow larger integer sizes.
(read_subrange_type): Increase size of bound values.
Add logic to determine signedness based on base-type size, signedness.
(read_attribute_value): Change format for bad byte size in message.
(read_8_bytes): Increase size of result type.
(dump_die_shallow): Change format for value.
(dwarf2_get_attr_constant_value): Increase size of return type.
Correct comment.
* gdbtypes.c (create_range_type): Change API to increase size of
bounds. struct field -> union field.
Always take signedness from base type.
(check_typedef): Use new API for TYPE_LOW_BOUND, TYPE_HIGH_BOUND.
(recursive_dump_type, copy_type_recursive): Adjust to new
representation of range types.
* gdbtypes.h (fields_or_bounds): New union containing struct field and
new struct range_bounds, used for range types.
(TYPE_RANGE_DATA): New macro to access range_bounds member.
(TYPE_LOW_BOUND, TYPE_HIGH_BOUND): Represent with new TYPE_RANGE_DATA.
(TYPE_LOW_BOUND_UNDEFINED, TYPE_HIGH_BOUND_UNDEFINED): New macros,
taking over the job of TYPE_FIELD_ARTIFICIAL for range bounds.
(SET_TYPE_LOW_BOUND, SET_TYPE_HIGH_BOUND, SET_TYPE_LOW_BOUND_DEFINED)
(SET_TYPE_HIGH_BOUND_DEFINED): New macros.
(TYPE_FIELDS, TYPE_BASECLASS, TYPE_BASECLASS_NAME, TYPE_FIELD)
(TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED)
(TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED, TYPE_ARRAY_UPPER_BOUND_VALUE)
(TYPE_ARRAY_LOWER_BOUND_VALUE): Adjust to new representation.
(create_range_type): Adjust API.
* ada-lang.c (ada_modulus): Use new extended bound values.
(discrete_type_low_bound): Rename to...
(ada_discrete_type_low_bound): ... and make external.
(discrete_type_high_bound): Rename to...
(ada_discrete_type_high_bound): ... and make external.
(ada_value_slice_from_ptr, ada_array_bound_from_type)
(ada_evaluate_subexp, to_fixed_range_type):
Use ada_discrete_type_low_bound, ada_discrete_type_high_bound.
* ada-typeprint.c (print_range): Use ada_discrete_type_low_bound,
ada_discrete_type_high_bound. Don't look at field count, which
is no longer meaningful. Print bounds whenever argument is a range
or enumeration.
* ada-lang.h (ada_discrete_type_low_bound,ada_discrete_type_high_bound):
Declare.
* varobj.c (c_describe_child): Adjust to render larger values.
* mdebugread.c (parse_type): Use proper abstractions for range types:
TYPE_RANGE_DATA, SET_TYPE_LOW_BOUND_DEFINED,
SET_TYPE_HIGH_BOUND_DEFINED.
* p-typeprint.c (pascal_type_print_varspec_prefix): Use larger format
for bounds.
2009-12-14 14:19:13 +08:00
|
|
|
union
|
1999-07-08 04:19:36 +08:00
|
|
|
{
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
struct field *fields;
|
2002-11-11 08:55:34 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Union member used for range types. */
|
* dwarf2read.c (struct attribute): Increase sizes of unsnd and snd
fields to allow larger integer sizes.
(read_subrange_type): Increase size of bound values.
Add logic to determine signedness based on base-type size, signedness.
(read_attribute_value): Change format for bad byte size in message.
(read_8_bytes): Increase size of result type.
(dump_die_shallow): Change format for value.
(dwarf2_get_attr_constant_value): Increase size of return type.
Correct comment.
* gdbtypes.c (create_range_type): Change API to increase size of
bounds. struct field -> union field.
Always take signedness from base type.
(check_typedef): Use new API for TYPE_LOW_BOUND, TYPE_HIGH_BOUND.
(recursive_dump_type, copy_type_recursive): Adjust to new
representation of range types.
* gdbtypes.h (fields_or_bounds): New union containing struct field and
new struct range_bounds, used for range types.
(TYPE_RANGE_DATA): New macro to access range_bounds member.
(TYPE_LOW_BOUND, TYPE_HIGH_BOUND): Represent with new TYPE_RANGE_DATA.
(TYPE_LOW_BOUND_UNDEFINED, TYPE_HIGH_BOUND_UNDEFINED): New macros,
taking over the job of TYPE_FIELD_ARTIFICIAL for range bounds.
(SET_TYPE_LOW_BOUND, SET_TYPE_HIGH_BOUND, SET_TYPE_LOW_BOUND_DEFINED)
(SET_TYPE_HIGH_BOUND_DEFINED): New macros.
(TYPE_FIELDS, TYPE_BASECLASS, TYPE_BASECLASS_NAME, TYPE_FIELD)
(TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED)
(TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED, TYPE_ARRAY_UPPER_BOUND_VALUE)
(TYPE_ARRAY_LOWER_BOUND_VALUE): Adjust to new representation.
(create_range_type): Adjust API.
* ada-lang.c (ada_modulus): Use new extended bound values.
(discrete_type_low_bound): Rename to...
(ada_discrete_type_low_bound): ... and make external.
(discrete_type_high_bound): Rename to...
(ada_discrete_type_high_bound): ... and make external.
(ada_value_slice_from_ptr, ada_array_bound_from_type)
(ada_evaluate_subexp, to_fixed_range_type):
Use ada_discrete_type_low_bound, ada_discrete_type_high_bound.
* ada-typeprint.c (print_range): Use ada_discrete_type_low_bound,
ada_discrete_type_high_bound. Don't look at field count, which
is no longer meaningful. Print bounds whenever argument is a range
or enumeration.
* ada-lang.h (ada_discrete_type_low_bound,ada_discrete_type_high_bound):
Declare.
* varobj.c (c_describe_child): Adjust to render larger values.
* mdebugread.c (parse_type): Use proper abstractions for range types:
TYPE_RANGE_DATA, SET_TYPE_LOW_BOUND_DEFINED,
SET_TYPE_HIGH_BOUND_DEFINED.
* p-typeprint.c (pascal_type_print_varspec_prefix): Use larger format
for bounds.
2009-12-14 14:19:13 +08:00
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
struct range_bounds *bounds;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2020-04-02 04:09:52 +08:00
|
|
|
/* If this is a scalar type, then this is its corresponding
|
|
|
|
complex type. */
|
|
|
|
struct type *complex_type;
|
|
|
|
|
* dwarf2read.c (struct attribute): Increase sizes of unsnd and snd
fields to allow larger integer sizes.
(read_subrange_type): Increase size of bound values.
Add logic to determine signedness based on base-type size, signedness.
(read_attribute_value): Change format for bad byte size in message.
(read_8_bytes): Increase size of result type.
(dump_die_shallow): Change format for value.
(dwarf2_get_attr_constant_value): Increase size of return type.
Correct comment.
* gdbtypes.c (create_range_type): Change API to increase size of
bounds. struct field -> union field.
Always take signedness from base type.
(check_typedef): Use new API for TYPE_LOW_BOUND, TYPE_HIGH_BOUND.
(recursive_dump_type, copy_type_recursive): Adjust to new
representation of range types.
* gdbtypes.h (fields_or_bounds): New union containing struct field and
new struct range_bounds, used for range types.
(TYPE_RANGE_DATA): New macro to access range_bounds member.
(TYPE_LOW_BOUND, TYPE_HIGH_BOUND): Represent with new TYPE_RANGE_DATA.
(TYPE_LOW_BOUND_UNDEFINED, TYPE_HIGH_BOUND_UNDEFINED): New macros,
taking over the job of TYPE_FIELD_ARTIFICIAL for range bounds.
(SET_TYPE_LOW_BOUND, SET_TYPE_HIGH_BOUND, SET_TYPE_LOW_BOUND_DEFINED)
(SET_TYPE_HIGH_BOUND_DEFINED): New macros.
(TYPE_FIELDS, TYPE_BASECLASS, TYPE_BASECLASS_NAME, TYPE_FIELD)
(TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED)
(TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED, TYPE_ARRAY_UPPER_BOUND_VALUE)
(TYPE_ARRAY_LOWER_BOUND_VALUE): Adjust to new representation.
(create_range_type): Adjust API.
* ada-lang.c (ada_modulus): Use new extended bound values.
(discrete_type_low_bound): Rename to...
(ada_discrete_type_low_bound): ... and make external.
(discrete_type_high_bound): Rename to...
(ada_discrete_type_high_bound): ... and make external.
(ada_value_slice_from_ptr, ada_array_bound_from_type)
(ada_evaluate_subexp, to_fixed_range_type):
Use ada_discrete_type_low_bound, ada_discrete_type_high_bound.
* ada-typeprint.c (print_range): Use ada_discrete_type_low_bound,
ada_discrete_type_high_bound. Don't look at field count, which
is no longer meaningful. Print bounds whenever argument is a range
or enumeration.
* ada-lang.h (ada_discrete_type_low_bound,ada_discrete_type_high_bound):
Declare.
* varobj.c (c_describe_child): Adjust to render larger values.
* mdebugread.c (parse_type): Use proper abstractions for range types:
TYPE_RANGE_DATA, SET_TYPE_LOW_BOUND_DEFINED,
SET_TYPE_HIGH_BOUND_DEFINED.
* p-typeprint.c (pascal_type_print_varspec_prefix): Use larger format
for bounds.
2009-12-14 14:19:13 +08:00
|
|
|
} flds_bnds;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Slot to point to additional language-specific fields of this
|
|
|
|
type. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
union type_specific type_specific;
|
2014-08-12 07:37:10 +08:00
|
|
|
|
2015-03-21 05:45:20 +08:00
|
|
|
/* * Contains all dynamic type properties. */
|
|
|
|
struct dynamic_prop_list *dyn_prop_list;
|
2002-05-15 02:30:53 +08:00
|
|
|
};
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Add initial type alignment support
This adds some basic type alignment support to gdb. It changes struct
type to store the alignment, and updates dwarf2read.c to handle
DW_AT_alignment. It also adds a new gdbarch method and updates
i386-tdep.c.
None of this new functionality is used anywhere yet, so tests will
wait until the next patch.
2018-04-30 Tom Tromey <tom@tromey.com>
* i386-tdep.c (i386_type_align): New function.
(i386_gdbarch_init): Update.
* gdbarch.sh (type_align): New method.
* gdbarch.c, gdbarch.h: Rebuild.
* arch-utils.h (default_type_align): Declare.
* arch-utils.c (default_type_align): New function.
* gdbtypes.h (TYPE_ALIGN_BITS): New define.
(struct type) <align_log2>: New field.
<instance_flags>: Now a bitfield.
(TYPE_RAW_ALIGN): New macro.
(type_align, type_raw_align, set_type_align): Declare.
* gdbtypes.c (type_align, type_raw_align, set_type_align): New
functions.
* dwarf2read.c (quirk_rust_enum): Set type alignment.
(get_alignment, maybe_set_alignment): New functions.
(read_structure_type, read_enumeration_type, read_array_type)
(read_set_type, read_tag_pointer_type, read_tag_reference_type)
(read_subrange_type, read_base_type): Set type alignment.
2018-04-21 01:50:09 +08:00
|
|
|
/* * Number of bits allocated for alignment. */
|
|
|
|
|
|
|
|
#define TYPE_ALIGN_BITS 8
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * A ``struct type'' describes a particular instance of a type, with
|
2002-05-15 02:30:53 +08:00
|
|
|
some particular qualification. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2002-05-15 02:30:53 +08:00
|
|
|
struct type
|
|
|
|
{
|
2020-05-15 01:45:40 +08:00
|
|
|
/* Get the type code of this type.
|
|
|
|
|
|
|
|
Note that the code can be TYPE_CODE_TYPEDEF, so if you want the real
|
|
|
|
type, you need to do `check_typedef (type)->code ()`. */
|
|
|
|
type_code code () const
|
|
|
|
{
|
|
|
|
return this->main_type->code;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the type code of this type. */
|
|
|
|
void set_code (type_code code)
|
|
|
|
{
|
|
|
|
this->main_type->code = code;
|
|
|
|
}
|
|
|
|
|
2020-05-17 00:15:54 +08:00
|
|
|
/* Get the name of this type. */
|
|
|
|
const char *name () const
|
|
|
|
{
|
|
|
|
return this->main_type->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the name of this type. */
|
|
|
|
void set_name (const char *name)
|
|
|
|
{
|
|
|
|
this->main_type->name = name;
|
|
|
|
}
|
|
|
|
|
2022-09-21 23:05:21 +08:00
|
|
|
/* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
|
|
|
|
But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
|
2023-02-01 04:25:17 +08:00
|
|
|
so you only have to call check_typedef once. Since value::allocate
|
2023-01-31 22:52:09 +08:00
|
|
|
calls check_typedef, X->type ()->length () is safe. */
|
2022-07-31 00:01:12 +08:00
|
|
|
ULONGEST length () const
|
|
|
|
{
|
|
|
|
return this->m_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_length (ULONGEST length)
|
|
|
|
{
|
|
|
|
this->m_length = length;
|
|
|
|
}
|
|
|
|
|
2020-05-23 04:55:14 +08:00
|
|
|
/* Get the number of fields of this type. */
|
Increase size of main_type::nfields
main_type::nfields is a 'short', and has been for many years. PR
c++/29985 points out that 'short' is too narrow for an enum that
contains more than 2^15 constants.
This patch bumps the size of 'nfields'. To verify that the field
isn't directly used, it is also renamed. Note that this does not
affect the size of main_type on x86-64 Fedora 36. And, if it does
have a negative effect somewhere, it's worth considering that types
could be shrunk more drastically by using subclasses for the different
codes.
This is v2 of this patch, which has these changes:
* I changed nfields to 'unsigned', per Simon's request. I looked at
changing all the uses, but this quickly fans out into a very large
patch. (One additional tweak was needed, though.)
* I wrote a test case. I discovered that GCC cannot compile a large
enough C test case, so I resorted to using the DWARF assembler.
This test doesn't reproduce the crash, but it does fail without the
patch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29985
2023-01-12 03:42:40 +08:00
|
|
|
unsigned int num_fields () const
|
2020-05-23 04:55:14 +08:00
|
|
|
{
|
Increase size of main_type::nfields
main_type::nfields is a 'short', and has been for many years. PR
c++/29985 points out that 'short' is too narrow for an enum that
contains more than 2^15 constants.
This patch bumps the size of 'nfields'. To verify that the field
isn't directly used, it is also renamed. Note that this does not
affect the size of main_type on x86-64 Fedora 36. And, if it does
have a negative effect somewhere, it's worth considering that types
could be shrunk more drastically by using subclasses for the different
codes.
This is v2 of this patch, which has these changes:
* I changed nfields to 'unsigned', per Simon's request. I looked at
changing all the uses, but this quickly fans out into a very large
patch. (One additional tweak was needed, though.)
* I wrote a test case. I discovered that GCC cannot compile a large
enough C test case, so I resorted to using the DWARF assembler.
This test doesn't reproduce the crash, but it does fail without the
patch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29985
2023-01-12 03:42:40 +08:00
|
|
|
return this->main_type->m_nfields;
|
2020-05-23 04:55:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the number of fields of this type. */
|
Increase size of main_type::nfields
main_type::nfields is a 'short', and has been for many years. PR
c++/29985 points out that 'short' is too narrow for an enum that
contains more than 2^15 constants.
This patch bumps the size of 'nfields'. To verify that the field
isn't directly used, it is also renamed. Note that this does not
affect the size of main_type on x86-64 Fedora 36. And, if it does
have a negative effect somewhere, it's worth considering that types
could be shrunk more drastically by using subclasses for the different
codes.
This is v2 of this patch, which has these changes:
* I changed nfields to 'unsigned', per Simon's request. I looked at
changing all the uses, but this quickly fans out into a very large
patch. (One additional tweak was needed, though.)
* I wrote a test case. I discovered that GCC cannot compile a large
enough C test case, so I resorted to using the DWARF assembler.
This test doesn't reproduce the crash, but it does fail without the
patch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29985
2023-01-12 03:42:40 +08:00
|
|
|
void set_num_fields (unsigned int num_fields)
|
2020-05-23 04:55:14 +08:00
|
|
|
{
|
Increase size of main_type::nfields
main_type::nfields is a 'short', and has been for many years. PR
c++/29985 points out that 'short' is too narrow for an enum that
contains more than 2^15 constants.
This patch bumps the size of 'nfields'. To verify that the field
isn't directly used, it is also renamed. Note that this does not
affect the size of main_type on x86-64 Fedora 36. And, if it does
have a negative effect somewhere, it's worth considering that types
could be shrunk more drastically by using subclasses for the different
codes.
This is v2 of this patch, which has these changes:
* I changed nfields to 'unsigned', per Simon's request. I looked at
changing all the uses, but this quickly fans out into a very large
patch. (One additional tweak was needed, though.)
* I wrote a test case. I discovered that GCC cannot compile a large
enough C test case, so I resorted to using the DWARF assembler.
This test doesn't reproduce the crash, but it does fail without the
patch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29985
2023-01-12 03:42:40 +08:00
|
|
|
this->main_type->m_nfields = num_fields;
|
2020-05-23 04:55:14 +08:00
|
|
|
}
|
|
|
|
|
2020-05-23 04:55:16 +08:00
|
|
|
/* Get the fields array of this type. */
|
2020-05-23 04:55:17 +08:00
|
|
|
struct field *fields () const
|
2020-05-23 04:55:16 +08:00
|
|
|
{
|
|
|
|
return this->main_type->flds_bnds.fields;
|
|
|
|
}
|
|
|
|
|
2020-05-23 04:55:17 +08:00
|
|
|
/* Get the field at index IDX. */
|
|
|
|
struct field &field (int idx) const
|
|
|
|
{
|
2021-10-19 02:32:18 +08:00
|
|
|
gdb_assert (idx >= 0 && idx < num_fields ());
|
2020-05-23 04:55:17 +08:00
|
|
|
return this->fields ()[idx];
|
|
|
|
}
|
|
|
|
|
2020-05-23 04:55:16 +08:00
|
|
|
/* Set the fields array of this type. */
|
2020-05-23 04:55:17 +08:00
|
|
|
void set_fields (struct field *fields)
|
2020-05-23 04:55:16 +08:00
|
|
|
{
|
|
|
|
this->main_type->flds_bnds.fields = fields;
|
|
|
|
}
|
|
|
|
|
2020-06-09 03:25:50 +08:00
|
|
|
type *index_type () const
|
|
|
|
{
|
2020-06-09 03:26:04 +08:00
|
|
|
return this->field (0).type ();
|
2020-06-09 03:25:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-31 00:07:39 +08:00
|
|
|
struct type *target_type () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_target_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_target_type (struct type *target_type)
|
|
|
|
{
|
|
|
|
this->main_type->m_target_type = target_type;
|
|
|
|
}
|
|
|
|
|
2020-06-09 03:25:50 +08:00
|
|
|
void set_index_type (type *index_type)
|
|
|
|
{
|
2020-06-09 03:26:04 +08:00
|
|
|
this->field (0).set_type (index_type);
|
2020-06-09 03:25:50 +08:00
|
|
|
}
|
|
|
|
|
Use type_instance_flags more throughout
A later patch in this series will rewrite enum_flags fixing some API
holes. That would cause build failures around code using
type_instance_flags. Or rather, that should be using it, but wasn't.
This patch fixes it by using type_instance_flags throughout instead of
plain integers.
Note that we can't make the seemingly obvious change to struct
type::instance_flags:
- unsigned instance_flags : 9;
+ ENUM_BITFIELD (type_instance_flag_value) instance_flags : 9;
Because G++ complains then that 9 bits isn't sufficient for holding
all values of type_instance_flag_value.
So the patch adds an type::instance_flags() method, which takes care
of casting appropriately, and adds a separate type::set_instance_flags
method, following the pattern of the ongoing TYPE_XXX macro
elimination. This converts uses of TYPE_INSTANCE_FLAGS to
type::instance_flags() in the places where the code was already being
touched, but there are still many references to the
TYPE_INSTANCE_FLAGS macro left behind. Those could/should be fully
replaced at some point.
gdb/ChangeLog:
* avr-tdep.c (avr_address_class_type_flags): Return
type_instance_flags.
(avr_address_class_type_flags_to_name): Take a
type_instance_flags.
(avr_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
* d-lang.c (build_d_types): Use type::set_instance_flags.
* ft32-tdep.c (ft32_address_class_type_flags): Return
type_instance_flags.
(ft32_address_class_type_flags_to_name): Take a
type_instance_flags.
(ft32_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
(ft32_gdbarch_init): Use type::set_instance_flags.
* eval.c (fake_method::fake_method): Use type::set_instance_flags.
* gdbarch.h, gdbarch.c: Regenerate.
* gdbarch.sh (address_class_type_flags): Use type_instance_flags.
(address_class_name_to_type_flags): Use type_instance_flags and
bool.
* gdbtypes.c (address_space_name_to_int)
(address_space_int_to_name, make_qualified_type): Use
type_instance_flags.
(make_qualified_type): Use type_instance_flags and
type::set_instance_flags.
(make_type_with_address_space, make_cv_type, make_vector_type)
(check_typedef): Use type_instance_flags.
(recursive_dump_type): Cast type_instance_flags to unsigned for
printing.
(copy_type_recursive): Use type::set_instance_flags.
(gdbtypes_post_init): Use type::set_instance_flags.
* gdbtypes.h (struct type) <instance_flags>: Rename to ...
<m_instance_flags>: ... this.
<instance_flags, set_instance_flags>: New methods.
(TYPE_INSTANCE_FLAGS): Use the instance_flags method.
(SET_TYPE_INSTANCE_FLAGS): New.
(address_space_name_to_int, address_space_int_to_name)
(make_type_with_address_space): Pass flags using
type_instance_flags instead of int.
* stabsread.c (cleanup_undefined_types_noname): Use
type::set_instance_flags.
* s390-tdep.c (s390_address_class_type_flags): Return
type_instance_flags.
(s390_address_class_type_flags_to_name): Take a
type_instance_flags.
(s390_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
* type-stack.c (type_stack::follow_types): Use
type_instance_flags.
* dwarf2/read.c (read_tag_pointer_type): Use type_instance_flags.
2020-09-15 04:16:56 +08:00
|
|
|
/* Return the instance flags converted to the correct type. */
|
|
|
|
const type_instance_flags instance_flags () const
|
|
|
|
{
|
|
|
|
return (enum type_instance_flag_value) this->m_instance_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the instance flags. */
|
|
|
|
void set_instance_flags (type_instance_flags flags)
|
|
|
|
{
|
|
|
|
this->m_instance_flags = flags;
|
|
|
|
}
|
|
|
|
|
2020-07-13 10:58:50 +08:00
|
|
|
/* Get the bounds bounds of this type. The type must be a range type. */
|
|
|
|
range_bounds *bounds () const
|
|
|
|
{
|
2020-07-13 11:05:08 +08:00
|
|
|
switch (this->code ())
|
|
|
|
{
|
|
|
|
case TYPE_CODE_RANGE:
|
|
|
|
return this->main_type->flds_bnds.bounds;
|
|
|
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
case TYPE_CODE_STRING:
|
|
|
|
return this->index_type ()->bounds ();
|
|
|
|
|
|
|
|
default:
|
|
|
|
gdb_assert_not_reached
|
|
|
|
("type::bounds called on type with invalid code");
|
|
|
|
}
|
2020-07-13 10:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the bounds of this type. The type must be a range type. */
|
|
|
|
void set_bounds (range_bounds *bounds)
|
|
|
|
{
|
|
|
|
gdb_assert (this->code () == TYPE_CODE_RANGE);
|
|
|
|
|
|
|
|
this->main_type->flds_bnds.bounds = bounds;
|
|
|
|
}
|
|
|
|
|
2020-07-13 10:58:53 +08:00
|
|
|
ULONGEST bit_stride () const
|
|
|
|
{
|
2021-06-19 03:08:33 +08:00
|
|
|
if (this->code () == TYPE_CODE_ARRAY && this->field (0).bitsize != 0)
|
|
|
|
return this->field (0).bitsize;
|
2020-07-13 10:58:53 +08:00
|
|
|
return this->bounds ()->bit_stride ();
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:07:57 +08:00
|
|
|
/* Unsigned integer type. If this is not set for a TYPE_CODE_INT,
|
|
|
|
the type is signed (unless TYPE_NOSIGN is set). */
|
|
|
|
|
2020-09-14 23:07:56 +08:00
|
|
|
bool is_unsigned () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_unsigned;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_is_unsigned (bool is_unsigned)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_unsigned = is_unsigned;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:07:58 +08:00
|
|
|
/* No sign for this type. In C++, "char", "signed char", and
|
|
|
|
"unsigned char" are distinct types; so we need an extra flag to
|
|
|
|
indicate the absence of a sign! */
|
|
|
|
|
2020-09-14 23:07:57 +08:00
|
|
|
bool has_no_signedness () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_nosign;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_has_no_signedness (bool has_no_signedness)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_nosign = has_no_signedness;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:07:59 +08:00
|
|
|
/* This appears in a type's flags word if it is a stub type (e.g.,
|
|
|
|
if someone referenced a type that wasn't defined in a source file
|
|
|
|
via (struct sir_not_appearing_in_this_film *)). */
|
|
|
|
|
2020-09-14 23:07:58 +08:00
|
|
|
bool is_stub () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_stub;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_is_stub (bool is_stub)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_stub = is_stub;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:08:00 +08:00
|
|
|
/* The target type of this type is a stub type, and this type needs
|
|
|
|
to be updated if it gets un-stubbed in check_typedef. Used for
|
|
|
|
arrays and ranges, in which TYPE_LENGTH of the array/range gets set
|
|
|
|
based on the TYPE_LENGTH of the target type. Also, set for
|
|
|
|
TYPE_CODE_TYPEDEF. */
|
|
|
|
|
2020-09-14 23:07:59 +08:00
|
|
|
bool target_is_stub () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_target_stub;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_target_is_stub (bool target_is_stub)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_target_stub = target_is_stub;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:08:01 +08:00
|
|
|
/* This is a function type which appears to have a prototype. We
|
|
|
|
need this for function calls in order to tell us if it's necessary
|
|
|
|
to coerce the args, or to just do the standard conversions. This
|
|
|
|
is used with a short field. */
|
|
|
|
|
2020-09-14 23:08:00 +08:00
|
|
|
bool is_prototyped () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_prototyped;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_is_prototyped (bool is_prototyped)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_prototyped = is_prototyped;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:08:02 +08:00
|
|
|
/* FIXME drow/2002-06-03: Only used for methods, but applies as well
|
|
|
|
to functions. */
|
|
|
|
|
2020-09-14 23:08:01 +08:00
|
|
|
bool has_varargs () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_varargs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_has_varargs (bool has_varargs)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_varargs = has_varargs;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:08:03 +08:00
|
|
|
/* Identify a vector type. Gcc is handling this by adding an extra
|
|
|
|
attribute to the array type. We slurp that in as a new flag of a
|
|
|
|
type. This is used only in dwarf2read.c. */
|
|
|
|
|
2020-09-14 23:08:02 +08:00
|
|
|
bool is_vector () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_vector;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_is_vector (bool is_vector)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_vector = is_vector;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:08:04 +08:00
|
|
|
/* This debug target supports TYPE_STUB(t). In the unsupported case
|
|
|
|
we have to rely on NFIELDS to be zero etc., see TYPE_IS_OPAQUE().
|
|
|
|
TYPE_STUB(t) with !TYPE_STUB_SUPPORTED(t) may exist if we only
|
|
|
|
guessed the TYPE_STUB(t) value (see dwarfread.c). */
|
|
|
|
|
2020-09-14 23:08:03 +08:00
|
|
|
bool stub_is_supported () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_stub_supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_stub_is_supported (bool stub_is_supported)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_stub_supported = stub_is_supported;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:08:06 +08:00
|
|
|
/* Used only for TYPE_CODE_FUNC where it specifies the real function
|
2022-07-31 10:43:54 +08:00
|
|
|
address is returned by this function call. The target_type method
|
2020-09-14 23:08:06 +08:00
|
|
|
determines the final returned function type to be presented to
|
|
|
|
user. */
|
|
|
|
|
2020-09-14 23:08:05 +08:00
|
|
|
bool is_gnu_ifunc () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_gnu_ifunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_is_gnu_ifunc (bool is_gnu_ifunc)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_gnu_ifunc = is_gnu_ifunc;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:08:07 +08:00
|
|
|
/* The debugging formats (especially STABS) do not contain enough
|
|
|
|
information to represent all Ada types---especially those whose
|
|
|
|
size depends on dynamic quantities. Therefore, the GNAT Ada
|
|
|
|
compiler includes extra information in the form of additional type
|
|
|
|
definitions connected by naming conventions. This flag indicates
|
|
|
|
that the type is an ordinary (unencoded) GDB type that has been
|
|
|
|
created from the necessary run-time information, and does not need
|
|
|
|
further interpretation. Optionally marks ordinary, fixed-size GDB
|
|
|
|
type. */
|
|
|
|
|
2020-09-14 23:08:06 +08:00
|
|
|
bool is_fixed_instance () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_fixed_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_is_fixed_instance (bool is_fixed_instance)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_fixed_instance = is_fixed_instance;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:08:08 +08:00
|
|
|
/* A compiler may supply dwarf instrumentation that indicates the desired
|
|
|
|
endian interpretation of the variable differs from the native endian
|
|
|
|
representation. */
|
|
|
|
|
2020-09-14 23:08:07 +08:00
|
|
|
bool endianity_is_not_default () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_endianity_not_default;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_endianity_is_not_default (bool endianity_is_not_default)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_endianity_not_default = endianity_is_not_default;
|
|
|
|
}
|
|
|
|
|
2021-04-02 09:10:08 +08:00
|
|
|
|
|
|
|
/* True if this type was declared using the "class" keyword. This is
|
|
|
|
only valid for C++ structure and enum types. If false, a structure
|
|
|
|
was declared as a "struct"; if true it was declared "class". For
|
|
|
|
enum types, this is true when "enum class" or "enum struct" was
|
|
|
|
used to declare the type. */
|
|
|
|
|
|
|
|
bool is_declared_class () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_declared_class;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_is_declared_class (bool is_declared_class) const
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_declared_class = is_declared_class;
|
|
|
|
}
|
|
|
|
|
2021-04-02 09:10:09 +08:00
|
|
|
/* True if this type is a "flag" enum. A flag enum is one where all
|
|
|
|
the values are pairwise disjoint when "and"ed together. This
|
|
|
|
affects how enum values are printed. */
|
|
|
|
|
|
|
|
bool is_flag_enum () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_flag_enum;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_is_flag_enum (bool is_flag_enum)
|
|
|
|
{
|
|
|
|
this->main_type->m_flag_flag_enum = is_flag_enum;
|
|
|
|
}
|
|
|
|
|
2022-09-20 22:39:09 +08:00
|
|
|
/* True if this array type is part of a multi-dimensional array. */
|
|
|
|
|
|
|
|
bool is_multi_dimensional () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_multi_dimensional;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_is_multi_dimensional (bool value)
|
|
|
|
{
|
|
|
|
this->main_type->m_multi_dimensional = value;
|
|
|
|
}
|
|
|
|
|
2020-11-24 10:47:40 +08:00
|
|
|
/* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return a reference
|
|
|
|
to this type's fixed_point_info. */
|
|
|
|
|
|
|
|
struct fixed_point_type_info &fixed_point_info () const
|
|
|
|
{
|
|
|
|
gdb_assert (this->code () == TYPE_CODE_FIXED_POINT);
|
|
|
|
gdb_assert (this->main_type->type_specific.fixed_point_info != nullptr);
|
|
|
|
|
|
|
|
return *this->main_type->type_specific.fixed_point_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, set this type's
|
|
|
|
fixed_point_info to INFO. */
|
|
|
|
|
|
|
|
void set_fixed_point_info (struct fixed_point_type_info *info) const
|
|
|
|
{
|
|
|
|
gdb_assert (this->code () == TYPE_CODE_FIXED_POINT);
|
|
|
|
|
|
|
|
this->main_type->type_specific.fixed_point_info = info;
|
|
|
|
}
|
|
|
|
|
2020-11-24 10:48:23 +08:00
|
|
|
/* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its base type.
|
|
|
|
|
|
|
|
In other words, this returns the type after having peeled all
|
|
|
|
intermediate type layers (such as TYPE_CODE_RANGE, for instance).
|
|
|
|
The TYPE_CODE of the type returned is guaranteed to be
|
|
|
|
a TYPE_CODE_FIXED_POINT. */
|
|
|
|
|
|
|
|
struct type *fixed_point_type_base_type ();
|
|
|
|
|
2020-11-24 10:49:13 +08:00
|
|
|
/* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its scaling
|
|
|
|
factor. */
|
|
|
|
|
|
|
|
const gdb_mpq &fixed_point_scaling_factor ();
|
|
|
|
|
2020-05-07 23:32:25 +08:00
|
|
|
/* * Return the dynamic property of the requested KIND from this type's
|
|
|
|
list of dynamic properties. */
|
|
|
|
dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
|
|
|
|
|
2020-05-07 23:17:33 +08:00
|
|
|
/* * Given a dynamic property PROP of a given KIND, add this dynamic
|
|
|
|
property to this type.
|
|
|
|
|
|
|
|
This function assumes that this type is objfile-owned. */
|
|
|
|
void add_dyn_prop (dynamic_prop_node_kind kind, dynamic_prop prop);
|
|
|
|
|
2020-05-07 23:08:54 +08:00
|
|
|
/* * Remove dynamic property of kind KIND from this type, if it exists. */
|
|
|
|
void remove_dyn_prop (dynamic_prop_node_kind kind);
|
|
|
|
|
2021-01-23 01:21:09 +08:00
|
|
|
/* Return true if this type is owned by an objfile. Return false if it is
|
|
|
|
owned by an architecture. */
|
|
|
|
bool is_objfile_owned () const
|
|
|
|
{
|
|
|
|
return this->main_type->m_flag_objfile_owned;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the owner of the type to be OBJFILE. */
|
|
|
|
void set_owner (objfile *objfile)
|
|
|
|
{
|
gdb: fix regression in copy_type_recursive
Commit 5b7d941b90d1 ("gdb: add owner-related methods to struct type")
introduced a regression when running gdb.base/jit-reader-simple.exp and
others. A NULL pointer dereference happens here:
#3 0x0000557b7e9e8650 in gdbarch_obstack (arch=0x0) at /home/simark/src/binutils-gdb/gdb/gdbarch.c:484
#4 0x0000557b7ea5b138 in copy_type_recursive (objfile=0x614000006640, type=0x62100018da80, copied_types=0x62100018e280) at /home/simark/src/binutils-gdb/gdb/gdbtypes.c:5537
#5 0x0000557b7ea5dcbb in copy_type_recursive (objfile=0x614000006640, type=0x62100018e200, copied_types=0x62100018e280) at /home/simark/src/binutils-gdb/gdb/gdbtypes.c:5598
#6 0x0000557b802cef51 in preserve_one_value (value=0x6110000b3640, objfile=0x614000006640, copied_types=0x62100018e280) at /home/simark/src/binutils-gdb/gdb/value.c:2518
#7 0x0000557b802cf787 in preserve_values (objfile=0x614000006640) at /home/simark/src/binutils-gdb/gdb/value.c:2562
#8 0x0000557b7fbaf19b in reread_symbols () at /home/simark/src/binutils-gdb/gdb/symfile.c:2489
#9 0x0000557b7ec65d1d in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at /home/simark/src/binutils-gdb/gdb/infcmd.c:439
#10 0x0000557b7ec67a97 in run_command (args=0x0, from_tty=1) at /home/simark/src/binutils-gdb/gdb/infcmd.c:546
This is inside a TYPE_ALLOC macro. The fact that gdbarch_obstack is
called means that the type is flagged as being arch-owned, but arch=0x0
means that type::arch returned NULL, probably meaning that the m_owner
field contains NULL.
If we look at the code before the problematic patch, in the
copy_type_recursive function, we see:
if (! TYPE_OBJFILE_OWNED (type))
return type;
...
TYPE_OBJFILE_OWNED (new_type) = 0;
TYPE_OWNER (new_type).gdbarch = get_type_arch (type);
The last two lines were replaced with:
new_type->set_owner (type->arch ());
get_type_arch and type->arch isn't the same thing: get_type_arch gets
the type's arch owner if it is arch-owned, and gets the objfile's arch
if the type is objfile owned. So it always returns non-NULL.
type->arch returns the type's arch if the type is arch-owned, else NULL.
So since the original type is objfile owned, it effectively made the new
type arch-owned (that is good) but set the owner to NULL (that is bad).
Fix this by using get_type_arch again there.
I spotted one other similar change in lookup_array_range_type, in the
original patch. But that one appears to be correct, as it is executed
only if the type is arch-owned.
Add some asserts in type::set_owner to ensure we never set a NULL owner.
That would have helped catch the issue a little bit earlier, so it could
help in the future.
gdb/ChangeLog:
* gdbtypes.c (copy_type_recursive): Use get_type_arch.
* gdbtypes.h (struct type) <set_owner>: Add asserts.
Change-Id: I5d8bc7bfc83b3abc579be0b5aadeae4241179a00
2021-01-24 06:36:55 +08:00
|
|
|
gdb_assert (objfile != nullptr);
|
|
|
|
|
2021-01-23 01:21:09 +08:00
|
|
|
this->main_type->m_owner.objfile = objfile;
|
|
|
|
this->main_type->m_flag_objfile_owned = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the owner of the type to be ARCH. */
|
|
|
|
void set_owner (gdbarch *arch)
|
|
|
|
{
|
gdb: fix regression in copy_type_recursive
Commit 5b7d941b90d1 ("gdb: add owner-related methods to struct type")
introduced a regression when running gdb.base/jit-reader-simple.exp and
others. A NULL pointer dereference happens here:
#3 0x0000557b7e9e8650 in gdbarch_obstack (arch=0x0) at /home/simark/src/binutils-gdb/gdb/gdbarch.c:484
#4 0x0000557b7ea5b138 in copy_type_recursive (objfile=0x614000006640, type=0x62100018da80, copied_types=0x62100018e280) at /home/simark/src/binutils-gdb/gdb/gdbtypes.c:5537
#5 0x0000557b7ea5dcbb in copy_type_recursive (objfile=0x614000006640, type=0x62100018e200, copied_types=0x62100018e280) at /home/simark/src/binutils-gdb/gdb/gdbtypes.c:5598
#6 0x0000557b802cef51 in preserve_one_value (value=0x6110000b3640, objfile=0x614000006640, copied_types=0x62100018e280) at /home/simark/src/binutils-gdb/gdb/value.c:2518
#7 0x0000557b802cf787 in preserve_values (objfile=0x614000006640) at /home/simark/src/binutils-gdb/gdb/value.c:2562
#8 0x0000557b7fbaf19b in reread_symbols () at /home/simark/src/binutils-gdb/gdb/symfile.c:2489
#9 0x0000557b7ec65d1d in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at /home/simark/src/binutils-gdb/gdb/infcmd.c:439
#10 0x0000557b7ec67a97 in run_command (args=0x0, from_tty=1) at /home/simark/src/binutils-gdb/gdb/infcmd.c:546
This is inside a TYPE_ALLOC macro. The fact that gdbarch_obstack is
called means that the type is flagged as being arch-owned, but arch=0x0
means that type::arch returned NULL, probably meaning that the m_owner
field contains NULL.
If we look at the code before the problematic patch, in the
copy_type_recursive function, we see:
if (! TYPE_OBJFILE_OWNED (type))
return type;
...
TYPE_OBJFILE_OWNED (new_type) = 0;
TYPE_OWNER (new_type).gdbarch = get_type_arch (type);
The last two lines were replaced with:
new_type->set_owner (type->arch ());
get_type_arch and type->arch isn't the same thing: get_type_arch gets
the type's arch owner if it is arch-owned, and gets the objfile's arch
if the type is objfile owned. So it always returns non-NULL.
type->arch returns the type's arch if the type is arch-owned, else NULL.
So since the original type is objfile owned, it effectively made the new
type arch-owned (that is good) but set the owner to NULL (that is bad).
Fix this by using get_type_arch again there.
I spotted one other similar change in lookup_array_range_type, in the
original patch. But that one appears to be correct, as it is executed
only if the type is arch-owned.
Add some asserts in type::set_owner to ensure we never set a NULL owner.
That would have helped catch the issue a little bit earlier, so it could
help in the future.
gdb/ChangeLog:
* gdbtypes.c (copy_type_recursive): Use get_type_arch.
* gdbtypes.h (struct type) <set_owner>: Add asserts.
Change-Id: I5d8bc7bfc83b3abc579be0b5aadeae4241179a00
2021-01-24 06:36:55 +08:00
|
|
|
gdb_assert (arch != nullptr);
|
|
|
|
|
2021-01-23 01:21:09 +08:00
|
|
|
this->main_type->m_owner.gdbarch = arch;
|
|
|
|
this->main_type->m_flag_objfile_owned = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the objfile owner of this type.
|
|
|
|
|
|
|
|
Return nullptr if this type is not objfile-owned. */
|
2021-01-28 23:09:02 +08:00
|
|
|
struct objfile *objfile_owner () const
|
2021-01-23 01:21:09 +08:00
|
|
|
{
|
|
|
|
if (!this->is_objfile_owned ())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return this->main_type->m_owner.objfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the gdbarch owner of this type.
|
|
|
|
|
|
|
|
Return nullptr if this type is not gdbarch-owned. */
|
2021-01-28 23:09:02 +08:00
|
|
|
gdbarch *arch_owner () const
|
2021-01-23 01:21:09 +08:00
|
|
|
{
|
|
|
|
if (this->is_objfile_owned ())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return this->main_type->m_owner.gdbarch;
|
|
|
|
}
|
|
|
|
|
2021-01-28 23:12:10 +08:00
|
|
|
/* Return the type's architecture. For types owned by an
|
|
|
|
architecture, that architecture is returned. For types owned by an
|
|
|
|
objfile, that objfile's architecture is returned.
|
|
|
|
|
|
|
|
The return value is always non-nullptr. */
|
|
|
|
gdbarch *arch () const;
|
|
|
|
|
Handle bit offset and bit size in base types
PR symtab/25470 points out that the Zig programming language allows
integers of various bit sizes (including zero), not just sizes that
are a multiple of 8.
This is supported in DWARF by applying both a byte size and a
DW_AT_bit_size.
This patch adds support for this feature to integer and boolean types.
Other base types are not handled -- for floating-point types, this
didn't seem to make sense, and for character types I didn't see much
need. (These can be added later if desired.)
I've also added support for DW_AT_data_bit_offset at the same time. I
don't know whether the Zig compiler requires this, but it was
described in the same section in the DWARF standard and was easy to
add.
A new test case is supplied, using the DWARF assembler.
gdb/ChangeLog
2020-09-23 Tom Tromey <tom@tromey.com>
PR symtab/25470:
* value.c (unpack_long, pack_long, pack_unsigned_long): Handle bit
offset and bit size.
* printcmd.c (print_scalar_formatted): Handle zero-length
integer.
(print_scalar_formatted): Use bit_size_differs_p.
* gdbtypes.h (enum type_specific_kind) <TYPE_SPECIFIC_INT>: New
constant.
(union type_specific): <int_stuff>: New member.
(struct type) <bit_size_differs_p, bit_size, bit_offset>: New
methods.
* gdbtypes.c (init_integer_type, init_boolean_type): Initialize
TYPE_SPECIFIC_FIELD.
(recursive_dump_type, copy_type_recursive): Update.
* dwarf2/read.c (read_base_type): Handle DW_AT_bit_size and
DW_AT_data_bit_offset.
gdb/testsuite/ChangeLog
2020-09-23 Tom Tromey <tom@tromey.com>
* gdb.dwarf2/intbits.exp: New file.
* gdb.dwarf2/intbits.c: New file.
2020-09-23 23:39:24 +08:00
|
|
|
/* * Return true if this is an integer type whose logical (bit) size
|
|
|
|
differs from its storage size; false otherwise. Always return
|
|
|
|
false for non-integer (i.e., non-TYPE_SPECIFIC_INT) types. */
|
|
|
|
bool bit_size_differs_p () const
|
|
|
|
{
|
|
|
|
return (main_type->type_specific_field == TYPE_SPECIFIC_INT
|
2022-07-31 00:01:12 +08:00
|
|
|
&& main_type->type_specific.int_stuff.bit_size != 8 * length ());
|
Handle bit offset and bit size in base types
PR symtab/25470 points out that the Zig programming language allows
integers of various bit sizes (including zero), not just sizes that
are a multiple of 8.
This is supported in DWARF by applying both a byte size and a
DW_AT_bit_size.
This patch adds support for this feature to integer and boolean types.
Other base types are not handled -- for floating-point types, this
didn't seem to make sense, and for character types I didn't see much
need. (These can be added later if desired.)
I've also added support for DW_AT_data_bit_offset at the same time. I
don't know whether the Zig compiler requires this, but it was
described in the same section in the DWARF standard and was easy to
add.
A new test case is supplied, using the DWARF assembler.
gdb/ChangeLog
2020-09-23 Tom Tromey <tom@tromey.com>
PR symtab/25470:
* value.c (unpack_long, pack_long, pack_unsigned_long): Handle bit
offset and bit size.
* printcmd.c (print_scalar_formatted): Handle zero-length
integer.
(print_scalar_formatted): Use bit_size_differs_p.
* gdbtypes.h (enum type_specific_kind) <TYPE_SPECIFIC_INT>: New
constant.
(union type_specific): <int_stuff>: New member.
(struct type) <bit_size_differs_p, bit_size, bit_offset>: New
methods.
* gdbtypes.c (init_integer_type, init_boolean_type): Initialize
TYPE_SPECIFIC_FIELD.
(recursive_dump_type, copy_type_recursive): Update.
* dwarf2/read.c (read_base_type): Handle DW_AT_bit_size and
DW_AT_data_bit_offset.
gdb/testsuite/ChangeLog
2020-09-23 Tom Tromey <tom@tromey.com>
* gdb.dwarf2/intbits.exp: New file.
* gdb.dwarf2/intbits.c: New file.
2020-09-23 23:39:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* * Return the logical (bit) size for this integer type. Only
|
|
|
|
valid for integer (TYPE_SPECIFIC_INT) types. */
|
|
|
|
unsigned short bit_size () const
|
|
|
|
{
|
|
|
|
gdb_assert (main_type->type_specific_field == TYPE_SPECIFIC_INT);
|
|
|
|
return main_type->type_specific.int_stuff.bit_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* * Return the bit offset for this integer type. Only valid for
|
|
|
|
integer (TYPE_SPECIFIC_INT) types. */
|
|
|
|
unsigned short bit_offset () const
|
|
|
|
{
|
|
|
|
gdb_assert (main_type->type_specific_field == TYPE_SPECIFIC_INT);
|
|
|
|
return main_type->type_specific.int_stuff.bit_offset;
|
|
|
|
}
|
|
|
|
|
2021-09-12 03:58:04 +08:00
|
|
|
/* Return true if this is a pointer or reference type. */
|
|
|
|
bool is_pointer_or_reference () const
|
|
|
|
{
|
|
|
|
return this->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (this);
|
|
|
|
}
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Type that is a pointer to this type.
|
2002-05-15 02:30:53 +08:00
|
|
|
NULL if no such pointer-to type is known yet.
|
|
|
|
The debugger may add the address of such a type
|
|
|
|
if it has to construct one later. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2002-05-15 02:30:53 +08:00
|
|
|
struct type *pointer_type;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * C++: also need a reference type. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2002-05-15 02:30:53 +08:00
|
|
|
struct type *reference_type;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2017-03-21 04:47:30 +08:00
|
|
|
/* * A C++ rvalue reference type added in C++11. */
|
|
|
|
|
|
|
|
struct type *rvalue_reference_type;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Variant chain. This points to a type that differs from this
|
|
|
|
one only in qualifiers and length. Currently, the possible
|
|
|
|
qualifiers are const, volatile, code-space, data-space, and
|
|
|
|
address class. The length may differ only when one of the
|
|
|
|
address class flags are set. The variants are linked in a
|
|
|
|
circular ring and share MAIN_TYPE. */
|
|
|
|
|
2002-05-15 02:30:53 +08:00
|
|
|
struct type *chain;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Add initial type alignment support
This adds some basic type alignment support to gdb. It changes struct
type to store the alignment, and updates dwarf2read.c to handle
DW_AT_alignment. It also adds a new gdbarch method and updates
i386-tdep.c.
None of this new functionality is used anywhere yet, so tests will
wait until the next patch.
2018-04-30 Tom Tromey <tom@tromey.com>
* i386-tdep.c (i386_type_align): New function.
(i386_gdbarch_init): Update.
* gdbarch.sh (type_align): New method.
* gdbarch.c, gdbarch.h: Rebuild.
* arch-utils.h (default_type_align): Declare.
* arch-utils.c (default_type_align): New function.
* gdbtypes.h (TYPE_ALIGN_BITS): New define.
(struct type) <align_log2>: New field.
<instance_flags>: Now a bitfield.
(TYPE_RAW_ALIGN): New macro.
(type_align, type_raw_align, set_type_align): Declare.
* gdbtypes.c (type_align, type_raw_align, set_type_align): New
functions.
* dwarf2read.c (quirk_rust_enum): Set type alignment.
(get_alignment, maybe_set_alignment): New functions.
(read_structure_type, read_enumeration_type, read_array_type)
(read_set_type, read_tag_pointer_type, read_tag_reference_type)
(read_subrange_type, read_base_type): Set type alignment.
2018-04-21 01:50:09 +08:00
|
|
|
/* * The alignment for this type. Zero means that the alignment was
|
|
|
|
not specified in the debug info. Note that this is stored in a
|
|
|
|
funny way: as the log base 2 (plus 1) of the alignment; so a
|
|
|
|
value of 1 means the alignment is 1, and a value of 9 means the
|
|
|
|
alignment is 256. */
|
|
|
|
|
|
|
|
unsigned align_log2 : TYPE_ALIGN_BITS;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Flags specific to this instance of the type, indicating where
|
2010-10-16 01:48:48 +08:00
|
|
|
on the ring we are.
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
For TYPE_CODE_TYPEDEF the flags of the typedef type should be
|
|
|
|
binary or-ed with the target type, with a special case for
|
|
|
|
address class and space class. For example if this typedef does
|
|
|
|
not specify any new qualifiers, TYPE_INSTANCE_FLAGS is 0 and the
|
|
|
|
instance flags are completely inherited from the target type. No
|
|
|
|
qualifiers can be cleared by the typedef. See also
|
|
|
|
check_typedef. */
|
Use type_instance_flags more throughout
A later patch in this series will rewrite enum_flags fixing some API
holes. That would cause build failures around code using
type_instance_flags. Or rather, that should be using it, but wasn't.
This patch fixes it by using type_instance_flags throughout instead of
plain integers.
Note that we can't make the seemingly obvious change to struct
type::instance_flags:
- unsigned instance_flags : 9;
+ ENUM_BITFIELD (type_instance_flag_value) instance_flags : 9;
Because G++ complains then that 9 bits isn't sufficient for holding
all values of type_instance_flag_value.
So the patch adds an type::instance_flags() method, which takes care
of casting appropriately, and adds a separate type::set_instance_flags
method, following the pattern of the ongoing TYPE_XXX macro
elimination. This converts uses of TYPE_INSTANCE_FLAGS to
type::instance_flags() in the places where the code was already being
touched, but there are still many references to the
TYPE_INSTANCE_FLAGS macro left behind. Those could/should be fully
replaced at some point.
gdb/ChangeLog:
* avr-tdep.c (avr_address_class_type_flags): Return
type_instance_flags.
(avr_address_class_type_flags_to_name): Take a
type_instance_flags.
(avr_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
* d-lang.c (build_d_types): Use type::set_instance_flags.
* ft32-tdep.c (ft32_address_class_type_flags): Return
type_instance_flags.
(ft32_address_class_type_flags_to_name): Take a
type_instance_flags.
(ft32_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
(ft32_gdbarch_init): Use type::set_instance_flags.
* eval.c (fake_method::fake_method): Use type::set_instance_flags.
* gdbarch.h, gdbarch.c: Regenerate.
* gdbarch.sh (address_class_type_flags): Use type_instance_flags.
(address_class_name_to_type_flags): Use type_instance_flags and
bool.
* gdbtypes.c (address_space_name_to_int)
(address_space_int_to_name, make_qualified_type): Use
type_instance_flags.
(make_qualified_type): Use type_instance_flags and
type::set_instance_flags.
(make_type_with_address_space, make_cv_type, make_vector_type)
(check_typedef): Use type_instance_flags.
(recursive_dump_type): Cast type_instance_flags to unsigned for
printing.
(copy_type_recursive): Use type::set_instance_flags.
(gdbtypes_post_init): Use type::set_instance_flags.
* gdbtypes.h (struct type) <instance_flags>: Rename to ...
<m_instance_flags>: ... this.
<instance_flags, set_instance_flags>: New methods.
(TYPE_INSTANCE_FLAGS): Use the instance_flags method.
(SET_TYPE_INSTANCE_FLAGS): New.
(address_space_name_to_int, address_space_int_to_name)
(make_type_with_address_space): Pass flags using
type_instance_flags instead of int.
* stabsread.c (cleanup_undefined_types_noname): Use
type::set_instance_flags.
* s390-tdep.c (s390_address_class_type_flags): Return
type_instance_flags.
(s390_address_class_type_flags_to_name): Take a
type_instance_flags.
(s390_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
* type-stack.c (type_stack::follow_types): Use
type_instance_flags.
* dwarf2/read.c (read_tag_pointer_type): Use type_instance_flags.
2020-09-15 04:16:56 +08:00
|
|
|
unsigned m_instance_flags : 9;
|
2001-08-23 09:09:38 +08:00
|
|
|
|
2015-07-28 23:01:49 +08:00
|
|
|
/* * Length of storage for a value of this type. The value is the
|
|
|
|
expression in host bytes of what sizeof(type) would return. This
|
|
|
|
size includes padding. For example, an i386 extended-precision
|
|
|
|
floating point value really only occupies ten bytes, but most
|
|
|
|
ABI's declare its size to be 12 bytes, to preserve alignment.
|
|
|
|
A `struct type' representing such a floating-point type would
|
|
|
|
have a `length' value of 12, even though the last two bytes are
|
|
|
|
unused.
|
|
|
|
|
|
|
|
Since this field is expressed in host bytes, its value is appropriate
|
|
|
|
to pass to memcpy and such (it is assumed that GDB itself always runs
|
|
|
|
on an 8-bits addressable architecture). However, when using it for
|
|
|
|
target address arithmetic (e.g. adding it to a target address), the
|
|
|
|
type_length_units function should be used in order to get the length
|
|
|
|
expressed in target addressable memory units. */
|
|
|
|
|
2022-07-31 00:01:12 +08:00
|
|
|
ULONGEST m_length;
|
2003-02-08 05:44:01 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Core type, shared by a group of qualified types. */
|
|
|
|
|
2002-05-15 02:30:53 +08:00
|
|
|
struct main_type *main_type;
|
|
|
|
};
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
struct fn_fieldlist
|
|
|
|
{
|
|
|
|
|
|
|
|
/* * The overloaded name.
|
|
|
|
This is generally allocated in the objfile's obstack.
|
|
|
|
However stabsread.c sometimes uses malloc. */
|
|
|
|
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/* * The number of methods with this name. */
|
|
|
|
|
|
|
|
int length;
|
|
|
|
|
|
|
|
/* * The list of methods. */
|
|
|
|
|
|
|
|
struct fn_field *fn_fields;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct fn_field
|
|
|
|
{
|
|
|
|
/* * If is_stub is clear, this is the mangled name which we can look
|
|
|
|
up to find the address of the method (FIXME: it would be cleaner
|
|
|
|
to have a pointer to the struct symbol here instead).
|
|
|
|
|
|
|
|
If is_stub is set, this is the portion of the mangled name which
|
|
|
|
specifies the arguments. For example, "ii", if there are two int
|
|
|
|
arguments, or "" if there are no arguments. See gdb_mangle_name
|
|
|
|
for the conversion from this format to the one used if is_stub is
|
|
|
|
clear. */
|
|
|
|
|
|
|
|
const char *physname;
|
|
|
|
|
|
|
|
/* * The function type for the method.
|
|
|
|
|
|
|
|
(This comment used to say "The return value of the method", but
|
|
|
|
that's wrong. The function type is expected here, i.e. something
|
|
|
|
with TYPE_CODE_METHOD, and *not* the return-value type). */
|
|
|
|
|
|
|
|
struct type *type;
|
|
|
|
|
|
|
|
/* * For virtual functions. First baseclass that defines this
|
|
|
|
virtual function. */
|
|
|
|
|
|
|
|
struct type *fcontext;
|
|
|
|
|
|
|
|
/* Attributes. */
|
|
|
|
|
|
|
|
unsigned int is_const:1;
|
|
|
|
unsigned int is_volatile:1;
|
|
|
|
unsigned int is_private:1;
|
|
|
|
unsigned int is_protected:1;
|
|
|
|
unsigned int is_artificial:1;
|
|
|
|
|
|
|
|
/* * A stub method only has some fields valid (but they are enough
|
|
|
|
to reconstruct the rest of the fields). */
|
|
|
|
|
|
|
|
unsigned int is_stub:1;
|
|
|
|
|
|
|
|
/* * True if this function is a constructor, false otherwise. */
|
|
|
|
|
|
|
|
unsigned int is_constructor : 1;
|
|
|
|
|
2019-12-21 00:43:06 +08:00
|
|
|
/* * True if this function is deleted, false otherwise. */
|
|
|
|
|
|
|
|
unsigned int is_deleted : 1;
|
|
|
|
|
|
|
|
/* * DW_AT_defaulted attribute for this function. The value is one
|
|
|
|
of the DW_DEFAULTED constants. */
|
|
|
|
|
|
|
|
ENUM_BITFIELD (dwarf_defaulted_attribute) defaulted : 2;
|
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
/* * Unused. */
|
|
|
|
|
2019-12-21 00:43:06 +08:00
|
|
|
unsigned int dummy:6;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
|
|
|
|
/* * Index into that baseclass's virtual function table, minus 2;
|
|
|
|
else if static: VOFFSET_STATIC; else: 0. */
|
|
|
|
|
|
|
|
unsigned int voffset:16;
|
|
|
|
|
|
|
|
#define VOFFSET_STATIC 1
|
|
|
|
|
|
|
|
};
|
|
|
|
|
Record nested types
GDB currently does not track types defined in classes. Consider:
class A
{
public:
class B
{
public:
class C { };
};
};
(gdb) ptype A
type = class A {
<no data fields>
}
This patch changes this behavior so that GDB records these nested types
and displays them to the user when he has set the (new) "print type"
option "nested-type-limit."
Example:
(gdb) set print type nested-type-limit 1
(gdb) ptype A
type = class A {
<no data fields>
class A::B {
<no data fields>
};
}
(gdb) set print type nested-type-limit 2
type = class A {
<no data fields>
class A::B {
<no data fields>
class A::B::C {
<no data fields>
};
};
}
By default, the code maintains the status quo, that is, it will not print
any nested type definitions at all.
Testing is carried out via cp_ptype_class which required quite a bit of
modification to permit recursive calling (for the nested types). This
was most easily facilitated by turning the ptype command output into a
queue. Upshot: the test suite now has stack and queue data structures that
may be used by test writers.
gdb/ChangeLog
* NEWS (New commands): Mention set/show print type nested-type-limit.
* c-typeprint.c (c_type_print_base): Print out nested types.
* dwarf2read.c (struct typedef_field_list): Rename to ...
(struct decl_field_list): ... this. Change all uses.
(struct field_info) <nested_types_list, nested_types_list_count>:
New fields.
(add_partial_symbol): Look for nested type definitions in C++, too.
(dwarf2_add_typedef): Rename to ...
(dwarf2_add_type_defn): ... this.
(type_can_define_types): New function.
Update assertion to use type_can_define_types.
Permit NULL for a field's name.
(process_structure_scope): Handle child DIEs of types that can
define types.
Copy the list of nested types into the type struct.
* gdbtypes.h (struct typedef_field): Rename to ...
(struct decl_field): ... this. Change all uses.
[is_protected, is_private]: New fields.
(struct cplus_struct_type) <nested_types, nested_types_count>: New
fields.
(TYPE_NESTED_TYPES_ARRAY, TYPE_NESTED_TYPES_FIELD)
(TYPE_NESTED_TYPES_FIELD_NAME, TYPE_NESTED_TYPES_FIELD_TYPE)
(TYPE_NESTED_TYPES_COUNT, TYPE_NESTED_TYPES_FIELD_PROTECTED)
(TYPE_NESTED_TYPES_FIELD_PRIVATE): New macros.
* typeprint.c (type_print_raw_options, default_ptype_flags): Add
default value for print_nested_type_limit.
(print_nested_type_limit): New static variable.
(set_print_type_nested_types, show_print_type_nested_types): New
functions.
(_initialize_typeprint): Register new commands for set/show
`print-nested-type-limit'.
* typeprint.h (struct type_print_options) [print_nested_type_limit]:
New field.
gdb/testsuite/ChangeLog
* gdb.cp/nested-types.cc: New file.
* gdb.cp/nested-types.exp: New file.
* lib/cp-support.exp: Load data-structures.exp library.
(debug_cp_test_ptype_class): New global.
(cp_ptype_class_verbose, next_line): New procedures.
(cp_test_ptype_class): Add and document new parameter `recursive_qid'.
Add and document new return value.
Switch the list of lines to a queue.
Add support for new `type' key for nested type definitions.
Add debugging/troubleshooting messages.
* lib/data-structures.exp: New file.
gdb/doc/ChangeLog
* gdb.texinfo (Symbols): Document "set print type nested-type-limit"
and "show print type nested-type-limit".
2017-12-08 07:01:30 +08:00
|
|
|
struct decl_field
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
{
|
|
|
|
/* * Unqualified name to be prefixed by owning class qualified
|
|
|
|
name. */
|
|
|
|
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/* * Type this typedef named NAME represents. */
|
|
|
|
|
|
|
|
struct type *type;
|
2017-10-17 08:19:29 +08:00
|
|
|
|
|
|
|
/* * True if this field was declared protected, false otherwise. */
|
|
|
|
unsigned int is_protected : 1;
|
|
|
|
|
|
|
|
/* * True if this field was declared private, false otherwise. */
|
|
|
|
unsigned int is_private : 1;
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
};
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * C++ language-specific information for TYPE_CODE_STRUCT and
|
|
|
|
TYPE_CODE_UNION nodes. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
struct cplus_struct_type
|
1999-07-08 04:19:36 +08:00
|
|
|
{
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Number of base classes this type derives from. The
|
|
|
|
baseclasses are stored in the first N_BASECLASSES fields
|
2015-04-29 12:23:24 +08:00
|
|
|
(i.e. the `fields' field of the struct type). The only fields
|
|
|
|
of struct field that are used are: type, name, loc.bitpos. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
short n_baseclasses;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Move vptr_{fieldno,basetype} out of main_type, and update everything accordingly.
Every type has to pay the price in memory usage for their presence.
The proper place for them is in the type_specific field which exists
for this purpose.
gdb/ChangeLog:
* dwarf2read.c (process_structure_scope): Update setting of
TYPE_VPTR_BASETYPE, TYPE_VPTR_FIELDNO.
* gdbtypes.c (internal_type_vptr_fieldno): New function.
(set_type_vptr_fieldno): New function.
(internal_type_vptr_basetype): New function.
(set_type_vptr_basetype): New function.
(get_vptr_fieldno): Update setting of TYPE_VPTR_FIELDNO,
TYPE_VPTR_BASETYPE.
(allocate_cplus_struct_type): Initialize vptr_fieldno.
(recursive_dump_type): Printing of vptr_fieldno, vptr_basetype ...
(print_cplus_stuff): ... moved here.
(copy_type_recursive): Don't copy TYPE_VPTR_BASETYPE.
* gdbtypes.h (struct main_type): Members vptr_fieldno, vptr_basetype
moved to ...
(struct cplus_struct_type): ... here. All uses updated.
(TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE): Rewrite.
(internal_type_vptr_fieldno, set_type_vptr_fieldno): Declare.
(internal_type_vptr_basetype, set_type_vptr_basetype): Declare.
* stabsread.c (read_tilde_fields): Update setting of
TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE.
gdb/testsuite/ChangeLog:
* gdb.base/maint.exp <maint print type argc>: Update expected output.
2015-02-01 13:40:57 +08:00
|
|
|
/* * Field number of the virtual function table pointer in VPTR_BASETYPE.
|
|
|
|
All access to this field must be through TYPE_VPTR_FIELDNO as one
|
|
|
|
thing it does is check whether the field has been initialized.
|
|
|
|
Initially TYPE_RAW_CPLUS_SPECIFIC has the value of cplus_struct_default,
|
|
|
|
which for portability reasons doesn't initialize this field.
|
|
|
|
TYPE_VPTR_FIELDNO returns -1 for this case.
|
|
|
|
|
|
|
|
If -1, we were unable to find the virtual function table pointer in
|
|
|
|
initial symbol reading, and get_vptr_fieldno should be called to find
|
|
|
|
it if possible. get_vptr_fieldno will update this field if possible.
|
|
|
|
Otherwise the value is left at -1.
|
|
|
|
|
|
|
|
Unused if this type does not have virtual functions. */
|
|
|
|
|
|
|
|
short vptr_fieldno;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Number of methods with unique names. All overloaded methods
|
|
|
|
with the same name count only once. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
short nfn_fields;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Number of template arguments. */
|
|
|
|
|
2010-07-29 00:23:59 +08:00
|
|
|
unsigned short n_template_arguments;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * One if this struct is a dynamic class, as defined by the
|
2010-02-20 06:22:49 +08:00
|
|
|
Itanium C++ ABI: if it requires a virtual table pointer,
|
|
|
|
because it or any of its base classes have one or more virtual
|
|
|
|
member functions or virtual base classes. Minus one if not
|
|
|
|
dynamic. Zero if not yet computed. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2010-02-20 06:22:49 +08:00
|
|
|
int is_dynamic : 2;
|
1999-07-08 04:19:36 +08:00
|
|
|
|
2019-12-21 00:43:06 +08:00
|
|
|
/* * The calling convention for this type, fetched from the
|
|
|
|
DW_AT_calling_convention attribute. The value is one of the
|
|
|
|
DW_CC constants. */
|
|
|
|
|
|
|
|
ENUM_BITFIELD (dwarf_calling_convention) calling_convention : 8;
|
|
|
|
|
Move vptr_{fieldno,basetype} out of main_type, and update everything accordingly.
Every type has to pay the price in memory usage for their presence.
The proper place for them is in the type_specific field which exists
for this purpose.
gdb/ChangeLog:
* dwarf2read.c (process_structure_scope): Update setting of
TYPE_VPTR_BASETYPE, TYPE_VPTR_FIELDNO.
* gdbtypes.c (internal_type_vptr_fieldno): New function.
(set_type_vptr_fieldno): New function.
(internal_type_vptr_basetype): New function.
(set_type_vptr_basetype): New function.
(get_vptr_fieldno): Update setting of TYPE_VPTR_FIELDNO,
TYPE_VPTR_BASETYPE.
(allocate_cplus_struct_type): Initialize vptr_fieldno.
(recursive_dump_type): Printing of vptr_fieldno, vptr_basetype ...
(print_cplus_stuff): ... moved here.
(copy_type_recursive): Don't copy TYPE_VPTR_BASETYPE.
* gdbtypes.h (struct main_type): Members vptr_fieldno, vptr_basetype
moved to ...
(struct cplus_struct_type): ... here. All uses updated.
(TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE): Rewrite.
(internal_type_vptr_fieldno, set_type_vptr_fieldno): Declare.
(internal_type_vptr_basetype, set_type_vptr_basetype): Declare.
* stabsread.c (read_tilde_fields): Update setting of
TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE.
gdb/testsuite/ChangeLog:
* gdb.base/maint.exp <maint print type argc>: Update expected output.
2015-02-01 13:40:57 +08:00
|
|
|
/* * The base class which defined the virtual function table pointer. */
|
|
|
|
|
|
|
|
struct type *vptr_basetype;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * For derived classes, the number of base classes is given by
|
2011-01-06 06:22:53 +08:00
|
|
|
n_baseclasses and virtual_field_bits is a bit vector containing
|
|
|
|
one bit per base class. If the base class is virtual, the
|
|
|
|
corresponding bit will be set.
|
1999-07-08 04:19:36 +08:00
|
|
|
I.E, given:
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
class A{};
|
|
|
|
class B{};
|
|
|
|
class C : public B, public virtual A {};
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
B is a baseclass of C; A is a virtual baseclass for C.
|
2011-01-08 03:36:19 +08:00
|
|
|
This is a C++ 2.0 language feature. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
B_TYPE *virtual_field_bits;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * For classes with private fields, the number of fields is
|
|
|
|
given by nfields and private_field_bits is a bit vector
|
|
|
|
containing one bit per field.
|
|
|
|
|
2011-01-08 03:36:19 +08:00
|
|
|
If the field is private, the corresponding bit will be set. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
B_TYPE *private_field_bits;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * For classes with protected fields, the number of fields is
|
|
|
|
given by nfields and protected_field_bits is a bit vector
|
|
|
|
containing one bit per field.
|
|
|
|
|
2011-01-08 03:36:19 +08:00
|
|
|
If the field is private, the corresponding bit will be set. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
B_TYPE *protected_field_bits;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * For classes with fields to be ignored, either this is
|
|
|
|
optimized out or this field has length 0. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
B_TYPE *ignore_field_bits;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * For classes, structures, and unions, a description of each
|
|
|
|
field, which consists of an overloaded name, followed by the
|
|
|
|
types of arguments that the method expects, and then the name
|
|
|
|
after it has been renamed to make it distinct.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2011-01-08 03:36:19 +08:00
|
|
|
fn_fieldlists points to an array of nfn_fields of these. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
struct fn_fieldlist *fn_fieldlists;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * typedefs defined inside this class. typedef_field points to
|
|
|
|
an array of typedef_field_count elements. */
|
|
|
|
|
Record nested types
GDB currently does not track types defined in classes. Consider:
class A
{
public:
class B
{
public:
class C { };
};
};
(gdb) ptype A
type = class A {
<no data fields>
}
This patch changes this behavior so that GDB records these nested types
and displays them to the user when he has set the (new) "print type"
option "nested-type-limit."
Example:
(gdb) set print type nested-type-limit 1
(gdb) ptype A
type = class A {
<no data fields>
class A::B {
<no data fields>
};
}
(gdb) set print type nested-type-limit 2
type = class A {
<no data fields>
class A::B {
<no data fields>
class A::B::C {
<no data fields>
};
};
}
By default, the code maintains the status quo, that is, it will not print
any nested type definitions at all.
Testing is carried out via cp_ptype_class which required quite a bit of
modification to permit recursive calling (for the nested types). This
was most easily facilitated by turning the ptype command output into a
queue. Upshot: the test suite now has stack and queue data structures that
may be used by test writers.
gdb/ChangeLog
* NEWS (New commands): Mention set/show print type nested-type-limit.
* c-typeprint.c (c_type_print_base): Print out nested types.
* dwarf2read.c (struct typedef_field_list): Rename to ...
(struct decl_field_list): ... this. Change all uses.
(struct field_info) <nested_types_list, nested_types_list_count>:
New fields.
(add_partial_symbol): Look for nested type definitions in C++, too.
(dwarf2_add_typedef): Rename to ...
(dwarf2_add_type_defn): ... this.
(type_can_define_types): New function.
Update assertion to use type_can_define_types.
Permit NULL for a field's name.
(process_structure_scope): Handle child DIEs of types that can
define types.
Copy the list of nested types into the type struct.
* gdbtypes.h (struct typedef_field): Rename to ...
(struct decl_field): ... this. Change all uses.
[is_protected, is_private]: New fields.
(struct cplus_struct_type) <nested_types, nested_types_count>: New
fields.
(TYPE_NESTED_TYPES_ARRAY, TYPE_NESTED_TYPES_FIELD)
(TYPE_NESTED_TYPES_FIELD_NAME, TYPE_NESTED_TYPES_FIELD_TYPE)
(TYPE_NESTED_TYPES_COUNT, TYPE_NESTED_TYPES_FIELD_PROTECTED)
(TYPE_NESTED_TYPES_FIELD_PRIVATE): New macros.
* typeprint.c (type_print_raw_options, default_ptype_flags): Add
default value for print_nested_type_limit.
(print_nested_type_limit): New static variable.
(set_print_type_nested_types, show_print_type_nested_types): New
functions.
(_initialize_typeprint): Register new commands for set/show
`print-nested-type-limit'.
* typeprint.h (struct type_print_options) [print_nested_type_limit]:
New field.
gdb/testsuite/ChangeLog
* gdb.cp/nested-types.cc: New file.
* gdb.cp/nested-types.exp: New file.
* lib/cp-support.exp: Load data-structures.exp library.
(debug_cp_test_ptype_class): New global.
(cp_ptype_class_verbose, next_line): New procedures.
(cp_test_ptype_class): Add and document new parameter `recursive_qid'.
Add and document new return value.
Switch the list of lines to a queue.
Add support for new `type' key for nested type definitions.
Add debugging/troubleshooting messages.
* lib/data-structures.exp: New file.
gdb/doc/ChangeLog
* gdb.texinfo (Symbols): Document "set print type nested-type-limit"
and "show print type nested-type-limit".
2017-12-08 07:01:30 +08:00
|
|
|
struct decl_field *typedef_field;
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2010-06-29 04:39:30 +08:00
|
|
|
unsigned typedef_field_count;
|
2010-07-29 00:23:59 +08:00
|
|
|
|
Record nested types
GDB currently does not track types defined in classes. Consider:
class A
{
public:
class B
{
public:
class C { };
};
};
(gdb) ptype A
type = class A {
<no data fields>
}
This patch changes this behavior so that GDB records these nested types
and displays them to the user when he has set the (new) "print type"
option "nested-type-limit."
Example:
(gdb) set print type nested-type-limit 1
(gdb) ptype A
type = class A {
<no data fields>
class A::B {
<no data fields>
};
}
(gdb) set print type nested-type-limit 2
type = class A {
<no data fields>
class A::B {
<no data fields>
class A::B::C {
<no data fields>
};
};
}
By default, the code maintains the status quo, that is, it will not print
any nested type definitions at all.
Testing is carried out via cp_ptype_class which required quite a bit of
modification to permit recursive calling (for the nested types). This
was most easily facilitated by turning the ptype command output into a
queue. Upshot: the test suite now has stack and queue data structures that
may be used by test writers.
gdb/ChangeLog
* NEWS (New commands): Mention set/show print type nested-type-limit.
* c-typeprint.c (c_type_print_base): Print out nested types.
* dwarf2read.c (struct typedef_field_list): Rename to ...
(struct decl_field_list): ... this. Change all uses.
(struct field_info) <nested_types_list, nested_types_list_count>:
New fields.
(add_partial_symbol): Look for nested type definitions in C++, too.
(dwarf2_add_typedef): Rename to ...
(dwarf2_add_type_defn): ... this.
(type_can_define_types): New function.
Update assertion to use type_can_define_types.
Permit NULL for a field's name.
(process_structure_scope): Handle child DIEs of types that can
define types.
Copy the list of nested types into the type struct.
* gdbtypes.h (struct typedef_field): Rename to ...
(struct decl_field): ... this. Change all uses.
[is_protected, is_private]: New fields.
(struct cplus_struct_type) <nested_types, nested_types_count>: New
fields.
(TYPE_NESTED_TYPES_ARRAY, TYPE_NESTED_TYPES_FIELD)
(TYPE_NESTED_TYPES_FIELD_NAME, TYPE_NESTED_TYPES_FIELD_TYPE)
(TYPE_NESTED_TYPES_COUNT, TYPE_NESTED_TYPES_FIELD_PROTECTED)
(TYPE_NESTED_TYPES_FIELD_PRIVATE): New macros.
* typeprint.c (type_print_raw_options, default_ptype_flags): Add
default value for print_nested_type_limit.
(print_nested_type_limit): New static variable.
(set_print_type_nested_types, show_print_type_nested_types): New
functions.
(_initialize_typeprint): Register new commands for set/show
`print-nested-type-limit'.
* typeprint.h (struct type_print_options) [print_nested_type_limit]:
New field.
gdb/testsuite/ChangeLog
* gdb.cp/nested-types.cc: New file.
* gdb.cp/nested-types.exp: New file.
* lib/cp-support.exp: Load data-structures.exp library.
(debug_cp_test_ptype_class): New global.
(cp_ptype_class_verbose, next_line): New procedures.
(cp_test_ptype_class): Add and document new parameter `recursive_qid'.
Add and document new return value.
Switch the list of lines to a queue.
Add support for new `type' key for nested type definitions.
Add debugging/troubleshooting messages.
* lib/data-structures.exp: New file.
gdb/doc/ChangeLog
* gdb.texinfo (Symbols): Document "set print type nested-type-limit"
and "show print type nested-type-limit".
2017-12-08 07:01:30 +08:00
|
|
|
/* * The nested types defined by this type. nested_types points to
|
|
|
|
an array of nested_types_count elements. */
|
|
|
|
|
|
|
|
struct decl_field *nested_types;
|
|
|
|
|
|
|
|
unsigned nested_types_count;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * The template arguments. This is an array with
|
2010-07-29 00:23:59 +08:00
|
|
|
N_TEMPLATE_ARGUMENTS elements. This is NULL for non-template
|
|
|
|
classes. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2010-07-29 00:23:59 +08:00
|
|
|
struct symbol **template_arguments;
|
1999-07-08 04:19:36 +08:00
|
|
|
};
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Struct used to store conversion rankings. */
|
|
|
|
|
2010-11-05 04:26:23 +08:00
|
|
|
struct rank
|
|
|
|
{
|
2010-11-05 04:43:25 +08:00
|
|
|
short rank;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * When two conversions are of the same type and therefore have
|
|
|
|
the same rank, subrank is used to differentiate the two.
|
|
|
|
|
|
|
|
Eg: Two derived-class-pointer to base-class-pointer conversions
|
|
|
|
would both have base pointer conversion rank, but the
|
|
|
|
conversion with the shorter distance to the ancestor is
|
|
|
|
preferable. 'subrank' would be used to reflect that. */
|
|
|
|
|
2010-11-05 04:43:25 +08:00
|
|
|
short subrank;
|
2010-11-05 04:26:23 +08:00
|
|
|
};
|
|
|
|
|
2018-11-21 19:55:14 +08:00
|
|
|
/* * Used for ranking a function for overload resolution. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2018-11-21 19:55:14 +08:00
|
|
|
typedef std::vector<rank> badness_vector;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * GNAT Ada-specific information for various Ada types. */
|
|
|
|
|
2010-01-12 13:49:00 +08:00
|
|
|
struct gnat_aux_type
|
|
|
|
{
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Parallel type used to encode information about dynamic types
|
2010-01-12 13:49:00 +08:00
|
|
|
used in Ada (such as variant records, variable-size array,
|
|
|
|
etc). */
|
|
|
|
struct type* descriptive_type;
|
|
|
|
};
|
|
|
|
|
Move TYPE_SELF_TYPE into new field type_specific.
This patch moves TYPE_SELF_TYPE into new field type_specific.self_type
for MEMBERPTR,METHODPTR types, and into type_specific.func_stuff
for METHODs, and then updates everything to use that.
TYPE_CODE_METHOD could share some things with TYPE_CODE_FUNC
(e.g. TYPE_NO_RETURN) and it seemed simplest to keep them together.
Moving TYPE_SELF_TYPE into type_specific.func_stuff for TYPE_CODE_METHOD
is also nice because when we allocate space for function types we assume
they're TYPE_CODE_FUNCs. If TYPE_CODE_METHODs don't need or use that
space then that space would be wasted, and cleaning that up would involve
more invasive changes.
In order to catch errant uses I've added accessor functions
that do some checking.
One can no longer assign to TYPE_SELF_TYPE like this:
TYPE_SELF_TYPE (foo) = bar;
One instead has to do:
set_type_self_type (foo, bar);
But I've left reading of the type to the macro:
bar = TYPE_SELF_TYPE (foo);
In order to discourage bypassing the TYPE_SELF_TYPE macro
I've named the underlying function that implements it
internal_type_self_type.
While testing this I found the stabs reader leaving methods
as TYPE_CODE_FUNCs, hitting my newly added asserts.
Since the dwarf reader smashes functions to methods (via
smash_to_method) I've done a similar thing for stabs.
gdb/ChangeLog:
* cp-valprint.c (cp_find_class_member): Rename parameter domain_p
to self_p.
(cp_print_class_member): Rename local domain to self_type.
* dwarf2read.c (quirk_gcc_member_function_pointer): Rename local
domain_type to self_type.
(set_die_type) <need_gnat_info>: Handle
TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, TYPE_CODE_METHOD.
* gdb-gdb.py (StructMainTypePrettyPrinter): Handle
TYPE_SPECIFIC_SELF_TYPE.
* gdbtypes.c (internal_type_self_type): New function.
(set_type_self_type): New function.
(smash_to_memberptr_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(smash_to_methodptr_type): Update setting of TYPE_SELF_TYPE.
(smash_to_method_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(check_stub_method): Call smash_to_method_type.
(recursive_dump_type): Handle TYPE_SPECIFIC_SELF_TYPE.
(copy_type_recursive): Ditto.
* gdbtypes.h (enum type_specific_kind): New value
TYPE_SPECIFIC_SELF_TYPE.
(struct main_type) <type_specific>: New member self_type.
(struct cplus_struct_type) <fn_field.type>: Update comment.
(TYPE_SELF_TYPE): Rewrite.
(internal_type_self_type, set_type_self_type): Declare.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Rename local domain to
self_type.
(gnuv3_method_ptr_to_value): Rename local domain_type to self_type.
* m2-typeprint.c (m2_range): Replace TYPE_SELF_TYPE with
TYPE_TARGET_TYPE.
* stabsread.c (read_member_functions): Mark methods with
TYPE_CODE_METHOD, not TYPE_CODE_FUNC. Update setting of
TYPE_SELF_TYPE.
2015-02-01 13:21:01 +08:00
|
|
|
/* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2011-10-10 03:10:52 +08:00
|
|
|
struct func_type
|
|
|
|
{
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * The calling convention for targets supporting multiple ABIs.
|
|
|
|
Right now this is only fetched from the Dwarf-2
|
2014-12-09 18:45:41 +08:00
|
|
|
DW_AT_calling_convention attribute. The value is one of the
|
2019-12-21 01:23:32 +08:00
|
|
|
DW_CC constants. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2019-12-21 01:23:32 +08:00
|
|
|
ENUM_BITFIELD (dwarf_calling_convention) calling_convention : 8;
|
2014-12-09 18:45:41 +08:00
|
|
|
|
|
|
|
/* * Whether this function normally returns to its caller. It is
|
|
|
|
set from the DW_AT_noreturn attribute if set on the
|
|
|
|
DW_TAG_subprogram. */
|
|
|
|
|
|
|
|
unsigned int is_noreturn : 1;
|
2011-10-10 03:23:41 +08:00
|
|
|
|
DWARF-5: call sites
this patch updates all call sites related DWARF-5 renames.
gdb/ChangeLog
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* block.c (call_site_for_pc): Rename DW_OP_GNU_*, DW_TAG_GNU_* and
DW_AT_GNU_*.
* common/common-exceptions.h (enum errors): Likewise.
* dwarf2-frame.c (class dwarf_expr_executor): Likewise.
* dwarf2expr.c (dwarf_block_to_dwarf_reg)
(dwarf_expr_context::execute_stack_op): Likewise.
* dwarf2expr.h (struct dwarf_expr_context, struct dwarf_expr_piece):
Likewise.
* dwarf2loc.c (dwarf_evaluate_loc_desc::get_base_type)
(dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value)
(show_entry_values_debug, call_site_to_target_addr)
(func_addr_to_tail_call_list, func_verify_no_selftailcall)
(dwarf_expr_reg_to_entry_parameter, dwarf_entry_parameter_to_value)
(entry_data_value_free_closure, value_of_dwarf_reg_entry)
(value_of_dwarf_block_entry, indirect_pieced_value)
(symbol_needs_eval_context::push_dwarf_reg_entry_value):
(disassemble_dwarf_expression): Likewise.
* dwarf2read.c (process_die, inherit_abstract_dies)
(read_call_site_scope): Likewise.
* gdbtypes.h (struct func_type, struct call_site_parameter)
(struct call_site): Likewise.
* stack.c (read_frame_arg): Likewise.
* std-operator.def (OP_VAR_ENTRY_VALUE): Likewise.
gdb/doc/ChangeLog
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Print Settings, Tail Call Frames): Rename DW_OP_GNU_*,
DW_TAG_GNU_* and DW_AT_GNU_*.
gdb/testsuite/ChangeLog
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.arch/amd64-entry-value-param-dwarf5.S: New file.
* gdb.arch/amd64-entry-value-param-dwarf5.c: New file.
* gdb.arch/amd64-entry-value-param-dwarf5.exp: New file.
* gdb.arch/amd64-entry-value.exp: Rename DW_OP_GNU_*, DW_TAG_GNU_* and
DW_AT_GNU_*.
2017-02-21 03:53:21 +08:00
|
|
|
/* * Only those DW_TAG_call_site's in this function that have
|
|
|
|
DW_AT_call_tail_call set are linked in this list. Function
|
2014-03-13 10:36:45 +08:00
|
|
|
without its tail call list complete
|
DWARF-5: call sites
this patch updates all call sites related DWARF-5 renames.
gdb/ChangeLog
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* block.c (call_site_for_pc): Rename DW_OP_GNU_*, DW_TAG_GNU_* and
DW_AT_GNU_*.
* common/common-exceptions.h (enum errors): Likewise.
* dwarf2-frame.c (class dwarf_expr_executor): Likewise.
* dwarf2expr.c (dwarf_block_to_dwarf_reg)
(dwarf_expr_context::execute_stack_op): Likewise.
* dwarf2expr.h (struct dwarf_expr_context, struct dwarf_expr_piece):
Likewise.
* dwarf2loc.c (dwarf_evaluate_loc_desc::get_base_type)
(dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value)
(show_entry_values_debug, call_site_to_target_addr)
(func_addr_to_tail_call_list, func_verify_no_selftailcall)
(dwarf_expr_reg_to_entry_parameter, dwarf_entry_parameter_to_value)
(entry_data_value_free_closure, value_of_dwarf_reg_entry)
(value_of_dwarf_block_entry, indirect_pieced_value)
(symbol_needs_eval_context::push_dwarf_reg_entry_value):
(disassemble_dwarf_expression): Likewise.
* dwarf2read.c (process_die, inherit_abstract_dies)
(read_call_site_scope): Likewise.
* gdbtypes.h (struct func_type, struct call_site_parameter)
(struct call_site): Likewise.
* stack.c (read_frame_arg): Likewise.
* std-operator.def (OP_VAR_ENTRY_VALUE): Likewise.
gdb/doc/ChangeLog
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Print Settings, Tail Call Frames): Rename DW_OP_GNU_*,
DW_TAG_GNU_* and DW_AT_GNU_*.
gdb/testsuite/ChangeLog
2017-02-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.arch/amd64-entry-value-param-dwarf5.S: New file.
* gdb.arch/amd64-entry-value-param-dwarf5.c: New file.
* gdb.arch/amd64-entry-value-param-dwarf5.exp: New file.
* gdb.arch/amd64-entry-value.exp: Rename DW_OP_GNU_*, DW_TAG_GNU_* and
DW_AT_GNU_*.
2017-02-21 03:53:21 +08:00
|
|
|
(DW_AT_call_all_tail_calls or its superset
|
|
|
|
DW_AT_call_all_calls) has TAIL_CALL_LIST NULL, even if some
|
|
|
|
DW_TAG_call_site's exist in such function. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2011-10-10 03:23:41 +08:00
|
|
|
struct call_site *tail_call_list;
|
Move TYPE_SELF_TYPE into new field type_specific.
This patch moves TYPE_SELF_TYPE into new field type_specific.self_type
for MEMBERPTR,METHODPTR types, and into type_specific.func_stuff
for METHODs, and then updates everything to use that.
TYPE_CODE_METHOD could share some things with TYPE_CODE_FUNC
(e.g. TYPE_NO_RETURN) and it seemed simplest to keep them together.
Moving TYPE_SELF_TYPE into type_specific.func_stuff for TYPE_CODE_METHOD
is also nice because when we allocate space for function types we assume
they're TYPE_CODE_FUNCs. If TYPE_CODE_METHODs don't need or use that
space then that space would be wasted, and cleaning that up would involve
more invasive changes.
In order to catch errant uses I've added accessor functions
that do some checking.
One can no longer assign to TYPE_SELF_TYPE like this:
TYPE_SELF_TYPE (foo) = bar;
One instead has to do:
set_type_self_type (foo, bar);
But I've left reading of the type to the macro:
bar = TYPE_SELF_TYPE (foo);
In order to discourage bypassing the TYPE_SELF_TYPE macro
I've named the underlying function that implements it
internal_type_self_type.
While testing this I found the stabs reader leaving methods
as TYPE_CODE_FUNCs, hitting my newly added asserts.
Since the dwarf reader smashes functions to methods (via
smash_to_method) I've done a similar thing for stabs.
gdb/ChangeLog:
* cp-valprint.c (cp_find_class_member): Rename parameter domain_p
to self_p.
(cp_print_class_member): Rename local domain to self_type.
* dwarf2read.c (quirk_gcc_member_function_pointer): Rename local
domain_type to self_type.
(set_die_type) <need_gnat_info>: Handle
TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, TYPE_CODE_METHOD.
* gdb-gdb.py (StructMainTypePrettyPrinter): Handle
TYPE_SPECIFIC_SELF_TYPE.
* gdbtypes.c (internal_type_self_type): New function.
(set_type_self_type): New function.
(smash_to_memberptr_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(smash_to_methodptr_type): Update setting of TYPE_SELF_TYPE.
(smash_to_method_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(check_stub_method): Call smash_to_method_type.
(recursive_dump_type): Handle TYPE_SPECIFIC_SELF_TYPE.
(copy_type_recursive): Ditto.
* gdbtypes.h (enum type_specific_kind): New value
TYPE_SPECIFIC_SELF_TYPE.
(struct main_type) <type_specific>: New member self_type.
(struct cplus_struct_type) <fn_field.type>: Update comment.
(TYPE_SELF_TYPE): Rewrite.
(internal_type_self_type, set_type_self_type): Declare.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Rename local domain to
self_type.
(gnuv3_method_ptr_to_value): Rename local domain_type to self_type.
* m2-typeprint.c (m2_range): Replace TYPE_SELF_TYPE with
TYPE_TARGET_TYPE.
* stabsread.c (read_member_functions): Mark methods with
TYPE_CODE_METHOD, not TYPE_CODE_FUNC. Update setting of
TYPE_SELF_TYPE.
2015-02-01 13:21:01 +08:00
|
|
|
|
|
|
|
/* * For method types (TYPE_CODE_METHOD), the aggregate type that
|
|
|
|
contains the method. */
|
|
|
|
|
|
|
|
struct type *self_type;
|
2011-10-10 03:10:52 +08:00
|
|
|
};
|
|
|
|
|
Add support for printing value of DWARF-based fixed-point type objects
This commit introduces a new kind of type, meant to describe
fixed-point types, using a new code added specifically for
this purpose (TYPE_CODE_FIXED_POINT).
It then adds handling of fixed-point base types in the DWARF reader.
And finally, as a first step, this commit adds support for printing
the value of fixed-point type objects.
Note that this commit has a known issue: Trying to print the value
of a fixed-point object with a format letter (e.g. "print /x NAME")
causes the wrong value to be printed because the scaling factor
is not applied. Since the fix for this issue is isolated, and
this is not a regression, the fix will be made in a pach of its own.
This is meant to simplify review and archeology.
Also, other functionalities related to fixed-point type handling
(ptype, arithmetics, etc), will be added piecemeal as well, for
the same reasons (faciliate reviews and archeology). Related to this,
the testcase gdb.ada/fixed_cmp.exp is adjusted to compile the test
program with -fgnat-encodings=all, so as to force the use of GNAT
encodings, rather than rely on the compiler's default to use them.
The intent is to enhance this testcase to also test the pure DWARF
approach using -fgnat-encodings=minimal as soon as the corresponding
suport gets added in. Thus, the modification to the testcase is made
in a way that it prepares this testcase to be tested in both modes.
gdb/ChangeLog:
* ada-valprint.c (ada_value_print_1): Add fixed-point type handling.
* dwarf2/read.c (get_dwarf2_rational_constant)
(get_dwarf2_unsigned_rational_constant, finish_fixed_point_type)
(has_zero_over_zero_small_attribute): New functions.
read_base_type, set_die_type): Add fixed-point type handling.
* gdb-gdb.py.in: Add fixed-point type handling.
* gdbtypes.c: #include "gmp-utils.h".
(create_range_type, set_type_code): Add fixed-point type handling.
(init_fixed_point_type): New function.
(is_integral_type, is_scalar_type): Add fixed-point type handling.
(print_fixed_point_type_info): New function.
(recursive_dump_type, copy_type_recursive): Add fixed-point type
handling.
(fixed_point_type_storage): New typedef.
(fixed_point_objfile_key): New static global.
(allocate_fixed_point_type_info, is_fixed_point_type): New functions.
(fixed_point_type_base_type, fixed_point_scaling_factor): New
functions.
* gdbtypes.h: #include "gmp-utils.h".
(enum type_code) <TYPE_SPECIFIC_FIXED_POINT>: New enum.
(union type_specific) <fixed_point_info>: New field.
(struct fixed_point_type_info): New struct.
(INIT_FIXED_POINT_SPECIFIC, TYPE_FIXED_POINT_INFO): New macros.
(init_fixed_point_type, is_fixed_point_type)
(fixed_point_type_base_type, fixed_point_scaling_factor)
(allocate_fixed_point_type_info): Add declarations.
* valprint.c (generic_val_print_fixed_point): New function.
(generic_value_print): Add fixed-point type handling.
* value.c (value_as_address, unpack_long): Add fixed-point type
handling.
gdb/testsuite/ChangeLog:
* gdb.ada/fixed_cmp.exp: Force compilation to use -fgnat-encodings=all.
* gdb.ada/fixed_points.exp: Add fixed-point variables printing tests.
* gdb.ada/fixed_points/pck.ads, gdb.ada/fixed_points/pck.adb:
New files.
* gdb.ada/fixed_points/fixed_points.adb: Add use of package Pck.
* gdb.dwarf2/dw2-fixed-point.c, gdb.dwarf2/dw2-fixed-point.exp:
New files.
2020-11-15 16:12:52 +08:00
|
|
|
/* The type-specific info for TYPE_CODE_FIXED_POINT types. */
|
|
|
|
|
|
|
|
struct fixed_point_type_info
|
|
|
|
{
|
|
|
|
/* The fixed point type's scaling factor. */
|
|
|
|
gdb_mpq scaling_factor;
|
|
|
|
};
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * The default value of TYPE_CPLUS_SPECIFIC(T) points to this shared
|
|
|
|
static structure. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
extern const struct cplus_struct_type cplus_struct_default;
|
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern void allocate_cplus_struct_type (struct type *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
#define INIT_CPLUS_SPECIFIC(type) \
|
2010-01-12 13:49:00 +08:00
|
|
|
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_CPLUS_STUFF, \
|
2011-01-06 06:22:53 +08:00
|
|
|
TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type*) \
|
|
|
|
&cplus_struct_default)
|
2010-01-12 13:49:00 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
#define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
|
2010-01-12 13:49:00 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
#define HAVE_CPLUS_STRUCT(type) \
|
2010-01-12 13:49:00 +08:00
|
|
|
(TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_CPLUS_STUFF \
|
|
|
|
&& TYPE_RAW_CPLUS_SPECIFIC (type) != &cplus_struct_default)
|
|
|
|
|
2019-04-09 21:46:39 +08:00
|
|
|
#define INIT_NONE_SPECIFIC(type) \
|
|
|
|
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_NONE, \
|
|
|
|
TYPE_MAIN_TYPE (type)->type_specific = {})
|
|
|
|
|
2010-01-12 13:49:00 +08:00
|
|
|
extern const struct gnat_aux_type gnat_aux_default;
|
|
|
|
|
|
|
|
extern void allocate_gnat_aux_type (struct type *);
|
|
|
|
|
|
|
|
#define INIT_GNAT_SPECIFIC(type) \
|
|
|
|
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_GNAT_STUFF, \
|
|
|
|
TYPE_GNAT_SPECIFIC (type) = (struct gnat_aux_type *) &gnat_aux_default)
|
|
|
|
#define ALLOCATE_GNAT_AUX_TYPE(type) allocate_gnat_aux_type (type)
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * A macro that returns non-zero if the type-specific data should be
|
2010-01-12 13:49:00 +08:00
|
|
|
read as "gnat-stuff". */
|
|
|
|
#define HAVE_GNAT_AUX_INFO(type) \
|
|
|
|
(TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2019-04-09 21:46:39 +08:00
|
|
|
/* * True if TYPE is known to be an Ada type of some kind. */
|
|
|
|
#define ADA_TYPE_P(type) \
|
|
|
|
(TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF \
|
|
|
|
|| (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE \
|
2020-09-14 23:08:07 +08:00
|
|
|
&& (type)->is_fixed_instance ()))
|
2019-04-09 21:46:39 +08:00
|
|
|
|
2011-10-10 03:10:52 +08:00
|
|
|
#define INIT_FUNC_SPECIFIC(type) \
|
|
|
|
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \
|
2015-09-26 02:08:06 +08:00
|
|
|
TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \
|
|
|
|
TYPE_ZALLOC (type, \
|
|
|
|
sizeof (*TYPE_MAIN_TYPE (type)->type_specific.func_stuff)))
|
2011-10-10 03:10:52 +08:00
|
|
|
|
Add support for printing value of DWARF-based fixed-point type objects
This commit introduces a new kind of type, meant to describe
fixed-point types, using a new code added specifically for
this purpose (TYPE_CODE_FIXED_POINT).
It then adds handling of fixed-point base types in the DWARF reader.
And finally, as a first step, this commit adds support for printing
the value of fixed-point type objects.
Note that this commit has a known issue: Trying to print the value
of a fixed-point object with a format letter (e.g. "print /x NAME")
causes the wrong value to be printed because the scaling factor
is not applied. Since the fix for this issue is isolated, and
this is not a regression, the fix will be made in a pach of its own.
This is meant to simplify review and archeology.
Also, other functionalities related to fixed-point type handling
(ptype, arithmetics, etc), will be added piecemeal as well, for
the same reasons (faciliate reviews and archeology). Related to this,
the testcase gdb.ada/fixed_cmp.exp is adjusted to compile the test
program with -fgnat-encodings=all, so as to force the use of GNAT
encodings, rather than rely on the compiler's default to use them.
The intent is to enhance this testcase to also test the pure DWARF
approach using -fgnat-encodings=minimal as soon as the corresponding
suport gets added in. Thus, the modification to the testcase is made
in a way that it prepares this testcase to be tested in both modes.
gdb/ChangeLog:
* ada-valprint.c (ada_value_print_1): Add fixed-point type handling.
* dwarf2/read.c (get_dwarf2_rational_constant)
(get_dwarf2_unsigned_rational_constant, finish_fixed_point_type)
(has_zero_over_zero_small_attribute): New functions.
read_base_type, set_die_type): Add fixed-point type handling.
* gdb-gdb.py.in: Add fixed-point type handling.
* gdbtypes.c: #include "gmp-utils.h".
(create_range_type, set_type_code): Add fixed-point type handling.
(init_fixed_point_type): New function.
(is_integral_type, is_scalar_type): Add fixed-point type handling.
(print_fixed_point_type_info): New function.
(recursive_dump_type, copy_type_recursive): Add fixed-point type
handling.
(fixed_point_type_storage): New typedef.
(fixed_point_objfile_key): New static global.
(allocate_fixed_point_type_info, is_fixed_point_type): New functions.
(fixed_point_type_base_type, fixed_point_scaling_factor): New
functions.
* gdbtypes.h: #include "gmp-utils.h".
(enum type_code) <TYPE_SPECIFIC_FIXED_POINT>: New enum.
(union type_specific) <fixed_point_info>: New field.
(struct fixed_point_type_info): New struct.
(INIT_FIXED_POINT_SPECIFIC, TYPE_FIXED_POINT_INFO): New macros.
(init_fixed_point_type, is_fixed_point_type)
(fixed_point_type_base_type, fixed_point_scaling_factor)
(allocate_fixed_point_type_info): Add declarations.
* valprint.c (generic_val_print_fixed_point): New function.
(generic_value_print): Add fixed-point type handling.
* value.c (value_as_address, unpack_long): Add fixed-point type
handling.
gdb/testsuite/ChangeLog:
* gdb.ada/fixed_cmp.exp: Force compilation to use -fgnat-encodings=all.
* gdb.ada/fixed_points.exp: Add fixed-point variables printing tests.
* gdb.ada/fixed_points/pck.ads, gdb.ada/fixed_points/pck.adb:
New files.
* gdb.ada/fixed_points/fixed_points.adb: Add use of package Pck.
* gdb.dwarf2/dw2-fixed-point.c, gdb.dwarf2/dw2-fixed-point.exp:
New files.
2020-11-15 16:12:52 +08:00
|
|
|
/* "struct fixed_point_type_info" has a field that has a destructor.
|
|
|
|
See allocate_fixed_point_type_info to understand how this is
|
|
|
|
handled. */
|
|
|
|
#define INIT_FIXED_POINT_SPECIFIC(type) \
|
|
|
|
(TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
|
2020-11-24 10:47:40 +08:00
|
|
|
allocate_fixed_point_type_info (type))
|
Add support for printing value of DWARF-based fixed-point type objects
This commit introduces a new kind of type, meant to describe
fixed-point types, using a new code added specifically for
this purpose (TYPE_CODE_FIXED_POINT).
It then adds handling of fixed-point base types in the DWARF reader.
And finally, as a first step, this commit adds support for printing
the value of fixed-point type objects.
Note that this commit has a known issue: Trying to print the value
of a fixed-point object with a format letter (e.g. "print /x NAME")
causes the wrong value to be printed because the scaling factor
is not applied. Since the fix for this issue is isolated, and
this is not a regression, the fix will be made in a pach of its own.
This is meant to simplify review and archeology.
Also, other functionalities related to fixed-point type handling
(ptype, arithmetics, etc), will be added piecemeal as well, for
the same reasons (faciliate reviews and archeology). Related to this,
the testcase gdb.ada/fixed_cmp.exp is adjusted to compile the test
program with -fgnat-encodings=all, so as to force the use of GNAT
encodings, rather than rely on the compiler's default to use them.
The intent is to enhance this testcase to also test the pure DWARF
approach using -fgnat-encodings=minimal as soon as the corresponding
suport gets added in. Thus, the modification to the testcase is made
in a way that it prepares this testcase to be tested in both modes.
gdb/ChangeLog:
* ada-valprint.c (ada_value_print_1): Add fixed-point type handling.
* dwarf2/read.c (get_dwarf2_rational_constant)
(get_dwarf2_unsigned_rational_constant, finish_fixed_point_type)
(has_zero_over_zero_small_attribute): New functions.
read_base_type, set_die_type): Add fixed-point type handling.
* gdb-gdb.py.in: Add fixed-point type handling.
* gdbtypes.c: #include "gmp-utils.h".
(create_range_type, set_type_code): Add fixed-point type handling.
(init_fixed_point_type): New function.
(is_integral_type, is_scalar_type): Add fixed-point type handling.
(print_fixed_point_type_info): New function.
(recursive_dump_type, copy_type_recursive): Add fixed-point type
handling.
(fixed_point_type_storage): New typedef.
(fixed_point_objfile_key): New static global.
(allocate_fixed_point_type_info, is_fixed_point_type): New functions.
(fixed_point_type_base_type, fixed_point_scaling_factor): New
functions.
* gdbtypes.h: #include "gmp-utils.h".
(enum type_code) <TYPE_SPECIFIC_FIXED_POINT>: New enum.
(union type_specific) <fixed_point_info>: New field.
(struct fixed_point_type_info): New struct.
(INIT_FIXED_POINT_SPECIFIC, TYPE_FIXED_POINT_INFO): New macros.
(init_fixed_point_type, is_fixed_point_type)
(fixed_point_type_base_type, fixed_point_scaling_factor)
(allocate_fixed_point_type_info): Add declarations.
* valprint.c (generic_val_print_fixed_point): New function.
(generic_value_print): Add fixed-point type handling.
* value.c (value_as_address, unpack_long): Add fixed-point type
handling.
gdb/testsuite/ChangeLog:
* gdb.ada/fixed_cmp.exp: Force compilation to use -fgnat-encodings=all.
* gdb.ada/fixed_points.exp: Add fixed-point variables printing tests.
* gdb.ada/fixed_points/pck.ads, gdb.ada/fixed_points/pck.adb:
New files.
* gdb.ada/fixed_points/fixed_points.adb: Add use of package Pck.
* gdb.dwarf2/dw2-fixed-point.c, gdb.dwarf2/dw2-fixed-point.exp:
New files.
2020-11-15 16:12:52 +08:00
|
|
|
|
2002-05-15 02:30:53 +08:00
|
|
|
#define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
|
1999-04-16 09:35:26 +08:00
|
|
|
#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
|
|
|
|
#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
|
2017-03-21 04:47:30 +08:00
|
|
|
#define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type
|
2002-05-15 02:30:53 +08:00
|
|
|
#define TYPE_CHAIN(thistype) (thistype)->chain
|
Add initial type alignment support
This adds some basic type alignment support to gdb. It changes struct
type to store the alignment, and updates dwarf2read.c to handle
DW_AT_alignment. It also adds a new gdbarch method and updates
i386-tdep.c.
None of this new functionality is used anywhere yet, so tests will
wait until the next patch.
2018-04-30 Tom Tromey <tom@tromey.com>
* i386-tdep.c (i386_type_align): New function.
(i386_gdbarch_init): Update.
* gdbarch.sh (type_align): New method.
* gdbarch.c, gdbarch.h: Rebuild.
* arch-utils.h (default_type_align): Declare.
* arch-utils.c (default_type_align): New function.
* gdbtypes.h (TYPE_ALIGN_BITS): New define.
(struct type) <align_log2>: New field.
<instance_flags>: Now a bitfield.
(TYPE_RAW_ALIGN): New macro.
(type_align, type_raw_align, set_type_align): Declare.
* gdbtypes.c (type_align, type_raw_align, set_type_align): New
functions.
* dwarf2read.c (quirk_rust_enum): Set type alignment.
(get_alignment, maybe_set_alignment): New functions.
(read_structure_type, read_enumeration_type, read_array_type)
(read_set_type, read_tag_pointer_type, read_tag_reference_type)
(read_subrange_type, read_base_type): Set type alignment.
2018-04-21 01:50:09 +08:00
|
|
|
|
|
|
|
/* * Return the alignment of the type in target addressable memory
|
|
|
|
units, or 0 if no alignment was specified. */
|
|
|
|
#define TYPE_RAW_ALIGN(thistype) type_raw_align (thistype)
|
|
|
|
|
|
|
|
/* * Return the alignment of the type in target addressable memory
|
|
|
|
units, or 0 if no alignment was specified. */
|
|
|
|
extern unsigned type_raw_align (struct type *);
|
|
|
|
|
|
|
|
/* * Return the alignment of the type in target addressable memory
|
|
|
|
units. Return 0 if the alignment cannot be determined; but note
|
|
|
|
that this makes an effort to compute the alignment even it it was
|
|
|
|
not specified in the debug info. */
|
|
|
|
extern unsigned type_align (struct type *);
|
|
|
|
|
|
|
|
/* * Set the alignment of the type. The alignment must be a power of
|
|
|
|
2. Returns false if the given value does not fit in the available
|
|
|
|
space in struct type. */
|
|
|
|
extern bool set_type_align (struct type *, ULONGEST);
|
|
|
|
|
2015-03-21 05:45:20 +08:00
|
|
|
/* Property accessors for the type data location. */
|
2014-08-12 07:37:10 +08:00
|
|
|
#define TYPE_DATA_LOCATION(thistype) \
|
2020-05-07 23:32:25 +08:00
|
|
|
((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION))
|
2014-08-12 07:37:10 +08:00
|
|
|
#define TYPE_DATA_LOCATION_BATON(thistype) \
|
|
|
|
TYPE_DATA_LOCATION (thistype)->data.baton
|
|
|
|
#define TYPE_DATA_LOCATION_ADDR(thistype) \
|
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
|
|
|
(TYPE_DATA_LOCATION (thistype)->const_val ())
|
2014-08-12 07:37:10 +08:00
|
|
|
#define TYPE_DATA_LOCATION_KIND(thistype) \
|
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
|
|
|
(TYPE_DATA_LOCATION (thistype)->kind ())
|
2020-04-25 03:40:31 +08:00
|
|
|
#define TYPE_DYNAMIC_LENGTH(thistype) \
|
2020-05-07 23:32:25 +08:00
|
|
|
((thistype)->dyn_prop (DYN_PROP_BYTE_SIZE))
|
2014-08-12 07:37:10 +08:00
|
|
|
|
2015-10-22 03:32:30 +08:00
|
|
|
/* Property accessors for the type allocated/associated. */
|
|
|
|
#define TYPE_ALLOCATED_PROP(thistype) \
|
2020-05-07 23:32:25 +08:00
|
|
|
((thistype)->dyn_prop (DYN_PROP_ALLOCATED))
|
2015-10-22 03:32:30 +08:00
|
|
|
#define TYPE_ASSOCIATED_PROP(thistype) \
|
2020-05-07 23:32:25 +08:00
|
|
|
((thistype)->dyn_prop (DYN_PROP_ASSOCIATED))
|
gdb: add support for Fortran's ASSUMED RANK arrays
This patch adds a new dynamic property DYN_PROP_RANK, this property is
read from the DW_AT_rank attribute and stored within the type just
like other dynamic properties.
As arrays with dynamic ranks make use of a single
DW_TAG_generic_subrange to represent all ranks of the array, support
for this tag has been added to dwarf2/read.c.
The final piece of this puzzle is to add support in gdbtypes.c so that
we can resolve an array type with dynamic rank. To do this the
existing resolve_dynamic_array_or_string function is split into two,
there's a new resolve_dynamic_array_or_string_1 core that is
responsible for resolving each rank of the array, while the now outer
resolve_dynamic_array_or_string is responsible for figuring out the
array rank (which might require resolving a dynamic property) and then
calling the inner core.
The resolve_dynamic_range function now takes a rank, which is passed
on to the dwarf expression evaluator. This rank will only be used in
the case where the array itself has dynamic rank, but we now pass the
rank in all cases, this should be harmless if the rank is not needed.
The only small nit is that resolve_dynamic_type_internal actually
handles resolving dynamic ranges itself, which now obviously requires
us to pass a rank value. But what rank value to use? In the end I
just passed '1' through here as a sane default, my thinking is that if
we are in resolve_dynamic_type_internal to resolve a range, then the
range isn't part of an array with dynamic rank, and so the range
should actually be using the rank value at all.
An alternative approach would be to make the rank value a
gdb::optional, however, this ends up adding a bunch of complexity to
the code (e.g. having to conditionally build the array to pass to
dwarf2_evaluate_property, and handling the 'rank - 1' in
resolve_dynamic_array_or_string_1) so I haven't done that, but could,
if people think that would be a better approach.
Finally, support for assumed rank arrays was only fixed very recently
in gcc, so you'll need the latest gcc in order to run the tests for
this.
Here's an example test program:
PROGRAM arank
REAL :: a1(10)
CALL sub1(a1)
CONTAINS
SUBROUTINE sub1(a)
REAL :: a(..)
PRINT *, RANK(a)
END SUBROUTINE sub1
END PROGRAM arank
Compiler Version:
gcc (GCC) 12.0.0 20211122 (experimental)
Compilation command:
gfortran assumedrank.f90 -gdwarf-5 -o assumedrank
Without Patch:
gdb -q assumedrank
Reading symbols from assumedrank...
(gdb) break sub1
Breakpoint 1 at 0x4006ff: file assumedrank.f90, line 10.
(gdb) run
Starting program: /home/rupesh/STAGING-BUILD-2787/bin/assumedrank
Breakpoint 1, arank::sub1 (a=<unknown type in /home/rupesh/STAGING-BUILD-2787
/bin/assumedrank, CU 0x0, DIE 0xd5>) at assumedrank.f90:10
10 PRINT *, RANK(a)
(gdb) print RANK(a)
'a' has unknown type; cast it to its declared type
With patch:
gdb -q assumedrank
Reading symbols from assumedrank...
(gdb) break sub1
Breakpoint 1 at 0x4006ff: file assumedrank.f90, line 10.
(gdb) run
Starting program: /home/rupesh/STAGING-BUILD-2787/bin/assumedrank
Breakpoint 1, arank::sub1 (a=...) at assumedrank.f90:10
10 PRINT *, RANK(a)
(gdb) print RANK(a)
$1 = 1
(gdb) ptype a
type = real(kind=4) (10)
(gdb)
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
2022-03-18 02:56:23 +08:00
|
|
|
#define TYPE_RANK_PROP(thistype) \
|
|
|
|
((thistype)->dyn_prop (DYN_PROP_RANK))
|
2015-10-22 03:32:30 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* C++ */
|
|
|
|
|
Move TYPE_SELF_TYPE into new field type_specific.
This patch moves TYPE_SELF_TYPE into new field type_specific.self_type
for MEMBERPTR,METHODPTR types, and into type_specific.func_stuff
for METHODs, and then updates everything to use that.
TYPE_CODE_METHOD could share some things with TYPE_CODE_FUNC
(e.g. TYPE_NO_RETURN) and it seemed simplest to keep them together.
Moving TYPE_SELF_TYPE into type_specific.func_stuff for TYPE_CODE_METHOD
is also nice because when we allocate space for function types we assume
they're TYPE_CODE_FUNCs. If TYPE_CODE_METHODs don't need or use that
space then that space would be wasted, and cleaning that up would involve
more invasive changes.
In order to catch errant uses I've added accessor functions
that do some checking.
One can no longer assign to TYPE_SELF_TYPE like this:
TYPE_SELF_TYPE (foo) = bar;
One instead has to do:
set_type_self_type (foo, bar);
But I've left reading of the type to the macro:
bar = TYPE_SELF_TYPE (foo);
In order to discourage bypassing the TYPE_SELF_TYPE macro
I've named the underlying function that implements it
internal_type_self_type.
While testing this I found the stabs reader leaving methods
as TYPE_CODE_FUNCs, hitting my newly added asserts.
Since the dwarf reader smashes functions to methods (via
smash_to_method) I've done a similar thing for stabs.
gdb/ChangeLog:
* cp-valprint.c (cp_find_class_member): Rename parameter domain_p
to self_p.
(cp_print_class_member): Rename local domain to self_type.
* dwarf2read.c (quirk_gcc_member_function_pointer): Rename local
domain_type to self_type.
(set_die_type) <need_gnat_info>: Handle
TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, TYPE_CODE_METHOD.
* gdb-gdb.py (StructMainTypePrettyPrinter): Handle
TYPE_SPECIFIC_SELF_TYPE.
* gdbtypes.c (internal_type_self_type): New function.
(set_type_self_type): New function.
(smash_to_memberptr_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(smash_to_methodptr_type): Update setting of TYPE_SELF_TYPE.
(smash_to_method_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(check_stub_method): Call smash_to_method_type.
(recursive_dump_type): Handle TYPE_SPECIFIC_SELF_TYPE.
(copy_type_recursive): Ditto.
* gdbtypes.h (enum type_specific_kind): New value
TYPE_SPECIFIC_SELF_TYPE.
(struct main_type) <type_specific>: New member self_type.
(struct cplus_struct_type) <fn_field.type>: Update comment.
(TYPE_SELF_TYPE): Rewrite.
(internal_type_self_type, set_type_self_type): Declare.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Rename local domain to
self_type.
(gnuv3_method_ptr_to_value): Rename local domain_type to self_type.
* m2-typeprint.c (m2_range): Replace TYPE_SELF_TYPE with
TYPE_TARGET_TYPE.
* stabsread.c (read_member_functions): Mark methods with
TYPE_CODE_METHOD, not TYPE_CODE_FUNC. Update setting of
TYPE_SELF_TYPE.
2015-02-01 13:21:01 +08:00
|
|
|
#define TYPE_SELF_TYPE(thistype) internal_type_self_type (thistype)
|
|
|
|
/* Do not call this, use TYPE_SELF_TYPE. */
|
|
|
|
extern struct type *internal_type_self_type (struct type *);
|
|
|
|
extern void set_type_self_type (struct type *, struct type *);
|
|
|
|
|
Move vptr_{fieldno,basetype} out of main_type, and update everything accordingly.
Every type has to pay the price in memory usage for their presence.
The proper place for them is in the type_specific field which exists
for this purpose.
gdb/ChangeLog:
* dwarf2read.c (process_structure_scope): Update setting of
TYPE_VPTR_BASETYPE, TYPE_VPTR_FIELDNO.
* gdbtypes.c (internal_type_vptr_fieldno): New function.
(set_type_vptr_fieldno): New function.
(internal_type_vptr_basetype): New function.
(set_type_vptr_basetype): New function.
(get_vptr_fieldno): Update setting of TYPE_VPTR_FIELDNO,
TYPE_VPTR_BASETYPE.
(allocate_cplus_struct_type): Initialize vptr_fieldno.
(recursive_dump_type): Printing of vptr_fieldno, vptr_basetype ...
(print_cplus_stuff): ... moved here.
(copy_type_recursive): Don't copy TYPE_VPTR_BASETYPE.
* gdbtypes.h (struct main_type): Members vptr_fieldno, vptr_basetype
moved to ...
(struct cplus_struct_type): ... here. All uses updated.
(TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE): Rewrite.
(internal_type_vptr_fieldno, set_type_vptr_fieldno): Declare.
(internal_type_vptr_basetype, set_type_vptr_basetype): Declare.
* stabsread.c (read_tilde_fields): Update setting of
TYPE_VPTR_FIELDNO, TYPE_VPTR_BASETYPE.
gdb/testsuite/ChangeLog:
* gdb.base/maint.exp <maint print type argc>: Update expected output.
2015-02-01 13:40:57 +08:00
|
|
|
extern int internal_type_vptr_fieldno (struct type *);
|
|
|
|
extern void set_type_vptr_fieldno (struct type *, int);
|
|
|
|
extern struct type *internal_type_vptr_basetype (struct type *);
|
|
|
|
extern void set_type_vptr_basetype (struct type *, struct type *);
|
|
|
|
#define TYPE_VPTR_FIELDNO(thistype) internal_type_vptr_fieldno (thistype)
|
|
|
|
#define TYPE_VPTR_BASETYPE(thistype) internal_type_vptr_basetype (thistype)
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
#define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
|
2010-01-12 13:49:00 +08:00
|
|
|
#define TYPE_SPECIFIC_FIELD(thistype) \
|
|
|
|
TYPE_MAIN_TYPE(thistype)->type_specific_field
|
|
|
|
/* We need this tap-dance with the TYPE_RAW_SPECIFIC because of the case
|
|
|
|
where we're trying to print an Ada array using the C language.
|
|
|
|
In that case, there is no "cplus_stuff", but the C language assumes
|
|
|
|
that there is. What we do, in that case, is pretend that there is
|
|
|
|
an implicit one which is the default cplus stuff. */
|
|
|
|
#define TYPE_CPLUS_SPECIFIC(thistype) \
|
|
|
|
(!HAVE_CPLUS_STRUCT(thistype) \
|
|
|
|
? (struct cplus_struct_type*)&cplus_struct_default \
|
|
|
|
: TYPE_RAW_CPLUS_SPECIFIC(thistype))
|
|
|
|
#define TYPE_RAW_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
|
2019-12-21 00:43:06 +08:00
|
|
|
#define TYPE_CPLUS_CALLING_CONVENTION(thistype) \
|
|
|
|
TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff->calling_convention
|
2002-05-15 02:30:53 +08:00
|
|
|
#define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
|
2010-01-12 13:49:00 +08:00
|
|
|
#define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff
|
|
|
|
#define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type
|
2011-10-10 03:10:52 +08:00
|
|
|
#define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->calling_convention
|
2014-12-09 18:45:41 +08:00
|
|
|
#define TYPE_NO_RETURN(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->is_noreturn
|
2011-10-10 03:23:41 +08:00
|
|
|
#define TYPE_TAIL_CALL_LIST(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->tail_call_list
|
2020-06-09 03:26:20 +08:00
|
|
|
#define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ())
|
1999-04-16 09:35:26 +08:00
|
|
|
#define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
|
2021-08-30 23:49:49 +08:00
|
|
|
#define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ())
|
2021-09-27 04:36:15 +08:00
|
|
|
#define TYPE_BASECLASS_BITPOS(thistype,index) (thistype->field (index).loc_bitpos ())
|
1999-04-16 09:35:26 +08:00
|
|
|
#define BASETYPE_VIA_PUBLIC(thistype, index) \
|
|
|
|
((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
|
2009-11-13 03:47:25 +08:00
|
|
|
#define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
#define BASETYPE_VIA_VIRTUAL(thistype, index) \
|
|
|
|
(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
|
|
|
|
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
|
|
|
|
|
2002-11-11 08:55:34 +08:00
|
|
|
#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
|
1999-04-16 09:35:26 +08:00
|
|
|
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
|
Convert static_kind into loc_kind enum.
* gdbtypes.h (enum field_loc_kind): New.
(union field_location): New field dwarf_block.
(struct field): Rename static_kind as loc_kind.
(FIELD_STATIC_KIND): Rename to ...
(FIELD_LOC_KIND): ... here.
(TYPE_FIELD_STATIC_KIND): Rename to ...
(TYPE_FIELD_LOC_KIND): ... here and use there now new FIELD_LOC_KIND.
(TYPE_FIELD_STATIC_HAS_ADDR): Remove.
(TYPE_FIELD_STATIC): Remove.
(TYPE_FIELD_BITPOS): Reformat.
(SET_FIELD_BITPOS): New.
(FIELD_PHYSADDR): Rename to ...
(FIELD_STATIC_PHYSADDR): ... here.
(TYPE_FIELD_STATIC_PHYSADDR): Follow the FIELD_PHYSADDR rename.
(SET_FIELD_PHYSADDR): Use new FIELD_LOC_KIND.
(FIELD_PHYSNAME): Rename to ...
(FIELD_STATIC_PHYSNAME): ... here.
(TYPE_FIELD_STATIC_PHYSNAME): Follow the FIELD_PHYSNAME rename.
(SET_FIELD_PHYSNAME): Use new FIELD_LOC_KIND.
(FIELD_DWARF_BLOCK, TYPE_FIELD_DWARF_BLOCK, SET_FIELD_DWARF_BLOCK): New.
(field_is_static): New declaration.
* gdbtypes.c (field_is_static): New function.
(copy_type_recursive): Update throughout.
* amd64-tdep.c, c-typeprint.c, coffread.c, cp-valprint.c, dwarf2read.c,
eval.c, jv-typeprint.c, jv-valprint.c, mdebugread.c, p-typeprint.c,
p-valprint.c, valops.c, value.c, varobj.c: Update throughout.
2008-10-08 20:49:13 +08:00
|
|
|
|
2020-05-24 05:39:54 +08:00
|
|
|
#define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
|
|
|
|
#define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE((thistype)->field (n))
|
|
|
|
#define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE((thistype)->field (n))!=0)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
#define TYPE_FIELD_PRIVATE_BITS(thistype) \
|
|
|
|
TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits
|
|
|
|
#define TYPE_FIELD_PROTECTED_BITS(thistype) \
|
|
|
|
TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits
|
|
|
|
#define TYPE_FIELD_IGNORE_BITS(thistype) \
|
|
|
|
TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits
|
|
|
|
#define TYPE_FIELD_VIRTUAL_BITS(thistype) \
|
|
|
|
TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits
|
|
|
|
#define SET_TYPE_FIELD_PRIVATE(thistype, n) \
|
|
|
|
B_SET (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n))
|
|
|
|
#define SET_TYPE_FIELD_PROTECTED(thistype, n) \
|
|
|
|
B_SET (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n))
|
|
|
|
#define SET_TYPE_FIELD_IGNORE(thistype, n) \
|
|
|
|
B_SET (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n))
|
|
|
|
#define SET_TYPE_FIELD_VIRTUAL(thistype, n) \
|
|
|
|
B_SET (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n))
|
|
|
|
#define TYPE_FIELD_PRIVATE(thistype, n) \
|
|
|
|
(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits == NULL ? 0 \
|
|
|
|
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n)))
|
|
|
|
#define TYPE_FIELD_PROTECTED(thistype, n) \
|
|
|
|
(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits == NULL ? 0 \
|
|
|
|
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n)))
|
|
|
|
#define TYPE_FIELD_IGNORE(thistype, n) \
|
|
|
|
(TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits == NULL ? 0 \
|
|
|
|
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n)))
|
|
|
|
#define TYPE_FIELD_VIRTUAL(thistype, n) \
|
|
|
|
(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
|
|
|
|
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n)))
|
|
|
|
|
|
|
|
#define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists
|
|
|
|
#define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n]
|
|
|
|
#define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
|
|
|
|
#define TYPE_FN_FIELDLIST_NAME(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].name
|
|
|
|
#define TYPE_FN_FIELDLIST_LENGTH(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].length
|
|
|
|
|
2010-07-29 00:23:59 +08:00
|
|
|
#define TYPE_N_TEMPLATE_ARGUMENTS(thistype) \
|
|
|
|
TYPE_CPLUS_SPECIFIC (thistype)->n_template_arguments
|
|
|
|
#define TYPE_TEMPLATE_ARGUMENTS(thistype) \
|
|
|
|
TYPE_CPLUS_SPECIFIC (thistype)->template_arguments
|
|
|
|
#define TYPE_TEMPLATE_ARGUMENT(thistype, n) \
|
|
|
|
TYPE_CPLUS_SPECIFIC (thistype)->template_arguments[n]
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
#define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
|
|
|
|
#define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
|
|
|
|
#define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
|
2020-05-23 04:55:17 +08:00
|
|
|
#define TYPE_FN_FIELD_ARGS(thisfn, n) (((thisfn)[n].type)->fields ())
|
1999-04-16 09:35:26 +08:00
|
|
|
#define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const)
|
|
|
|
#define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile)
|
|
|
|
#define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private)
|
|
|
|
#define TYPE_FN_FIELD_PROTECTED(thisfn, n) ((thisfn)[n].is_protected)
|
2002-01-21 03:20:16 +08:00
|
|
|
#define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial)
|
1999-04-16 09:35:26 +08:00
|
|
|
#define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
|
2012-12-15 04:33:29 +08:00
|
|
|
#define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor)
|
1999-04-16 09:35:26 +08:00
|
|
|
#define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
|
|
|
|
#define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
|
|
|
|
#define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
|
|
|
|
#define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
|
2019-12-21 00:43:06 +08:00
|
|
|
#define TYPE_FN_FIELD_DEFAULTED(thisfn, n) ((thisfn)[n].defaulted)
|
|
|
|
#define TYPE_FN_FIELD_DELETED(thisfn, n) ((thisfn)[n].is_deleted)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2017-10-17 08:19:29 +08:00
|
|
|
/* Accessors for typedefs defined by a class. */
|
2010-06-29 04:39:30 +08:00
|
|
|
#define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \
|
|
|
|
TYPE_CPLUS_SPECIFIC (thistype)->typedef_field
|
|
|
|
#define TYPE_TYPEDEF_FIELD(thistype, n) \
|
|
|
|
TYPE_CPLUS_SPECIFIC (thistype)->typedef_field[n]
|
|
|
|
#define TYPE_TYPEDEF_FIELD_NAME(thistype, n) \
|
|
|
|
TYPE_TYPEDEF_FIELD (thistype, n).name
|
|
|
|
#define TYPE_TYPEDEF_FIELD_TYPE(thistype, n) \
|
|
|
|
TYPE_TYPEDEF_FIELD (thistype, n).type
|
|
|
|
#define TYPE_TYPEDEF_FIELD_COUNT(thistype) \
|
|
|
|
TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count
|
2017-10-17 08:19:29 +08:00
|
|
|
#define TYPE_TYPEDEF_FIELD_PROTECTED(thistype, n) \
|
|
|
|
TYPE_TYPEDEF_FIELD (thistype, n).is_protected
|
|
|
|
#define TYPE_TYPEDEF_FIELD_PRIVATE(thistype, n) \
|
|
|
|
TYPE_TYPEDEF_FIELD (thistype, n).is_private
|
2010-06-29 04:39:30 +08:00
|
|
|
|
Record nested types
GDB currently does not track types defined in classes. Consider:
class A
{
public:
class B
{
public:
class C { };
};
};
(gdb) ptype A
type = class A {
<no data fields>
}
This patch changes this behavior so that GDB records these nested types
and displays them to the user when he has set the (new) "print type"
option "nested-type-limit."
Example:
(gdb) set print type nested-type-limit 1
(gdb) ptype A
type = class A {
<no data fields>
class A::B {
<no data fields>
};
}
(gdb) set print type nested-type-limit 2
type = class A {
<no data fields>
class A::B {
<no data fields>
class A::B::C {
<no data fields>
};
};
}
By default, the code maintains the status quo, that is, it will not print
any nested type definitions at all.
Testing is carried out via cp_ptype_class which required quite a bit of
modification to permit recursive calling (for the nested types). This
was most easily facilitated by turning the ptype command output into a
queue. Upshot: the test suite now has stack and queue data structures that
may be used by test writers.
gdb/ChangeLog
* NEWS (New commands): Mention set/show print type nested-type-limit.
* c-typeprint.c (c_type_print_base): Print out nested types.
* dwarf2read.c (struct typedef_field_list): Rename to ...
(struct decl_field_list): ... this. Change all uses.
(struct field_info) <nested_types_list, nested_types_list_count>:
New fields.
(add_partial_symbol): Look for nested type definitions in C++, too.
(dwarf2_add_typedef): Rename to ...
(dwarf2_add_type_defn): ... this.
(type_can_define_types): New function.
Update assertion to use type_can_define_types.
Permit NULL for a field's name.
(process_structure_scope): Handle child DIEs of types that can
define types.
Copy the list of nested types into the type struct.
* gdbtypes.h (struct typedef_field): Rename to ...
(struct decl_field): ... this. Change all uses.
[is_protected, is_private]: New fields.
(struct cplus_struct_type) <nested_types, nested_types_count>: New
fields.
(TYPE_NESTED_TYPES_ARRAY, TYPE_NESTED_TYPES_FIELD)
(TYPE_NESTED_TYPES_FIELD_NAME, TYPE_NESTED_TYPES_FIELD_TYPE)
(TYPE_NESTED_TYPES_COUNT, TYPE_NESTED_TYPES_FIELD_PROTECTED)
(TYPE_NESTED_TYPES_FIELD_PRIVATE): New macros.
* typeprint.c (type_print_raw_options, default_ptype_flags): Add
default value for print_nested_type_limit.
(print_nested_type_limit): New static variable.
(set_print_type_nested_types, show_print_type_nested_types): New
functions.
(_initialize_typeprint): Register new commands for set/show
`print-nested-type-limit'.
* typeprint.h (struct type_print_options) [print_nested_type_limit]:
New field.
gdb/testsuite/ChangeLog
* gdb.cp/nested-types.cc: New file.
* gdb.cp/nested-types.exp: New file.
* lib/cp-support.exp: Load data-structures.exp library.
(debug_cp_test_ptype_class): New global.
(cp_ptype_class_verbose, next_line): New procedures.
(cp_test_ptype_class): Add and document new parameter `recursive_qid'.
Add and document new return value.
Switch the list of lines to a queue.
Add support for new `type' key for nested type definitions.
Add debugging/troubleshooting messages.
* lib/data-structures.exp: New file.
gdb/doc/ChangeLog
* gdb.texinfo (Symbols): Document "set print type nested-type-limit"
and "show print type nested-type-limit".
2017-12-08 07:01:30 +08:00
|
|
|
#define TYPE_NESTED_TYPES_ARRAY(thistype) \
|
|
|
|
TYPE_CPLUS_SPECIFIC (thistype)->nested_types
|
|
|
|
#define TYPE_NESTED_TYPES_FIELD(thistype, n) \
|
|
|
|
TYPE_CPLUS_SPECIFIC (thistype)->nested_types[n]
|
|
|
|
#define TYPE_NESTED_TYPES_FIELD_NAME(thistype, n) \
|
|
|
|
TYPE_NESTED_TYPES_FIELD (thistype, n).name
|
|
|
|
#define TYPE_NESTED_TYPES_FIELD_TYPE(thistype, n) \
|
|
|
|
TYPE_NESTED_TYPES_FIELD (thistype, n).type
|
|
|
|
#define TYPE_NESTED_TYPES_COUNT(thistype) \
|
|
|
|
TYPE_CPLUS_SPECIFIC (thistype)->nested_types_count
|
|
|
|
#define TYPE_NESTED_TYPES_FIELD_PROTECTED(thistype, n) \
|
|
|
|
TYPE_NESTED_TYPES_FIELD (thistype, n).is_protected
|
|
|
|
#define TYPE_NESTED_TYPES_FIELD_PRIVATE(thistype, n) \
|
|
|
|
TYPE_NESTED_TYPES_FIELD (thistype, n).is_private
|
|
|
|
|
2010-12-09 05:35:59 +08:00
|
|
|
#define TYPE_IS_OPAQUE(thistype) \
|
2020-05-15 01:46:38 +08:00
|
|
|
((((thistype)->code () == TYPE_CODE_STRUCT) \
|
|
|
|
|| ((thistype)->code () == TYPE_CODE_UNION)) \
|
2020-05-23 04:55:15 +08:00
|
|
|
&& ((thistype)->num_fields () == 0) \
|
2010-12-09 05:35:59 +08:00
|
|
|
&& (!HAVE_CPLUS_STRUCT (thistype) \
|
|
|
|
|| TYPE_NFN_FIELDS (thistype) == 0) \
|
2020-09-14 23:08:04 +08:00
|
|
|
&& ((thistype)->is_stub () || !(thistype)->stub_is_supported ()))
|
1999-07-08 04:19:36 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * A helper macro that returns the name of a type or "unnamed type"
|
|
|
|
if the type has no name. */
|
|
|
|
|
2011-10-17 22:04:37 +08:00
|
|
|
#define TYPE_SAFE_NAME(type) \
|
2020-05-17 00:16:06 +08:00
|
|
|
(type->name () != nullptr ? type->name () : _("<unnamed type>"))
|
2011-10-17 22:04:37 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * A helper macro that returns the name of an error type. If the
|
|
|
|
type has a name, it is used; otherwise, a default is used. */
|
|
|
|
|
2010-06-22 02:01:51 +08:00
|
|
|
#define TYPE_ERROR_NAME(type) \
|
2020-05-17 00:16:06 +08:00
|
|
|
(type->name () ? type->name () : _("<error type>"))
|
2010-06-22 02:01:51 +08:00
|
|
|
|
Simplify floatformat_from_type
For historical reasons, the TYPE_FLOATFORMAT element is still set to hold
an array of two floatformat structs, one for big-endian and the other for
little-endian. When accessing the element via floatformat_from_type,
the code would check the type's byte order and return the appropriate
floatformat.
However, these days this is quite unnecessary, since the type's byte order
is already known at the time the type is allocated and the floatformat is
installed into TYPE_FLOATFORMAT. Therefore, we can just install the correct
version here.
Also, moves the (now trivially simple) floatformat_from_type accessor to
gdbtypes.{c,h}, since it doesn't really need to be in doublest.c now.
gdb/ChangeLog
2017-09-27 Ulrich Weigand <uweigand@de.ibm.com>
* doublest.h (floatformat_from_type): Move to gdbtypes.h.
* doublest.c (floatformat_from_type): Move to gdbtypes.c.
* gdbtypes.h (union type_specific): Make field floatformat hold
just a single struct floatformat, not an array.
(floatformat_from_type): Move here.
* gdbtypes.c (floatformat_from_type): Move here. Update to
changed TYPE_FLOATFORMAT definition.
(verify_floatformat): Update to changed TYPE_FLOATFORMAT.
(recursive_dump_type): Likewise.
(init_float_type): Install correct floatformat for byte order.
(arch_float_type): Likewise.
2017-09-28 01:03:36 +08:00
|
|
|
/* Given TYPE, return its floatformat. */
|
|
|
|
const struct floatformat *floatformat_from_type (const struct type *type);
|
|
|
|
|
2004-07-28 10:03:52 +08:00
|
|
|
struct builtin_type
|
|
|
|
{
|
* gdbtypes.h (struct builtin_type): Remove builtin_core_addr,
nodebug_text_symbol, nodebug_data_symbol, nodebug_unknown_symbol,
and nodebug_tls_symbol members.
(struct objfile_type): New data structure.
(objfile_type): Add prototype.
* gdbtypes.c (gdbtypes_post_init): Remove initialization code
for types no longer in struct builtin_type.
(objfile_type_data): New static variable.
(_initialize_gdbtypes): Initialize it.
(objfile_type): New function.
* gdbtypes.h (builtin_type_error): Remove.
* gdbtypes.c (build_complex): Do not use builtin_type_error.
* symtab.c (builtin_type_error): Remove.
(_initialize_symtab): Remove initialization.
* stabsread.c (dbx_lookup_type, define_symbol, error_type,
rs6000_builtin_type, read_range_type): Use per-objfile types
instead of global or per-architecture builtin types.
* coffread.c (decode_type): Likewise.
* dwarf2read.c (read_array_type, read_tag_string_type,
new_symbol, die_type): Likewise.
* mdebugread.c (parse_symbol, basic_type, upgrade_type,
parse_procedure, psymtab_to_symtab_1): Likewise.
* xcoffread.c (process_xcoff_symbol): Likewise.
* parse.c (write_exp_msymbol): Likewise.
* stabsread.c (rs6000_builtin_type_data): New static variable.
(_initialize_stabsread): Initialize it.
(rs6000_builtin_type): Add OBJFILE argument. Allocate builtin
types per-objfile instead of globally.
* stabsread.c (dbx_lookup_type): Add OBJFILE argument. Use it
instead of current_objfile; pass it to rs6000_builtin_type.
(dbx_alloc_type, read_type, read_range_type): Update calls.
(cleanup_undefined_types_noname): Add OBJFILE argument and
pass it to dbx_lookup_type.
(cleanup_undefined_types): Add OBJFILE argument and pass it
to cleanup_undefined_types_noname.
* stabsread.h (cleanup_undefined_types): Add OBJFILE argument.
* buildsym.c (end_symtab): Update call.
2009-06-29 21:18:37 +08:00
|
|
|
/* Integral types. */
|
|
|
|
|
2011-02-26 10:07:10 +08:00
|
|
|
/* Implicit size/sign (based on the architecture's ABI). */
|
2022-06-02 05:31:15 +08:00
|
|
|
struct type *builtin_void = nullptr;
|
|
|
|
struct type *builtin_char = nullptr;
|
|
|
|
struct type *builtin_short = nullptr;
|
|
|
|
struct type *builtin_int = nullptr;
|
|
|
|
struct type *builtin_long = nullptr;
|
|
|
|
struct type *builtin_signed_char = nullptr;
|
|
|
|
struct type *builtin_unsigned_char = nullptr;
|
|
|
|
struct type *builtin_unsigned_short = nullptr;
|
|
|
|
struct type *builtin_unsigned_int = nullptr;
|
|
|
|
struct type *builtin_unsigned_long = nullptr;
|
|
|
|
struct type *builtin_bfloat16 = nullptr;
|
|
|
|
struct type *builtin_half = nullptr;
|
|
|
|
struct type *builtin_float = nullptr;
|
|
|
|
struct type *builtin_double = nullptr;
|
|
|
|
struct type *builtin_long_double = nullptr;
|
|
|
|
struct type *builtin_complex = nullptr;
|
|
|
|
struct type *builtin_double_complex = nullptr;
|
|
|
|
struct type *builtin_string = nullptr;
|
|
|
|
struct type *builtin_bool = nullptr;
|
|
|
|
struct type *builtin_long_long = nullptr;
|
|
|
|
struct type *builtin_unsigned_long_long = nullptr;
|
|
|
|
struct type *builtin_decfloat = nullptr;
|
|
|
|
struct type *builtin_decdouble = nullptr;
|
|
|
|
struct type *builtin_declong = nullptr;
|
* gdbtypes.h (struct builtin_type): Remove builtin_core_addr,
nodebug_text_symbol, nodebug_data_symbol, nodebug_unknown_symbol,
and nodebug_tls_symbol members.
(struct objfile_type): New data structure.
(objfile_type): Add prototype.
* gdbtypes.c (gdbtypes_post_init): Remove initialization code
for types no longer in struct builtin_type.
(objfile_type_data): New static variable.
(_initialize_gdbtypes): Initialize it.
(objfile_type): New function.
* gdbtypes.h (builtin_type_error): Remove.
* gdbtypes.c (build_complex): Do not use builtin_type_error.
* symtab.c (builtin_type_error): Remove.
(_initialize_symtab): Remove initialization.
* stabsread.c (dbx_lookup_type, define_symbol, error_type,
rs6000_builtin_type, read_range_type): Use per-objfile types
instead of global or per-architecture builtin types.
* coffread.c (decode_type): Likewise.
* dwarf2read.c (read_array_type, read_tag_string_type,
new_symbol, die_type): Likewise.
* mdebugread.c (parse_symbol, basic_type, upgrade_type,
parse_procedure, psymtab_to_symtab_1): Likewise.
* xcoffread.c (process_xcoff_symbol): Likewise.
* parse.c (write_exp_msymbol): Likewise.
* stabsread.c (rs6000_builtin_type_data): New static variable.
(_initialize_stabsread): Initialize it.
(rs6000_builtin_type): Add OBJFILE argument. Allocate builtin
types per-objfile instead of globally.
* stabsread.c (dbx_lookup_type): Add OBJFILE argument. Use it
instead of current_objfile; pass it to rs6000_builtin_type.
(dbx_alloc_type, read_type, read_range_type): Update calls.
(cleanup_undefined_types_noname): Add OBJFILE argument and
pass it to dbx_lookup_type.
(cleanup_undefined_types): Add OBJFILE argument and pass it
to cleanup_undefined_types_noname.
* stabsread.h (cleanup_undefined_types): Add OBJFILE argument.
* buildsym.c (end_symtab): Update call.
2009-06-29 21:18:37 +08:00
|
|
|
|
2009-07-02 20:44:34 +08:00
|
|
|
/* "True" character types.
|
|
|
|
We use these for the '/c' print format, because c_char is just a
|
|
|
|
one-byte integral type, which languages less laid back than C
|
|
|
|
will print as ... well, a one-byte integral type. */
|
2022-06-02 05:31:15 +08:00
|
|
|
struct type *builtin_true_char = nullptr;
|
|
|
|
struct type *builtin_true_unsigned_char = nullptr;
|
2009-07-02 20:44:34 +08:00
|
|
|
|
* gdbtypes.h (builtin_type_int0, builtin_type_int8, builtin_type_uint8,
builtin_type_int16, builtin_type_uint16, builtin_type_int32,
builtin_type_uint32, builtin_type_int64, builtin_type_uint64,
builtin_type_int128, builtin_type_uint128): Remove.
(struct builtin_type): New members builtin_int0, builtin_int8,
builtin_uint8, builtin_int16, builtin_uint16, builtin_int32,
builtin_uint32, builtin_int64, builtin_uint64, builtin_int128,
and builtin_uint128.
* gdbtypes.c (builtin_type_int0, builtin_type_int8, builtin_type_uint8,
builtin_type_int16, builtin_type_uint16, builtin_type_int32,
builtin_type_uint32, builtin_type_int64, builtin_type_uint64,
builtin_type_int128, builtin_type_uint128): Remove.
(_initialize_gdbtypes): Do not initialize them.
(gdbtypes_post_init): Initialize fixed-size integer types.
* dwarf2expr.c (unsigned_address_type, signed_address_type): Add
GDBARCH argument. Return platform-specific type.
(dwarf2_read_address, execute_stack_op): Update calls.
* target-descriptions.c (tdesc_gdb_type): Use platform-specific types
instead of global builtin_int_... variables.
* mi/mi-main.c (mi_cmd_data_read_memory): Likewise.
* printcmd.c (do_examine): Likewise.
* jv-exp.y (parse_number): Likewise.
* alpha-tdep.c (alpha_register_type, alpha_push_dummy_call,
alpha_store_return_value): Likewise.
* amd64-linux-tdep.c (amd64_linux_register_type): Likewise.
* amd64-tdep.c (amd64_register_type): Likewise.
* arm-tdep.c (arm_register_type): Likewise.
* avr-tdep.c (avr_register_type): Likewise.
* cris-tdep.c (cris_register_type, crisv32_register_type): Likewise.
* frv-tdep.c (frv_register_type): Likewise.
* h8300-tdep.c h8300_register_type): Likewise.
* hppa-tdep.c (hppa64_push_dummy_call, hppa32_register_type,
hppa64_register_type): Likewise.
* i386-tdep.c (i386_mmx_type, i386_sse_type): Likewise.
* iq2000-tdep.c (iq2000_register_type): Likewise.
* lm32-tdep.c (lm32_register_type, lm32_push_dummy_call): Likewise.
* m32r-tdep.c (m32r_register_type): Likewise.
* m68hc11-tdep.c (m68hc11_register_type, m68hc11_pseudo_register_read,
m68hc11_pseudo_register_write): Likewise.
* m68k-tdep.c (m68k_register_type): Likewise.
* m88k-tdep.c (m88k_register_type, m88k_store_arguments): Likewise.
* mep-tdep.c (mep_register_type): Likewise.
* mips-tdep.c (mips_register_type, mips_pseudo_register_type,
mips_print_fp_register): Likewise.
* moxie-tdep.c (moxie_register_type): Likewise.
* mt-tdep.c (mt_copro_register_type, mt_register_type): Likewise.
* rs6000-tdep.c (rs6000_builtin_type_vec64,
rs6000_builtin_type_vec128): Likewise.
* score-tdep.c (score_register_type): Likewise.
* sparc-tdep.c (sparc32_register_type, sparc32_store_arguments):
Likewise.
* sparc64-tdep.c (sparc64_register_type, sparc64_store_arguments):
Likewise.
* spu-tdep.c (spu_builtin_type_vec128, spu_register_type): Likewise.
* v850-tdep.c (v850_register_type): Likewise.
* xstormy16-tdep.c (xstormy16_register_type): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* mt-tdep.c (struct gdbarch_tdep): New data structure.
(mt_gdbarch_init): Alloc TDEP structures.
(mt_register_type): Cache coprocessor type in TDEP instead of
static global variable.
* xtensa-tdep.h (struct gdbarch_tdep): Add type_entries member.
* xtensa-tdep.c (type_entries): Remove.
(xtensa_register_type): Cache fixed-size types in TDEP instead
of in global variable.
2009-07-02 20:46:19 +08:00
|
|
|
/* Explicit sizes - see C9X <intypes.h> for naming scheme. The "int0"
|
|
|
|
is for when an architecture needs to describe a register that has
|
|
|
|
no size. */
|
2022-06-02 05:31:15 +08:00
|
|
|
struct type *builtin_int0 = nullptr;
|
|
|
|
struct type *builtin_int8 = nullptr;
|
|
|
|
struct type *builtin_uint8 = nullptr;
|
|
|
|
struct type *builtin_int16 = nullptr;
|
|
|
|
struct type *builtin_uint16 = nullptr;
|
|
|
|
struct type *builtin_int24 = nullptr;
|
|
|
|
struct type *builtin_uint24 = nullptr;
|
|
|
|
struct type *builtin_int32 = nullptr;
|
|
|
|
struct type *builtin_uint32 = nullptr;
|
|
|
|
struct type *builtin_int64 = nullptr;
|
|
|
|
struct type *builtin_uint64 = nullptr;
|
|
|
|
struct type *builtin_int128 = nullptr;
|
|
|
|
struct type *builtin_uint128 = nullptr;
|
* gdbtypes.h (builtin_type_int0, builtin_type_int8, builtin_type_uint8,
builtin_type_int16, builtin_type_uint16, builtin_type_int32,
builtin_type_uint32, builtin_type_int64, builtin_type_uint64,
builtin_type_int128, builtin_type_uint128): Remove.
(struct builtin_type): New members builtin_int0, builtin_int8,
builtin_uint8, builtin_int16, builtin_uint16, builtin_int32,
builtin_uint32, builtin_int64, builtin_uint64, builtin_int128,
and builtin_uint128.
* gdbtypes.c (builtin_type_int0, builtin_type_int8, builtin_type_uint8,
builtin_type_int16, builtin_type_uint16, builtin_type_int32,
builtin_type_uint32, builtin_type_int64, builtin_type_uint64,
builtin_type_int128, builtin_type_uint128): Remove.
(_initialize_gdbtypes): Do not initialize them.
(gdbtypes_post_init): Initialize fixed-size integer types.
* dwarf2expr.c (unsigned_address_type, signed_address_type): Add
GDBARCH argument. Return platform-specific type.
(dwarf2_read_address, execute_stack_op): Update calls.
* target-descriptions.c (tdesc_gdb_type): Use platform-specific types
instead of global builtin_int_... variables.
* mi/mi-main.c (mi_cmd_data_read_memory): Likewise.
* printcmd.c (do_examine): Likewise.
* jv-exp.y (parse_number): Likewise.
* alpha-tdep.c (alpha_register_type, alpha_push_dummy_call,
alpha_store_return_value): Likewise.
* amd64-linux-tdep.c (amd64_linux_register_type): Likewise.
* amd64-tdep.c (amd64_register_type): Likewise.
* arm-tdep.c (arm_register_type): Likewise.
* avr-tdep.c (avr_register_type): Likewise.
* cris-tdep.c (cris_register_type, crisv32_register_type): Likewise.
* frv-tdep.c (frv_register_type): Likewise.
* h8300-tdep.c h8300_register_type): Likewise.
* hppa-tdep.c (hppa64_push_dummy_call, hppa32_register_type,
hppa64_register_type): Likewise.
* i386-tdep.c (i386_mmx_type, i386_sse_type): Likewise.
* iq2000-tdep.c (iq2000_register_type): Likewise.
* lm32-tdep.c (lm32_register_type, lm32_push_dummy_call): Likewise.
* m32r-tdep.c (m32r_register_type): Likewise.
* m68hc11-tdep.c (m68hc11_register_type, m68hc11_pseudo_register_read,
m68hc11_pseudo_register_write): Likewise.
* m68k-tdep.c (m68k_register_type): Likewise.
* m88k-tdep.c (m88k_register_type, m88k_store_arguments): Likewise.
* mep-tdep.c (mep_register_type): Likewise.
* mips-tdep.c (mips_register_type, mips_pseudo_register_type,
mips_print_fp_register): Likewise.
* moxie-tdep.c (moxie_register_type): Likewise.
* mt-tdep.c (mt_copro_register_type, mt_register_type): Likewise.
* rs6000-tdep.c (rs6000_builtin_type_vec64,
rs6000_builtin_type_vec128): Likewise.
* score-tdep.c (score_register_type): Likewise.
* sparc-tdep.c (sparc32_register_type, sparc32_store_arguments):
Likewise.
* sparc64-tdep.c (sparc64_register_type, sparc64_store_arguments):
Likewise.
* spu-tdep.c (spu_builtin_type_vec128, spu_register_type): Likewise.
* v850-tdep.c (v850_register_type): Likewise.
* xstormy16-tdep.c (xstormy16_register_type): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* mt-tdep.c (struct gdbarch_tdep): New data structure.
(mt_gdbarch_init): Alloc TDEP structures.
(mt_register_type): Cache coprocessor type in TDEP instead of
static global variable.
* xtensa-tdep.h (struct gdbarch_tdep): Add type_entries member.
* xtensa-tdep.c (type_entries): Remove.
(xtensa_register_type): Cache fixed-size types in TDEP instead
of in global variable.
2009-07-02 20:46:19 +08:00
|
|
|
|
2010-04-22 07:21:04 +08:00
|
|
|
/* Wide character types. */
|
2022-06-02 05:31:15 +08:00
|
|
|
struct type *builtin_char16 = nullptr;
|
|
|
|
struct type *builtin_char32 = nullptr;
|
|
|
|
struct type *builtin_wchar = nullptr;
|
* gdbtypes.h (struct builtin_type): Remove builtin_core_addr,
nodebug_text_symbol, nodebug_data_symbol, nodebug_unknown_symbol,
and nodebug_tls_symbol members.
(struct objfile_type): New data structure.
(objfile_type): Add prototype.
* gdbtypes.c (gdbtypes_post_init): Remove initialization code
for types no longer in struct builtin_type.
(objfile_type_data): New static variable.
(_initialize_gdbtypes): Initialize it.
(objfile_type): New function.
* gdbtypes.h (builtin_type_error): Remove.
* gdbtypes.c (build_complex): Do not use builtin_type_error.
* symtab.c (builtin_type_error): Remove.
(_initialize_symtab): Remove initialization.
* stabsread.c (dbx_lookup_type, define_symbol, error_type,
rs6000_builtin_type, read_range_type): Use per-objfile types
instead of global or per-architecture builtin types.
* coffread.c (decode_type): Likewise.
* dwarf2read.c (read_array_type, read_tag_string_type,
new_symbol, die_type): Likewise.
* mdebugread.c (parse_symbol, basic_type, upgrade_type,
parse_procedure, psymtab_to_symtab_1): Likewise.
* xcoffread.c (process_xcoff_symbol): Likewise.
* parse.c (write_exp_msymbol): Likewise.
* stabsread.c (rs6000_builtin_type_data): New static variable.
(_initialize_stabsread): Initialize it.
(rs6000_builtin_type): Add OBJFILE argument. Allocate builtin
types per-objfile instead of globally.
* stabsread.c (dbx_lookup_type): Add OBJFILE argument. Use it
instead of current_objfile; pass it to rs6000_builtin_type.
(dbx_alloc_type, read_type, read_range_type): Update calls.
(cleanup_undefined_types_noname): Add OBJFILE argument and
pass it to dbx_lookup_type.
(cleanup_undefined_types): Add OBJFILE argument and pass it
to cleanup_undefined_types_noname.
* stabsread.h (cleanup_undefined_types): Add OBJFILE argument.
* buildsym.c (end_symtab): Update call.
2009-06-29 21:18:37 +08:00
|
|
|
|
|
|
|
/* Pointer types. */
|
2004-07-28 10:03:52 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * `pointer to data' type. Some target platforms use an implicitly
|
2004-07-28 10:03:52 +08:00
|
|
|
{sign,zero} -extended 32-bit ABI pointer on a 64-bit ISA. */
|
2022-06-02 05:31:15 +08:00
|
|
|
struct type *builtin_data_ptr = nullptr;
|
2004-07-28 10:03:52 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * `pointer to function (returning void)' type. Harvard
|
2004-07-28 10:03:52 +08:00
|
|
|
architectures mean that ABI function and code pointers are not
|
|
|
|
interconvertible. Similarly, since ANSI, C standards have
|
|
|
|
explicitly said that pointers to functions and pointers to data
|
|
|
|
are not interconvertible --- that is, you can't cast a function
|
|
|
|
pointer to void * and back, and expect to get the same value.
|
|
|
|
However, all function pointer types are interconvertible, so void
|
|
|
|
(*) () can server as a generic function pointer. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2022-06-02 05:31:15 +08:00
|
|
|
struct type *builtin_func_ptr = nullptr;
|
2009-07-02 20:11:19 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * `function returning pointer to function (returning void)' type.
|
2011-03-29 04:21:04 +08:00
|
|
|
The final void return type is not significant for it. */
|
|
|
|
|
2022-06-02 05:31:15 +08:00
|
|
|
struct type *builtin_func_func = nullptr;
|
2009-07-02 20:11:19 +08:00
|
|
|
|
|
|
|
/* Special-purpose types. */
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * This type is used to represent a GDB internal function. */
|
|
|
|
|
2022-06-02 05:31:15 +08:00
|
|
|
struct type *internal_fn = nullptr;
|
2014-05-20 21:30:29 +08:00
|
|
|
|
|
|
|
/* * This type is used to represent an xmethod. */
|
2022-06-02 05:31:15 +08:00
|
|
|
struct type *xmethod = nullptr;
|
2023-03-12 00:51:23 +08:00
|
|
|
|
|
|
|
/* * This type is used to represent symbol addresses. */
|
|
|
|
struct type *builtin_core_addr = nullptr;
|
|
|
|
|
|
|
|
/* * This type represents a type that was unrecognized in symbol
|
|
|
|
read-in. */
|
|
|
|
struct type *builtin_error = nullptr;
|
|
|
|
|
|
|
|
/* * Types used for symbols with no debug information. */
|
|
|
|
struct type *nodebug_text_symbol = nullptr;
|
|
|
|
struct type *nodebug_text_gnu_ifunc_symbol = nullptr;
|
|
|
|
struct type *nodebug_got_plt_symbol = nullptr;
|
|
|
|
struct type *nodebug_data_symbol = nullptr;
|
|
|
|
struct type *nodebug_unknown_symbol = nullptr;
|
|
|
|
struct type *nodebug_tls_symbol = nullptr;
|
* gdbtypes.h (struct builtin_type): Remove builtin_core_addr,
nodebug_text_symbol, nodebug_data_symbol, nodebug_unknown_symbol,
and nodebug_tls_symbol members.
(struct objfile_type): New data structure.
(objfile_type): Add prototype.
* gdbtypes.c (gdbtypes_post_init): Remove initialization code
for types no longer in struct builtin_type.
(objfile_type_data): New static variable.
(_initialize_gdbtypes): Initialize it.
(objfile_type): New function.
* gdbtypes.h (builtin_type_error): Remove.
* gdbtypes.c (build_complex): Do not use builtin_type_error.
* symtab.c (builtin_type_error): Remove.
(_initialize_symtab): Remove initialization.
* stabsread.c (dbx_lookup_type, define_symbol, error_type,
rs6000_builtin_type, read_range_type): Use per-objfile types
instead of global or per-architecture builtin types.
* coffread.c (decode_type): Likewise.
* dwarf2read.c (read_array_type, read_tag_string_type,
new_symbol, die_type): Likewise.
* mdebugread.c (parse_symbol, basic_type, upgrade_type,
parse_procedure, psymtab_to_symtab_1): Likewise.
* xcoffread.c (process_xcoff_symbol): Likewise.
* parse.c (write_exp_msymbol): Likewise.
* stabsread.c (rs6000_builtin_type_data): New static variable.
(_initialize_stabsread): Initialize it.
(rs6000_builtin_type): Add OBJFILE argument. Allocate builtin
types per-objfile instead of globally.
* stabsread.c (dbx_lookup_type): Add OBJFILE argument. Use it
instead of current_objfile; pass it to rs6000_builtin_type.
(dbx_alloc_type, read_type, read_range_type): Update calls.
(cleanup_undefined_types_noname): Add OBJFILE argument and
pass it to dbx_lookup_type.
(cleanup_undefined_types): Add OBJFILE argument and pass it
to cleanup_undefined_types_noname.
* stabsread.h (cleanup_undefined_types): Add OBJFILE argument.
* buildsym.c (end_symtab): Update call.
2009-06-29 21:18:37 +08:00
|
|
|
};
|
2004-07-28 10:03:52 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Return the type table for the specified architecture. */
|
2007-06-22 20:27:00 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
|
2007-06-22 20:27:00 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Return the type table for the specified objfile. */
|
1999-07-08 04:19:36 +08:00
|
|
|
|
2023-03-12 00:58:15 +08:00
|
|
|
extern const struct builtin_type *builtin_type (struct objfile *objfile);
|
* gdbtypes.h (builtin_type_true_char, builtin_type_void,
builtin_type_char, builtin_type_short, builtin_type_int,
builtin_type_long, builtin_type_signed_char,
builtin_type_unsigned_char, builtin_type_unsigned_short,
builtin_type_unsigned_int, builtin_type_unsigned_long,
builtin_type_float, builtin_type_double, builtin_type_long_double,
builtin_type_complex, builtin_type_double_complex, builtin_type_string,
builtin_type_bool, builtin_type_long_long,
builtin_type_unsigned_long_long, builtin_type_void_data_ptr,
builtin_type_void_func_ptr, builtin_type_CORE_ADDR): Replace global
variable declaration with compatibility macro.
* gdbtypes.c (builtin_type_true_char, builtin_type_void,
builtin_type_char, builtin_type_short, builtin_type_int,
builtin_type_long, builtin_type_signed_char,
builtin_type_unsigned_char, builtin_type_unsigned_short,
builtin_type_unsigned_int, builtin_type_unsigned_long,
builtin_type_float, builtin_type_double, builtin_type_long_double,
builtin_type_complex, builtin_type_double_complex, builtin_type_string,
builtin_type_bool, builtin_type_long_long,
builtin_type_unsigned_long_long, builtin_type_void_data_ptr,
builtin_type_void_func_ptr, builtin_type_CORE_ADDR): Remove.
(build_gdbtypes): Remove.
(_initialize_gdbtypes): Do not call build_gdbtypes, move installing
opaque-type-resolution command here. Do not call
deprecated_register_gdbarch_swap.
2007-06-22 20:32:19 +08:00
|
|
|
|
* gdbtypes.h (builtin_type_ieee_single_big)
(builtin_type_ieee_single_little, builtin_type_ieee_double_big)
(builtin_type_ieee_double_little)
(builtin_type_ieee_double_littlebyte_bigword)
(builtin_type_i387_ext, builtin_type_m68881_ext)
(builtin_type_i960_ext, builtin_type_m88110_ext)
(builtin_type_m88110_harris_ext, builtin_type_arm_ext_big)
(builtin_type_arm_ext_littlebyte_bigword)
(builtin_type_ia64_spill_big, builtin_type_ia64_spill_little)
(builtin_type_ia64_quad_big)
(builtin_type_ia64_quad_little): Declare.
* gdbtypes.c (builtin_type_ieee_single_big)
(builtin_type_ieee_single_little, builtin_type_ieee_double_big)
(builtin_type_ieee_double_little)
(builtin_type_ieee_double_littlebyte_bigword)
(builtin_type_i387_ext, builtin_type_m68881_ext)
(builtin_type_i960_ext, builtin_type_m88110_ext)
(builtin_type_m88110_harris_ext, builtin_type_arm_ext_big)
(builtin_type_arm_ext_littlebyte_bigword)
(builtin_type_ia64_spill_big, builtin_type_ia64_spill_little)
(builtin_type_ia64_quad_big)
(builtin_type_ia64_quad_little): Define.
(_initialize_gdbtypes): Initialize builtin floatformat types.
2001-08-24 12:46:43 +08:00
|
|
|
/* Explicit floating-point formats. See "floatformat.h". */
|
2010-07-06 20:56:24 +08:00
|
|
|
extern const struct floatformat *floatformats_ieee_half[BFD_ENDIAN_UNKNOWN];
|
* doublest.c (floatformat_from_length): Use the right element from
gdbarch floatformats.
(floatformat_from_type, extract_typed_floating)
(store_typed_floating): Likewise.
* doublest.h: Remove declarations for undefined floatformat arrays.
* gdbarch.sh (float_format, double_format, long_double_format): Change
to pairs.
(pformat): Update for pairs.
* gdbarch.c, gdbarch.h: Regenerated.
* gdbtypes.c (floatformats_ieee_single, floatformats_ieee_double)
(floatformats_ieee_double_littlebyte_bigword)
(floatformats_i387_ext, floatformats_m68881_ext, floatformats_arm_ext)
(floatformats_ia64_spill, floatformats_ia64_quad, floatformats_vax_f)
(floatformats_vax_d): New variables.
(builtin_type_ieee_single, builtin_type_ieee_double)
(builtin_type_arm_ext, builtin_type_ia64_spill)
(builtin_type_ia64_quad): Replace arrays with individual types.
(builtin_type_ieee_single_big, builtin_type_ieee_single_little)
(builtin_type_ieee_double_big, builtin_type_ieee_double_little)
(builtin_type_ieee_double_littlebyte_bigword, builtin_type_i960_ext)
(builtin_type_m88110_ext, builtin_type_m88110_harris_ext)
(builtin_type_arm_ext_big, builtin_type_arm_ext_littlebyte_bigword)
(builtin_type_ia64_spill_big, builtin_type_ia64_spill_little)
(builtin_type_ia64_quad_big, builtin_type_ia64_quad_little): Delete
unused and endian-specific types.
(recursive_dump_type): Update for floatformat pairs.
(build_flt): Move higher. Handle bit == -1. Take a floatformat pair.
(build_gdbtypes): Use build_flt.
(_initialize_gdbtypes): Update set of initialized types.
* gdbtypes.h: Update declarations to match gdbtypes.c.
(struct main_type): Store a pointer to two floatformats.
* arch-utils.c (default_float_format, default_double_format): Delete.
* arch-utils.h (default_float_format, default_double_format): Delete.
* arm-tdep.c, avr-tdep.c, hppa-tdep.c, hppabsd-tdep.c, i386-tdep.c,
ia64-tdep.c, iq2000-tdep.c, m68k-tdep.c, m88k-tdep.c,
mips-linux-tdep.c, mips-tdep.c, mt-tdep.c, ppcobsd-tdep.c,
sparc-linux-tdep.c, sparc-tdep.c, sparcnbsd-tdep.c, spu-tdep.c,
vax-tdep.c, alpha-tdep.c, ppc-sysv-tdep.c: Update.
2007-01-30 01:31:06 +08:00
|
|
|
extern const struct floatformat *floatformats_ieee_single[BFD_ENDIAN_UNKNOWN];
|
|
|
|
extern const struct floatformat *floatformats_ieee_double[BFD_ENDIAN_UNKNOWN];
|
2022-03-21 14:43:41 +08:00
|
|
|
extern const struct floatformat *floatformats_ieee_quad[BFD_ENDIAN_UNKNOWN];
|
* doublest.c (floatformat_from_length): Use the right element from
gdbarch floatformats.
(floatformat_from_type, extract_typed_floating)
(store_typed_floating): Likewise.
* doublest.h: Remove declarations for undefined floatformat arrays.
* gdbarch.sh (float_format, double_format, long_double_format): Change
to pairs.
(pformat): Update for pairs.
* gdbarch.c, gdbarch.h: Regenerated.
* gdbtypes.c (floatformats_ieee_single, floatformats_ieee_double)
(floatformats_ieee_double_littlebyte_bigword)
(floatformats_i387_ext, floatformats_m68881_ext, floatformats_arm_ext)
(floatformats_ia64_spill, floatformats_ia64_quad, floatformats_vax_f)
(floatformats_vax_d): New variables.
(builtin_type_ieee_single, builtin_type_ieee_double)
(builtin_type_arm_ext, builtin_type_ia64_spill)
(builtin_type_ia64_quad): Replace arrays with individual types.
(builtin_type_ieee_single_big, builtin_type_ieee_single_little)
(builtin_type_ieee_double_big, builtin_type_ieee_double_little)
(builtin_type_ieee_double_littlebyte_bigword, builtin_type_i960_ext)
(builtin_type_m88110_ext, builtin_type_m88110_harris_ext)
(builtin_type_arm_ext_big, builtin_type_arm_ext_littlebyte_bigword)
(builtin_type_ia64_spill_big, builtin_type_ia64_spill_little)
(builtin_type_ia64_quad_big, builtin_type_ia64_quad_little): Delete
unused and endian-specific types.
(recursive_dump_type): Update for floatformat pairs.
(build_flt): Move higher. Handle bit == -1. Take a floatformat pair.
(build_gdbtypes): Use build_flt.
(_initialize_gdbtypes): Update set of initialized types.
* gdbtypes.h: Update declarations to match gdbtypes.c.
(struct main_type): Store a pointer to two floatformats.
* arch-utils.c (default_float_format, default_double_format): Delete.
* arch-utils.h (default_float_format, default_double_format): Delete.
* arm-tdep.c, avr-tdep.c, hppa-tdep.c, hppabsd-tdep.c, i386-tdep.c,
ia64-tdep.c, iq2000-tdep.c, m68k-tdep.c, m88k-tdep.c,
mips-linux-tdep.c, mips-tdep.c, mt-tdep.c, ppcobsd-tdep.c,
sparc-linux-tdep.c, sparc-tdep.c, sparcnbsd-tdep.c, spu-tdep.c,
vax-tdep.c, alpha-tdep.c, ppc-sysv-tdep.c: Update.
2007-01-30 01:31:06 +08:00
|
|
|
extern const struct floatformat *floatformats_ieee_double_littlebyte_bigword[BFD_ENDIAN_UNKNOWN];
|
|
|
|
extern const struct floatformat *floatformats_i387_ext[BFD_ENDIAN_UNKNOWN];
|
|
|
|
extern const struct floatformat *floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN];
|
|
|
|
extern const struct floatformat *floatformats_arm_ext[BFD_ENDIAN_UNKNOWN];
|
|
|
|
extern const struct floatformat *floatformats_ia64_spill[BFD_ENDIAN_UNKNOWN];
|
|
|
|
extern const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN];
|
|
|
|
extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
|
include:
2007-11-07 Joseph Myers <joseph@codesourcery.com>
Daniel Jacobowitz <dan@codesourcery.com>
* floatformat.h (struct floatformat): Add split_half field.
(floatformat_ibm_long_double): New.
libiberty:
2007-11-07 Joseph Myers <joseph@codesourcery.com>
Daniel Jacobowitz <dan@codesourcery.com>
* floatformat.c (mant_bits_set): New.
(floatformat_to_double): Use it. Note no special handling of
split formats.
(floatformat_from_double): Note no special handing of split
formats.
(floatformat_ibm_long_double_is_valid,
floatformat_ibm_long_double): New.
(floatformat_ieee_single_big, floatformat_ieee_single_little,
floatformat_ieee_double_big, floatformat_ieee_double_little,
floatformat_ieee_double_littlebyte_bigword, floatformat_vax_f,
floatformat_vax_d, floatformat_vax_g, floatformat_i387_ext,
floatformat_m68881_ext, floatformat_i960_ext,
floatformat_m88110_ext, floatformat_m88110_harris_ext,
floatformat_arm_ext_big, floatformat_arm_ext_littlebyte_bigword,
floatformat_ia64_spill_big, floatformat_ia64_spill_little,
floatformat_ia64_quad_big, floatformat_ia64_quad_little): Update
for addition of split_half field.
gdb:
2007-11-07 Joseph Myers <joseph@codesourcery.com>
Daniel Jacobowitz <dan@codesourcery.com>
* gdbtypes.c (floatformats_ibm_long_double): New.
* gdbtypes.h (floatformats_ibm_long_double): Declare.
* ia64-tdep.c (floatformat_ia64_ext): Update for addition of
split_half field.
* mips-tdep.c (n32n64_floatformat_always_valid,
floatformat_n32n64_long_double_big, floatformats_n32n64_long):
Remove.
(mips_gdbarch_init): Use floatformats_ibm_long_double instead of
floatformats_n32n64_long.
* ppc-linux-tdep.c (ppc_linux_init_abi): Use 128-bit IBM long
double.
* doublest.c (convert_floatformat_to_doublest,
convert_doublest_to_floatformat): Handle split floating-point
formats.
* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Handle IBM long
double arguments.
(ppc64_sysv_abi_push_dummy_call): Likewise.
(do_ppc_sysv_return_value): Handle IBM long double return.
2007-11-08 08:08:48 +08:00
|
|
|
extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN];
|
2020-09-10 20:29:53 +08:00
|
|
|
extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN];
|
2008-09-11 22:20:50 +08:00
|
|
|
|
gdb: Don't leak memory with TYPE_ALLOC / TYPE_ZALLOC
This patch started as an observation from valgrind that GDB appeared
to be loosing track of some memory associated with types. An example
valgrind stack would be:
24 bytes in 1 blocks are possibly lost in loss record 419 of 5,361
at 0x4C2EA1E: calloc (vg_replace_malloc.c:711)
by 0x623D26: xcalloc (common-utils.c:85)
by 0x623D65: xzalloc(unsigned long) (common-utils.c:95)
by 0x72A066: make_function_type(type*, type**) (gdbtypes.c:510)
by 0x72A098: lookup_function_type(type*) (gdbtypes.c:521)
by 0x73635D: gdbtypes_post_init(gdbarch*) (gdbtypes.c:5439)
by 0x727590: gdbarch_data(gdbarch*, gdbarch_data*) (gdbarch.c:5230)
by 0x735B99: builtin_type(gdbarch*) (gdbtypes.c:5313)
by 0x514D95: elf_rel_plt_read(minimal_symbol_reader&, objfile*, bfd_symbol**) (elfread.c:542)
by 0x51662F: elf_read_minimal_symbols(objfile*, int, elfinfo const*) (elfread.c:1121)
by 0x5168A5: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1207)
by 0x8520F5: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:794)
When we look in make_function_type we find a call to TYPE_ZALLOC
(inside the INIT_FUNC_SPECIFIC macro). It is this call to TYPE_ZALLOC
that is allocating memory with xcalloc, that is then getting lost.
The problem is tht calling TYPE_ALLOC or TYPE_ZALLOC currently
allocates memory from either the objfile obstack or by using malloc.
The problem with this is that types are allocated either on the
objfile obstack, or on the gdbarch obstack.
As a result, if we discard a type associated with an objfile then
auxiliary data allocated with TYPE_(Z)ALLOC will be correctly
discarded. But, if we were ever to discard a gdbarch then any
auxiliary type data would be leaked. Right now there are very few
places in GDB where a gdbarch is ever discarded, but it shouldn't hurt
to close down these bugs as we spot them.
This commit ensures that auxiliary type data is allocated from the
same obstack as the type itself, which should reduce leaked memory.
The one problem case that I found with this change was in eval.c,
where in one place we allocate a local type structure, and then used
TYPE_ZALLOC to allocate some space for the type. This local type is
neither object file owned, nor gdbarch owned, and so the updated
TYPE_ALLOC code is unable to find an objstack to allocate space on.
My proposed solution for this issue is that the space should be
allocated with a direct call to xzalloc. We could extend TYPE_ALLOC
to check for type->gdbarch being null, and then fall back to a direct
call to xzalloc, however, I think that making this rare case of a
local type require special handling is not a bad thing, this serves to
highlight that clearing up the memory will require special handling
too.
This special case of a local type is interesting as the types owner
field (contained within the main_type) is completely null. While
reflecting on this I looked at how types use the get_type_arch
function. It seems clear that, based on how this is used, it is never
intended that null will be returned from this function. This only
goes to reinforce, how locally alloctaed types, with no owner, are
both special, and need to be handled carefully. To help spot errors
earlier, I added an assert into get_type_arch that the returned arch
is not null.
Inside gdbarch.c I found a few other places where auxiliary type data
was being allocated directly on the heap rather than on the types
obstack. I have fixed these to call TYPE_ALLOC now.
Finally, it is worth noting that as we don't clean up our gdbarch
objects yet, then this will not make much of an impact on the amount
of memory reported as lost at program termination time. Memory
allocated for auxiliary type information is still not freed, however,
it is now on the correct obstack. If we do ever start freeing our
gdbarch structures then the associated type data will be cleaned up
correctly.
Tested on X86-64 GNU/Linux with no regressions.
gdb/ChangeLog:
* eval.c (fake_method::fake_method): Call xzalloc directly for a
type that is neither object file owned, nor gdbarch owned.
* gdbtypes.c (get_type_gdbarch): Add an assert that returned
gdbarch is non-NULL.
(alloc_type_instance): Allocate non-objfile owned types on the
gdbarch obstack.
(copy_type_recursive): Allocate TYPE_FIELDS and TYPE_RANGE_DATA
using TYPE_ALLOC to ensure memory is allocated on the correct
obstack.
* gdbtypes.h (TYPE_ALLOC): Allocate space on either the objfile
obstack, or the gdbarch obstack.
(TYPE_ZALLOC): Rewrite using TYPE_ALLOC.
2018-09-10 20:50:34 +08:00
|
|
|
/* Allocate space for storing data associated with a particular
|
2014-03-13 10:36:45 +08:00
|
|
|
type. We ensure that the space is allocated using the same
|
|
|
|
mechanism that was used to allocate the space for the type
|
|
|
|
structure itself. I.e. if the type is on an objfile's
|
|
|
|
objfile_obstack, then the space for data associated with that type
|
gdb: Don't leak memory with TYPE_ALLOC / TYPE_ZALLOC
This patch started as an observation from valgrind that GDB appeared
to be loosing track of some memory associated with types. An example
valgrind stack would be:
24 bytes in 1 blocks are possibly lost in loss record 419 of 5,361
at 0x4C2EA1E: calloc (vg_replace_malloc.c:711)
by 0x623D26: xcalloc (common-utils.c:85)
by 0x623D65: xzalloc(unsigned long) (common-utils.c:95)
by 0x72A066: make_function_type(type*, type**) (gdbtypes.c:510)
by 0x72A098: lookup_function_type(type*) (gdbtypes.c:521)
by 0x73635D: gdbtypes_post_init(gdbarch*) (gdbtypes.c:5439)
by 0x727590: gdbarch_data(gdbarch*, gdbarch_data*) (gdbarch.c:5230)
by 0x735B99: builtin_type(gdbarch*) (gdbtypes.c:5313)
by 0x514D95: elf_rel_plt_read(minimal_symbol_reader&, objfile*, bfd_symbol**) (elfread.c:542)
by 0x51662F: elf_read_minimal_symbols(objfile*, int, elfinfo const*) (elfread.c:1121)
by 0x5168A5: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1207)
by 0x8520F5: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:794)
When we look in make_function_type we find a call to TYPE_ZALLOC
(inside the INIT_FUNC_SPECIFIC macro). It is this call to TYPE_ZALLOC
that is allocating memory with xcalloc, that is then getting lost.
The problem is tht calling TYPE_ALLOC or TYPE_ZALLOC currently
allocates memory from either the objfile obstack or by using malloc.
The problem with this is that types are allocated either on the
objfile obstack, or on the gdbarch obstack.
As a result, if we discard a type associated with an objfile then
auxiliary data allocated with TYPE_(Z)ALLOC will be correctly
discarded. But, if we were ever to discard a gdbarch then any
auxiliary type data would be leaked. Right now there are very few
places in GDB where a gdbarch is ever discarded, but it shouldn't hurt
to close down these bugs as we spot them.
This commit ensures that auxiliary type data is allocated from the
same obstack as the type itself, which should reduce leaked memory.
The one problem case that I found with this change was in eval.c,
where in one place we allocate a local type structure, and then used
TYPE_ZALLOC to allocate some space for the type. This local type is
neither object file owned, nor gdbarch owned, and so the updated
TYPE_ALLOC code is unable to find an objstack to allocate space on.
My proposed solution for this issue is that the space should be
allocated with a direct call to xzalloc. We could extend TYPE_ALLOC
to check for type->gdbarch being null, and then fall back to a direct
call to xzalloc, however, I think that making this rare case of a
local type require special handling is not a bad thing, this serves to
highlight that clearing up the memory will require special handling
too.
This special case of a local type is interesting as the types owner
field (contained within the main_type) is completely null. While
reflecting on this I looked at how types use the get_type_arch
function. It seems clear that, based on how this is used, it is never
intended that null will be returned from this function. This only
goes to reinforce, how locally alloctaed types, with no owner, are
both special, and need to be handled carefully. To help spot errors
earlier, I added an assert into get_type_arch that the returned arch
is not null.
Inside gdbarch.c I found a few other places where auxiliary type data
was being allocated directly on the heap rather than on the types
obstack. I have fixed these to call TYPE_ALLOC now.
Finally, it is worth noting that as we don't clean up our gdbarch
objects yet, then this will not make much of an impact on the amount
of memory reported as lost at program termination time. Memory
allocated for auxiliary type information is still not freed, however,
it is now on the correct obstack. If we do ever start freeing our
gdbarch structures then the associated type data will be cleaned up
correctly.
Tested on X86-64 GNU/Linux with no regressions.
gdb/ChangeLog:
* eval.c (fake_method::fake_method): Call xzalloc directly for a
type that is neither object file owned, nor gdbarch owned.
* gdbtypes.c (get_type_gdbarch): Add an assert that returned
gdbarch is non-NULL.
(alloc_type_instance): Allocate non-objfile owned types on the
gdbarch obstack.
(copy_type_recursive): Allocate TYPE_FIELDS and TYPE_RANGE_DATA
using TYPE_ALLOC to ensure memory is allocated on the correct
obstack.
* gdbtypes.h (TYPE_ALLOC): Allocate space on either the objfile
obstack, or the gdbarch obstack.
(TYPE_ZALLOC): Rewrite using TYPE_ALLOC.
2018-09-10 20:50:34 +08:00
|
|
|
will also be allocated on the objfile_obstack. If the type is
|
|
|
|
associated with a gdbarch, then the space for data associated with that
|
|
|
|
type will also be allocated on the gdbarch_obstack.
|
|
|
|
|
|
|
|
If a type is not associated with neither an objfile or a gdbarch then
|
|
|
|
you should not use this macro to allocate space for data, instead you
|
|
|
|
should call xmalloc directly, and ensure the memory is correctly freed
|
|
|
|
when it is no longer needed. */
|
|
|
|
|
|
|
|
#define TYPE_ALLOC(t,size) \
|
2021-01-23 01:23:40 +08:00
|
|
|
(obstack_alloc (((t)->is_objfile_owned () \
|
2021-01-28 23:09:02 +08:00
|
|
|
? &((t)->objfile_owner ()->objfile_obstack) \
|
|
|
|
: gdbarch_obstack ((t)->arch_owner ())), \
|
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
|
|
|
size))
|
gdb: Don't leak memory with TYPE_ALLOC / TYPE_ZALLOC
This patch started as an observation from valgrind that GDB appeared
to be loosing track of some memory associated with types. An example
valgrind stack would be:
24 bytes in 1 blocks are possibly lost in loss record 419 of 5,361
at 0x4C2EA1E: calloc (vg_replace_malloc.c:711)
by 0x623D26: xcalloc (common-utils.c:85)
by 0x623D65: xzalloc(unsigned long) (common-utils.c:95)
by 0x72A066: make_function_type(type*, type**) (gdbtypes.c:510)
by 0x72A098: lookup_function_type(type*) (gdbtypes.c:521)
by 0x73635D: gdbtypes_post_init(gdbarch*) (gdbtypes.c:5439)
by 0x727590: gdbarch_data(gdbarch*, gdbarch_data*) (gdbarch.c:5230)
by 0x735B99: builtin_type(gdbarch*) (gdbtypes.c:5313)
by 0x514D95: elf_rel_plt_read(minimal_symbol_reader&, objfile*, bfd_symbol**) (elfread.c:542)
by 0x51662F: elf_read_minimal_symbols(objfile*, int, elfinfo const*) (elfread.c:1121)
by 0x5168A5: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1207)
by 0x8520F5: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:794)
When we look in make_function_type we find a call to TYPE_ZALLOC
(inside the INIT_FUNC_SPECIFIC macro). It is this call to TYPE_ZALLOC
that is allocating memory with xcalloc, that is then getting lost.
The problem is tht calling TYPE_ALLOC or TYPE_ZALLOC currently
allocates memory from either the objfile obstack or by using malloc.
The problem with this is that types are allocated either on the
objfile obstack, or on the gdbarch obstack.
As a result, if we discard a type associated with an objfile then
auxiliary data allocated with TYPE_(Z)ALLOC will be correctly
discarded. But, if we were ever to discard a gdbarch then any
auxiliary type data would be leaked. Right now there are very few
places in GDB where a gdbarch is ever discarded, but it shouldn't hurt
to close down these bugs as we spot them.
This commit ensures that auxiliary type data is allocated from the
same obstack as the type itself, which should reduce leaked memory.
The one problem case that I found with this change was in eval.c,
where in one place we allocate a local type structure, and then used
TYPE_ZALLOC to allocate some space for the type. This local type is
neither object file owned, nor gdbarch owned, and so the updated
TYPE_ALLOC code is unable to find an objstack to allocate space on.
My proposed solution for this issue is that the space should be
allocated with a direct call to xzalloc. We could extend TYPE_ALLOC
to check for type->gdbarch being null, and then fall back to a direct
call to xzalloc, however, I think that making this rare case of a
local type require special handling is not a bad thing, this serves to
highlight that clearing up the memory will require special handling
too.
This special case of a local type is interesting as the types owner
field (contained within the main_type) is completely null. While
reflecting on this I looked at how types use the get_type_arch
function. It seems clear that, based on how this is used, it is never
intended that null will be returned from this function. This only
goes to reinforce, how locally alloctaed types, with no owner, are
both special, and need to be handled carefully. To help spot errors
earlier, I added an assert into get_type_arch that the returned arch
is not null.
Inside gdbarch.c I found a few other places where auxiliary type data
was being allocated directly on the heap rather than on the types
obstack. I have fixed these to call TYPE_ALLOC now.
Finally, it is worth noting that as we don't clean up our gdbarch
objects yet, then this will not make much of an impact on the amount
of memory reported as lost at program termination time. Memory
allocated for auxiliary type information is still not freed, however,
it is now on the correct obstack. If we do ever start freeing our
gdbarch structures then the associated type data will be cleaned up
correctly.
Tested on X86-64 GNU/Linux with no regressions.
gdb/ChangeLog:
* eval.c (fake_method::fake_method): Call xzalloc directly for a
type that is neither object file owned, nor gdbarch owned.
* gdbtypes.c (get_type_gdbarch): Add an assert that returned
gdbarch is non-NULL.
(alloc_type_instance): Allocate non-objfile owned types on the
gdbarch obstack.
(copy_type_recursive): Allocate TYPE_FIELDS and TYPE_RANGE_DATA
using TYPE_ALLOC to ensure memory is allocated on the correct
obstack.
* gdbtypes.h (TYPE_ALLOC): Allocate space on either the objfile
obstack, or the gdbarch obstack.
(TYPE_ZALLOC): Rewrite using TYPE_ALLOC.
2018-09-10 20:50:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* See comment on TYPE_ALLOC. */
|
|
|
|
|
|
|
|
#define TYPE_ZALLOC(t,size) (memset (TYPE_ALLOC (t, size), 0, size))
|
gdb/
* Makefile.in (gdbtypes_h, gdbtypes.o, utils.o): Update.
* defs.h (hashtab_obstack_allocate, dummy_obstack_deallocate): Add
prototypes.
* dwarf2read.c (read_subroutine_type): Use TYPE_ZALLOC.
(hashtab_obstack_allocate, dummy_obstack_deallocate): Moved to...
* utils.c (hashtab_obstack_allocate, dummy_obstack_deallocate):
...here.
* gdbtypes.c: Include "hashtab.h".
(build_gdbtypes): Remove extra prototype.
(struct type_pair, type_pair_hash, type_pair_eq)
(create_copied_types_hash, copy_type_recursive): New.
* gdbtypes.h: Include "hashtab.h".
(TYPE_ZALLOC): New.
(create_copied_types_hash, copy_type_recursive): New prototypes.
* objfiles.c (free_objfile): Call preserve_values.
* symfile.c (reread_symbols): Likewise.
(clear_symtab_users): Remove calls to clear_value_history and
clear_internalvars.
* value.c (clear_value_history, clear_internalvars): Removed.
(preserve_one_value, preserve_values): New functions.
* value.h (clear_value_history, clear_internalvars): Removed.
(preserve_values): New prototype.
* tracepoint.c (_initialize_tracepoint): Do not initialize convenience
variables here.
gdb/doc/
* gdb.texinfo (Files): Remove obsolete bits from the description
of "symbol-file".
2006-02-02 07:14:11 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * This returns the target type (or NULL) of TYPE, also skipping
|
gdb/
* Makefile.in (SFILES): Add c-varobj.c and jv-varobj.c.
(COMMON_OBS): Add c-varobj.o and jv-varobj.o.
* ada-varobj.c: Include "varobj.h".
(ada_number_of_children): New. Moved from varobj.c.
(ada_name_of_variable, ada_name_of_child): Likewise.
(ada_path_expr_of_child, ada_value_of_child): Likewise.
(ada_type_of_child, ada_value_of_variable): Likewise.
(ada_value_is_changeable_p, ada_value_has_mutated): Likewise.
(ada_varobj_ops): New.
* c-varobj.c, jv-varobj.c: New file. Moved from varobj.c.
* gdbtypes.c (get_target_type): New. Moved from varobj.c.
* gdbtypes.h (get_target_type): Declare.
* varobj.c: Remove the inclusion of "ada-varobj.h" and
"ada-lang.h".
(ANONYMOUS_STRUCT_NAME): Move it to c-varobj.c.
(ANONYMOUS_UNION_NAME): Likewise.
(get_type, get_value_type, get_target_type): Remove declarations.
(value_get_print_value, varobj_value_get_print_value): Likewise.
(c_number_of_children, c_name_of_variable): Likewise.
(c_name_of_child, c_path_expr_of_child): Likewise.
(c_value_of_child, c_type_of_child): Likewise.
(c_value_of_variable, cplus_number_of_children): Likewise.
(cplus_class_num_children, cplus_name_of_variable): Likewise.
(cplus_name_of_child, cplus_path_expr_of_child): Likewise.
(cplus_value_of_child, cplus_type_of_child): Likewise.
(cplus_value_of_variable, java_number_of_children): Likewise.
(java_name_of_variable, java_name_of_child): Likewise.
(java_path_expr_of_child, java_value_of_child): Likewise.
(java_type_of_child, java_value_of_variable): Likewise.
(ada_number_of_children, ada_name_of_variable): Likewise.
(ada_name_of_child, ada_path_expr_of_child): Likewise.
(ada_value_of_child, ada_type_of_child): Likewise.
(ada_value_of_variable, ada_value_is_changeable_p): Likewise.
(ada_value_has_mutated): Likewise.
(struct language_specific): Move it to varobj.h.
(CPLUS_FAKE_CHILD): Move it to varobj.h.
(restrict_range): Rename it varobj_restrict_range. Make it extern.
Callers update.
(get_path_expr_parent): Rename it to varobj_get_path_expr_parent.
Make it extern.
(is_anonymous_child): Move it to c-varobj.c and rename to
varobj_is_anonymous_child. Caller update.
(get_type): Move it to c-varobj.c.
(get_value_type): Rename it varobj_get_value_type. Make it
extern.
(get_target_type): Move it gdbtypes.c.
(varobj_formatted_print_options): New function.
(value_get_print_value): Rename it to
varobj_value_get_print_value and make it extern.
(varobj_value_is_changeable_p): Make it extern.
(adjust_value_for_child_access): Move it to c-varobj.c.
(default_value_is_changeable_p): Rename it to
varobj_default_value_is_changeable_p. Make it extern.
(c_number_of_children, c_name_of_variable): Move it to c-varobj.c
(c_name_of_child, c_path_expr_of_child): Likewise.
(c_value_of_child, c_type_of_child): Likewise.
(c_value_of_variable, cplus_number_of_children): Likewise.
(cplus_class_num_children, cplus_name_of_variable): Likewise.
(cplus_name_of_child, cplus_path_expr_of_child): Likewise.
(cplus_value_of_child, cplus_type_of_child): Likewise.
(cplus_value_of_variable): Likewise.
(java_number_of_children, java_name_of_variable): Move it to jv-varobj.c.
(java_name_of_child, java_path_expr_of_child): Likewise.
(java_value_of_child, java_type_of_child): Likewise.
(java_value_of_variable): Likewise.
(ada_number_of_children, ada_name_of_variable): Move it to ada-varobj.c.
(ada_name_of_child, ada_path_expr_of_child): Likewise.
(ada_value_of_child, ada_type_of_child): Likewise.
(ada_value_of_variable, ada_value_is_changeable_p): Likewise.
(ada_value_has_mutated): Likewise.
* varobj.h (CPLUS_FAKE_CHILD): New macro, moved from varobj.c.
(struct lang_varobj_ops): New. Renamed by 'struct language_specific'.
(c_varobj_ops, cplus_varobj_ops): Declare.
(java_varobj_ops, ada_varobj_ops): Declare.
(varobj_default_value_is_changeable_p): Declare.
(varobj_value_is_changeable_p): Declare.
(varobj_get_value_type, varobj_is_anonymous_child): Declare.
(varobj_get_path_expr_parent): Declare.
(varobj_value_get_print_value): Declare.
(varobj_formatted_print_options): Declare.
(varobj_restrict_range): Declare.
2013-10-17 21:28:37 +08:00
|
|
|
past typedefs. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
gdb/
* Makefile.in (SFILES): Add c-varobj.c and jv-varobj.c.
(COMMON_OBS): Add c-varobj.o and jv-varobj.o.
* ada-varobj.c: Include "varobj.h".
(ada_number_of_children): New. Moved from varobj.c.
(ada_name_of_variable, ada_name_of_child): Likewise.
(ada_path_expr_of_child, ada_value_of_child): Likewise.
(ada_type_of_child, ada_value_of_variable): Likewise.
(ada_value_is_changeable_p, ada_value_has_mutated): Likewise.
(ada_varobj_ops): New.
* c-varobj.c, jv-varobj.c: New file. Moved from varobj.c.
* gdbtypes.c (get_target_type): New. Moved from varobj.c.
* gdbtypes.h (get_target_type): Declare.
* varobj.c: Remove the inclusion of "ada-varobj.h" and
"ada-lang.h".
(ANONYMOUS_STRUCT_NAME): Move it to c-varobj.c.
(ANONYMOUS_UNION_NAME): Likewise.
(get_type, get_value_type, get_target_type): Remove declarations.
(value_get_print_value, varobj_value_get_print_value): Likewise.
(c_number_of_children, c_name_of_variable): Likewise.
(c_name_of_child, c_path_expr_of_child): Likewise.
(c_value_of_child, c_type_of_child): Likewise.
(c_value_of_variable, cplus_number_of_children): Likewise.
(cplus_class_num_children, cplus_name_of_variable): Likewise.
(cplus_name_of_child, cplus_path_expr_of_child): Likewise.
(cplus_value_of_child, cplus_type_of_child): Likewise.
(cplus_value_of_variable, java_number_of_children): Likewise.
(java_name_of_variable, java_name_of_child): Likewise.
(java_path_expr_of_child, java_value_of_child): Likewise.
(java_type_of_child, java_value_of_variable): Likewise.
(ada_number_of_children, ada_name_of_variable): Likewise.
(ada_name_of_child, ada_path_expr_of_child): Likewise.
(ada_value_of_child, ada_type_of_child): Likewise.
(ada_value_of_variable, ada_value_is_changeable_p): Likewise.
(ada_value_has_mutated): Likewise.
(struct language_specific): Move it to varobj.h.
(CPLUS_FAKE_CHILD): Move it to varobj.h.
(restrict_range): Rename it varobj_restrict_range. Make it extern.
Callers update.
(get_path_expr_parent): Rename it to varobj_get_path_expr_parent.
Make it extern.
(is_anonymous_child): Move it to c-varobj.c and rename to
varobj_is_anonymous_child. Caller update.
(get_type): Move it to c-varobj.c.
(get_value_type): Rename it varobj_get_value_type. Make it
extern.
(get_target_type): Move it gdbtypes.c.
(varobj_formatted_print_options): New function.
(value_get_print_value): Rename it to
varobj_value_get_print_value and make it extern.
(varobj_value_is_changeable_p): Make it extern.
(adjust_value_for_child_access): Move it to c-varobj.c.
(default_value_is_changeable_p): Rename it to
varobj_default_value_is_changeable_p. Make it extern.
(c_number_of_children, c_name_of_variable): Move it to c-varobj.c
(c_name_of_child, c_path_expr_of_child): Likewise.
(c_value_of_child, c_type_of_child): Likewise.
(c_value_of_variable, cplus_number_of_children): Likewise.
(cplus_class_num_children, cplus_name_of_variable): Likewise.
(cplus_name_of_child, cplus_path_expr_of_child): Likewise.
(cplus_value_of_child, cplus_type_of_child): Likewise.
(cplus_value_of_variable): Likewise.
(java_number_of_children, java_name_of_variable): Move it to jv-varobj.c.
(java_name_of_child, java_path_expr_of_child): Likewise.
(java_value_of_child, java_type_of_child): Likewise.
(java_value_of_variable): Likewise.
(ada_number_of_children, ada_name_of_variable): Move it to ada-varobj.c.
(ada_name_of_child, ada_path_expr_of_child): Likewise.
(ada_value_of_child, ada_type_of_child): Likewise.
(ada_value_of_variable, ada_value_is_changeable_p): Likewise.
(ada_value_has_mutated): Likewise.
* varobj.h (CPLUS_FAKE_CHILD): New macro, moved from varobj.c.
(struct lang_varobj_ops): New. Renamed by 'struct language_specific'.
(c_varobj_ops, cplus_varobj_ops): Declare.
(java_varobj_ops, ada_varobj_ops): Declare.
(varobj_default_value_is_changeable_p): Declare.
(varobj_value_is_changeable_p): Declare.
(varobj_get_value_type, varobj_is_anonymous_child): Declare.
(varobj_get_path_expr_parent): Declare.
(varobj_value_get_print_value): Declare.
(varobj_formatted_print_options): Declare.
(varobj_restrict_range): Declare.
2013-10-17 21:28:37 +08:00
|
|
|
extern struct type *get_target_type (struct type *type);
|
|
|
|
|
2015-07-28 23:01:49 +08:00
|
|
|
/* Return the equivalent of TYPE_LENGTH, but in number of target
|
|
|
|
addressable memory units of the associated gdbarch instead of bytes. */
|
|
|
|
|
|
|
|
extern unsigned int type_length_units (struct type *type);
|
|
|
|
|
2023-03-13 22:51:34 +08:00
|
|
|
/* An object of this type is passed when allocating certain types. It
|
|
|
|
determines where the new type is allocated. Ultimately a type is
|
|
|
|
either allocated on a on an objfile obstack or on a gdbarch
|
|
|
|
obstack. However, it's also possible to request that a new type be
|
|
|
|
allocated on the same obstack as some existing type, or that a
|
|
|
|
"new" type instead overwrite a supplied type object. */
|
|
|
|
|
|
|
|
class type_allocator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/* Create new types on OBJFILE. */
|
|
|
|
explicit type_allocator (objfile *objfile)
|
|
|
|
: m_is_objfile (true)
|
|
|
|
{
|
|
|
|
m_data.objfile = objfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create new types on GDBARCH. */
|
|
|
|
explicit type_allocator (gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
m_data.gdbarch = gdbarch;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This determines whether a passed-in type should be rewritten in
|
|
|
|
place, or whether it should simply determine where the new type
|
|
|
|
is created. */
|
|
|
|
enum type_allocator_kind
|
|
|
|
{
|
|
|
|
/* Allocate on same obstack as existing type. */
|
|
|
|
SAME = 0,
|
|
|
|
/* Smash the existing type. */
|
|
|
|
SMASH = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Create new types either on the same obstack as TYPE; or if SMASH
|
|
|
|
is passed, overwrite TYPE. */
|
|
|
|
explicit type_allocator (struct type *type,
|
|
|
|
type_allocator_kind kind = SAME)
|
|
|
|
{
|
|
|
|
if (kind == SAME)
|
|
|
|
{
|
|
|
|
if (type->is_objfile_owned ())
|
|
|
|
{
|
|
|
|
m_data.objfile = type->objfile_owner ();
|
|
|
|
m_is_objfile = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_data.gdbarch = type->arch_owner ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_smash = true;
|
|
|
|
m_data.type = type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create new types on the same obstack as TYPE. */
|
|
|
|
explicit type_allocator (const struct type *type)
|
|
|
|
: m_is_objfile (type->is_objfile_owned ())
|
|
|
|
{
|
|
|
|
if (type->is_objfile_owned ())
|
|
|
|
m_data.objfile = type->objfile_owner ();
|
|
|
|
else
|
|
|
|
m_data.gdbarch = type->arch_owner ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a new type on the desired obstack. Note that a "new" type
|
|
|
|
is not created if type-smashing was selected at construction. */
|
|
|
|
type *new_type ();
|
|
|
|
|
|
|
|
/* Create a new type on the desired obstack, and fill in its code,
|
|
|
|
length, and name. If NAME is non-null, it is copied to the
|
|
|
|
destination obstack first. Note that a "new" type is not created
|
|
|
|
if type-smashing was selected at construction. */
|
|
|
|
type *new_type (enum type_code code, int bit, const char *name);
|
|
|
|
|
|
|
|
/* Return the architecture associated with this allocator. This
|
|
|
|
comes from whatever object was supplied to the constructor. */
|
|
|
|
gdbarch *arch ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/* Where the type should wind up. */
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct objfile *objfile;
|
|
|
|
struct gdbarch *gdbarch;
|
|
|
|
struct type *type;
|
|
|
|
} m_data {};
|
|
|
|
|
|
|
|
/* True if this allocator uses the objfile field above. */
|
|
|
|
bool m_is_objfile = false;
|
|
|
|
/* True if this allocator uses the type field above, indicating that
|
|
|
|
the "allocation" should be done in-place. */
|
|
|
|
bool m_smash = false;
|
|
|
|
};
|
|
|
|
|
2023-03-14 00:31:06 +08:00
|
|
|
/* Allocate a TYPE_CODE_INT type structure using ALLOC. BIT is the
|
|
|
|
type size in bits. If UNSIGNED_P is non-zero, set the type's
|
|
|
|
TYPE_UNSIGNED flag. NAME is the type name. */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
2023-03-14 00:31:06 +08:00
|
|
|
extern struct type *init_integer_type (type_allocator &alloc, int bit,
|
|
|
|
int unsigned_p, const char *name);
|
2023-03-14 00:57:56 +08:00
|
|
|
|
|
|
|
/* Allocate a TYPE_CODE_CHAR type structure using ALLOC. BIT is the
|
|
|
|
type size in bits. If UNSIGNED_P is non-zero, set the type's
|
|
|
|
TYPE_UNSIGNED flag. NAME is the type name. */
|
|
|
|
|
|
|
|
extern struct type *init_character_type (type_allocator &alloc, int bit,
|
|
|
|
int unsigned_p, const char *name);
|
2023-03-14 01:09:08 +08:00
|
|
|
|
|
|
|
/* Allocate a TYPE_CODE_BOOL type structure using ALLOC. BIT is the
|
|
|
|
type size in bits. If UNSIGNED_P is non-zero, set the type's
|
|
|
|
TYPE_UNSIGNED flag. NAME is the type name. */
|
|
|
|
|
|
|
|
extern struct type *init_boolean_type (type_allocator &alloc, int bit,
|
|
|
|
int unsigned_p, const char *name);
|
|
|
|
|
2023-03-14 01:30:08 +08:00
|
|
|
/* Allocate a TYPE_CODE_FLT type structure using ALLOC.
|
|
|
|
BIT is the type size in bits; if BIT equals -1, the size is
|
|
|
|
determined by the floatformat. NAME is the type name. Set the
|
|
|
|
TYPE_FLOATFORMAT from FLOATFORMATS. BYTE_ORDER is the byte order
|
|
|
|
to use. If it is BFD_ENDIAN_UNKNOWN (the default), then the byte
|
|
|
|
order of the objfile's architecture is used. */
|
|
|
|
|
|
|
|
extern struct type *init_float_type
|
|
|
|
(type_allocator &alloc, int bit, const char *name,
|
|
|
|
const struct floatformat **floatformats,
|
|
|
|
enum bfd_endian byte_order = BFD_ENDIAN_UNKNOWN);
|
|
|
|
|
2023-03-14 01:58:31 +08:00
|
|
|
/* Allocate a TYPE_CODE_DECFLOAT type structure using ALLOC.
|
|
|
|
BIT is the type size in bits. NAME is the type name. */
|
|
|
|
|
|
|
|
extern struct type *init_decfloat_type (type_allocator &alloc, int bit,
|
|
|
|
const char *name);
|
|
|
|
|
2021-02-05 17:56:39 +08:00
|
|
|
extern bool can_create_complex_type (struct type *);
|
2020-04-02 04:09:52 +08:00
|
|
|
extern struct type *init_complex_type (const char *, struct type *);
|
2023-03-14 02:25:27 +08:00
|
|
|
|
|
|
|
/* Allocate a TYPE_CODE_PTR type structure using ALLOC.
|
|
|
|
BIT is the pointer type size in bits. NAME is the type name.
|
|
|
|
TARGET_TYPE is the pointer target type. Always sets the pointer type's
|
|
|
|
TYPE_UNSIGNED flag. */
|
|
|
|
|
|
|
|
extern struct type *init_pointer_type (type_allocator &alloc, int bit,
|
|
|
|
const char *name,
|
|
|
|
struct type *target_type);
|
|
|
|
|
Add support for printing value of DWARF-based fixed-point type objects
This commit introduces a new kind of type, meant to describe
fixed-point types, using a new code added specifically for
this purpose (TYPE_CODE_FIXED_POINT).
It then adds handling of fixed-point base types in the DWARF reader.
And finally, as a first step, this commit adds support for printing
the value of fixed-point type objects.
Note that this commit has a known issue: Trying to print the value
of a fixed-point object with a format letter (e.g. "print /x NAME")
causes the wrong value to be printed because the scaling factor
is not applied. Since the fix for this issue is isolated, and
this is not a regression, the fix will be made in a pach of its own.
This is meant to simplify review and archeology.
Also, other functionalities related to fixed-point type handling
(ptype, arithmetics, etc), will be added piecemeal as well, for
the same reasons (faciliate reviews and archeology). Related to this,
the testcase gdb.ada/fixed_cmp.exp is adjusted to compile the test
program with -fgnat-encodings=all, so as to force the use of GNAT
encodings, rather than rely on the compiler's default to use them.
The intent is to enhance this testcase to also test the pure DWARF
approach using -fgnat-encodings=minimal as soon as the corresponding
suport gets added in. Thus, the modification to the testcase is made
in a way that it prepares this testcase to be tested in both modes.
gdb/ChangeLog:
* ada-valprint.c (ada_value_print_1): Add fixed-point type handling.
* dwarf2/read.c (get_dwarf2_rational_constant)
(get_dwarf2_unsigned_rational_constant, finish_fixed_point_type)
(has_zero_over_zero_small_attribute): New functions.
read_base_type, set_die_type): Add fixed-point type handling.
* gdb-gdb.py.in: Add fixed-point type handling.
* gdbtypes.c: #include "gmp-utils.h".
(create_range_type, set_type_code): Add fixed-point type handling.
(init_fixed_point_type): New function.
(is_integral_type, is_scalar_type): Add fixed-point type handling.
(print_fixed_point_type_info): New function.
(recursive_dump_type, copy_type_recursive): Add fixed-point type
handling.
(fixed_point_type_storage): New typedef.
(fixed_point_objfile_key): New static global.
(allocate_fixed_point_type_info, is_fixed_point_type): New functions.
(fixed_point_type_base_type, fixed_point_scaling_factor): New
functions.
* gdbtypes.h: #include "gmp-utils.h".
(enum type_code) <TYPE_SPECIFIC_FIXED_POINT>: New enum.
(union type_specific) <fixed_point_info>: New field.
(struct fixed_point_type_info): New struct.
(INIT_FIXED_POINT_SPECIFIC, TYPE_FIXED_POINT_INFO): New macros.
(init_fixed_point_type, is_fixed_point_type)
(fixed_point_type_base_type, fixed_point_scaling_factor)
(allocate_fixed_point_type_info): Add declarations.
* valprint.c (generic_val_print_fixed_point): New function.
(generic_value_print): Add fixed-point type handling.
* value.c (value_as_address, unpack_long): Add fixed-point type
handling.
gdb/testsuite/ChangeLog:
* gdb.ada/fixed_cmp.exp: Force compilation to use -fgnat-encodings=all.
* gdb.ada/fixed_points.exp: Add fixed-point variables printing tests.
* gdb.ada/fixed_points/pck.ads, gdb.ada/fixed_points/pck.adb:
New files.
* gdb.ada/fixed_points/fixed_points.adb: Add use of package Pck.
* gdb.dwarf2/dw2-fixed-point.c, gdb.dwarf2/dw2-fixed-point.exp:
New files.
2020-11-15 16:12:52 +08:00
|
|
|
extern struct type *init_fixed_point_type (struct objfile *, int, int,
|
|
|
|
const char *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2002-03-23 09:24:54 +08:00
|
|
|
/* Helper functions to construct a struct or record type. An
|
* gdbtypes.h (TYPE_OBJFILE_OWNED, TYPE_OWNER): New macros.
(TYPE_OBJFILE, TYPE_ALLOC, TYPE_ZALLOC): Reimplement.
(alloc_type_arch): Add prototype.
(alloc_type_copy): Likewise.
(get_type_arch): Likewise.
(arch_type): Likewise.
(arch_integer_type): Likewise.
(arch_character_type): Likewise.
(arch_boolean_type): Likewise.
(init_float_type): Remove, replace by ...
(arch_float_type): ... this.
(init_complex_type): Remove, replace by ...
(arch_complex_type): ... this.
(init_flags_type): Remove, replace by ...
(arch_flags_type): ... this.
(init_composite_type): Remove, replace by ...
(arch_composite_type): ... this.
* gdbtypes.c (alloc_type): No longer support NULL objfile.
(init_type): Likewise.
(alloc_type_arch): New function.
(alloc_type_copy): New function.
(get_type_arch): New function.
(smash_type): Preserve type ownership information.
(make_pointer_type, make_reference_type, make_function_type,
smash_to_memberptr_type, smash_to_method_type): No longer
preserve OBJFILE across smash_type calls.
(make_pointer_type, make_reference_type, make_function_type,
lookup_memberptr_type, lookup_methodptr_type, allocate_stub_method,
create_range_type, create_array_type, create_set_type, copy_type):
Use alloc_type_copy when allocating types.
(check_typedef): Use alloc_type_arch.
(copy_type_recursive): Likewise. Preserve type ownership data
after copying type.
(recursive_dump_type): Dump type ownership data.
(alloc_type_instance): Update type ownership check.
(copy_type, copy_type_recursive): Likewise.
(arch_type): New function.
(arch_integer_type): Likewise.
(arch_character_type): Likewise.
(arch_boolean_type): Likewise.
(init_float_type): Remove, replace by ...
(arch_float_type): ... this.
(init_complex_type): Remove, replace by ...
(arch_complex_type): ... this.
(init_flags_type): Remove, replace by ...
(arch_flags_type): ... this.
(append_flags_type_flag): Move down.
(init_composite_type): Remove, replace by ...
(arch_composite_type): ... this.
(append_composite_type_field_aligned,
append_composite_type_field): Move down.
* gdbarch.c (gdbtypes_post_init): Allocate all types
using per-architecture routines.
* ada-lang.c (ada_language_arch_info): Likewise.
* f-lang.c (build_fortran_types): Likewise.
* jv-lang.c (build_java_types): Likewise.
* m2-lang.c (build_m2_types): Likewise.
* scm-lang.c (build_scm_types): Likewise.
* ada-lang.c (ada_type_of_array): Use alloc_type_copy.
(packed_array_type): Likewise.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_variant_branch_type): Likewise.
(to_fixed_array_type): Likewise.
(to_fixed_range_type): Likewise.
(empty_record): Use type instead of objfile argument.
Use alloc_type_copy.
(to_fixed_variant_branch_type): Update call to empty_record.
* jv-lang.c (type_from_class): Use alloc_type_arch.
* arm-tdep.c (arm_ext_type): Allocate per-architecture type.
* i386-tdep.c (i386_eflags_type, i386_mxcsr_type, i387_ext_type,
i386_mmx_type, i386_sse_type): Likewise.
* ia64-tdep.c (ia64_ext_type): Likewise.
* m32c-tdep.c (make_types): Likewise.
* m68k-tdep.c (m68k_ps_type, m68881_ext_type): Likewise.
* rs6000-tdep.c (rs6000_builtin_type_vec64,
rs6000_builtin_type_vec128): Likewise.
* sparc-tdep.c (sparc_psr_type, sparc_fsr_type): Likewise.
* sparc64-tdep.c (sparc64_pstate_type, sparc64_fsr_type,
sparc64_fprs_type): Likewise.
* spu-tdep.c (spu_builtin_type_vec128): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* linux-tdep.c (linux_get_siginfo_type): Likewise.
* target-descriptions.c (tdesc_gdb_type): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
2009-07-02 20:55:30 +08:00
|
|
|
initially empty type is created using arch_composite_type().
|
2010-01-15 02:58:57 +08:00
|
|
|
Fields are then added using append_composite_type_field*(). A union
|
2002-03-23 09:24:54 +08:00
|
|
|
type has its size set to the largest field. A struct type has each
|
|
|
|
field packed against the previous. */
|
|
|
|
|
* gdbtypes.h (TYPE_OBJFILE_OWNED, TYPE_OWNER): New macros.
(TYPE_OBJFILE, TYPE_ALLOC, TYPE_ZALLOC): Reimplement.
(alloc_type_arch): Add prototype.
(alloc_type_copy): Likewise.
(get_type_arch): Likewise.
(arch_type): Likewise.
(arch_integer_type): Likewise.
(arch_character_type): Likewise.
(arch_boolean_type): Likewise.
(init_float_type): Remove, replace by ...
(arch_float_type): ... this.
(init_complex_type): Remove, replace by ...
(arch_complex_type): ... this.
(init_flags_type): Remove, replace by ...
(arch_flags_type): ... this.
(init_composite_type): Remove, replace by ...
(arch_composite_type): ... this.
* gdbtypes.c (alloc_type): No longer support NULL objfile.
(init_type): Likewise.
(alloc_type_arch): New function.
(alloc_type_copy): New function.
(get_type_arch): New function.
(smash_type): Preserve type ownership information.
(make_pointer_type, make_reference_type, make_function_type,
smash_to_memberptr_type, smash_to_method_type): No longer
preserve OBJFILE across smash_type calls.
(make_pointer_type, make_reference_type, make_function_type,
lookup_memberptr_type, lookup_methodptr_type, allocate_stub_method,
create_range_type, create_array_type, create_set_type, copy_type):
Use alloc_type_copy when allocating types.
(check_typedef): Use alloc_type_arch.
(copy_type_recursive): Likewise. Preserve type ownership data
after copying type.
(recursive_dump_type): Dump type ownership data.
(alloc_type_instance): Update type ownership check.
(copy_type, copy_type_recursive): Likewise.
(arch_type): New function.
(arch_integer_type): Likewise.
(arch_character_type): Likewise.
(arch_boolean_type): Likewise.
(init_float_type): Remove, replace by ...
(arch_float_type): ... this.
(init_complex_type): Remove, replace by ...
(arch_complex_type): ... this.
(init_flags_type): Remove, replace by ...
(arch_flags_type): ... this.
(append_flags_type_flag): Move down.
(init_composite_type): Remove, replace by ...
(arch_composite_type): ... this.
(append_composite_type_field_aligned,
append_composite_type_field): Move down.
* gdbarch.c (gdbtypes_post_init): Allocate all types
using per-architecture routines.
* ada-lang.c (ada_language_arch_info): Likewise.
* f-lang.c (build_fortran_types): Likewise.
* jv-lang.c (build_java_types): Likewise.
* m2-lang.c (build_m2_types): Likewise.
* scm-lang.c (build_scm_types): Likewise.
* ada-lang.c (ada_type_of_array): Use alloc_type_copy.
(packed_array_type): Likewise.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_variant_branch_type): Likewise.
(to_fixed_array_type): Likewise.
(to_fixed_range_type): Likewise.
(empty_record): Use type instead of objfile argument.
Use alloc_type_copy.
(to_fixed_variant_branch_type): Update call to empty_record.
* jv-lang.c (type_from_class): Use alloc_type_arch.
* arm-tdep.c (arm_ext_type): Allocate per-architecture type.
* i386-tdep.c (i386_eflags_type, i386_mxcsr_type, i387_ext_type,
i386_mmx_type, i386_sse_type): Likewise.
* ia64-tdep.c (ia64_ext_type): Likewise.
* m32c-tdep.c (make_types): Likewise.
* m68k-tdep.c (m68k_ps_type, m68881_ext_type): Likewise.
* rs6000-tdep.c (rs6000_builtin_type_vec64,
rs6000_builtin_type_vec128): Likewise.
* sparc-tdep.c (sparc_psr_type, sparc_fsr_type): Likewise.
* sparc64-tdep.c (sparc64_pstate_type, sparc64_fsr_type,
sparc64_fprs_type): Likewise.
* spu-tdep.c (spu_builtin_type_vec128): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* linux-tdep.c (linux_get_siginfo_type): Likewise.
* target-descriptions.c (tdesc_gdb_type): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
2009-07-02 20:55:30 +08:00
|
|
|
extern struct type *arch_composite_type (struct gdbarch *gdbarch,
|
Constify arch_type and friends
While working on the Rust support, I happened to notice that arch_type
and related functions take "char *" arguments, where "const char *"
would be more correct. This patch fixes this oversight. Tested by
rebuilding.
2016-06-10 Tom Tromey <tom@tromey.com>
* gdbtypes.c (arch_type, arch_integer_type, arch_character_type)
(arch_boolean_type, arch_float_type, arch_complex_type)
(arch_flags_type, append_flags_type_field)
(append_flags_type_flag, arch_composite_type)
(append_composite_type_field_raw)
(append_composite_type_field_aligned)
(append_composite_type_field): Make "name" parameter const.
* gdbtypes.h (arch_type, arch_integer_type, arch_character_type)
(arch_boolean_type, arch_float_type, arch_complex_type)
(append_composite_type_field, append_composite_type_field_aligned)
(append_composite_type_field_raw, arch_flags_type)
(append_flags_type_field, append_flags_type_flag): Constify.
2016-06-06 22:06:15 +08:00
|
|
|
const char *name, enum type_code code);
|
|
|
|
extern void append_composite_type_field (struct type *t, const char *name,
|
2002-03-23 09:24:54 +08:00
|
|
|
struct type *field);
|
2009-02-07 06:59:01 +08:00
|
|
|
extern void append_composite_type_field_aligned (struct type *t,
|
Constify arch_type and friends
While working on the Rust support, I happened to notice that arch_type
and related functions take "char *" arguments, where "const char *"
would be more correct. This patch fixes this oversight. Tested by
rebuilding.
2016-06-10 Tom Tromey <tom@tromey.com>
* gdbtypes.c (arch_type, arch_integer_type, arch_character_type)
(arch_boolean_type, arch_float_type, arch_complex_type)
(arch_flags_type, append_flags_type_field)
(append_flags_type_flag, arch_composite_type)
(append_composite_type_field_raw)
(append_composite_type_field_aligned)
(append_composite_type_field): Make "name" parameter const.
* gdbtypes.h (arch_type, arch_integer_type, arch_character_type)
(arch_boolean_type, arch_float_type, arch_complex_type)
(append_composite_type_field, append_composite_type_field_aligned)
(append_composite_type_field_raw, arch_flags_type)
(append_flags_type_field, append_flags_type_flag): Constify.
2016-06-06 22:06:15 +08:00
|
|
|
const char *name,
|
2009-02-07 06:59:01 +08:00
|
|
|
struct type *field,
|
|
|
|
int alignment);
|
Constify arch_type and friends
While working on the Rust support, I happened to notice that arch_type
and related functions take "char *" arguments, where "const char *"
would be more correct. This patch fixes this oversight. Tested by
rebuilding.
2016-06-10 Tom Tromey <tom@tromey.com>
* gdbtypes.c (arch_type, arch_integer_type, arch_character_type)
(arch_boolean_type, arch_float_type, arch_complex_type)
(arch_flags_type, append_flags_type_field)
(append_flags_type_flag, arch_composite_type)
(append_composite_type_field_raw)
(append_composite_type_field_aligned)
(append_composite_type_field): Make "name" parameter const.
* gdbtypes.h (arch_type, arch_integer_type, arch_character_type)
(arch_boolean_type, arch_float_type, arch_complex_type)
(append_composite_type_field, append_composite_type_field_aligned)
(append_composite_type_field_raw, arch_flags_type)
(append_flags_type_field, append_flags_type_flag): Constify.
2016-06-06 22:06:15 +08:00
|
|
|
struct field *append_composite_type_field_raw (struct type *t, const char *name,
|
* gdbtypes.c (append_composite_type_field_raw): New.
(append_composite_type_field_aligned): Use the new function.
* gdbtypes.h (append_composite_type_field_raw): Declare.
* target-descriptions.c (struct tdesc_type_field): Add start and end.
(struct tdesc_type_flag): New type.
(struct tdesc_type): Add TDESC_TYPE_STRUCT and TDESC_TYPE_FLAGS to
kind. Add size to u.u. Add u.f for flags.
(tdesc_gdb_type): Handle TDESC_TYPE_STRUCT and TDESC_TYPE_FLAGS.
(tdesc_free_type): Likewise.
(tdesc_create_struct, tdesc_set_struct_size, tdesc_create_flags): New.
(tdesc_add_field): Handle TDESC_TYPE_STRUCT.
(tdesc_add_bitfield, tdesc_add_flag): New.
* target-descriptions.h (tdesc_create_struct, tdesc_set_struct_size)
(tdesc_create_flags, tdesc_add_bitfield, tdesc_add_flag): Declare.
* xml-tdesc.c (struct tdesc_parsing_data): Rename current_union to
current_type. Add current_type_size and current_type_is_flags.
(tdesc_start_union): Clear the new fields.
(tdesc_start_struct, tdesc_start_flags): New.
(tdesc_start_field): Handle struct fields, including bitfields.
(field_attributes): Make type optional. Add start and end.
(union_children): Rename to struct_union_children.
(union_attributes): Rename to struct_union_attributes. Add optional
size.
(flags_attributes): New.
(feature_children): Add struct and flags.
* features/gdb-target.dtd: Add flags and struct to features.
Make field type optional. Add field start and end.
doc/
* gdb.texinfo (Types): Describe <struct> and <flags>.
testsuite/
* gdb.xml/extra-regs.xml: Add struct1, struct2, and flags
types. Add structreg, bitfields, and flags registers.
* gdb.xml/tdesc-regs.exp: Test structreg and bitfields
registers.
2010-03-02 01:19:23 +08:00
|
|
|
struct type *field);
|
2002-03-23 09:24:54 +08:00
|
|
|
|
2006-01-19 05:24:19 +08:00
|
|
|
/* Helper functions to construct a bit flags type. An initially empty
|
* gdbtypes.h (TYPE_OBJFILE_OWNED, TYPE_OWNER): New macros.
(TYPE_OBJFILE, TYPE_ALLOC, TYPE_ZALLOC): Reimplement.
(alloc_type_arch): Add prototype.
(alloc_type_copy): Likewise.
(get_type_arch): Likewise.
(arch_type): Likewise.
(arch_integer_type): Likewise.
(arch_character_type): Likewise.
(arch_boolean_type): Likewise.
(init_float_type): Remove, replace by ...
(arch_float_type): ... this.
(init_complex_type): Remove, replace by ...
(arch_complex_type): ... this.
(init_flags_type): Remove, replace by ...
(arch_flags_type): ... this.
(init_composite_type): Remove, replace by ...
(arch_composite_type): ... this.
* gdbtypes.c (alloc_type): No longer support NULL objfile.
(init_type): Likewise.
(alloc_type_arch): New function.
(alloc_type_copy): New function.
(get_type_arch): New function.
(smash_type): Preserve type ownership information.
(make_pointer_type, make_reference_type, make_function_type,
smash_to_memberptr_type, smash_to_method_type): No longer
preserve OBJFILE across smash_type calls.
(make_pointer_type, make_reference_type, make_function_type,
lookup_memberptr_type, lookup_methodptr_type, allocate_stub_method,
create_range_type, create_array_type, create_set_type, copy_type):
Use alloc_type_copy when allocating types.
(check_typedef): Use alloc_type_arch.
(copy_type_recursive): Likewise. Preserve type ownership data
after copying type.
(recursive_dump_type): Dump type ownership data.
(alloc_type_instance): Update type ownership check.
(copy_type, copy_type_recursive): Likewise.
(arch_type): New function.
(arch_integer_type): Likewise.
(arch_character_type): Likewise.
(arch_boolean_type): Likewise.
(init_float_type): Remove, replace by ...
(arch_float_type): ... this.
(init_complex_type): Remove, replace by ...
(arch_complex_type): ... this.
(init_flags_type): Remove, replace by ...
(arch_flags_type): ... this.
(append_flags_type_flag): Move down.
(init_composite_type): Remove, replace by ...
(arch_composite_type): ... this.
(append_composite_type_field_aligned,
append_composite_type_field): Move down.
* gdbarch.c (gdbtypes_post_init): Allocate all types
using per-architecture routines.
* ada-lang.c (ada_language_arch_info): Likewise.
* f-lang.c (build_fortran_types): Likewise.
* jv-lang.c (build_java_types): Likewise.
* m2-lang.c (build_m2_types): Likewise.
* scm-lang.c (build_scm_types): Likewise.
* ada-lang.c (ada_type_of_array): Use alloc_type_copy.
(packed_array_type): Likewise.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_variant_branch_type): Likewise.
(to_fixed_array_type): Likewise.
(to_fixed_range_type): Likewise.
(empty_record): Use type instead of objfile argument.
Use alloc_type_copy.
(to_fixed_variant_branch_type): Update call to empty_record.
* jv-lang.c (type_from_class): Use alloc_type_arch.
* arm-tdep.c (arm_ext_type): Allocate per-architecture type.
* i386-tdep.c (i386_eflags_type, i386_mxcsr_type, i387_ext_type,
i386_mmx_type, i386_sse_type): Likewise.
* ia64-tdep.c (ia64_ext_type): Likewise.
* m32c-tdep.c (make_types): Likewise.
* m68k-tdep.c (m68k_ps_type, m68881_ext_type): Likewise.
* rs6000-tdep.c (rs6000_builtin_type_vec64,
rs6000_builtin_type_vec128): Likewise.
* sparc-tdep.c (sparc_psr_type, sparc_fsr_type): Likewise.
* sparc64-tdep.c (sparc64_pstate_type, sparc64_fsr_type,
sparc64_fprs_type): Likewise.
* spu-tdep.c (spu_builtin_type_vec128): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* linux-tdep.c (linux_get_siginfo_type): Likewise.
* target-descriptions.c (tdesc_gdb_type): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
2009-07-02 20:55:30 +08:00
|
|
|
type is created using arch_flag_type(). Flags are then added using
|
2016-03-16 05:37:29 +08:00
|
|
|
append_flag_type_field() and append_flag_type_flag(). */
|
* gdbtypes.h (TYPE_OBJFILE_OWNED, TYPE_OWNER): New macros.
(TYPE_OBJFILE, TYPE_ALLOC, TYPE_ZALLOC): Reimplement.
(alloc_type_arch): Add prototype.
(alloc_type_copy): Likewise.
(get_type_arch): Likewise.
(arch_type): Likewise.
(arch_integer_type): Likewise.
(arch_character_type): Likewise.
(arch_boolean_type): Likewise.
(init_float_type): Remove, replace by ...
(arch_float_type): ... this.
(init_complex_type): Remove, replace by ...
(arch_complex_type): ... this.
(init_flags_type): Remove, replace by ...
(arch_flags_type): ... this.
(init_composite_type): Remove, replace by ...
(arch_composite_type): ... this.
* gdbtypes.c (alloc_type): No longer support NULL objfile.
(init_type): Likewise.
(alloc_type_arch): New function.
(alloc_type_copy): New function.
(get_type_arch): New function.
(smash_type): Preserve type ownership information.
(make_pointer_type, make_reference_type, make_function_type,
smash_to_memberptr_type, smash_to_method_type): No longer
preserve OBJFILE across smash_type calls.
(make_pointer_type, make_reference_type, make_function_type,
lookup_memberptr_type, lookup_methodptr_type, allocate_stub_method,
create_range_type, create_array_type, create_set_type, copy_type):
Use alloc_type_copy when allocating types.
(check_typedef): Use alloc_type_arch.
(copy_type_recursive): Likewise. Preserve type ownership data
after copying type.
(recursive_dump_type): Dump type ownership data.
(alloc_type_instance): Update type ownership check.
(copy_type, copy_type_recursive): Likewise.
(arch_type): New function.
(arch_integer_type): Likewise.
(arch_character_type): Likewise.
(arch_boolean_type): Likewise.
(init_float_type): Remove, replace by ...
(arch_float_type): ... this.
(init_complex_type): Remove, replace by ...
(arch_complex_type): ... this.
(init_flags_type): Remove, replace by ...
(arch_flags_type): ... this.
(append_flags_type_flag): Move down.
(init_composite_type): Remove, replace by ...
(arch_composite_type): ... this.
(append_composite_type_field_aligned,
append_composite_type_field): Move down.
* gdbarch.c (gdbtypes_post_init): Allocate all types
using per-architecture routines.
* ada-lang.c (ada_language_arch_info): Likewise.
* f-lang.c (build_fortran_types): Likewise.
* jv-lang.c (build_java_types): Likewise.
* m2-lang.c (build_m2_types): Likewise.
* scm-lang.c (build_scm_types): Likewise.
* ada-lang.c (ada_type_of_array): Use alloc_type_copy.
(packed_array_type): Likewise.
(ada_template_to_fixed_record_type_1): Likewise.
(template_to_static_fixed_type): Likewise.
(to_record_with_fixed_variant_part): Likewise.
(to_fixed_variant_branch_type): Likewise.
(to_fixed_array_type): Likewise.
(to_fixed_range_type): Likewise.
(empty_record): Use type instead of objfile argument.
Use alloc_type_copy.
(to_fixed_variant_branch_type): Update call to empty_record.
* jv-lang.c (type_from_class): Use alloc_type_arch.
* arm-tdep.c (arm_ext_type): Allocate per-architecture type.
* i386-tdep.c (i386_eflags_type, i386_mxcsr_type, i387_ext_type,
i386_mmx_type, i386_sse_type): Likewise.
* ia64-tdep.c (ia64_ext_type): Likewise.
* m32c-tdep.c (make_types): Likewise.
* m68k-tdep.c (m68k_ps_type, m68881_ext_type): Likewise.
* rs6000-tdep.c (rs6000_builtin_type_vec64,
rs6000_builtin_type_vec128): Likewise.
* sparc-tdep.c (sparc_psr_type, sparc_fsr_type): Likewise.
* sparc64-tdep.c (sparc64_pstate_type, sparc64_fsr_type,
sparc64_fprs_type): Likewise.
* spu-tdep.c (spu_builtin_type_vec128): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* linux-tdep.c (linux_get_siginfo_type): Likewise.
* target-descriptions.c (tdesc_gdb_type): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
2009-07-02 20:55:30 +08:00
|
|
|
extern struct type *arch_flags_type (struct gdbarch *gdbarch,
|
2017-09-28 01:02:00 +08:00
|
|
|
const char *name, int bit);
|
2016-03-16 05:37:29 +08:00
|
|
|
extern void append_flags_type_field (struct type *type,
|
|
|
|
int start_bitpos, int nr_bits,
|
Constify arch_type and friends
While working on the Rust support, I happened to notice that arch_type
and related functions take "char *" arguments, where "const char *"
would be more correct. This patch fixes this oversight. Tested by
rebuilding.
2016-06-10 Tom Tromey <tom@tromey.com>
* gdbtypes.c (arch_type, arch_integer_type, arch_character_type)
(arch_boolean_type, arch_float_type, arch_complex_type)
(arch_flags_type, append_flags_type_field)
(append_flags_type_flag, arch_composite_type)
(append_composite_type_field_raw)
(append_composite_type_field_aligned)
(append_composite_type_field): Make "name" parameter const.
* gdbtypes.h (arch_type, arch_integer_type, arch_character_type)
(arch_boolean_type, arch_float_type, arch_complex_type)
(append_composite_type_field, append_composite_type_field_aligned)
(append_composite_type_field_raw, arch_flags_type)
(append_flags_type_field, append_flags_type_flag): Constify.
2016-06-06 22:06:15 +08:00
|
|
|
struct type *field_type, const char *name);
|
|
|
|
extern void append_flags_type_flag (struct type *type, int bitpos,
|
|
|
|
const char *name);
|
2006-01-19 05:24:19 +08:00
|
|
|
|
2007-09-05 08:51:49 +08:00
|
|
|
extern void make_vector_type (struct type *array_type);
|
* gdbtypes.c (builtin_type_v2_double, builtin_type_v4_float,
builtin_type_v2_int64, builtin_type_v4_int32, builtin_type_v8_int16,
builtin_type_v16_int8, builtin_type_v2_float, builtin_type_v2_int32,
builtin_type_v4_int16, builtin_type_v8_int8, builtin_type_v4sf,
builtin_type_v4si, builtin_type_v16qi, builtin_type_v8qi,
builtin_type_v8hi, builtin_type_v4hi, builtin_type_v2si,
builtin_type_vec64, builtin_type_vec128): Remove.
(init_simd_type): Remove.
(init_vector_type): Make global.
(build_builtin_type_vec64, build_builtin_type_vec128): Remove.
(build_gdbtypes): Do not build vector types.
(_initialize_gdbtypes): Do not swap vector types.
* gdbtypes.h (builtin_type_v2_double, builtin_type_v4_float,
builtin_type_v2_int64, builtin_type_v4_int32, builtin_type_v8_int16,
builtin_type_v16_int8, builtin_type_v2_float, builtin_type_v2_int32,
builtin_type_v4_int16, builtin_type_v8_int8, builtin_type_v4sf,
builtin_type_v4si, builtin_type_v16qi, builtin_type_v8qi,
builtin_type_v8hi, builtin_type_v4hi, builtin_type_v2si,
builtin_type_vec64, builtin_type_vec128): Remove declarations.
(init_vector_type): Add prototype.
* i386-tdep.h (struct gdbarch_tdep): Add i386_mmx_type and
i386_sse_type members.
(i386_mmx_type, i386_sse_type): Change from variables to functions.
* i386-tdep.c (i386_mmx_type, i386_sse_type): Remove variables.
(i386_init_types): Do not build vector types.
(i386_mmx_type, i386_sse_type): New functions.
(i386_register_type): Call them instead of using global variables.
(i386_gdbarch_init): Use XCALLOC to allocate tdep structure.
* amd64-tdep.c (amd64_register_type): Call i386_sse_type instead
of using global variable.
* rs6000-tdep.h (struct gdbarch_tdep): Add ppc_builtin_type_vec64
and ppc_builtin_type_vec128 members.
* rs6000-tdep.c (rs6000_builtin_type_vec64): New function.
(rs6000_builtin_type_vec128): Likewise.
(rs6000_register_type): Call them instead of using builtin_type_vec64
and builtin_type_vec128.
(rs6000_gdbarch_init): Use XCALLOC to allocate tdep structure.
* spu-tdep.c (struct gdbarch_tdep): New data type.
(spu_builtin_type_vec128): Remove variable.
(spu_builtin_type_vec128): New function.
(spu_register_type): Call it instead of using global variable.
(spu_gdbarch_init): Allocate tdep structure.
(spu_init_vector_type): Remove function.
(_initialize_spu_tdep): Do not call it.
2007-06-17 01:25:59 +08:00
|
|
|
extern struct type *init_vector_type (struct type *elt_type, int n);
|
|
|
|
|
2017-03-21 04:47:39 +08:00
|
|
|
extern struct type *lookup_reference_type (struct type *, enum type_code);
|
|
|
|
extern struct type *lookup_lvalue_reference_type (struct type *);
|
|
|
|
extern struct type *lookup_rvalue_reference_type (struct type *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2017-03-21 04:47:39 +08:00
|
|
|
|
|
|
|
extern struct type *make_reference_type (struct type *, struct type **,
|
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
|
|
|
enum type_code);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern struct type *make_cv_type (int, int, struct type *, struct type **);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2013-01-15 04:59:27 +08:00
|
|
|
extern struct type *make_restrict_type (struct type *);
|
|
|
|
|
2014-05-15 03:52:04 +08:00
|
|
|
extern struct type *make_unqualified_type (struct type *);
|
|
|
|
|
2015-02-09 21:58:25 +08:00
|
|
|
extern struct type *make_atomic_type (struct type *);
|
|
|
|
|
2002-02-04 06:57:56 +08:00
|
|
|
extern void replace_type (struct type *, struct type *);
|
|
|
|
|
2020-09-15 04:16:57 +08:00
|
|
|
extern type_instance_flags address_space_name_to_type_instance_flags
|
|
|
|
(struct gdbarch *, const char *);
|
2001-11-15 09:55:59 +08:00
|
|
|
|
2020-09-15 04:16:57 +08:00
|
|
|
extern const char *address_space_type_instance_flags_to_name
|
|
|
|
(struct gdbarch *, type_instance_flags);
|
2001-11-15 09:55:59 +08:00
|
|
|
|
Use type_instance_flags more throughout
A later patch in this series will rewrite enum_flags fixing some API
holes. That would cause build failures around code using
type_instance_flags. Or rather, that should be using it, but wasn't.
This patch fixes it by using type_instance_flags throughout instead of
plain integers.
Note that we can't make the seemingly obvious change to struct
type::instance_flags:
- unsigned instance_flags : 9;
+ ENUM_BITFIELD (type_instance_flag_value) instance_flags : 9;
Because G++ complains then that 9 bits isn't sufficient for holding
all values of type_instance_flag_value.
So the patch adds an type::instance_flags() method, which takes care
of casting appropriately, and adds a separate type::set_instance_flags
method, following the pattern of the ongoing TYPE_XXX macro
elimination. This converts uses of TYPE_INSTANCE_FLAGS to
type::instance_flags() in the places where the code was already being
touched, but there are still many references to the
TYPE_INSTANCE_FLAGS macro left behind. Those could/should be fully
replaced at some point.
gdb/ChangeLog:
* avr-tdep.c (avr_address_class_type_flags): Return
type_instance_flags.
(avr_address_class_type_flags_to_name): Take a
type_instance_flags.
(avr_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
* d-lang.c (build_d_types): Use type::set_instance_flags.
* ft32-tdep.c (ft32_address_class_type_flags): Return
type_instance_flags.
(ft32_address_class_type_flags_to_name): Take a
type_instance_flags.
(ft32_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
(ft32_gdbarch_init): Use type::set_instance_flags.
* eval.c (fake_method::fake_method): Use type::set_instance_flags.
* gdbarch.h, gdbarch.c: Regenerate.
* gdbarch.sh (address_class_type_flags): Use type_instance_flags.
(address_class_name_to_type_flags): Use type_instance_flags and
bool.
* gdbtypes.c (address_space_name_to_int)
(address_space_int_to_name, make_qualified_type): Use
type_instance_flags.
(make_qualified_type): Use type_instance_flags and
type::set_instance_flags.
(make_type_with_address_space, make_cv_type, make_vector_type)
(check_typedef): Use type_instance_flags.
(recursive_dump_type): Cast type_instance_flags to unsigned for
printing.
(copy_type_recursive): Use type::set_instance_flags.
(gdbtypes_post_init): Use type::set_instance_flags.
* gdbtypes.h (struct type) <instance_flags>: Rename to ...
<m_instance_flags>: ... this.
<instance_flags, set_instance_flags>: New methods.
(TYPE_INSTANCE_FLAGS): Use the instance_flags method.
(SET_TYPE_INSTANCE_FLAGS): New.
(address_space_name_to_int, address_space_int_to_name)
(make_type_with_address_space): Pass flags using
type_instance_flags instead of int.
* stabsread.c (cleanup_undefined_types_noname): Use
type::set_instance_flags.
* s390-tdep.c (s390_address_class_type_flags): Return
type_instance_flags.
(s390_address_class_type_flags_to_name): Take a
type_instance_flags.
(s390_address_class_name_to_type_flags): Return bool and take a
type_instance_flags.
* type-stack.c (type_stack::follow_types): Use
type_instance_flags.
* dwarf2/read.c (read_tag_pointer_type): Use type_instance_flags.
2020-09-15 04:16:56 +08:00
|
|
|
extern struct type *make_type_with_address_space
|
|
|
|
(struct type *type, type_instance_flags space_identifier);
|
2001-11-15 09:55:59 +08:00
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-04 02:05:45 +08:00
|
|
|
extern struct type *lookup_memberptr_type (struct type *, struct type *);
|
|
|
|
|
|
|
|
extern struct type *lookup_methodptr_type (struct type *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
Move TYPE_SELF_TYPE into new field type_specific.
This patch moves TYPE_SELF_TYPE into new field type_specific.self_type
for MEMBERPTR,METHODPTR types, and into type_specific.func_stuff
for METHODs, and then updates everything to use that.
TYPE_CODE_METHOD could share some things with TYPE_CODE_FUNC
(e.g. TYPE_NO_RETURN) and it seemed simplest to keep them together.
Moving TYPE_SELF_TYPE into type_specific.func_stuff for TYPE_CODE_METHOD
is also nice because when we allocate space for function types we assume
they're TYPE_CODE_FUNCs. If TYPE_CODE_METHODs don't need or use that
space then that space would be wasted, and cleaning that up would involve
more invasive changes.
In order to catch errant uses I've added accessor functions
that do some checking.
One can no longer assign to TYPE_SELF_TYPE like this:
TYPE_SELF_TYPE (foo) = bar;
One instead has to do:
set_type_self_type (foo, bar);
But I've left reading of the type to the macro:
bar = TYPE_SELF_TYPE (foo);
In order to discourage bypassing the TYPE_SELF_TYPE macro
I've named the underlying function that implements it
internal_type_self_type.
While testing this I found the stabs reader leaving methods
as TYPE_CODE_FUNCs, hitting my newly added asserts.
Since the dwarf reader smashes functions to methods (via
smash_to_method) I've done a similar thing for stabs.
gdb/ChangeLog:
* cp-valprint.c (cp_find_class_member): Rename parameter domain_p
to self_p.
(cp_print_class_member): Rename local domain to self_type.
* dwarf2read.c (quirk_gcc_member_function_pointer): Rename local
domain_type to self_type.
(set_die_type) <need_gnat_info>: Handle
TYPE_CODE_METHODPTR, TYPE_CODE_MEMBERPTR, TYPE_CODE_METHOD.
* gdb-gdb.py (StructMainTypePrettyPrinter): Handle
TYPE_SPECIFIC_SELF_TYPE.
* gdbtypes.c (internal_type_self_type): New function.
(set_type_self_type): New function.
(smash_to_memberptr_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(smash_to_methodptr_type): Update setting of TYPE_SELF_TYPE.
(smash_to_method_type): Rename parameter domain to self_type.
Update setting of TYPE_SELF_TYPE.
(check_stub_method): Call smash_to_method_type.
(recursive_dump_type): Handle TYPE_SPECIFIC_SELF_TYPE.
(copy_type_recursive): Ditto.
* gdbtypes.h (enum type_specific_kind): New value
TYPE_SPECIFIC_SELF_TYPE.
(struct main_type) <type_specific>: New member self_type.
(struct cplus_struct_type) <fn_field.type>: Update comment.
(TYPE_SELF_TYPE): Rewrite.
(internal_type_self_type, set_type_self_type): Declare.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Rename local domain to
self_type.
(gnuv3_method_ptr_to_value): Rename local domain_type to self_type.
* m2-typeprint.c (m2_range): Replace TYPE_SELF_TYPE with
TYPE_TARGET_TYPE.
* stabsread.c (read_member_functions): Mark methods with
TYPE_CODE_METHOD, not TYPE_CODE_FUNC. Update setting of
TYPE_SELF_TYPE.
2015-02-01 13:21:01 +08:00
|
|
|
extern void smash_to_method_type (struct type *type, struct type *self_type,
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-04 02:05:45 +08:00
|
|
|
struct type *to_type, struct field *args,
|
|
|
|
int nargs, int varargs);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-04 02:05:45 +08:00
|
|
|
extern void smash_to_memberptr_type (struct type *, struct type *,
|
|
|
|
struct type *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2010-01-23 01:06:49 +08:00
|
|
|
extern void smash_to_methodptr_type (struct type *, struct type *);
|
|
|
|
|
Remove type_name_no_tag and rename type_name_no_tag_or_error
type_name_no_tag is just a plain wrapper for TYPE_NAME now, so this
patch removes it. And, because tag names no longer exist, this
renames type_name_no_tag_or_error to type_name_or_error.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (value_cast_structs, destructor_name_p): Update.
* symtab.c (gdb_mangle_name): Update.
* stabsread.c (define_symbol, read_cpp_abbrev, read_baseclasses):
Update.
* p-valprint.c (pascal_object_is_vtbl_ptr_type)
(pascal_object_print_value_fields, pascal_object_print_value):
Update.
* p-typeprint.c (pascal_type_print_derivation_info): Update.
* linespec.c (find_methods): Update.
* gdbtypes.h (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
* gdbtypes.c (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
(lookup_struct_elt_type, check_typedef): Update.
* expprint.c (print_subexp_standard): Update.
* dwarf2read.c (dwarf2_add_field, load_partial_dies): Update.
* d-namespace.c (d_lookup_nested_symbol): Update.
* cp-valprint.c (cp_is_vtbl_ptr_type, cp_print_value_fields)
(cp_print_class_member): Update.
* cp-namespace.c (cp_lookup_nested_symbol): Update.
* completer.c (add_struct_fields): Update.
* c-typeprint.c (cp_type_print_derivation_info)
(c_type_print_varspec_prefix, c_type_print_base_struct_union):
Update.
* ada-lang.c (parse_old_style_renaming, xget_renaming_scope)
(ada_prefer_type, ada_is_exception_sym): Update.
2018-04-18 03:51:25 +08:00
|
|
|
extern const char *type_name_or_error (struct type *type);
|
2011-05-06 22:12:18 +08:00
|
|
|
|
2019-03-13 04:39:02 +08:00
|
|
|
struct struct_elt
|
|
|
|
{
|
|
|
|
/* The field of the element, or NULL if no element was found. */
|
|
|
|
struct field *field;
|
|
|
|
|
|
|
|
/* The bit offset of the element in the parent structure. */
|
|
|
|
LONGEST offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Given a type TYPE, lookup the field and offset of the component named
|
|
|
|
NAME.
|
|
|
|
|
|
|
|
TYPE can be either a struct or union, or a pointer or reference to
|
|
|
|
a struct or union. If it is a pointer or reference, its target
|
|
|
|
type is automatically used. Thus '.' and '->' are interchangable,
|
|
|
|
as specified for the definitions of the expression element types
|
|
|
|
STRUCTOP_STRUCT and STRUCTOP_PTR.
|
|
|
|
|
|
|
|
If NOERR is nonzero, the returned structure will have field set to
|
|
|
|
NULL if there is no component named NAME.
|
|
|
|
|
|
|
|
If the component NAME is a field in an anonymous substructure of
|
|
|
|
TYPE, the returned offset is a "global" offset relative to TYPE
|
|
|
|
rather than an offset within the substructure. */
|
|
|
|
|
|
|
|
extern struct_elt lookup_struct_elt (struct type *, const char *, int);
|
|
|
|
|
|
|
|
/* Given a type TYPE, lookup the type of the component named NAME.
|
|
|
|
|
|
|
|
TYPE can be either a struct or union, or a pointer or reference to
|
|
|
|
a struct or union. If it is a pointer or reference, its target
|
|
|
|
type is automatically used. Thus '.' and '->' are interchangable,
|
|
|
|
as specified for the definitions of the expression element types
|
|
|
|
STRUCTOP_STRUCT and STRUCTOP_PTR.
|
|
|
|
|
|
|
|
If NOERR is nonzero, return NULL if there is no component named
|
|
|
|
NAME. */
|
|
|
|
|
2013-10-02 08:46:07 +08:00
|
|
|
extern struct type *lookup_struct_elt_type (struct type *, const char *, int);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern struct type *make_pointer_type (struct type *, struct type **);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern struct type *lookup_pointer_type (struct type *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2009-06-29 21:19:19 +08:00
|
|
|
extern struct type *make_function_type (struct type *, struct type **);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern struct type *lookup_function_type (struct type *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2012-07-06 22:47:00 +08:00
|
|
|
extern struct type *lookup_function_type_with_arguments (struct type *,
|
|
|
|
int,
|
|
|
|
struct type **);
|
|
|
|
|
2023-03-14 02:53:48 +08:00
|
|
|
/* Create a range type using ALLOC.
|
|
|
|
|
|
|
|
Indices will be of type INDEX_TYPE, and will range from LOW_BOUND
|
|
|
|
to HIGH_BOUND, inclusive. */
|
|
|
|
|
|
|
|
extern struct type *create_static_range_type (type_allocator &alloc,
|
|
|
|
struct type *index_type,
|
|
|
|
LONGEST low_bound,
|
|
|
|
LONGEST high_bound);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2023-03-14 03:20:22 +08:00
|
|
|
/* Create an array type using ALLOC.
|
|
|
|
|
|
|
|
Elements will be of type ELEMENT_TYPE, the indices will be of type
|
|
|
|
RANGE_TYPE.
|
|
|
|
|
|
|
|
BYTE_STRIDE_PROP, when not NULL, provides the array's byte stride.
|
|
|
|
This byte stride property is added to the resulting array type
|
|
|
|
as a DYN_PROP_BYTE_STRIDE. As a consequence, the BYTE_STRIDE_PROP
|
|
|
|
argument can only be used to create types that are objfile-owned
|
|
|
|
(see add_dyn_prop), meaning that either this function must be called
|
|
|
|
with an objfile-owned RESULT_TYPE, or an objfile-owned RANGE_TYPE.
|
|
|
|
|
|
|
|
BIT_STRIDE is taken into account only when BYTE_STRIDE_PROP is NULL.
|
|
|
|
If BIT_STRIDE is not zero, build a packed array type whose element
|
|
|
|
size is BIT_STRIDE. Otherwise, ignore this parameter. */
|
2013-10-08 22:04:49 +08:00
|
|
|
|
DWARF: Add array DW_AT_bit_stride and DW_AT_byte_stride support
Consider the following declarations in Ada...
type Item is range -32 .. 31;
for Item'Size use 6;
type Table is array (Natural range 0 .. 4) of Item;
pragma Pack (Table);
... which declare a packed array whose elements are 6 bits long.
The debugger currently does not notice that the array is packed,
and thus prints values of this type incorrectly. This can be seen
in the "ptype" output:
(gdb) ptype table
type = array (0 .. 4) of foo.item
Normally, the debugger should print:
(gdb) ptype table
type = array (0 .. 4) of foo.item <packed: 6-bit elements>
The debugging information for this array looks like this:
.uleb128 0xf # (DIE (0x15c) DW_TAG_array_type)
.long .LASF9 # DW_AT_name: "pck__table"
.byte 0x6 # DW_AT_bit_stride
.long 0x1a9 # DW_AT_type
.uleb128 0x10 # (DIE (0x16a) DW_TAG_subrange_type)
.long 0x3b # DW_AT_type
.byte 0 # DW_AT_lower_bound
.byte 0x4 # DW_AT_upper_bound
.byte 0 # end of children of DIE 0x15c
The interesting part is the DW_AT_bit_stride attribute, which tells
the size of the array elements is 6 bits, rather than the normal
element type's size.
This patch adds support for this attribute by first creating
gdbtypes.c::create_array_type_with_stride, which is an enhanced
version of create_array_type taking an extra parameter as the stride.
The old create_array_type can then be re-implemented very simply
by calling the new create_array_type_with_stride.
We can then use this new function from dwarf2read, to create
arrays with or without stride.
gdb/ChangeLog:
* gdbtypes.h (create_array_type_with_stride): Add declaration.
* gdbtypes.c (create_array_type_with_stride): New function,
renaming create_array_type, but with an added parameter
called "bit_stride".
(create_array_type): Re-implement using
create_array_type_with_stride.
* dwarf2read.c (read_array_type): Add support for DW_AT_byte_stride
and DW_AT_bit_stride attributes.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/arr-stride.c: New file.
* gdb.dwarf2/arr-stride.exp: New file.
The test, relying purely on generating an assembly file, only
verifies the type description of our array. But I was also
able to verify manually that the debugger print values of these
types correctly as well (which was not the case prior to this
patch).
2014-01-29 21:39:56 +08:00
|
|
|
extern struct type *create_array_type_with_stride
|
2023-03-14 03:20:22 +08:00
|
|
|
(type_allocator &alloc, struct type *element_type,
|
|
|
|
struct type *range_type, struct dynamic_prop *byte_stride_prop,
|
|
|
|
unsigned int bit_stride);
|
DWARF: Add array DW_AT_bit_stride and DW_AT_byte_stride support
Consider the following declarations in Ada...
type Item is range -32 .. 31;
for Item'Size use 6;
type Table is array (Natural range 0 .. 4) of Item;
pragma Pack (Table);
... which declare a packed array whose elements are 6 bits long.
The debugger currently does not notice that the array is packed,
and thus prints values of this type incorrectly. This can be seen
in the "ptype" output:
(gdb) ptype table
type = array (0 .. 4) of foo.item
Normally, the debugger should print:
(gdb) ptype table
type = array (0 .. 4) of foo.item <packed: 6-bit elements>
The debugging information for this array looks like this:
.uleb128 0xf # (DIE (0x15c) DW_TAG_array_type)
.long .LASF9 # DW_AT_name: "pck__table"
.byte 0x6 # DW_AT_bit_stride
.long 0x1a9 # DW_AT_type
.uleb128 0x10 # (DIE (0x16a) DW_TAG_subrange_type)
.long 0x3b # DW_AT_type
.byte 0 # DW_AT_lower_bound
.byte 0x4 # DW_AT_upper_bound
.byte 0 # end of children of DIE 0x15c
The interesting part is the DW_AT_bit_stride attribute, which tells
the size of the array elements is 6 bits, rather than the normal
element type's size.
This patch adds support for this attribute by first creating
gdbtypes.c::create_array_type_with_stride, which is an enhanced
version of create_array_type taking an extra parameter as the stride.
The old create_array_type can then be re-implemented very simply
by calling the new create_array_type_with_stride.
We can then use this new function from dwarf2read, to create
arrays with or without stride.
gdb/ChangeLog:
* gdbtypes.h (create_array_type_with_stride): Add declaration.
* gdbtypes.c (create_array_type_with_stride): New function,
renaming create_array_type, but with an added parameter
called "bit_stride".
(create_array_type): Re-implement using
create_array_type_with_stride.
* dwarf2read.c (read_array_type): Add support for DW_AT_byte_stride
and DW_AT_bit_stride attributes.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/arr-stride.c: New file.
* gdb.dwarf2/arr-stride.exp: New file.
The test, relying purely on generating an assembly file, only
verifies the type description of our array. But I was also
able to verify manually that the debugger print values of these
types correctly as well (which was not the case prior to this
patch).
2014-01-29 21:39:56 +08:00
|
|
|
|
2023-03-14 02:53:48 +08:00
|
|
|
/* Create a range type using ALLOC with a dynamic range from LOW_BOUND
|
|
|
|
to HIGH_BOUND, inclusive. INDEX_TYPE is the underlying type. BIAS
|
|
|
|
is the bias to be applied when storing or retrieving values of this
|
|
|
|
type. */
|
|
|
|
|
|
|
|
extern struct type *create_range_type (type_allocator &alloc,
|
|
|
|
struct type *index_type,
|
|
|
|
const struct dynamic_prop *low_bound,
|
|
|
|
const struct dynamic_prop *high_bound,
|
|
|
|
LONGEST bias);
|
2013-10-08 22:04:49 +08:00
|
|
|
|
gdb/fortran: array stride support
Currently GDB supports a byte or bit stride on arrays, in DWARF this
would be DW_AT_bit_stride or DW_AT_byte_stride on DW_TAG_array_type.
However, DWARF can also support DW_AT_byte_stride or DW_AT_bit_stride
on DW_TAG_subrange_type, the tag used to describe each dimension of an
array.
Strides on subranges are used by gFortran to represent Fortran arrays,
and this commit adds support for this to GDB.
I've extended the range_bounds struct to include the stride
information. The name is possibly a little inaccurate now, but this
still sort of makes sense, the structure represents information about
the bounds of the range, and also how to move from the lower to the
upper bound (the stride).
I've added initial support for bit strides, but I've never actually
seen an example of this being generated. Further, I don't really see
right now how GDB would currently handle a bit stride that was not a
multiple of the byte size as the code in, for example,
valarith.c:value_subscripted_rvalue seems geared around byte
addressing. As a consequence if we see a bit stride that is not a
multiple of 8 then GDB will give an error.
gdb/ChangeLog:
* dwarf2read.c (read_subrange_type): Read bit and byte stride and
create a range with stride where appropriate.
* f-valprint.c: Include 'gdbarch.h'.
(f77_print_array_1): Take the stride into account when walking the
array. Also convert the stride into addressable units.
* gdbtypes.c (create_range_type): Initialise the stride to
constant zero.
(create_range_type_with_stride): New function, initialise the
range as normal, and then setup the stride.
(has_static_range): Include the stride here. Also change the
return type to bool.
(create_array_type_with_stride): Consider the range stride if the
array isn't given its own stride.
(resolve_dynamic_range): Resolve the stride if needed.
* gdbtypes.h (struct range_bounds) <stride>: New member variable.
(struct range_bounds) <flag_is_byte_stride>: New member variable.
(TYPE_BIT_STRIDE): Define.
(TYPE_ARRAY_BIT_STRIDE): Define.
(create_range_type_with_stride): Declare.
* valarith.c (value_subscripted_rvalue): Take range stride into
account when walking the array.
gdb/testsuite/ChangeLog:
* gdb.fortran/derived-type-striding.exp: New file.
* gdb.fortran/derived-type-striding.f90: New file.
* gdb.fortran/array-slices.exp: New file.
* gdb.fortran/array-slices.f90: New file.
Change-Id: I9af2bcd1f2d4c56f76f5f3f9f89d8f06bef10d9a
2019-10-24 18:12:11 +08:00
|
|
|
/* Like CREATE_RANGE_TYPE but also sets up a stride. When BYTE_STRIDE_P
|
|
|
|
is true the value in STRIDE is a byte stride, otherwise STRIDE is a bit
|
|
|
|
stride. */
|
|
|
|
|
2023-03-14 02:53:48 +08:00
|
|
|
extern struct type *create_range_type_with_stride
|
|
|
|
(type_allocator &alloc, struct type *index_type,
|
gdb/fortran: array stride support
Currently GDB supports a byte or bit stride on arrays, in DWARF this
would be DW_AT_bit_stride or DW_AT_byte_stride on DW_TAG_array_type.
However, DWARF can also support DW_AT_byte_stride or DW_AT_bit_stride
on DW_TAG_subrange_type, the tag used to describe each dimension of an
array.
Strides on subranges are used by gFortran to represent Fortran arrays,
and this commit adds support for this to GDB.
I've extended the range_bounds struct to include the stride
information. The name is possibly a little inaccurate now, but this
still sort of makes sense, the structure represents information about
the bounds of the range, and also how to move from the lower to the
upper bound (the stride).
I've added initial support for bit strides, but I've never actually
seen an example of this being generated. Further, I don't really see
right now how GDB would currently handle a bit stride that was not a
multiple of the byte size as the code in, for example,
valarith.c:value_subscripted_rvalue seems geared around byte
addressing. As a consequence if we see a bit stride that is not a
multiple of 8 then GDB will give an error.
gdb/ChangeLog:
* dwarf2read.c (read_subrange_type): Read bit and byte stride and
create a range with stride where appropriate.
* f-valprint.c: Include 'gdbarch.h'.
(f77_print_array_1): Take the stride into account when walking the
array. Also convert the stride into addressable units.
* gdbtypes.c (create_range_type): Initialise the stride to
constant zero.
(create_range_type_with_stride): New function, initialise the
range as normal, and then setup the stride.
(has_static_range): Include the stride here. Also change the
return type to bool.
(create_array_type_with_stride): Consider the range stride if the
array isn't given its own stride.
(resolve_dynamic_range): Resolve the stride if needed.
* gdbtypes.h (struct range_bounds) <stride>: New member variable.
(struct range_bounds) <flag_is_byte_stride>: New member variable.
(TYPE_BIT_STRIDE): Define.
(TYPE_ARRAY_BIT_STRIDE): Define.
(create_range_type_with_stride): Declare.
* valarith.c (value_subscripted_rvalue): Take range stride into
account when walking the array.
gdb/testsuite/ChangeLog:
* gdb.fortran/derived-type-striding.exp: New file.
* gdb.fortran/derived-type-striding.f90: New file.
* gdb.fortran/array-slices.exp: New file.
* gdb.fortran/array-slices.f90: New file.
Change-Id: I9af2bcd1f2d4c56f76f5f3f9f89d8f06bef10d9a
2019-10-24 18:12:11 +08:00
|
|
|
const struct dynamic_prop *low_bound,
|
|
|
|
const struct dynamic_prop *high_bound, LONGEST bias,
|
|
|
|
const struct dynamic_prop *stride, bool byte_stride_p);
|
|
|
|
|
2023-03-14 03:20:22 +08:00
|
|
|
/* Same as create_array_type_with_stride but with no bit_stride
|
|
|
|
(BIT_STRIDE = 0), thus building an unpacked array. */
|
|
|
|
|
|
|
|
extern struct type *create_array_type (type_allocator &alloc,
|
|
|
|
struct type *element_type,
|
|
|
|
struct type *range_type);
|
DWARF: Add array DW_AT_bit_stride and DW_AT_byte_stride support
Consider the following declarations in Ada...
type Item is range -32 .. 31;
for Item'Size use 6;
type Table is array (Natural range 0 .. 4) of Item;
pragma Pack (Table);
... which declare a packed array whose elements are 6 bits long.
The debugger currently does not notice that the array is packed,
and thus prints values of this type incorrectly. This can be seen
in the "ptype" output:
(gdb) ptype table
type = array (0 .. 4) of foo.item
Normally, the debugger should print:
(gdb) ptype table
type = array (0 .. 4) of foo.item <packed: 6-bit elements>
The debugging information for this array looks like this:
.uleb128 0xf # (DIE (0x15c) DW_TAG_array_type)
.long .LASF9 # DW_AT_name: "pck__table"
.byte 0x6 # DW_AT_bit_stride
.long 0x1a9 # DW_AT_type
.uleb128 0x10 # (DIE (0x16a) DW_TAG_subrange_type)
.long 0x3b # DW_AT_type
.byte 0 # DW_AT_lower_bound
.byte 0x4 # DW_AT_upper_bound
.byte 0 # end of children of DIE 0x15c
The interesting part is the DW_AT_bit_stride attribute, which tells
the size of the array elements is 6 bits, rather than the normal
element type's size.
This patch adds support for this attribute by first creating
gdbtypes.c::create_array_type_with_stride, which is an enhanced
version of create_array_type taking an extra parameter as the stride.
The old create_array_type can then be re-implemented very simply
by calling the new create_array_type_with_stride.
We can then use this new function from dwarf2read, to create
arrays with or without stride.
gdb/ChangeLog:
* gdbtypes.h (create_array_type_with_stride): Add declaration.
* gdbtypes.c (create_array_type_with_stride): New function,
renaming create_array_type, but with an added parameter
called "bit_stride".
(create_array_type): Re-implement using
create_array_type_with_stride.
* dwarf2read.c (read_array_type): Add support for DW_AT_byte_stride
and DW_AT_bit_stride attributes.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/arr-stride.c: New file.
* gdb.dwarf2/arr-stride.exp: New file.
The test, relying purely on generating an assembly file, only
verifies the type description of our array. But I was also
able to verify manually that the debugger print values of these
types correctly as well (which was not the case prior to this
patch).
2014-01-29 21:39:56 +08:00
|
|
|
|
2012-09-27 16:57:16 +08:00
|
|
|
extern struct type *lookup_array_range_type (struct type *, LONGEST, LONGEST);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2023-03-14 03:20:22 +08:00
|
|
|
/* Create a string type using ALLOC. String types are similar enough
|
|
|
|
to array of char types that we can use create_array_type to build
|
|
|
|
the basic type and then bash it into a string type.
|
|
|
|
|
|
|
|
For fixed length strings, the range type contains 0 as the lower
|
|
|
|
bound and the length of the string minus one as the upper bound. */
|
|
|
|
|
|
|
|
extern struct type *create_string_type (type_allocator &alloc,
|
|
|
|
struct type *string_char_type,
|
|
|
|
struct type *range_type);
|
|
|
|
|
2012-09-27 16:57:16 +08:00
|
|
|
extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2023-03-14 03:25:41 +08:00
|
|
|
extern struct type *create_set_type (type_allocator &alloc,
|
|
|
|
struct type *domain_type);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2009-06-18 02:46:26 +08:00
|
|
|
extern struct type *lookup_unsigned_typename (const struct language_defn *,
|
2019-12-06 02:44:30 +08:00
|
|
|
const char *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2009-06-18 02:46:26 +08:00
|
|
|
extern struct type *lookup_signed_typename (const struct language_defn *,
|
2019-12-06 02:44:30 +08:00
|
|
|
const char *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2021-07-29 23:12:03 +08:00
|
|
|
extern ULONGEST get_unsigned_type_max (struct type *);
|
Add Guile as an extension language.
* NEWS: Mention Guile scripting.
* Makefile.in (SUBDIR_GUILE_OBS): New variable.
(SUBDIR_GUILE_SRCS, SUBDIR_GUILE_DEPS): New variables
(SUBDIR_GUILE_LDFLAGS, SUBDIR_GUILE_CFLAGS): New variables.
(INTERNAL_CPPFLAGS): Add GUILE_CPPFLAGS.
(CLIBS): Add GUILE_LIBS.
(install-guile): New rule.
(guile.o): New rule.
(scm-arch.o, scm-auto-load.o, scm-block.o): New rules.
(scm-breakpoint.o, scm-disasm.o, scm-exception.o): New rules.
(scm-frame.o, scm-iterator.o, scm-lazy-string.o): New rules.
(scm-math.o, scm-objfile.o, scm-ports.o): New rules.
(scm-pretty-print.o, scm-safe-call.o, scm-gsmob.o): New rules.
(scm-string.o, scm-symbol.o, scm-symtab.o): New rules.
(scm-type.o, scm-utils.o, scm-value.o): New rules.
* configure.ac: New option --with-guile.
* configure: Regenerate.
* config.in: Regenerate.
* auto-load.c: Remove #include "python/python.h". Add #include
"gdb/section-scripts.h".
(source_section_scripts): Handle Guile scripts.
(_initialize_auto_load): Add name of Guile objfile script to
scripts-directory help text.
* breakpoint.c (condition_command): Tweak comment to include Scheme.
* breakpoint.h (gdbscm_breakpoint_object): Add forward decl.
(struct breakpoint): New member scm_bp_object.
* defs.h (enum command_control_type): New value guile_control.
* cli/cli-cmds.c: Remove #include "python/python.h". Add #include
"extension.h".
(show_user): Update comment.
(_initialize_cli_cmds): Update help text for "show user". Update help
text for max-user-call-depth.
* cli/cli-script.c: Remove #include "python/python.h". Add #include
"extension.h".
(multi_line_command_p): Add guile_control.
(print_command_lines): Handle guile_control.
(execute_control_command, recurse_read_control_structure): Ditto.
(process_next_line): Recognize "guile" commands.
* disasm.c (gdb_disassemble_info): Make non-static.
* disasm.h: #include "dis-asm.h".
(struct gdbarch): Add forward decl.
(gdb_disassemble_info): Declare.
* extension.c: #include "guile/guile.h".
(extension_languages): Add guile.
(get_ext_lang_defn): Handle EXT_LANG_GDB.
* extension.h (enum extension_language): New value EXT_LANG_GUILE.
* gdbtypes.c (get_unsigned_type_max): New function.
(get_signed_type_minmax): New function.
* gdbtypes.h (get_unsigned_type_max): Declare.
(get_signed_type_minmax): Declare.
* guile/README: New file.
* guile/guile-internal.h: New file.
* guile/guile.c: New file.
* guile/guile.h: New file.
* guile/scm-arch.c: New file.
* guile/scm-auto-load.c: New file.
* guile/scm-block.c: New file.
* guile/scm-breakpoint.c: New file.
* guile/scm-disasm.c: New file.
* guile/scm-exception.c: New file.
* guile/scm-frame.c: New file.
* guile/scm-gsmob.c: New file.
* guile/scm-iterator.c: New file.
* guile/scm-lazy-string.c: New file.
* guile/scm-math.c: New file.
* guile/scm-objfile.c: New file.
* guile/scm-ports.c: New file.
* guile/scm-pretty-print.c: New file.
* guile/scm-safe-call.c: New file.
* guile/scm-string.c: New file.
* guile/scm-symbol.c: New file.
* guile/scm-symtab.c: New file.
* guile/scm-type.c: New file.
* guile/scm-utils.c: New file.
* guile/scm-value.c: New file.
* guile/lib/gdb.scm: New file.
* guile/lib/gdb/boot.scm: New file.
* guile/lib/gdb/experimental.scm: New file.
* guile/lib/gdb/init.scm: New file.
* guile/lib/gdb/iterator.scm: New file.
* guile/lib/gdb/printing.scm: New file.
* guile/lib/gdb/types.scm: New file.
* data-directory/Makefile.in (GUILE_SRCDIR): New variable.
(VPATH): Add $(GUILE_SRCDIR).
(GUILE_DIR): New variable.
(GUILE_INSTALL_DIR, GUILE_FILES): New variables.
(all): Add stamp-guile dependency.
(stamp-guile): New rule.
(clean-guile, install-guile, uninstall-guile): New rules.
(install-only): Add install-guile dependency.
(uninstall): Add uninstall-guile dependency.
(clean): Add clean-guile dependency.
doc/
* Makefile.in (GDB_DOC_FILES): Add guile.texi.
* gdb.texinfo (Auto-loading): Add set/show auto-load guile-scripts.
(Extending GDB): New menu entries Guile, Multiple Extension Languages.
(Guile docs): Include guile.texi.
(objfile-gdbdotext file): Add objfile-gdb.scm.
(dotdebug_gdb_scripts section): Mention Guile scripts.
(Multiple Extension Languages): New node.
* guile.texi: New file.
testsuite/
* configure.ac (AC_OUTPUT): Add gdb.guile.
* configure: Regenerate.
* lib/gdb-guile.exp: New file.
* lib/gdb.exp (get_target_charset): New function.
* gdb.base/help.exp: Update expected output from "apropos apropos".
* gdb.guile/Makefile.in: New file.
* gdb.guile/guile.exp: New file.
* gdb.guile/scm-arch.c: New file.
* gdb.guile/scm-arch.exp: New file.
* gdb.guile/scm-block.c: New file.
* gdb.guile/scm-block.exp: New file.
* gdb.guile/scm-breakpoint.c: New file.
* gdb.guile/scm-breakpoint.exp: New file.
* gdb.guile/scm-disasm.c: New file.
* gdb.guile/scm-disasm.exp: New file.
* gdb.guile/scm-equal.c: New file.
* gdb.guile/scm-equal.exp: New file.
* gdb.guile/scm-error.exp: New file.
* gdb.guile/scm-error.scm: New file.
* gdb.guile/scm-frame-args.c: New file.
* gdb.guile/scm-frame-args.exp: New file.
* gdb.guile/scm-frame-args.scm: New file.
* gdb.guile/scm-frame-inline.c: New file.
* gdb.guile/scm-frame-inline.exp: New file.
* gdb.guile/scm-frame.c: New file.
* gdb.guile/scm-frame.exp: New file.
* gdb.guile/scm-generics.exp: New file.
* gdb.guile/scm-gsmob.exp: New file.
* gdb.guile/scm-iterator.c: New file.
* gdb.guile/scm-iterator.exp: New file.
* gdb.guile/scm-math.c: New file.
* gdb.guile/scm-math.exp: New file.
* gdb.guile/scm-objfile-script-gdb.in: New file.
* gdb.guile/scm-objfile-script.c: New file.
* gdb.guile/scm-objfile-script.exp: New file.
* gdb.guile/scm-objfile.c: New file.
* gdb.guile/scm-objfile.exp: New file.
* gdb.guile/scm-ports.exp: New file.
* gdb.guile/scm-pretty-print.c: New file.
* gdb.guile/scm-pretty-print.exp: New file.
* gdb.guile/scm-pretty-print.scm: New file.
* gdb.guile/scm-section-script.c: New file.
* gdb.guile/scm-section-script.exp: New file.
* gdb.guile/scm-section-script.scm: New file.
* gdb.guile/scm-symbol.c: New file.
* gdb.guile/scm-symbol.exp: New file.
* gdb.guile/scm-symtab-2.c: New file.
* gdb.guile/scm-symtab.c: New file.
* gdb.guile/scm-symtab.exp: New file.
* gdb.guile/scm-type.c: New file.
* gdb.guile/scm-type.exp: New file.
* gdb.guile/scm-value-cc.cc: New file.
* gdb.guile/scm-value-cc.exp: New file.
* gdb.guile/scm-value.c: New file.
* gdb.guile/scm-value.exp: New file.
* gdb.guile/source2.scm: New file.
* gdb.guile/types-module.cc: New file.
* gdb.guile/types-module.exp: New file.
2014-02-10 11:40:01 +08:00
|
|
|
|
|
|
|
extern void get_signed_type_minmax (struct type *, LONGEST *, LONGEST *);
|
|
|
|
|
2021-07-29 23:12:18 +08:00
|
|
|
extern CORE_ADDR get_pointer_type_max (struct type *);
|
|
|
|
|
2013-10-09 22:28:22 +08:00
|
|
|
/* * Resolve all dynamic values of a type e.g. array bounds to static values.
|
|
|
|
ADDR specifies the location of the variable the type is bound to.
|
|
|
|
If TYPE has no dynamic properties return TYPE; otherwise a new type with
|
2021-10-20 04:42:04 +08:00
|
|
|
static properties is returned.
|
|
|
|
|
2023-03-02 00:54:04 +08:00
|
|
|
If FRAME is given, it is used when evaluating dynamic properties.
|
|
|
|
This can be important when a static link is seen. If not given,
|
|
|
|
the selected frame is used.
|
|
|
|
|
2021-10-20 04:42:04 +08:00
|
|
|
For an array type, if the element type is dynamic, then that will
|
|
|
|
not be resolved. This is done because each individual element may
|
|
|
|
have a different type when resolved (depending on the contents of
|
|
|
|
memory). In this situation, 'is_dynamic_type' will still return
|
|
|
|
true for the return value of this function. */
|
Prefer existing data when evaluating DWARF expression
When evaluating a DWARF expression, the dynamic type resolution code
will pass in a buffer of bytes via the property_addr_info. However,
the DWARF expression evaluator will then proceed to read memory from
the inferior, even when the request could be filled from this buffer.
This, in turn, is a problem in some cases; and specifically when
trying to handle the Ada scenario of extracting a variable-length
value from a packed array. Here, the ordinary DWARF expression cannot
be directly evaluated, because the data may appear at some arbitrary
bit offset. So, it is unpacked into a staging area and then the
expression is evaluated -- using an address of 0.
This patch fixes the problem by arranging for the DWARF evaluator, in
this case, to prefer passed-in memory when possible. The type of the
buffer in the property_addr_info is changed to an array_view so that
bounds checking can be done.
gdb/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_discrete_type_high_bound, ada_discrete_type_low)
(ada_value_primitive_packed_val): Update.
* ada-valprint.c (ada_value_print_1): Update.
* dwarf2/loc.c (evaluate_for_locexpr_baton): New struct.
(dwarf2_locexpr_baton_eval): Take a property_addr_info rather than
just an address. Use evaluate_for_locexpr_baton.
(dwarf2_evaluate_property): Update.
* dwarf2/loc.h (struct property_addr_info) <valaddr>: Now an
array_view.
* findvar.c (default_read_var_value): Update.
* gdbtypes.c (compute_variant_fields_inner)
(resolve_dynamic_type_internal): Update.
(resolve_dynamic_type): Change type of valaddr parameter.
* gdbtypes.h (resolve_dynamic_type): Update.
* valarith.c (value_subscripted_rvalue): Update.
* value.c (value_from_contents_and_address): Update.
2020-04-25 03:40:31 +08:00
|
|
|
extern struct type *resolve_dynamic_type
|
|
|
|
(struct type *type, gdb::array_view<const gdb_byte> valaddr,
|
2023-03-02 00:54:04 +08:00
|
|
|
CORE_ADDR addr, const frame_info_ptr *frame = nullptr);
|
2013-10-09 22:28:22 +08:00
|
|
|
|
2021-10-20 04:42:04 +08:00
|
|
|
/* * Predicate if the type has dynamic values, which are not resolved yet.
|
|
|
|
See the caveat in 'resolve_dynamic_type' to understand a scenario
|
|
|
|
where an apparently-resolved type may still be considered
|
|
|
|
"dynamic". */
|
2013-10-09 22:28:22 +08:00
|
|
|
extern int is_dynamic_type (struct type *type);
|
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern struct type *check_typedef (struct type *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2002-09-14 10:09:39 +08:00
|
|
|
extern void check_stub_method_group (struct type *, int);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern char *gdb_mangle_name (struct type *, int, int);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2009-06-18 02:46:26 +08:00
|
|
|
extern struct type *lookup_typename (const struct language_defn *,
|
2019-12-06 02:44:30 +08:00
|
|
|
const char *, const struct block *, int);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2019-04-08 05:29:58 +08:00
|
|
|
extern struct type *lookup_template_type (const char *, struct type *,
|
* ada-exp.y (write_object_renaming, write_var_or_type)
(write_ambiguous_var, write_var_from_sym): Make blocks const.
* ada-lang.c (replace_operator_with_call)
(find_old_style_renaming_symbol): Make blocks const.
* ada-lang.h (ada_find_renaming_symbol): Update.
(struct ada_symbol_info) <block>: Now const.
* breakpoint.c (watch_command_1): Update.
* breakpoint.h (struct watchpoint) <exp_valid_block,
cond_exp_valid_block>: Now const.
* c-exp.y (classify_inner_name, classify_name): Make block
argument const.
* expprint.c (print_subexp_standard) <OP_VAR_VALUE>: Make 'b'
const.
* expression.h (innermost_block, parse_exp_1): Update.
(union exp_element) <block>: Now const.
* gdbtypes.c (lookup_template_type, lookup_enum, lookup_union)
(lookup_struct): Make block argument const.
* gdbtypes.h (lookup_template_type): Update.
* go-exp.y (classify_name, classify_packaged_name)
(package_name_p): Make block argument const.
* objc-lang.c (lookup_struct_typedef): Make block argument const.
* objc-lang.h (lookup_struct_typedef): Update.
* parse.c (parse_exp_in_context, parse_exp_1)
(write_exp_elt_block): Make block arguments const.
(expression_context_block, innermost_block): Now const.
* parser-defs.h (write_exp_elt_block): Update.
(expression_context_block, innermost_block, block_found): Now
const.
* printcmd.c (struct display) <block>: Now const.
* symtab.h (lookup_struct, lookup_union, lookup_enum): Update.
* valops.c (address_of_variable): Make block argument const.
* value.h (value_of_variable): Update.
* varobj.c (struct varobj_root) <valid_block>: Now const.
2012-12-04 03:59:14 +08:00
|
|
|
const struct block *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2008-02-04 06:13:30 +08:00
|
|
|
extern int get_vptr_fieldno (struct type *, struct type **);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2020-12-10 02:51:57 +08:00
|
|
|
/* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type
|
|
|
|
TYPE.
|
|
|
|
|
|
|
|
Return true if the two bounds are available, false otherwise. */
|
|
|
|
|
|
|
|
extern bool get_discrete_bounds (struct type *type, LONGEST *lowp,
|
|
|
|
LONGEST *highp);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
gdb: fix value_subscript when array upper bound is not known
Since commit 7c6f27129631 ("gdb: make get_discrete_bounds check for
non-constant range bounds"), subscripting flexible array member fails:
struct no_size
{
int n;
int items[];
};
(gdb) p *ns
$1 = {n = 3, items = 0x5555555592a4}
(gdb) p ns->items[0]
Cannot access memory at address 0xfffe555b733a0164
(gdb) p *((int *) 0x5555555592a4)
$2 = 101 <--- we would expect that
(gdb) p &ns->items[0]
$3 = (int *) 0xfffe5559ee829a24 <--- wrong address
Since the flexible array member (items) has an unspecified size, the array type
created for it in the DWARF doesn't have dimensions (this is with gcc 9.3.0,
Ubuntu 20.04):
0x000000a4: DW_TAG_array_type
DW_AT_type [DW_FORM_ref4] (0x00000038 "int")
DW_AT_sibling [DW_FORM_ref4] (0x000000b3)
0x000000ad: DW_TAG_subrange_type
DW_AT_type [DW_FORM_ref4] (0x00000031 "long unsigned int")
This causes GDB to create a range type (TYPE_CODE_RANGE) with a defined
constant low bound (dynamic_prop with kind PROP_CONST) and an undefined
high bound (dynamic_prop with kind PROP_UNDEFINED).
value_subscript gets both bounds of that range using
get_discrete_bounds. Before commit 7c6f27129631, get_discrete_bounds
didn't check the kind of the dynamic_props and would just blindly read
them as if they were PROP_CONST. It would return 0 for the high bound,
because we zero-initialize the range_bounds structure. And it didn't
really matter in this case, because the returned high bound wasn't used
in the end.
Commit 7c6f27129631 changed get_discrete_bounds to return a failure if
either the low or high bound is not a constant, to make sure we don't
read a dynamic prop that isn't a PROP_CONST as a PROP_CONST. This
change made get_discrete_bounds start to return a failure for that
range, and as a result would not set *lowp and *highp. And since
value_subscript doesn't check get_discrete_bounds' return value, it just
carries on an uses an uninitialized value for the low bound. If
value_subscript did check the return value of get_discrete_bounds, we
would get an error message instead of a bogus value. But it would still
be a bug, as we wouldn't be able to print the flexible array member's
elements.
Looking at value_subscript, we see that the low bound is always needed,
but the high bound is only needed if !c_style. So, change
value_subscript to use get_discrete_low_bound and
get_discrete_high_bound separately. This fixes the case described
above, where the low bound is known but the high bound isn't (and is not
needed). This restores the original behavior without accessing a
dynamic_prop in a wrong way.
A test is added. In addition to the case described above, a case with
an array member of size 0 is added, which is a GNU C extension that
existed before flexible array members were introduced. That case
currently fails when compiled with gcc <= 8. gcc <= 8 produces DWARF
similar to the one shown above, while gcc 9 adds a DW_AT_count of 0 in
there, which makes the high bound known. A case where an array member
of size 0 is the only member of the struct is also added, as that was
how PR 28675 was originally reported, and it's an interesting corner
case that I think could trigger other funny bugs.
Question about the implementation: in value_subscript, I made it such
that if the low or high bound is unknown, we fall back to zero. That
effectively makes it the same as it was before 7c6f27129631. But should
we instead error() out?
gdb/ChangeLog:
PR 26875, PR 26901
* gdbtypes.c (get_discrete_low_bound): Make non-static.
(get_discrete_high_bound): Make non-static.
* gdbtypes.h (get_discrete_low_bound): New declaration.
(get_discrete_high_bound): New declaration.
* valarith.c (value_subscript): Only fetch high bound if
necessary.
gdb/testsuite/ChangeLog:
PR 26875, PR 26901
* gdb.base/flexible-array-member.c: New test.
* gdb.base/flexible-array-member.exp: New test.
Change-Id: I832056f80e6c56f621f398b4780d55a3a1e299d7
2020-12-10 02:52:12 +08:00
|
|
|
/* If TYPE's low bound is a known constant, return it, else return nullopt. */
|
|
|
|
|
|
|
|
extern gdb::optional<LONGEST> get_discrete_low_bound (struct type *type);
|
|
|
|
|
|
|
|
/* If TYPE's high bound is a known constant, return it, else return nullopt. */
|
|
|
|
|
|
|
|
extern gdb::optional<LONGEST> get_discrete_high_bound (struct type *type);
|
|
|
|
|
2020-11-18 06:53:27 +08:00
|
|
|
/* Assuming TYPE is a simple, non-empty array type, compute its upper
|
|
|
|
and lower bound. Save the low bound into LOW_BOUND if not NULL.
|
|
|
|
Save the high bound into HIGH_BOUND if not NULL.
|
|
|
|
|
|
|
|
Return true if the operation was successful. Return false otherwise,
|
|
|
|
in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified. */
|
|
|
|
|
|
|
|
extern bool get_array_bounds (struct type *type, LONGEST *low_bound,
|
|
|
|
LONGEST *high_bound);
|
2010-11-03 22:21:58 +08:00
|
|
|
|
2020-12-10 02:51:45 +08:00
|
|
|
extern gdb::optional<LONGEST> discrete_position (struct type *type,
|
|
|
|
LONGEST val);
|
Array indexed by non-contiguous enumeration types
In Ada, index types of arrays can be enumeration types, and enumeration
types can be non-contiguous. In which case the address of elements is
not given by the value of the index, but by its position in the enumeration
type.
In other words, in this example:
type Color is (Blue, Red);
for Color use (Blue => 8, Red => 12, Green => 16);
type A is array (Color) of Integer;
type B is array (1 .. 3) of Integer;
Arrays of type A and B will have the same layout in memory, even if
the enumeration Color has a hole in its set of integer value.
Since recently support for such a feature was in ada-lang.c, where the
array was casted to a regular continuous index range. We were losing
the information of index type. And this was not quite working for
subranges in variable-length fields; their bounds are expressed using
the integer value of the bounds, not its position in the enumeration,
and there was some confusion all over ada-lang.c as to whether we had
the position or the integer value was used for indexes.
The idea behind this patch is to clean this up by keeping the real
representation of these array index types and bounds when representing
the value, and only use the position when accessing the elements or
computing the length. This first patch fixes the printing of such
an array.
To the best of my knowledge, this feature only exists in Ada so it
should only affect this language.
gdb/ChangeLog:
Jerome Guitton <guitton@adacore.com>:
* ada-lang.c (ada_value_ptr_subscript): Use enum position of
index to get element instead of enum value.
(ada_value_slice_from_ptr, ada_value_slice): Use enum position
of index to compute length, but enum values to compute bounds.
(ada_array_length): Use enum position of index instead of enum value.
(pos_atr): Move position computation to...
(ada_evaluate_subexp): Use enum values to compute bounds.
* gdbtypes.c (discrete_position): ...this new function.
* gdbtypes.h (discrete_position): New function declaration.
* valprint.c (val_print_array_elements): Call discrete_position
to handle array indexed by non-contiguous enumeration types.
gdb/testsuite/ChangeLog:
* gdb.ada/arr_enum_with_gap: New testcase.
2015-03-27 21:45:08 +08:00
|
|
|
|
2010-01-19 04:54:35 +08:00
|
|
|
extern int class_types_same_p (const struct type *, const struct type *);
|
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern int is_ancestor (struct type *, struct type *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2010-01-19 04:54:35 +08:00
|
|
|
extern int is_public_ancestor (struct type *, struct type *);
|
|
|
|
|
|
|
|
extern int is_unique_ancestor (struct type *, struct value *);
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Overload resolution */
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness if parameter list length doesn't match arg list length. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank LENGTH_MISMATCH_BADNESS;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Dummy badness value for nonexistent parameter positions. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank TOO_FEW_PARAMS_BADNESS;
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness if no conversion among types. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank INCOMPATIBLE_TYPE_BADNESS;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of an exact match. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank EXACT_MATCH_BADNESS;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of integral promotion. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank INTEGER_PROMOTION_BADNESS;
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of floating promotion. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank FLOAT_PROMOTION_BADNESS;
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of converting a derived class pointer
|
2010-10-15 00:13:43 +08:00
|
|
|
to a base class pointer. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank BASE_PTR_CONVERSION_BADNESS;
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of integral conversion. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank INTEGER_CONVERSION_BADNESS;
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of floating conversion. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank FLOAT_CONVERSION_BADNESS;
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of integer<->floating conversions. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank INT_FLOAT_CONVERSION_BADNESS;
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of conversion of pointer to void pointer. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank VOID_PTR_CONVERSION_BADNESS;
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of conversion to boolean. */
|
2012-09-11 01:12:53 +08:00
|
|
|
extern const struct rank BOOL_CONVERSION_BADNESS;
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of converting derived to base class. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank BASE_CONVERSION_BADNESS;
|
2017-04-28 06:55:26 +08:00
|
|
|
/* * Badness of converting from non-reference to reference. Subrank
|
|
|
|
is the type of reference conversion being done. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank REFERENCE_CONVERSION_BADNESS;
|
gdb: fix overload resolution for see-through references
The overload resolution mechanism assigns badness values to the
necessary conversions to be made on types to pick a champion. A
badness value consists of a "rank" that scores the conversion and a
"subrank" to differentiate conversions of the same kind.
An auxiliary function, 'sum_ranks', is used for adding two badness
values. In all of its uses, except two, 'sum_ranks' is used for
populating the subrank of a badness value. The two exceptions are in
'rank_one_type':
~~~
/* See through references, since we can almost make non-references
references. */
if (TYPE_IS_REFERENCE (arg))
return (sum_ranks (rank_one_type (parm, TYPE_TARGET_TYPE (arg), NULL),
REFERENCE_CONVERSION_BADNESS));
if (TYPE_IS_REFERENCE (parm))
return (sum_ranks (rank_one_type (TYPE_TARGET_TYPE (parm), arg, NULL),
REFERENCE_CONVERSION_BADNESS));
~~~
Here, the result of a recursive call is combined with
REFERENCE_CONVERSION_BADNESS. This leads to the problem of
over-punishment by combining two ranks. Consider this:
void an_overloaded_function (const foo &);
void an_overloaded_function (const foo &&);
...
foo arg;
an_overloaded_function(arg);
When ranking 'an_overloaded_function (const foo &)', the badness
values REFERENCE_CONVERSION_BADNESS and CV_CONVERSION_BADNESS are
combined, whereas 'rank_one_type' assigns only the
REFERENCE_CONVERSION_BADNESS value to 'an_overloaded_function (const
foo &&)' (there is a different execution flow for that). This yields
in GDB picking the latter function as the overload champion instead of
the former.
In fact, the 'rank_one_type' function should have given
'an_overloaded_function (const foo &)' the CV_CONVERSION_BADNESS
value, with the see-through referencing increasing the subrank a
little bit. This can be achieved by introducing a new badness value,
REFERENCE_SEE_THROUGH_BADNESS, which bumps up the subrank only, and
using it in the two "exceptional" cases of 'sum_ranks'.
gdb/ChangeLog:
2019-12-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdbtypes.h: Define the REFERENCE_SEE_THROUGH_BADNESS value.
* gdbtypes.c (rank_one_type): Use REFERENCE_SEE_THROUGH_BADNESS
for ranking see-through reference cases.
gdb/testsuite/ChangeLog:
2019-12-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.cp/rvalue-ref-overload.cc: Add a case that involves both
CV and reference conversion for overload resolution.
* gdb.cp/rvalue-ref-overload.exp: Test it.
Change-Id: I39ae6505ab85ad0bd21915368c82540ceeb3aae9
2019-11-12 22:12:43 +08:00
|
|
|
extern const struct rank REFERENCE_SEE_THROUGH_BADNESS;
|
2017-04-28 06:55:26 +08:00
|
|
|
/* * Conversion to rvalue reference. */
|
|
|
|
#define REFERENCE_CONVERSION_RVALUE 1
|
|
|
|
/* * Conversion to const lvalue reference. */
|
|
|
|
#define REFERENCE_CONVERSION_CONST_LVALUE 2
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of converting integer 0 to NULL pointer. */
|
2011-10-15 04:22:17 +08:00
|
|
|
extern const struct rank NULL_POINTER_CONVERSION;
|
2017-04-28 06:55:26 +08:00
|
|
|
/* * Badness of cv-conversion. Subrank is a flag describing the conversions
|
|
|
|
being done. */
|
|
|
|
extern const struct rank CV_CONVERSION_BADNESS;
|
|
|
|
#define CV_CONVERSION_CONST 1
|
|
|
|
#define CV_CONVERSION_VOLATILE 2
|
2000-03-13 15:30:00 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Non-standard conversions allowed by the debugger */
|
2014-03-13 10:36:45 +08:00
|
|
|
|
|
|
|
/* * Converting a pointer to an int is usually OK. */
|
2010-11-05 04:26:23 +08:00
|
|
|
extern const struct rank NS_POINTER_CONVERSION_BADNESS;
|
|
|
|
|
2014-03-13 10:36:45 +08:00
|
|
|
/* * Badness of converting a (non-zero) integer constant
|
2012-08-18 01:37:03 +08:00
|
|
|
to a pointer. */
|
|
|
|
extern const struct rank NS_INTEGER_POINTER_CONVERSION_BADNESS;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2010-11-05 04:26:23 +08:00
|
|
|
extern struct rank sum_ranks (struct rank a, struct rank b);
|
|
|
|
extern int compare_ranks (struct rank a, struct rank b);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2018-11-21 19:55:14 +08:00
|
|
|
extern int compare_badness (const badness_vector &,
|
|
|
|
const badness_vector &);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2018-11-21 19:55:14 +08:00
|
|
|
extern badness_vector rank_function (gdb::array_view<type *> parms,
|
|
|
|
gdb::array_view<value *> args);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2011-10-15 04:22:17 +08:00
|
|
|
extern struct rank rank_one_type (struct type *, struct type *,
|
|
|
|
struct value *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern void recursive_dump_type (struct type *, int);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
/* printcmd.c */
|
|
|
|
|
2015-10-09 22:08:23 +08:00
|
|
|
extern void print_scalar_formatted (const gdb_byte *, struct type *,
|
gdb
* varobj.c (value_get_print_value): Include valprint.h.
(value_get_print_value): Use get_formatted_print_options.
* value.h (struct value_print_options): Declare.
(value_print, val_print, common_val_print, val_print_string):
Update.
* value.c: Include valprint.h.
(show_values): Use get_user_print_options.
(show_convenience): Likewise.
* valprint.h (prettyprint_arrays, prettyprint_structs): Don't
declare.
(struct value_print_options): New type.
(vtblprint, unionprint, addressprint, objectprint, print_max,
inspect_it, repeat_count_threshold, output_format,
stop_print_at_null): Don't declare.
(user_print_options, get_user_print_options,
get_raw_print_options, get_formatted_print_options): Declare.
(print_array_indexes_p): Don't declare.
(maybe_print_array_index, val_print_array_elements): Update.
* valprint.c (print_max): Remove.
(user_print_options): New global.
(get_user_print_options, get_raw_print_options,
get_formatted_print_options): New functions.
(print_array_indexes, repeat_count_threshold, stop_print_at_null,
prettyprint_structs, prettyprint_arrays, unionprint,
addressprint): Remove.
(val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(common_val_print): Likewise.
(print_array_indexes_p): Remove.
(maybe_print_array_index): Remove format, pretty arguments; add
options. Update.
(val_print_array_elements): Remove format, deref_ref, pretty
arguments; add options. Update.
(val_print_string): Add options argument. Update.
(_initialize_valprint): Use user_print_options.
(output_format): Remove.
(set_output_radix_1): Use user_print_options.
* typeprint.c: Include valprint.h.
(objectprint): Don't declare.
(whatis_exp): Use get_user_print_options.
* tui/tui-regs.c: Include valprint.h.
(tui_register_format): Use get_formatted_print_options.
* tracepoint.c: Include valprint.h.
(addressprint): Don't declare.
(trace_mention): Use get_user_print_options.
(tracepoints_info): Likewise.
* stack.c (print_frame_args): Use get_raw_print_options.
(print_frame_info): Use get_user_print_options.
(print_frame): Likewise.
* sh64-tdep.c: Include valprint.h
(sh64_do_register): Use get_formatted_print_options.
* scm-valprint.c (scm_inferior_print): Remove format, deref_ref,
pretty arguments; add options.
(scm_scmlist_print): Likewise. Update.
(scm_scmval_print): Likewise.
(scm_val_print): Likewise.
(scm_value_print): Remove format, pretty arguments; add options.
Update.
* scm-lang.h (scm_value_print, scm_val_print, scm_scmval_print):
Update.
* scm-lang.c (scm_printstr): Add options argument.
* python/python-value.c: Include valprint.h.
(valpy_str): Use get_user_print_options.
* printcmd.c: Include valprint.h.
(addressprint): Don't declare.
(inspect_it): Remove.
(print_formatted): Remove format option; add options. Update.
(print_scalar_formatted): Likewise.
(print_address_demangle): Use get_user_print_options.
(do_examine): Use get_formatted_print_options.
(print_command_1): Likewise.
(output_command): Use get_formatted_print_options.
(do_one_display): Likewise.
(print_variable_value): Use get_user_print_options.
* p-valprint.c (pascal_val_print): Remove format, deref_ref,
pretty arguments; add options. Update.
(pascal_value_print): Remove format, pretty arguments; add
options. Update.
(vtblprint, objectprint): Don't declare.
(pascal_static_field_print): Remove.
(pascal_object_print_value_fields): Remove format, pretty
arguments; add options. Update.
(pascal_object_print_static_field): Likewise.
(_initialize_pascal_valprint): Use user_print_options. Update.
* p-lang.h (pascal_val_print, pascal_value_print,
pascal_printstr, pascal_object_print_value_fields): Update.
(vtblprint, static_field_print): Don't declare.
* p-lang.c (pascal_printstr): Add options argument. Update.
* objc-lang.c (objc_printstr): Add options argument. Update.
* mt-tdep.c: Include valprint.h.
(mt_registers_info): Use get_raw_print_options.
* mips-tdep.c: Include valprint.h.
(mips_print_fp_register): Use get_formatted_print_options.
(mips_print_register): Likewise.
* mi/mi-main.c: Include valprint.h.
(get_register): Use get_user_print_options.
(mi_cmd_data_evaluate_expression): Likewise.
(mi_cmd_data_read_memory): Use get_formatted_print_options.
* mi/mi-cmd-stack.c: Include valprint.h.
(list_args_or_locals): Use get_raw_print_options.
* m2-valprint.c (print_function_pointer_address): Add addressprint
argument.
(m2_print_long_set): Remove format, pretty arguments.
(m2_print_unbounded_array): Remove format, deref_ref, pretty
arguments; add options. Update.
(print_unpacked_pointer): Remove format argument; add options.
Now static. Update.
(print_variable_at_address): Remove format, deref_ref, pretty
arguments; add options. Update.
(m2_print_array_contents): Likewise.
(m2_val_print): Likewise.
* m2-lang.h (m2_val_print): Update.
* m2-lang.c (m2_printstr): Add options argument. Update.
* language.h (struct value_print_options): Declare.
(struct language_defn) <la_printstr>: Add options argument.
<la_val_print>: Remove format, deref_ref, pretty argument; add
options.
<la_value_print>: Remove format, pretty arguments; add options.
<la_print_array_index>: Likewise.
(LA_VAL_PRINT, LA_VALUE_PRINT, LA_PRINT_STRING,
LA_PRINT_ARRAY_INDEX): Update.
(default_print_array_index): Update.
* language.c (default_print_array_index): Remove format, pretty
arguments; add options. Update.
(unk_lang_printstr): Add options argument.
(unk_lang_val_print): Remove format, deref_ref, pretty arguments;
add options.
(unk_lang_value_print): Remove format, pretty arguments; add
options.
* jv-valprint.c (java_value_print): Remove format, pretty
arguments; add options. Update.
(java_print_value_fields): Likewise.
(java_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
* jv-lang.h (java_val_print, java_value_print): Declare.
* infcmd.c: Include valprint.h.
(print_return_value): Use get_raw_print_options.
(default_print_registers_info): Use get_user_print_options,
get_formatted_print_options.
(registers_info): Use get_formatted_print_options.
* gdbtypes.h (struct value_print_options): Declare.
(print_scalar_formatted): Update.
* f-valprint.c (f77_print_array_1): Remove format, deref_ref,
pretty arguments; add options. Update.
(f77_print_array): Likewise.
(f_val_print): Likewise.
* f-lang.h (f_val_print): Update.
* f-lang.c (f_printstr): Add options argument. Update.
(c_value_print): Update declaration.
* expprint.c: Include valprint.h.
(print_subexp_standard): Use get_raw_print_options,
get_user_print_options.
* eval.c: Include valprint.h.
(objectprint): Don't declare.
(evaluate_subexp_standard): Use get_user_print_options.
* cp-valprint.c (vtblprint, objectprint, static_field_print):
Remove.
(cp_print_value_fields): Remove format, pretty arguments; add
options. Update.
(cp_print_value): Likewise.
(cp_print_static_field): Likewise.
(_initialize_cp_valprint): Use user_print_options. Update.
* c-valprint.c (print_function_pointer_address): Add addressprint
argument.
(c_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(c_value_print): Add options argument. Update.
* c-lang.h (c_val_print, c_value_print, c_printstr): Update.
(vtblprint, static_field_print): Don't declare.
(cp_print_value_fields): Update.
* c-lang.c (c_printstr): Add options argument. Update.
* breakpoint.c: Include valprint.h.
(addressprint): Don't declare.
(watchpoint_value_print): Use get_user_print_options.
(print_one_breakpoint_location): Likewise.
(breakpoint_1, print_it_catch_fork, print_it_catch_vfork, mention,
print_exception_catchpoint): Likewise.
* auxv.c (fprint_target_auxv): Don't declare addressprint. Use
get_user_print_options.
* ada-valprint.c (struct ada_val_print_args): Remove format,
deref_ref, and pretty; add options.
(print_optional_low_bound): Add options argument.
(val_print_packed_array_elements): Remove format and pretty
arguments; add options. Update.
(printstr): Add options argument. Update.
(ada_printstr): Likewise.
(ada_val_print): Remove format, deref_ref, pretty arguments; add
options argument. Update.
(ada_val_print_stub): Update.
(ada_val_print_array): Remove format, deref_ref, pretty arguments;
add options. Update.
(ada_val_print_1): Likewise.
(print_variant_part): Likewise.
(ada_value_print): Remove format, pretty arguments; add options.
Update.
(print_record): Likewise.
(print_field_values): Likewise.
* ada-lang.h (ada_val_print, ada_value_print, ada_printstr):
Update.
* ada-lang.c (ada_print_array_index): Add options argument; remove
format and pretty arguments.
(print_one_exception): Use get_user_print_options.
gdb/testsuite
* gdb.base/exprs.exp (test_expr): Add enum formatting tests.
2008-10-29 01:19:58 +08:00
|
|
|
const struct value_print_options *,
|
|
|
|
int, struct ui_file *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern int can_dereference (struct type *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-05-28 09:12:42 +08:00
|
|
|
extern int is_integral_type (struct type *);
|
1999-07-20 07:30:11 +08:00
|
|
|
|
Target FP: Introduce target-float.{c,h}
This patch introduces the new set of target floating-point handling routines
in target-float.{c,h}. In the end, the intention is that this file will
contain support for all operations in target FP format, fully replacing
both the current doublest.{c,h} and dfp.{c,h}.
To begin with, this patch only adds a target_float_is_zero routine,
which handles the equivalent of decimal_is_zero for both binary and
decimal FP. For the binary case, to avoid conversion to DOUBLEST,
this is implemented using the floatformat_classify routine.
However, it turns out that floatformat_classify actually has a bug
(it was not used to check for zero before), so this is fixed as well.
The new routine is used in both value_logical_not and valpy_nonzero.
There is one extra twist: the code previously used value_as_double
to convert to DOUBLEST and then compare against zero. That routine
performs an extra task: it detects invalid floating-point values
and raises an error. In any place where value_as_double is removed
in favor of some target-float.c routine, we need to replace that check.
To keep this check centralized in one place, I've added a new routine
is_floating_value, which returns a boolean determining whether a
value's type is floating point (binary or decimal), and if so, also
performs the validity check. Since we need to check whether a value
is FP before calling any of the target-float routines anyway, this
seems a good place to add the check without much code size overhead.
In some places where we only want to check for floating-point types
and not perform a validity check (e.g. for the *output* of an operation),
we can use the new is_floating_type routine (in gdbarch) instead.
The validity check itself is done by a new target_float_is_valid
routine in target-float, encapsulating floatformat_is_valid.
ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* Makefile.c (SFILES): Add target-float.c.
(HFILES_NO_SRCDIR): Add target-float.h.
(COMMON_OBS): Add target-float.o.
* target-float.h: New file.
* target-float.c: New file.
* doublest.c (floatformat_classify): Fix detection of float_zero.
* gdbtypes.c (is_floating_type): New function.
* gdbtypes.h (is_floating_type): Add prototype.
* value.c: Do not include "floatformat.h".
(unpack_double): Use target_float_is_valid.
(is_floating_value): New function.
* value.h (is_floating_value): Add prototype-
* valarith.c: Include "target-float.h".
(value_logical_not): Use target_float_is_zero.
* python/py-value.c: Include "target-float.h".
(valpy_nonzero): Use target_float_is_zero.
2017-11-06 22:55:11 +08:00
|
|
|
extern int is_floating_type (struct type *);
|
|
|
|
|
2015-10-10 05:14:43 +08:00
|
|
|
extern int is_scalar_type (struct type *type);
|
|
|
|
|
2011-01-12 03:23:03 +08:00
|
|
|
extern int is_scalar_type_recursive (struct type *);
|
|
|
|
|
2014-11-11 21:43:03 +08:00
|
|
|
extern int class_or_union_p (const struct type *);
|
|
|
|
|
2017-09-13 04:40:43 +08:00
|
|
|
extern void maintenance_print_type (const char *, int);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2022-05-25 05:17:19 +08:00
|
|
|
extern htab_up create_copied_types_hash ();
|
gdb/
* Makefile.in (gdbtypes_h, gdbtypes.o, utils.o): Update.
* defs.h (hashtab_obstack_allocate, dummy_obstack_deallocate): Add
prototypes.
* dwarf2read.c (read_subroutine_type): Use TYPE_ZALLOC.
(hashtab_obstack_allocate, dummy_obstack_deallocate): Moved to...
* utils.c (hashtab_obstack_allocate, dummy_obstack_deallocate):
...here.
* gdbtypes.c: Include "hashtab.h".
(build_gdbtypes): Remove extra prototype.
(struct type_pair, type_pair_hash, type_pair_eq)
(create_copied_types_hash, copy_type_recursive): New.
* gdbtypes.h: Include "hashtab.h".
(TYPE_ZALLOC): New.
(create_copied_types_hash, copy_type_recursive): New prototypes.
* objfiles.c (free_objfile): Call preserve_values.
* symfile.c (reread_symbols): Likewise.
(clear_symtab_users): Remove calls to clear_value_history and
clear_internalvars.
* value.c (clear_value_history, clear_internalvars): Removed.
(preserve_one_value, preserve_values): New functions.
* value.h (clear_value_history, clear_internalvars): Removed.
(preserve_values): New prototype.
* tracepoint.c (_initialize_tracepoint): Do not initialize convenience
variables here.
gdb/doc/
* gdb.texinfo (Files): Remove obsolete bits from the description
of "symbol-file".
2006-02-02 07:14:11 +08:00
|
|
|
|
2022-05-25 05:17:19 +08:00
|
|
|
extern struct type *copy_type_recursive (struct type *type,
|
gdb/
* Makefile.in (gdbtypes_h, gdbtypes.o, utils.o): Update.
* defs.h (hashtab_obstack_allocate, dummy_obstack_deallocate): Add
prototypes.
* dwarf2read.c (read_subroutine_type): Use TYPE_ZALLOC.
(hashtab_obstack_allocate, dummy_obstack_deallocate): Moved to...
* utils.c (hashtab_obstack_allocate, dummy_obstack_deallocate):
...here.
* gdbtypes.c: Include "hashtab.h".
(build_gdbtypes): Remove extra prototype.
(struct type_pair, type_pair_hash, type_pair_eq)
(create_copied_types_hash, copy_type_recursive): New.
* gdbtypes.h: Include "hashtab.h".
(TYPE_ZALLOC): New.
(create_copied_types_hash, copy_type_recursive): New prototypes.
* objfiles.c (free_objfile): Call preserve_values.
* symfile.c (reread_symbols): Likewise.
(clear_symtab_users): Remove calls to clear_value_history and
clear_internalvars.
* value.c (clear_value_history, clear_internalvars): Removed.
(preserve_one_value, preserve_values): New functions.
* value.h (clear_value_history, clear_internalvars): Removed.
(preserve_values): New prototype.
* tracepoint.c (_initialize_tracepoint): Do not initialize convenience
variables here.
gdb/doc/
* gdb.texinfo (Files): Remove obsolete bits from the description
of "symbol-file".
2006-02-02 07:14:11 +08:00
|
|
|
htab_t copied_types);
|
|
|
|
|
2008-10-23 04:11:56 +08:00
|
|
|
extern struct type *copy_type (const struct type *type);
|
|
|
|
|
2018-05-29 14:29:23 +08:00
|
|
|
extern bool types_equal (struct type *, struct type *);
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-13 01:37:38 +08:00
|
|
|
|
2018-05-29 14:29:23 +08:00
|
|
|
extern bool types_deeply_equal (struct type *, struct type *);
|
2013-11-22 12:28:35 +08:00
|
|
|
|
2015-10-22 03:32:30 +08:00
|
|
|
extern int type_not_allocated (const struct type *type);
|
|
|
|
|
|
|
|
extern int type_not_associated (const struct type *type);
|
|
|
|
|
Add support for printing value of DWARF-based fixed-point type objects
This commit introduces a new kind of type, meant to describe
fixed-point types, using a new code added specifically for
this purpose (TYPE_CODE_FIXED_POINT).
It then adds handling of fixed-point base types in the DWARF reader.
And finally, as a first step, this commit adds support for printing
the value of fixed-point type objects.
Note that this commit has a known issue: Trying to print the value
of a fixed-point object with a format letter (e.g. "print /x NAME")
causes the wrong value to be printed because the scaling factor
is not applied. Since the fix for this issue is isolated, and
this is not a regression, the fix will be made in a pach of its own.
This is meant to simplify review and archeology.
Also, other functionalities related to fixed-point type handling
(ptype, arithmetics, etc), will be added piecemeal as well, for
the same reasons (faciliate reviews and archeology). Related to this,
the testcase gdb.ada/fixed_cmp.exp is adjusted to compile the test
program with -fgnat-encodings=all, so as to force the use of GNAT
encodings, rather than rely on the compiler's default to use them.
The intent is to enhance this testcase to also test the pure DWARF
approach using -fgnat-encodings=minimal as soon as the corresponding
suport gets added in. Thus, the modification to the testcase is made
in a way that it prepares this testcase to be tested in both modes.
gdb/ChangeLog:
* ada-valprint.c (ada_value_print_1): Add fixed-point type handling.
* dwarf2/read.c (get_dwarf2_rational_constant)
(get_dwarf2_unsigned_rational_constant, finish_fixed_point_type)
(has_zero_over_zero_small_attribute): New functions.
read_base_type, set_die_type): Add fixed-point type handling.
* gdb-gdb.py.in: Add fixed-point type handling.
* gdbtypes.c: #include "gmp-utils.h".
(create_range_type, set_type_code): Add fixed-point type handling.
(init_fixed_point_type): New function.
(is_integral_type, is_scalar_type): Add fixed-point type handling.
(print_fixed_point_type_info): New function.
(recursive_dump_type, copy_type_recursive): Add fixed-point type
handling.
(fixed_point_type_storage): New typedef.
(fixed_point_objfile_key): New static global.
(allocate_fixed_point_type_info, is_fixed_point_type): New functions.
(fixed_point_type_base_type, fixed_point_scaling_factor): New
functions.
* gdbtypes.h: #include "gmp-utils.h".
(enum type_code) <TYPE_SPECIFIC_FIXED_POINT>: New enum.
(union type_specific) <fixed_point_info>: New field.
(struct fixed_point_type_info): New struct.
(INIT_FIXED_POINT_SPECIFIC, TYPE_FIXED_POINT_INFO): New macros.
(init_fixed_point_type, is_fixed_point_type)
(fixed_point_type_base_type, fixed_point_scaling_factor)
(allocate_fixed_point_type_info): Add declarations.
* valprint.c (generic_val_print_fixed_point): New function.
(generic_value_print): Add fixed-point type handling.
* value.c (value_as_address, unpack_long): Add fixed-point type
handling.
gdb/testsuite/ChangeLog:
* gdb.ada/fixed_cmp.exp: Force compilation to use -fgnat-encodings=all.
* gdb.ada/fixed_points.exp: Add fixed-point variables printing tests.
* gdb.ada/fixed_points/pck.ads, gdb.ada/fixed_points/pck.adb:
New files.
* gdb.ada/fixed_points/fixed_points.adb: Add use of package Pck.
* gdb.dwarf2/dw2-fixed-point.c, gdb.dwarf2/dw2-fixed-point.exp:
New files.
2020-11-15 16:12:52 +08:00
|
|
|
/* Return True if TYPE is a TYPE_CODE_FIXED_POINT or if TYPE is
|
|
|
|
a range type whose base type is a TYPE_CODE_FIXED_POINT. */
|
|
|
|
extern bool is_fixed_point_type (struct type *type);
|
|
|
|
|
|
|
|
/* Allocate a fixed-point type info for TYPE. This should only be
|
|
|
|
called by INIT_FIXED_POINT_SPECIFIC. */
|
2020-11-24 10:47:40 +08:00
|
|
|
extern void allocate_fixed_point_type_info (struct type *type);
|
Add support for printing value of DWARF-based fixed-point type objects
This commit introduces a new kind of type, meant to describe
fixed-point types, using a new code added specifically for
this purpose (TYPE_CODE_FIXED_POINT).
It then adds handling of fixed-point base types in the DWARF reader.
And finally, as a first step, this commit adds support for printing
the value of fixed-point type objects.
Note that this commit has a known issue: Trying to print the value
of a fixed-point object with a format letter (e.g. "print /x NAME")
causes the wrong value to be printed because the scaling factor
is not applied. Since the fix for this issue is isolated, and
this is not a regression, the fix will be made in a pach of its own.
This is meant to simplify review and archeology.
Also, other functionalities related to fixed-point type handling
(ptype, arithmetics, etc), will be added piecemeal as well, for
the same reasons (faciliate reviews and archeology). Related to this,
the testcase gdb.ada/fixed_cmp.exp is adjusted to compile the test
program with -fgnat-encodings=all, so as to force the use of GNAT
encodings, rather than rely on the compiler's default to use them.
The intent is to enhance this testcase to also test the pure DWARF
approach using -fgnat-encodings=minimal as soon as the corresponding
suport gets added in. Thus, the modification to the testcase is made
in a way that it prepares this testcase to be tested in both modes.
gdb/ChangeLog:
* ada-valprint.c (ada_value_print_1): Add fixed-point type handling.
* dwarf2/read.c (get_dwarf2_rational_constant)
(get_dwarf2_unsigned_rational_constant, finish_fixed_point_type)
(has_zero_over_zero_small_attribute): New functions.
read_base_type, set_die_type): Add fixed-point type handling.
* gdb-gdb.py.in: Add fixed-point type handling.
* gdbtypes.c: #include "gmp-utils.h".
(create_range_type, set_type_code): Add fixed-point type handling.
(init_fixed_point_type): New function.
(is_integral_type, is_scalar_type): Add fixed-point type handling.
(print_fixed_point_type_info): New function.
(recursive_dump_type, copy_type_recursive): Add fixed-point type
handling.
(fixed_point_type_storage): New typedef.
(fixed_point_objfile_key): New static global.
(allocate_fixed_point_type_info, is_fixed_point_type): New functions.
(fixed_point_type_base_type, fixed_point_scaling_factor): New
functions.
* gdbtypes.h: #include "gmp-utils.h".
(enum type_code) <TYPE_SPECIFIC_FIXED_POINT>: New enum.
(union type_specific) <fixed_point_info>: New field.
(struct fixed_point_type_info): New struct.
(INIT_FIXED_POINT_SPECIFIC, TYPE_FIXED_POINT_INFO): New macros.
(init_fixed_point_type, is_fixed_point_type)
(fixed_point_type_base_type, fixed_point_scaling_factor)
(allocate_fixed_point_type_info): Add declarations.
* valprint.c (generic_val_print_fixed_point): New function.
(generic_value_print): Add fixed-point type handling.
* value.c (value_as_address, unpack_long): Add fixed-point type
handling.
gdb/testsuite/ChangeLog:
* gdb.ada/fixed_cmp.exp: Force compilation to use -fgnat-encodings=all.
* gdb.ada/fixed_points.exp: Add fixed-point variables printing tests.
* gdb.ada/fixed_points/pck.ads, gdb.ada/fixed_points/pck.adb:
New files.
* gdb.ada/fixed_points/fixed_points.adb: Add use of package Pck.
* gdb.dwarf2/dw2-fixed-point.c, gdb.dwarf2/dw2-fixed-point.exp:
New files.
2020-11-15 16:12:52 +08:00
|
|
|
|
Adjust byte order variable display/change if DW_AT_endianity is present.
- Rationale:
It is possible for compilers to indicate the desired byte order
interpretation of scalar variables using the DWARF attribute:
DW_AT_endianity
A type flagged with this variable would typically use one of:
DW_END_big
DW_END_little
which instructs the debugger what the desired byte order interpretation
of the variable should be.
The GCC compiler (as of V6) has a mechanism for setting the desired byte
ordering of the fields within a structure or union. For, example, on a
little endian target, a structure declared as:
struct big {
int v;
short a[4];
} __attribute__( ( scalar_storage_order( "big-endian" ) ) );
could be used to ensure all the structure members have a big-endian
interpretation (the compiler would automatically insert byte swap
instructions before and after respective store and load instructions).
- To reproduce
GCC V8 is required to correctly emit DW_AT_endianity DWARF attributes
in all situations when the scalar_storage_order attribute is used.
A fix for (dwarf endianity instrumentation) for GCC V6-V7 can be found
in the URL field of the following PR:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509
- Test-case:
A new test case (testsuite/gdb.base/endianity.*) is included with this
patch.
Manual testing for mixed endianity code has also been done with GCC V8.
See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509#c4
- Observed vs. expected:
Without this change, using scalar_storage_order that doesn't match the
target, such as
struct otherendian
{
int v;
} __attribute__( ( scalar_storage_order( "big-endian" ) ) );
would behave like the following on a little endian target:
Breakpoint 1 at 0x401135: file endianity.c, line 41.
(gdb) run
Starting program: /home/pjoot/freeware/t/a.out
Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.x86_64
Breakpoint 1, main () at endianity.c:41
41 struct otherendian o = {3};
(gdb) n
43 do_nothing (&o); /* START */
(gdb) p o
$1 = {v = 50331648}
(gdb) p /x
$2 = {v = 0x3000000}
whereas with this gdb enhancement we can access the variable with the user
specified endianity:
Breakpoint 1, main () at endianity.c:41
41 struct otherendian o = {3};
(gdb) p o
$1 = {v = 0}
(gdb) n
43 do_nothing (&o); /* START */
(gdb) p o
$2 = {v = 3}
(gdb) p o.v = 4
$3 = 4
(gdb) p o.v
$4 = 4
(gdb) x/4xb &o.v
0x7fffffffd90c: 0x00 0x00 0x00 0x04
(observe that the 4 byte int variable has a big endian representation in the
hex dump.)
gdb/ChangeLog
2019-11-21 Peeter Joot <peeter.joot@lzlabs.com>
Byte reverse display of variables with DW_END_big, DW_END_little
(DW_AT_endianity) dwarf attributes if different than the native
byte order.
* ada-lang.c (ada_value_binop):
Use type_byte_order instead of gdbarch_byte_order.
* ada-valprint.c (printstr):
(ada_val_print_string):
* ada-lang.c (value_pointer):
(ada_value_binop):
Use type_byte_order instead of gdbarch_byte_order.
* c-lang.c (c_get_string):
Use type_byte_order instead of gdbarch_byte_order.
* c-valprint.c (c_val_print_array):
Use type_byte_order instead of gdbarch_byte_order.
* cp-valprint.c (cp_print_class_member):
Use type_byte_order instead of gdbarch_byte_order.
* dwarf2loc.c (rw_pieced_value):
Use type_byte_order instead of gdbarch_byte_order.
* dwarf2read.c (read_base_type): Handle DW_END_big,
DW_END_little
* f-lang.c (f_get_encoding):
Use type_byte_order instead of gdbarch_byte_order.
* findvar.c (default_read_var_value):
Use type_byte_order instead of gdbarch_byte_order.
* gdbtypes.c (check_types_equal):
Require matching TYPE_ENDIANITY_NOT_DEFAULT if set.
(recursive_dump_type): Print TYPE_ENDIANITY_BIG,
and TYPE_ENDIANITY_LITTLE if set.
(type_byte_order): new function.
* gdbtypes.h (TYPE_ENDIANITY_NOT_DEFAULT): New macro.
(struct main_type) <flag_endianity_not_default>:
New field.
(type_byte_order): New function.
* infcmd.c (default_print_one_register_info):
Use type_byte_order instead of gdbarch_byte_order.
* p-lang.c (pascal_printstr):
Use type_byte_order instead of gdbarch_byte_order.
* p-valprint.c (pascal_val_print):
Use type_byte_order instead of gdbarch_byte_order.
* printcmd.c (print_scalar_formatted):
Use type_byte_order instead of gdbarch_byte_order.
* solib-darwin.c (darwin_current_sos):
Use type_byte_order instead of gdbarch_byte_order.
* solib-svr4.c (solib_svr4_r_ldsomap):
Use type_byte_order instead of gdbarch_byte_order.
* stap-probe.c (stap_modify_semaphore):
Use type_byte_order instead of gdbarch_byte_order.
* target-float.c (target_float_same_format_p):
Use type_byte_order instead of gdbarch_byte_order.
* valarith.c (scalar_binop):
(value_bit_index):
Use type_byte_order instead of gdbarch_byte_order.
* valops.c (value_cast):
Use type_byte_order instead of gdbarch_byte_order.
* valprint.c (generic_emit_char):
(generic_printstr):
(val_print_string):
Use type_byte_order instead of gdbarch_byte_order.
* value.c (unpack_long):
(unpack_bits_as_long):
(unpack_value_bitfield):
(modify_field):
(pack_long):
(pack_unsigned_long):
Use type_byte_order instead of gdbarch_byte_order.
* findvar.c (unsigned_pointer_to_address):
(signed_pointer_to_address):
(unsigned_address_to_pointer):
(address_to_signed_pointer):
(default_read_var_value):
(default_value_from_register):
Use type_byte_order instead of gdbarch_byte_order.
* gnu-v3-abi.c (gnuv3_make_method_ptr):
Use type_byte_order instead of gdbarch_byte_order.
* riscv-tdep.c (riscv_print_one_register_info):
Use type_byte_order instead of gdbarch_byte_order.
gdb/testsuite/ChangeLog
2019-11-21 Peeter Joot <peeter.joot@lzlabs.com>
* gdb.base/endianity.c: New test.
* gdb.base/endianity.exp: New file.
Change-Id: I4bd98c1b4508c2d7c5a5dbb15d7b7b1cb4e667e2
2017-10-07 04:13:04 +08:00
|
|
|
/* * When the type includes explicit byte ordering, return that.
|
2021-01-28 23:12:10 +08:00
|
|
|
Otherwise, the byte ordering from gdbarch_byte_order for
|
|
|
|
the type's arch is returned. */
|
|
|
|
|
Adjust byte order variable display/change if DW_AT_endianity is present.
- Rationale:
It is possible for compilers to indicate the desired byte order
interpretation of scalar variables using the DWARF attribute:
DW_AT_endianity
A type flagged with this variable would typically use one of:
DW_END_big
DW_END_little
which instructs the debugger what the desired byte order interpretation
of the variable should be.
The GCC compiler (as of V6) has a mechanism for setting the desired byte
ordering of the fields within a structure or union. For, example, on a
little endian target, a structure declared as:
struct big {
int v;
short a[4];
} __attribute__( ( scalar_storage_order( "big-endian" ) ) );
could be used to ensure all the structure members have a big-endian
interpretation (the compiler would automatically insert byte swap
instructions before and after respective store and load instructions).
- To reproduce
GCC V8 is required to correctly emit DW_AT_endianity DWARF attributes
in all situations when the scalar_storage_order attribute is used.
A fix for (dwarf endianity instrumentation) for GCC V6-V7 can be found
in the URL field of the following PR:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509
- Test-case:
A new test case (testsuite/gdb.base/endianity.*) is included with this
patch.
Manual testing for mixed endianity code has also been done with GCC V8.
See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509#c4
- Observed vs. expected:
Without this change, using scalar_storage_order that doesn't match the
target, such as
struct otherendian
{
int v;
} __attribute__( ( scalar_storage_order( "big-endian" ) ) );
would behave like the following on a little endian target:
Breakpoint 1 at 0x401135: file endianity.c, line 41.
(gdb) run
Starting program: /home/pjoot/freeware/t/a.out
Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.x86_64
Breakpoint 1, main () at endianity.c:41
41 struct otherendian o = {3};
(gdb) n
43 do_nothing (&o); /* START */
(gdb) p o
$1 = {v = 50331648}
(gdb) p /x
$2 = {v = 0x3000000}
whereas with this gdb enhancement we can access the variable with the user
specified endianity:
Breakpoint 1, main () at endianity.c:41
41 struct otherendian o = {3};
(gdb) p o
$1 = {v = 0}
(gdb) n
43 do_nothing (&o); /* START */
(gdb) p o
$2 = {v = 3}
(gdb) p o.v = 4
$3 = 4
(gdb) p o.v
$4 = 4
(gdb) x/4xb &o.v
0x7fffffffd90c: 0x00 0x00 0x00 0x04
(observe that the 4 byte int variable has a big endian representation in the
hex dump.)
gdb/ChangeLog
2019-11-21 Peeter Joot <peeter.joot@lzlabs.com>
Byte reverse display of variables with DW_END_big, DW_END_little
(DW_AT_endianity) dwarf attributes if different than the native
byte order.
* ada-lang.c (ada_value_binop):
Use type_byte_order instead of gdbarch_byte_order.
* ada-valprint.c (printstr):
(ada_val_print_string):
* ada-lang.c (value_pointer):
(ada_value_binop):
Use type_byte_order instead of gdbarch_byte_order.
* c-lang.c (c_get_string):
Use type_byte_order instead of gdbarch_byte_order.
* c-valprint.c (c_val_print_array):
Use type_byte_order instead of gdbarch_byte_order.
* cp-valprint.c (cp_print_class_member):
Use type_byte_order instead of gdbarch_byte_order.
* dwarf2loc.c (rw_pieced_value):
Use type_byte_order instead of gdbarch_byte_order.
* dwarf2read.c (read_base_type): Handle DW_END_big,
DW_END_little
* f-lang.c (f_get_encoding):
Use type_byte_order instead of gdbarch_byte_order.
* findvar.c (default_read_var_value):
Use type_byte_order instead of gdbarch_byte_order.
* gdbtypes.c (check_types_equal):
Require matching TYPE_ENDIANITY_NOT_DEFAULT if set.
(recursive_dump_type): Print TYPE_ENDIANITY_BIG,
and TYPE_ENDIANITY_LITTLE if set.
(type_byte_order): new function.
* gdbtypes.h (TYPE_ENDIANITY_NOT_DEFAULT): New macro.
(struct main_type) <flag_endianity_not_default>:
New field.
(type_byte_order): New function.
* infcmd.c (default_print_one_register_info):
Use type_byte_order instead of gdbarch_byte_order.
* p-lang.c (pascal_printstr):
Use type_byte_order instead of gdbarch_byte_order.
* p-valprint.c (pascal_val_print):
Use type_byte_order instead of gdbarch_byte_order.
* printcmd.c (print_scalar_formatted):
Use type_byte_order instead of gdbarch_byte_order.
* solib-darwin.c (darwin_current_sos):
Use type_byte_order instead of gdbarch_byte_order.
* solib-svr4.c (solib_svr4_r_ldsomap):
Use type_byte_order instead of gdbarch_byte_order.
* stap-probe.c (stap_modify_semaphore):
Use type_byte_order instead of gdbarch_byte_order.
* target-float.c (target_float_same_format_p):
Use type_byte_order instead of gdbarch_byte_order.
* valarith.c (scalar_binop):
(value_bit_index):
Use type_byte_order instead of gdbarch_byte_order.
* valops.c (value_cast):
Use type_byte_order instead of gdbarch_byte_order.
* valprint.c (generic_emit_char):
(generic_printstr):
(val_print_string):
Use type_byte_order instead of gdbarch_byte_order.
* value.c (unpack_long):
(unpack_bits_as_long):
(unpack_value_bitfield):
(modify_field):
(pack_long):
(pack_unsigned_long):
Use type_byte_order instead of gdbarch_byte_order.
* findvar.c (unsigned_pointer_to_address):
(signed_pointer_to_address):
(unsigned_address_to_pointer):
(address_to_signed_pointer):
(default_read_var_value):
(default_value_from_register):
Use type_byte_order instead of gdbarch_byte_order.
* gnu-v3-abi.c (gnuv3_make_method_ptr):
Use type_byte_order instead of gdbarch_byte_order.
* riscv-tdep.c (riscv_print_one_register_info):
Use type_byte_order instead of gdbarch_byte_order.
gdb/testsuite/ChangeLog
2019-11-21 Peeter Joot <peeter.joot@lzlabs.com>
* gdb.base/endianity.c: New test.
* gdb.base/endianity.exp: New file.
Change-Id: I4bd98c1b4508c2d7c5a5dbb15d7b7b1cb4e667e2
2017-10-07 04:13:04 +08:00
|
|
|
extern enum bfd_endian type_byte_order (const struct type *type);
|
|
|
|
|
2019-10-08 03:40:32 +08:00
|
|
|
/* A flag to enable printing of debugging information of C++
|
|
|
|
overloading. */
|
|
|
|
|
|
|
|
extern unsigned int overload_debug;
|
|
|
|
|
gdb: Respect the DW_CC_nocall attribute
It is possible for a compiler to optimize a function in a such ways that
the function does not follow the calling convention of the target. In
such situation, the compiler can use the DW_AT_calling_convention
attribute with the value DW_CC_nocall to tell the debugger that it is
unsafe to call the function. The DWARF5 standard states, in 3.3.1.1:
> If the value of the calling convention attribute is the constant
> DW_CC_nocall, the subroutine does not obey standard calling
> conventions, and it may not be safe for the debugger to call this
> subroutine.
Non standard calling convention can affect GDB's assumptions in multiple
ways, including how arguments are passed to the function, how values are
returned, and so on. For this reason, it is unsafe for GDB to try to do
the following operations on a function with marked with DW_CC_nocall:
- call / print an expression requiring the function to be evaluated,
- inspect the value a function returns using the 'finish' command,
- force the value returned by a function using the 'return' command.
This patch ensures that if a command which relies on GDB's knowledge of
the target's calling convention is used on a function marked nocall, GDB
prints an appropriate message to the user and does not proceed with the
operation which is unreliable.
Note that it is still possible for someone to use a vendor specific
value for the DW_AT_calling_convention attribute for example to indicate
the use of an alternative calling convention. This commit does not
prevent this, and target dependent code can be adjusted if one wanted to
support multiple calling conventions.
Tested on x86_64-Linux, with no regression observed.
Change-Id: I72970dae68234cb83edbc0cf71aa3d6002a4a540
2022-01-17 19:13:39 +08:00
|
|
|
/* Return whether the function type represented by TYPE is marked as unsafe
|
|
|
|
to call by the debugger.
|
|
|
|
|
|
|
|
This usually indicates that the function does not follow the target's
|
2022-12-12 03:48:07 +08:00
|
|
|
standard calling convention. */
|
gdb: Respect the DW_CC_nocall attribute
It is possible for a compiler to optimize a function in a such ways that
the function does not follow the calling convention of the target. In
such situation, the compiler can use the DW_AT_calling_convention
attribute with the value DW_CC_nocall to tell the debugger that it is
unsafe to call the function. The DWARF5 standard states, in 3.3.1.1:
> If the value of the calling convention attribute is the constant
> DW_CC_nocall, the subroutine does not obey standard calling
> conventions, and it may not be safe for the debugger to call this
> subroutine.
Non standard calling convention can affect GDB's assumptions in multiple
ways, including how arguments are passed to the function, how values are
returned, and so on. For this reason, it is unsafe for GDB to try to do
the following operations on a function with marked with DW_CC_nocall:
- call / print an expression requiring the function to be evaluated,
- inspect the value a function returns using the 'finish' command,
- force the value returned by a function using the 'return' command.
This patch ensures that if a command which relies on GDB's knowledge of
the target's calling convention is used on a function marked nocall, GDB
prints an appropriate message to the user and does not proceed with the
operation which is unreliable.
Note that it is still possible for someone to use a vendor specific
value for the DW_AT_calling_convention attribute for example to indicate
the use of an alternative calling convention. This commit does not
prevent this, and target dependent code can be adjusted if one wanted to
support multiple calling conventions.
Tested on x86_64-Linux, with no regression observed.
Change-Id: I72970dae68234cb83edbc0cf71aa3d6002a4a540
2022-01-17 19:13:39 +08:00
|
|
|
|
|
|
|
extern bool is_nocall_function (const struct type *type);
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
#endif /* GDBTYPES_H */
|