binutils-gdb/gdb/c-typeprint.c

1723 lines
50 KiB
C
Raw Normal View History

/* Support for printing C and C++ types for GDB, the GNU debugger.
Copyright (C) 1986-2020 Free Software Foundation, Inc.
1999-07-07 22:19:36 +02:00
This file is part of GDB.
1999-07-07 22:19:36 +02: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
the Free Software Foundation; either version 3 of the License, or
1999-07-07 22:19:36 +02:00
(at your option) any later version.
1999-07-07 22:19:36 +02: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-07-07 22:19:36 +02:00
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
Sort includes for files gdb/[a-f]*.[chyl]. This patch sorts the include files for the files [a-f]*.[chyl]. The patch was written by a script. Tested by the buildbot. I will follow up with patches to sort the remaining files, by sorting a subset, testing them, and then checking them in. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> * ft32-tdep.c: Sort headers. * frv-tdep.c: Sort headers. * frv-linux-tdep.c: Sort headers. * frame.c: Sort headers. * frame-unwind.c: Sort headers. * frame-base.c: Sort headers. * fork-child.c: Sort headers. * findvar.c: Sort headers. * findcmd.c: Sort headers. * filesystem.c: Sort headers. * filename-seen-cache.h: Sort headers. * filename-seen-cache.c: Sort headers. * fbsd-tdep.c: Sort headers. * fbsd-nat.h: Sort headers. * fbsd-nat.c: Sort headers. * f-valprint.c: Sort headers. * f-typeprint.c: Sort headers. * f-lang.c: Sort headers. * extension.h: Sort headers. * extension.c: Sort headers. * extension-priv.h: Sort headers. * expprint.c: Sort headers. * exec.h: Sort headers. * exec.c: Sort headers. * exceptions.c: Sort headers. * event-top.c: Sort headers. * event-loop.c: Sort headers. * eval.c: Sort headers. * elfread.c: Sort headers. * dwarf2read.h: Sort headers. * dwarf2read.c: Sort headers. * dwarf2loc.c: Sort headers. * dwarf2expr.h: Sort headers. * dwarf2expr.c: Sort headers. * dwarf2-frame.c: Sort headers. * dwarf2-frame-tailcall.c: Sort headers. * dwarf-index-write.h: Sort headers. * dwarf-index-write.c: Sort headers. * dwarf-index-common.c: Sort headers. * dwarf-index-cache.h: Sort headers. * dwarf-index-cache.c: Sort headers. * dummy-frame.c: Sort headers. * dtrace-probe.c: Sort headers. * disasm.h: Sort headers. * disasm.c: Sort headers. * disasm-selftests.c: Sort headers. * dictionary.c: Sort headers. * dicos-tdep.c: Sort headers. * demangle.c: Sort headers. * dcache.h: Sort headers. * dcache.c: Sort headers. * darwin-nat.h: Sort headers. * darwin-nat.c: Sort headers. * darwin-nat-info.c: Sort headers. * d-valprint.c: Sort headers. * d-namespace.c: Sort headers. * d-lang.c: Sort headers. * ctf.c: Sort headers. * csky-tdep.c: Sort headers. * csky-linux-tdep.c: Sort headers. * cris-tdep.c: Sort headers. * cris-linux-tdep.c: Sort headers. * cp-valprint.c: Sort headers. * cp-support.c: Sort headers. * cp-namespace.c: Sort headers. * cp-abi.c: Sort headers. * corelow.c: Sort headers. * corefile.c: Sort headers. * continuations.c: Sort headers. * completer.h: Sort headers. * completer.c: Sort headers. * complaints.c: Sort headers. * coffread.c: Sort headers. * coff-pe-read.c: Sort headers. * cli-out.h: Sort headers. * cli-out.c: Sort headers. * charset.c: Sort headers. * c-varobj.c: Sort headers. * c-valprint.c: Sort headers. * c-typeprint.c: Sort headers. * c-lang.c: Sort headers. * buildsym.c: Sort headers. * buildsym-legacy.c: Sort headers. * build-id.h: Sort headers. * build-id.c: Sort headers. * btrace.c: Sort headers. * bsd-uthread.c: Sort headers. * breakpoint.h: Sort headers. * breakpoint.c: Sort headers. * break-catch-throw.c: Sort headers. * break-catch-syscall.c: Sort headers. * break-catch-sig.c: Sort headers. * blockframe.c: Sort headers. * block.c: Sort headers. * bfin-tdep.c: Sort headers. * bfin-linux-tdep.c: Sort headers. * bfd-target.c: Sort headers. * bcache.c: Sort headers. * ax-general.c: Sort headers. * ax-gdb.h: Sort headers. * ax-gdb.c: Sort headers. * avr-tdep.c: Sort headers. * auxv.c: Sort headers. * auto-load.c: Sort headers. * arm-wince-tdep.c: Sort headers. * arm-tdep.c: Sort headers. * arm-symbian-tdep.c: Sort headers. * arm-pikeos-tdep.c: Sort headers. * arm-obsd-tdep.c: Sort headers. * arm-nbsd-tdep.c: Sort headers. * arm-nbsd-nat.c: Sort headers. * arm-linux-tdep.c: Sort headers. * arm-linux-nat.c: Sort headers. * arm-fbsd-tdep.c: Sort headers. * arm-fbsd-nat.c: Sort headers. * arm-bsd-tdep.c: Sort headers. * arch-utils.c: Sort headers. * arc-tdep.c: Sort headers. * arc-newlib-tdep.c: Sort headers. * annotate.h: Sort headers. * annotate.c: Sort headers. * amd64-windows-tdep.c: Sort headers. * amd64-windows-nat.c: Sort headers. * amd64-tdep.c: Sort headers. * amd64-sol2-tdep.c: Sort headers. * amd64-obsd-tdep.c: Sort headers. * amd64-obsd-nat.c: Sort headers. * amd64-nbsd-tdep.c: Sort headers. * amd64-nbsd-nat.c: Sort headers. * amd64-nat.c: Sort headers. * amd64-linux-tdep.c: Sort headers. * amd64-linux-nat.c: Sort headers. * amd64-fbsd-tdep.c: Sort headers. * amd64-fbsd-nat.c: Sort headers. * amd64-dicos-tdep.c: Sort headers. * amd64-darwin-tdep.c: Sort headers. * amd64-bsd-nat.c: Sort headers. * alpha-tdep.c: Sort headers. * alpha-obsd-tdep.c: Sort headers. * alpha-nbsd-tdep.c: Sort headers. * alpha-mdebug-tdep.c: Sort headers. * alpha-linux-tdep.c: Sort headers. * alpha-linux-nat.c: Sort headers. * alpha-bsd-tdep.c: Sort headers. * alpha-bsd-nat.c: Sort headers. * aix-thread.c: Sort headers. * agent.c: Sort headers. * addrmap.c: Sort headers. * ada-varobj.c: Sort headers. * ada-valprint.c: Sort headers. * ada-typeprint.c: Sort headers. * ada-tasks.c: Sort headers. * ada-lang.c: Sort headers. * aarch64-tdep.c: Sort headers. * aarch64-ravenscar-thread.c: Sort headers. * aarch64-newlib-tdep.c: Sort headers. * aarch64-linux-tdep.c: Sort headers. * aarch64-linux-nat.c: Sort headers. * aarch64-fbsd-tdep.c: Sort headers. * aarch64-fbsd-nat.c: Sort headers. * aarch32-linux-nat.c: Sort headers.
2019-04-03 04:04:24 +02:00
#include "gdb_obstack.h"
Revert the header-sorting patch Andreas Schwab and John Baldwin pointed out some bugs in the header sorting patch; and I noticed that the output was not correct when limited to a subset of files (a bug in my script). So, I'm reverting the patch. I may try again after fixing the issues pointed out. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> Revert the header-sorting patch. * ft32-tdep.c: Revert. * frv-tdep.c: Revert. * frv-linux-tdep.c: Revert. * frame.c: Revert. * frame-unwind.c: Revert. * frame-base.c: Revert. * fork-child.c: Revert. * findvar.c: Revert. * findcmd.c: Revert. * filesystem.c: Revert. * filename-seen-cache.h: Revert. * filename-seen-cache.c: Revert. * fbsd-tdep.c: Revert. * fbsd-nat.h: Revert. * fbsd-nat.c: Revert. * f-valprint.c: Revert. * f-typeprint.c: Revert. * f-lang.c: Revert. * extension.h: Revert. * extension.c: Revert. * extension-priv.h: Revert. * expprint.c: Revert. * exec.h: Revert. * exec.c: Revert. * exceptions.c: Revert. * event-top.c: Revert. * event-loop.c: Revert. * eval.c: Revert. * elfread.c: Revert. * dwarf2read.h: Revert. * dwarf2read.c: Revert. * dwarf2loc.c: Revert. * dwarf2expr.h: Revert. * dwarf2expr.c: Revert. * dwarf2-frame.c: Revert. * dwarf2-frame-tailcall.c: Revert. * dwarf-index-write.h: Revert. * dwarf-index-write.c: Revert. * dwarf-index-common.c: Revert. * dwarf-index-cache.h: Revert. * dwarf-index-cache.c: Revert. * dummy-frame.c: Revert. * dtrace-probe.c: Revert. * disasm.h: Revert. * disasm.c: Revert. * disasm-selftests.c: Revert. * dictionary.c: Revert. * dicos-tdep.c: Revert. * demangle.c: Revert. * dcache.h: Revert. * dcache.c: Revert. * darwin-nat.h: Revert. * darwin-nat.c: Revert. * darwin-nat-info.c: Revert. * d-valprint.c: Revert. * d-namespace.c: Revert. * d-lang.c: Revert. * ctf.c: Revert. * csky-tdep.c: Revert. * csky-linux-tdep.c: Revert. * cris-tdep.c: Revert. * cris-linux-tdep.c: Revert. * cp-valprint.c: Revert. * cp-support.c: Revert. * cp-namespace.c: Revert. * cp-abi.c: Revert. * corelow.c: Revert. * corefile.c: Revert. * continuations.c: Revert. * completer.h: Revert. * completer.c: Revert. * complaints.c: Revert. * coffread.c: Revert. * coff-pe-read.c: Revert. * cli-out.h: Revert. * cli-out.c: Revert. * charset.c: Revert. * c-varobj.c: Revert. * c-valprint.c: Revert. * c-typeprint.c: Revert. * c-lang.c: Revert. * buildsym.c: Revert. * buildsym-legacy.c: Revert. * build-id.h: Revert. * build-id.c: Revert. * btrace.c: Revert. * bsd-uthread.c: Revert. * breakpoint.h: Revert. * breakpoint.c: Revert. * break-catch-throw.c: Revert. * break-catch-syscall.c: Revert. * break-catch-sig.c: Revert. * blockframe.c: Revert. * block.c: Revert. * bfin-tdep.c: Revert. * bfin-linux-tdep.c: Revert. * bfd-target.c: Revert. * bcache.c: Revert. * ax-general.c: Revert. * ax-gdb.h: Revert. * ax-gdb.c: Revert. * avr-tdep.c: Revert. * auxv.c: Revert. * auto-load.c: Revert. * arm-wince-tdep.c: Revert. * arm-tdep.c: Revert. * arm-symbian-tdep.c: Revert. * arm-pikeos-tdep.c: Revert. * arm-obsd-tdep.c: Revert. * arm-nbsd-tdep.c: Revert. * arm-nbsd-nat.c: Revert. * arm-linux-tdep.c: Revert. * arm-linux-nat.c: Revert. * arm-fbsd-tdep.c: Revert. * arm-fbsd-nat.c: Revert. * arm-bsd-tdep.c: Revert. * arch-utils.c: Revert. * arc-tdep.c: Revert. * arc-newlib-tdep.c: Revert. * annotate.h: Revert. * annotate.c: Revert. * amd64-windows-tdep.c: Revert. * amd64-windows-nat.c: Revert. * amd64-tdep.c: Revert. * amd64-sol2-tdep.c: Revert. * amd64-obsd-tdep.c: Revert. * amd64-obsd-nat.c: Revert. * amd64-nbsd-tdep.c: Revert. * amd64-nbsd-nat.c: Revert. * amd64-nat.c: Revert. * amd64-linux-tdep.c: Revert. * amd64-linux-nat.c: Revert. * amd64-fbsd-tdep.c: Revert. * amd64-fbsd-nat.c: Revert. * amd64-dicos-tdep.c: Revert. * amd64-darwin-tdep.c: Revert. * amd64-bsd-nat.c: Revert. * alpha-tdep.c: Revert. * alpha-obsd-tdep.c: Revert. * alpha-nbsd-tdep.c: Revert. * alpha-mdebug-tdep.c: Revert. * alpha-linux-tdep.c: Revert. * alpha-linux-nat.c: Revert. * alpha-bsd-tdep.c: Revert. * alpha-bsd-nat.c: Revert. * aix-thread.c: Revert. * agent.c: Revert. * addrmap.c: Revert. * ada-varobj.c: Revert. * ada-valprint.c: Revert. * ada-typeprint.c: Revert. * ada-tasks.c: Revert. * ada-lang.c: Revert. * aarch64-tdep.c: Revert. * aarch64-ravenscar-thread.c: Revert. * aarch64-newlib-tdep.c: Revert. * aarch64-linux-tdep.c: Revert. * aarch64-linux-nat.c: Revert. * aarch64-fbsd-tdep.c: Revert. * aarch64-fbsd-nat.c: Revert. * aarch32-linux-nat.c: Revert.
2019-04-06 21:38:10 +02:00
#include "bfd.h" /* Binary File Description. */
Sort includes for files gdb/[a-f]*.[chyl]. This patch sorts the include files for the files [a-f]*.[chyl]. The patch was written by a script. Tested by the buildbot. I will follow up with patches to sort the remaining files, by sorting a subset, testing them, and then checking them in. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> * ft32-tdep.c: Sort headers. * frv-tdep.c: Sort headers. * frv-linux-tdep.c: Sort headers. * frame.c: Sort headers. * frame-unwind.c: Sort headers. * frame-base.c: Sort headers. * fork-child.c: Sort headers. * findvar.c: Sort headers. * findcmd.c: Sort headers. * filesystem.c: Sort headers. * filename-seen-cache.h: Sort headers. * filename-seen-cache.c: Sort headers. * fbsd-tdep.c: Sort headers. * fbsd-nat.h: Sort headers. * fbsd-nat.c: Sort headers. * f-valprint.c: Sort headers. * f-typeprint.c: Sort headers. * f-lang.c: Sort headers. * extension.h: Sort headers. * extension.c: Sort headers. * extension-priv.h: Sort headers. * expprint.c: Sort headers. * exec.h: Sort headers. * exec.c: Sort headers. * exceptions.c: Sort headers. * event-top.c: Sort headers. * event-loop.c: Sort headers. * eval.c: Sort headers. * elfread.c: Sort headers. * dwarf2read.h: Sort headers. * dwarf2read.c: Sort headers. * dwarf2loc.c: Sort headers. * dwarf2expr.h: Sort headers. * dwarf2expr.c: Sort headers. * dwarf2-frame.c: Sort headers. * dwarf2-frame-tailcall.c: Sort headers. * dwarf-index-write.h: Sort headers. * dwarf-index-write.c: Sort headers. * dwarf-index-common.c: Sort headers. * dwarf-index-cache.h: Sort headers. * dwarf-index-cache.c: Sort headers. * dummy-frame.c: Sort headers. * dtrace-probe.c: Sort headers. * disasm.h: Sort headers. * disasm.c: Sort headers. * disasm-selftests.c: Sort headers. * dictionary.c: Sort headers. * dicos-tdep.c: Sort headers. * demangle.c: Sort headers. * dcache.h: Sort headers. * dcache.c: Sort headers. * darwin-nat.h: Sort headers. * darwin-nat.c: Sort headers. * darwin-nat-info.c: Sort headers. * d-valprint.c: Sort headers. * d-namespace.c: Sort headers. * d-lang.c: Sort headers. * ctf.c: Sort headers. * csky-tdep.c: Sort headers. * csky-linux-tdep.c: Sort headers. * cris-tdep.c: Sort headers. * cris-linux-tdep.c: Sort headers. * cp-valprint.c: Sort headers. * cp-support.c: Sort headers. * cp-namespace.c: Sort headers. * cp-abi.c: Sort headers. * corelow.c: Sort headers. * corefile.c: Sort headers. * continuations.c: Sort headers. * completer.h: Sort headers. * completer.c: Sort headers. * complaints.c: Sort headers. * coffread.c: Sort headers. * coff-pe-read.c: Sort headers. * cli-out.h: Sort headers. * cli-out.c: Sort headers. * charset.c: Sort headers. * c-varobj.c: Sort headers. * c-valprint.c: Sort headers. * c-typeprint.c: Sort headers. * c-lang.c: Sort headers. * buildsym.c: Sort headers. * buildsym-legacy.c: Sort headers. * build-id.h: Sort headers. * build-id.c: Sort headers. * btrace.c: Sort headers. * bsd-uthread.c: Sort headers. * breakpoint.h: Sort headers. * breakpoint.c: Sort headers. * break-catch-throw.c: Sort headers. * break-catch-syscall.c: Sort headers. * break-catch-sig.c: Sort headers. * blockframe.c: Sort headers. * block.c: Sort headers. * bfin-tdep.c: Sort headers. * bfin-linux-tdep.c: Sort headers. * bfd-target.c: Sort headers. * bcache.c: Sort headers. * ax-general.c: Sort headers. * ax-gdb.h: Sort headers. * ax-gdb.c: Sort headers. * avr-tdep.c: Sort headers. * auxv.c: Sort headers. * auto-load.c: Sort headers. * arm-wince-tdep.c: Sort headers. * arm-tdep.c: Sort headers. * arm-symbian-tdep.c: Sort headers. * arm-pikeos-tdep.c: Sort headers. * arm-obsd-tdep.c: Sort headers. * arm-nbsd-tdep.c: Sort headers. * arm-nbsd-nat.c: Sort headers. * arm-linux-tdep.c: Sort headers. * arm-linux-nat.c: Sort headers. * arm-fbsd-tdep.c: Sort headers. * arm-fbsd-nat.c: Sort headers. * arm-bsd-tdep.c: Sort headers. * arch-utils.c: Sort headers. * arc-tdep.c: Sort headers. * arc-newlib-tdep.c: Sort headers. * annotate.h: Sort headers. * annotate.c: Sort headers. * amd64-windows-tdep.c: Sort headers. * amd64-windows-nat.c: Sort headers. * amd64-tdep.c: Sort headers. * amd64-sol2-tdep.c: Sort headers. * amd64-obsd-tdep.c: Sort headers. * amd64-obsd-nat.c: Sort headers. * amd64-nbsd-tdep.c: Sort headers. * amd64-nbsd-nat.c: Sort headers. * amd64-nat.c: Sort headers. * amd64-linux-tdep.c: Sort headers. * amd64-linux-nat.c: Sort headers. * amd64-fbsd-tdep.c: Sort headers. * amd64-fbsd-nat.c: Sort headers. * amd64-dicos-tdep.c: Sort headers. * amd64-darwin-tdep.c: Sort headers. * amd64-bsd-nat.c: Sort headers. * alpha-tdep.c: Sort headers. * alpha-obsd-tdep.c: Sort headers. * alpha-nbsd-tdep.c: Sort headers. * alpha-mdebug-tdep.c: Sort headers. * alpha-linux-tdep.c: Sort headers. * alpha-linux-nat.c: Sort headers. * alpha-bsd-tdep.c: Sort headers. * alpha-bsd-nat.c: Sort headers. * aix-thread.c: Sort headers. * agent.c: Sort headers. * addrmap.c: Sort headers. * ada-varobj.c: Sort headers. * ada-valprint.c: Sort headers. * ada-typeprint.c: Sort headers. * ada-tasks.c: Sort headers. * ada-lang.c: Sort headers. * aarch64-tdep.c: Sort headers. * aarch64-ravenscar-thread.c: Sort headers. * aarch64-newlib-tdep.c: Sort headers. * aarch64-linux-tdep.c: Sort headers. * aarch64-linux-nat.c: Sort headers. * aarch64-fbsd-tdep.c: Sort headers. * aarch64-fbsd-nat.c: Sort headers. * aarch32-linux-nat.c: Sort headers.
2019-04-03 04:04:24 +02:00
#include "symtab.h"
Revert the header-sorting patch Andreas Schwab and John Baldwin pointed out some bugs in the header sorting patch; and I noticed that the output was not correct when limited to a subset of files (a bug in my script). So, I'm reverting the patch. I may try again after fixing the issues pointed out. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> Revert the header-sorting patch. * ft32-tdep.c: Revert. * frv-tdep.c: Revert. * frv-linux-tdep.c: Revert. * frame.c: Revert. * frame-unwind.c: Revert. * frame-base.c: Revert. * fork-child.c: Revert. * findvar.c: Revert. * findcmd.c: Revert. * filesystem.c: Revert. * filename-seen-cache.h: Revert. * filename-seen-cache.c: Revert. * fbsd-tdep.c: Revert. * fbsd-nat.h: Revert. * fbsd-nat.c: Revert. * f-valprint.c: Revert. * f-typeprint.c: Revert. * f-lang.c: Revert. * extension.h: Revert. * extension.c: Revert. * extension-priv.h: Revert. * expprint.c: Revert. * exec.h: Revert. * exec.c: Revert. * exceptions.c: Revert. * event-top.c: Revert. * event-loop.c: Revert. * eval.c: Revert. * elfread.c: Revert. * dwarf2read.h: Revert. * dwarf2read.c: Revert. * dwarf2loc.c: Revert. * dwarf2expr.h: Revert. * dwarf2expr.c: Revert. * dwarf2-frame.c: Revert. * dwarf2-frame-tailcall.c: Revert. * dwarf-index-write.h: Revert. * dwarf-index-write.c: Revert. * dwarf-index-common.c: Revert. * dwarf-index-cache.h: Revert. * dwarf-index-cache.c: Revert. * dummy-frame.c: Revert. * dtrace-probe.c: Revert. * disasm.h: Revert. * disasm.c: Revert. * disasm-selftests.c: Revert. * dictionary.c: Revert. * dicos-tdep.c: Revert. * demangle.c: Revert. * dcache.h: Revert. * dcache.c: Revert. * darwin-nat.h: Revert. * darwin-nat.c: Revert. * darwin-nat-info.c: Revert. * d-valprint.c: Revert. * d-namespace.c: Revert. * d-lang.c: Revert. * ctf.c: Revert. * csky-tdep.c: Revert. * csky-linux-tdep.c: Revert. * cris-tdep.c: Revert. * cris-linux-tdep.c: Revert. * cp-valprint.c: Revert. * cp-support.c: Revert. * cp-namespace.c: Revert. * cp-abi.c: Revert. * corelow.c: Revert. * corefile.c: Revert. * continuations.c: Revert. * completer.h: Revert. * completer.c: Revert. * complaints.c: Revert. * coffread.c: Revert. * coff-pe-read.c: Revert. * cli-out.h: Revert. * cli-out.c: Revert. * charset.c: Revert. * c-varobj.c: Revert. * c-valprint.c: Revert. * c-typeprint.c: Revert. * c-lang.c: Revert. * buildsym.c: Revert. * buildsym-legacy.c: Revert. * build-id.h: Revert. * build-id.c: Revert. * btrace.c: Revert. * bsd-uthread.c: Revert. * breakpoint.h: Revert. * breakpoint.c: Revert. * break-catch-throw.c: Revert. * break-catch-syscall.c: Revert. * break-catch-sig.c: Revert. * blockframe.c: Revert. * block.c: Revert. * bfin-tdep.c: Revert. * bfin-linux-tdep.c: Revert. * bfd-target.c: Revert. * bcache.c: Revert. * ax-general.c: Revert. * ax-gdb.h: Revert. * ax-gdb.c: Revert. * avr-tdep.c: Revert. * auxv.c: Revert. * auto-load.c: Revert. * arm-wince-tdep.c: Revert. * arm-tdep.c: Revert. * arm-symbian-tdep.c: Revert. * arm-pikeos-tdep.c: Revert. * arm-obsd-tdep.c: Revert. * arm-nbsd-tdep.c: Revert. * arm-nbsd-nat.c: Revert. * arm-linux-tdep.c: Revert. * arm-linux-nat.c: Revert. * arm-fbsd-tdep.c: Revert. * arm-fbsd-nat.c: Revert. * arm-bsd-tdep.c: Revert. * arch-utils.c: Revert. * arc-tdep.c: Revert. * arc-newlib-tdep.c: Revert. * annotate.h: Revert. * annotate.c: Revert. * amd64-windows-tdep.c: Revert. * amd64-windows-nat.c: Revert. * amd64-tdep.c: Revert. * amd64-sol2-tdep.c: Revert. * amd64-obsd-tdep.c: Revert. * amd64-obsd-nat.c: Revert. * amd64-nbsd-tdep.c: Revert. * amd64-nbsd-nat.c: Revert. * amd64-nat.c: Revert. * amd64-linux-tdep.c: Revert. * amd64-linux-nat.c: Revert. * amd64-fbsd-tdep.c: Revert. * amd64-fbsd-nat.c: Revert. * amd64-dicos-tdep.c: Revert. * amd64-darwin-tdep.c: Revert. * amd64-bsd-nat.c: Revert. * alpha-tdep.c: Revert. * alpha-obsd-tdep.c: Revert. * alpha-nbsd-tdep.c: Revert. * alpha-mdebug-tdep.c: Revert. * alpha-linux-tdep.c: Revert. * alpha-linux-nat.c: Revert. * alpha-bsd-tdep.c: Revert. * alpha-bsd-nat.c: Revert. * aix-thread.c: Revert. * agent.c: Revert. * addrmap.c: Revert. * ada-varobj.c: Revert. * ada-valprint.c: Revert. * ada-typeprint.c: Revert. * ada-tasks.c: Revert. * ada-lang.c: Revert. * aarch64-tdep.c: Revert. * aarch64-ravenscar-thread.c: Revert. * aarch64-newlib-tdep.c: Revert. * aarch64-linux-tdep.c: Revert. * aarch64-linux-nat.c: Revert. * aarch64-fbsd-tdep.c: Revert. * aarch64-fbsd-nat.c: Revert. * aarch32-linux-nat.c: Revert.
2019-04-06 21:38:10 +02:00
#include "gdbtypes.h"
#include "expression.h"
#include "value.h"
#include "gdbcore.h"
Sort includes for files gdb/[a-f]*.[chyl]. This patch sorts the include files for the files [a-f]*.[chyl]. The patch was written by a script. Tested by the buildbot. I will follow up with patches to sort the remaining files, by sorting a subset, testing them, and then checking them in. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> * ft32-tdep.c: Sort headers. * frv-tdep.c: Sort headers. * frv-linux-tdep.c: Sort headers. * frame.c: Sort headers. * frame-unwind.c: Sort headers. * frame-base.c: Sort headers. * fork-child.c: Sort headers. * findvar.c: Sort headers. * findcmd.c: Sort headers. * filesystem.c: Sort headers. * filename-seen-cache.h: Sort headers. * filename-seen-cache.c: Sort headers. * fbsd-tdep.c: Sort headers. * fbsd-nat.h: Sort headers. * fbsd-nat.c: Sort headers. * f-valprint.c: Sort headers. * f-typeprint.c: Sort headers. * f-lang.c: Sort headers. * extension.h: Sort headers. * extension.c: Sort headers. * extension-priv.h: Sort headers. * expprint.c: Sort headers. * exec.h: Sort headers. * exec.c: Sort headers. * exceptions.c: Sort headers. * event-top.c: Sort headers. * event-loop.c: Sort headers. * eval.c: Sort headers. * elfread.c: Sort headers. * dwarf2read.h: Sort headers. * dwarf2read.c: Sort headers. * dwarf2loc.c: Sort headers. * dwarf2expr.h: Sort headers. * dwarf2expr.c: Sort headers. * dwarf2-frame.c: Sort headers. * dwarf2-frame-tailcall.c: Sort headers. * dwarf-index-write.h: Sort headers. * dwarf-index-write.c: Sort headers. * dwarf-index-common.c: Sort headers. * dwarf-index-cache.h: Sort headers. * dwarf-index-cache.c: Sort headers. * dummy-frame.c: Sort headers. * dtrace-probe.c: Sort headers. * disasm.h: Sort headers. * disasm.c: Sort headers. * disasm-selftests.c: Sort headers. * dictionary.c: Sort headers. * dicos-tdep.c: Sort headers. * demangle.c: Sort headers. * dcache.h: Sort headers. * dcache.c: Sort headers. * darwin-nat.h: Sort headers. * darwin-nat.c: Sort headers. * darwin-nat-info.c: Sort headers. * d-valprint.c: Sort headers. * d-namespace.c: Sort headers. * d-lang.c: Sort headers. * ctf.c: Sort headers. * csky-tdep.c: Sort headers. * csky-linux-tdep.c: Sort headers. * cris-tdep.c: Sort headers. * cris-linux-tdep.c: Sort headers. * cp-valprint.c: Sort headers. * cp-support.c: Sort headers. * cp-namespace.c: Sort headers. * cp-abi.c: Sort headers. * corelow.c: Sort headers. * corefile.c: Sort headers. * continuations.c: Sort headers. * completer.h: Sort headers. * completer.c: Sort headers. * complaints.c: Sort headers. * coffread.c: Sort headers. * coff-pe-read.c: Sort headers. * cli-out.h: Sort headers. * cli-out.c: Sort headers. * charset.c: Sort headers. * c-varobj.c: Sort headers. * c-valprint.c: Sort headers. * c-typeprint.c: Sort headers. * c-lang.c: Sort headers. * buildsym.c: Sort headers. * buildsym-legacy.c: Sort headers. * build-id.h: Sort headers. * build-id.c: Sort headers. * btrace.c: Sort headers. * bsd-uthread.c: Sort headers. * breakpoint.h: Sort headers. * breakpoint.c: Sort headers. * break-catch-throw.c: Sort headers. * break-catch-syscall.c: Sort headers. * break-catch-sig.c: Sort headers. * blockframe.c: Sort headers. * block.c: Sort headers. * bfin-tdep.c: Sort headers. * bfin-linux-tdep.c: Sort headers. * bfd-target.c: Sort headers. * bcache.c: Sort headers. * ax-general.c: Sort headers. * ax-gdb.h: Sort headers. * ax-gdb.c: Sort headers. * avr-tdep.c: Sort headers. * auxv.c: Sort headers. * auto-load.c: Sort headers. * arm-wince-tdep.c: Sort headers. * arm-tdep.c: Sort headers. * arm-symbian-tdep.c: Sort headers. * arm-pikeos-tdep.c: Sort headers. * arm-obsd-tdep.c: Sort headers. * arm-nbsd-tdep.c: Sort headers. * arm-nbsd-nat.c: Sort headers. * arm-linux-tdep.c: Sort headers. * arm-linux-nat.c: Sort headers. * arm-fbsd-tdep.c: Sort headers. * arm-fbsd-nat.c: Sort headers. * arm-bsd-tdep.c: Sort headers. * arch-utils.c: Sort headers. * arc-tdep.c: Sort headers. * arc-newlib-tdep.c: Sort headers. * annotate.h: Sort headers. * annotate.c: Sort headers. * amd64-windows-tdep.c: Sort headers. * amd64-windows-nat.c: Sort headers. * amd64-tdep.c: Sort headers. * amd64-sol2-tdep.c: Sort headers. * amd64-obsd-tdep.c: Sort headers. * amd64-obsd-nat.c: Sort headers. * amd64-nbsd-tdep.c: Sort headers. * amd64-nbsd-nat.c: Sort headers. * amd64-nat.c: Sort headers. * amd64-linux-tdep.c: Sort headers. * amd64-linux-nat.c: Sort headers. * amd64-fbsd-tdep.c: Sort headers. * amd64-fbsd-nat.c: Sort headers. * amd64-dicos-tdep.c: Sort headers. * amd64-darwin-tdep.c: Sort headers. * amd64-bsd-nat.c: Sort headers. * alpha-tdep.c: Sort headers. * alpha-obsd-tdep.c: Sort headers. * alpha-nbsd-tdep.c: Sort headers. * alpha-mdebug-tdep.c: Sort headers. * alpha-linux-tdep.c: Sort headers. * alpha-linux-nat.c: Sort headers. * alpha-bsd-tdep.c: Sort headers. * alpha-bsd-nat.c: Sort headers. * aix-thread.c: Sort headers. * agent.c: Sort headers. * addrmap.c: Sort headers. * ada-varobj.c: Sort headers. * ada-valprint.c: Sort headers. * ada-typeprint.c: Sort headers. * ada-tasks.c: Sort headers. * ada-lang.c: Sort headers. * aarch64-tdep.c: Sort headers. * aarch64-ravenscar-thread.c: Sort headers. * aarch64-newlib-tdep.c: Sort headers. * aarch64-linux-tdep.c: Sort headers. * aarch64-linux-nat.c: Sort headers. * aarch64-fbsd-tdep.c: Sort headers. * aarch64-fbsd-nat.c: Sort headers. * aarch32-linux-nat.c: Sort headers.
2019-04-03 04:04:24 +02:00
#include "target.h"
Revert the header-sorting patch Andreas Schwab and John Baldwin pointed out some bugs in the header sorting patch; and I noticed that the output was not correct when limited to a subset of files (a bug in my script). So, I'm reverting the patch. I may try again after fixing the issues pointed out. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> Revert the header-sorting patch. * ft32-tdep.c: Revert. * frv-tdep.c: Revert. * frv-linux-tdep.c: Revert. * frame.c: Revert. * frame-unwind.c: Revert. * frame-base.c: Revert. * fork-child.c: Revert. * findvar.c: Revert. * findcmd.c: Revert. * filesystem.c: Revert. * filename-seen-cache.h: Revert. * filename-seen-cache.c: Revert. * fbsd-tdep.c: Revert. * fbsd-nat.h: Revert. * fbsd-nat.c: Revert. * f-valprint.c: Revert. * f-typeprint.c: Revert. * f-lang.c: Revert. * extension.h: Revert. * extension.c: Revert. * extension-priv.h: Revert. * expprint.c: Revert. * exec.h: Revert. * exec.c: Revert. * exceptions.c: Revert. * event-top.c: Revert. * event-loop.c: Revert. * eval.c: Revert. * elfread.c: Revert. * dwarf2read.h: Revert. * dwarf2read.c: Revert. * dwarf2loc.c: Revert. * dwarf2expr.h: Revert. * dwarf2expr.c: Revert. * dwarf2-frame.c: Revert. * dwarf2-frame-tailcall.c: Revert. * dwarf-index-write.h: Revert. * dwarf-index-write.c: Revert. * dwarf-index-common.c: Revert. * dwarf-index-cache.h: Revert. * dwarf-index-cache.c: Revert. * dummy-frame.c: Revert. * dtrace-probe.c: Revert. * disasm.h: Revert. * disasm.c: Revert. * disasm-selftests.c: Revert. * dictionary.c: Revert. * dicos-tdep.c: Revert. * demangle.c: Revert. * dcache.h: Revert. * dcache.c: Revert. * darwin-nat.h: Revert. * darwin-nat.c: Revert. * darwin-nat-info.c: Revert. * d-valprint.c: Revert. * d-namespace.c: Revert. * d-lang.c: Revert. * ctf.c: Revert. * csky-tdep.c: Revert. * csky-linux-tdep.c: Revert. * cris-tdep.c: Revert. * cris-linux-tdep.c: Revert. * cp-valprint.c: Revert. * cp-support.c: Revert. * cp-namespace.c: Revert. * cp-abi.c: Revert. * corelow.c: Revert. * corefile.c: Revert. * continuations.c: Revert. * completer.h: Revert. * completer.c: Revert. * complaints.c: Revert. * coffread.c: Revert. * coff-pe-read.c: Revert. * cli-out.h: Revert. * cli-out.c: Revert. * charset.c: Revert. * c-varobj.c: Revert. * c-valprint.c: Revert. * c-typeprint.c: Revert. * c-lang.c: Revert. * buildsym.c: Revert. * buildsym-legacy.c: Revert. * build-id.h: Revert. * build-id.c: Revert. * btrace.c: Revert. * bsd-uthread.c: Revert. * breakpoint.h: Revert. * breakpoint.c: Revert. * break-catch-throw.c: Revert. * break-catch-syscall.c: Revert. * break-catch-sig.c: Revert. * blockframe.c: Revert. * block.c: Revert. * bfin-tdep.c: Revert. * bfin-linux-tdep.c: Revert. * bfd-target.c: Revert. * bcache.c: Revert. * ax-general.c: Revert. * ax-gdb.h: Revert. * ax-gdb.c: Revert. * avr-tdep.c: Revert. * auxv.c: Revert. * auto-load.c: Revert. * arm-wince-tdep.c: Revert. * arm-tdep.c: Revert. * arm-symbian-tdep.c: Revert. * arm-pikeos-tdep.c: Revert. * arm-obsd-tdep.c: Revert. * arm-nbsd-tdep.c: Revert. * arm-nbsd-nat.c: Revert. * arm-linux-tdep.c: Revert. * arm-linux-nat.c: Revert. * arm-fbsd-tdep.c: Revert. * arm-fbsd-nat.c: Revert. * arm-bsd-tdep.c: Revert. * arch-utils.c: Revert. * arc-tdep.c: Revert. * arc-newlib-tdep.c: Revert. * annotate.h: Revert. * annotate.c: Revert. * amd64-windows-tdep.c: Revert. * amd64-windows-nat.c: Revert. * amd64-tdep.c: Revert. * amd64-sol2-tdep.c: Revert. * amd64-obsd-tdep.c: Revert. * amd64-obsd-nat.c: Revert. * amd64-nbsd-tdep.c: Revert. * amd64-nbsd-nat.c: Revert. * amd64-nat.c: Revert. * amd64-linux-tdep.c: Revert. * amd64-linux-nat.c: Revert. * amd64-fbsd-tdep.c: Revert. * amd64-fbsd-nat.c: Revert. * amd64-dicos-tdep.c: Revert. * amd64-darwin-tdep.c: Revert. * amd64-bsd-nat.c: Revert. * alpha-tdep.c: Revert. * alpha-obsd-tdep.c: Revert. * alpha-nbsd-tdep.c: Revert. * alpha-mdebug-tdep.c: Revert. * alpha-linux-tdep.c: Revert. * alpha-linux-nat.c: Revert. * alpha-bsd-tdep.c: Revert. * alpha-bsd-nat.c: Revert. * aix-thread.c: Revert. * agent.c: Revert. * addrmap.c: Revert. * ada-varobj.c: Revert. * ada-valprint.c: Revert. * ada-typeprint.c: Revert. * ada-tasks.c: Revert. * ada-lang.c: Revert. * aarch64-tdep.c: Revert. * aarch64-ravenscar-thread.c: Revert. * aarch64-newlib-tdep.c: Revert. * aarch64-linux-tdep.c: Revert. * aarch64-linux-nat.c: Revert. * aarch64-fbsd-tdep.c: Revert. * aarch64-fbsd-nat.c: Revert. * aarch32-linux-nat.c: Revert.
2019-04-06 21:38:10 +02:00
#include "language.h"
#include "demangle.h"
#include "c-lang.h"
#include "cli/cli-style.h"
Sort includes for files gdb/[a-f]*.[chyl]. This patch sorts the include files for the files [a-f]*.[chyl]. The patch was written by a script. Tested by the buildbot. I will follow up with patches to sort the remaining files, by sorting a subset, testing them, and then checking them in. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> * ft32-tdep.c: Sort headers. * frv-tdep.c: Sort headers. * frv-linux-tdep.c: Sort headers. * frame.c: Sort headers. * frame-unwind.c: Sort headers. * frame-base.c: Sort headers. * fork-child.c: Sort headers. * findvar.c: Sort headers. * findcmd.c: Sort headers. * filesystem.c: Sort headers. * filename-seen-cache.h: Sort headers. * filename-seen-cache.c: Sort headers. * fbsd-tdep.c: Sort headers. * fbsd-nat.h: Sort headers. * fbsd-nat.c: Sort headers. * f-valprint.c: Sort headers. * f-typeprint.c: Sort headers. * f-lang.c: Sort headers. * extension.h: Sort headers. * extension.c: Sort headers. * extension-priv.h: Sort headers. * expprint.c: Sort headers. * exec.h: Sort headers. * exec.c: Sort headers. * exceptions.c: Sort headers. * event-top.c: Sort headers. * event-loop.c: Sort headers. * eval.c: Sort headers. * elfread.c: Sort headers. * dwarf2read.h: Sort headers. * dwarf2read.c: Sort headers. * dwarf2loc.c: Sort headers. * dwarf2expr.h: Sort headers. * dwarf2expr.c: Sort headers. * dwarf2-frame.c: Sort headers. * dwarf2-frame-tailcall.c: Sort headers. * dwarf-index-write.h: Sort headers. * dwarf-index-write.c: Sort headers. * dwarf-index-common.c: Sort headers. * dwarf-index-cache.h: Sort headers. * dwarf-index-cache.c: Sort headers. * dummy-frame.c: Sort headers. * dtrace-probe.c: Sort headers. * disasm.h: Sort headers. * disasm.c: Sort headers. * disasm-selftests.c: Sort headers. * dictionary.c: Sort headers. * dicos-tdep.c: Sort headers. * demangle.c: Sort headers. * dcache.h: Sort headers. * dcache.c: Sort headers. * darwin-nat.h: Sort headers. * darwin-nat.c: Sort headers. * darwin-nat-info.c: Sort headers. * d-valprint.c: Sort headers. * d-namespace.c: Sort headers. * d-lang.c: Sort headers. * ctf.c: Sort headers. * csky-tdep.c: Sort headers. * csky-linux-tdep.c: Sort headers. * cris-tdep.c: Sort headers. * cris-linux-tdep.c: Sort headers. * cp-valprint.c: Sort headers. * cp-support.c: Sort headers. * cp-namespace.c: Sort headers. * cp-abi.c: Sort headers. * corelow.c: Sort headers. * corefile.c: Sort headers. * continuations.c: Sort headers. * completer.h: Sort headers. * completer.c: Sort headers. * complaints.c: Sort headers. * coffread.c: Sort headers. * coff-pe-read.c: Sort headers. * cli-out.h: Sort headers. * cli-out.c: Sort headers. * charset.c: Sort headers. * c-varobj.c: Sort headers. * c-valprint.c: Sort headers. * c-typeprint.c: Sort headers. * c-lang.c: Sort headers. * buildsym.c: Sort headers. * buildsym-legacy.c: Sort headers. * build-id.h: Sort headers. * build-id.c: Sort headers. * btrace.c: Sort headers. * bsd-uthread.c: Sort headers. * breakpoint.h: Sort headers. * breakpoint.c: Sort headers. * break-catch-throw.c: Sort headers. * break-catch-syscall.c: Sort headers. * break-catch-sig.c: Sort headers. * blockframe.c: Sort headers. * block.c: Sort headers. * bfin-tdep.c: Sort headers. * bfin-linux-tdep.c: Sort headers. * bfd-target.c: Sort headers. * bcache.c: Sort headers. * ax-general.c: Sort headers. * ax-gdb.h: Sort headers. * ax-gdb.c: Sort headers. * avr-tdep.c: Sort headers. * auxv.c: Sort headers. * auto-load.c: Sort headers. * arm-wince-tdep.c: Sort headers. * arm-tdep.c: Sort headers. * arm-symbian-tdep.c: Sort headers. * arm-pikeos-tdep.c: Sort headers. * arm-obsd-tdep.c: Sort headers. * arm-nbsd-tdep.c: Sort headers. * arm-nbsd-nat.c: Sort headers. * arm-linux-tdep.c: Sort headers. * arm-linux-nat.c: Sort headers. * arm-fbsd-tdep.c: Sort headers. * arm-fbsd-nat.c: Sort headers. * arm-bsd-tdep.c: Sort headers. * arch-utils.c: Sort headers. * arc-tdep.c: Sort headers. * arc-newlib-tdep.c: Sort headers. * annotate.h: Sort headers. * annotate.c: Sort headers. * amd64-windows-tdep.c: Sort headers. * amd64-windows-nat.c: Sort headers. * amd64-tdep.c: Sort headers. * amd64-sol2-tdep.c: Sort headers. * amd64-obsd-tdep.c: Sort headers. * amd64-obsd-nat.c: Sort headers. * amd64-nbsd-tdep.c: Sort headers. * amd64-nbsd-nat.c: Sort headers. * amd64-nat.c: Sort headers. * amd64-linux-tdep.c: Sort headers. * amd64-linux-nat.c: Sort headers. * amd64-fbsd-tdep.c: Sort headers. * amd64-fbsd-nat.c: Sort headers. * amd64-dicos-tdep.c: Sort headers. * amd64-darwin-tdep.c: Sort headers. * amd64-bsd-nat.c: Sort headers. * alpha-tdep.c: Sort headers. * alpha-obsd-tdep.c: Sort headers. * alpha-nbsd-tdep.c: Sort headers. * alpha-mdebug-tdep.c: Sort headers. * alpha-linux-tdep.c: Sort headers. * alpha-linux-nat.c: Sort headers. * alpha-bsd-tdep.c: Sort headers. * alpha-bsd-nat.c: Sort headers. * aix-thread.c: Sort headers. * agent.c: Sort headers. * addrmap.c: Sort headers. * ada-varobj.c: Sort headers. * ada-valprint.c: Sort headers. * ada-typeprint.c: Sort headers. * ada-tasks.c: Sort headers. * ada-lang.c: Sort headers. * aarch64-tdep.c: Sort headers. * aarch64-ravenscar-thread.c: Sort headers. * aarch64-newlib-tdep.c: Sort headers. * aarch64-linux-tdep.c: Sort headers. * aarch64-linux-nat.c: Sort headers. * aarch64-fbsd-tdep.c: Sort headers. * aarch64-fbsd-nat.c: Sort headers. * aarch32-linux-nat.c: Sort headers.
2019-04-03 04:04:24 +02:00
#include "typeprint.h"
Revert the header-sorting patch Andreas Schwab and John Baldwin pointed out some bugs in the header sorting patch; and I noticed that the output was not correct when limited to a subset of files (a bug in my script). So, I'm reverting the patch. I may try again after fixing the issues pointed out. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> Revert the header-sorting patch. * ft32-tdep.c: Revert. * frv-tdep.c: Revert. * frv-linux-tdep.c: Revert. * frame.c: Revert. * frame-unwind.c: Revert. * frame-base.c: Revert. * fork-child.c: Revert. * findvar.c: Revert. * findcmd.c: Revert. * filesystem.c: Revert. * filename-seen-cache.h: Revert. * filename-seen-cache.c: Revert. * fbsd-tdep.c: Revert. * fbsd-nat.h: Revert. * fbsd-nat.c: Revert. * f-valprint.c: Revert. * f-typeprint.c: Revert. * f-lang.c: Revert. * extension.h: Revert. * extension.c: Revert. * extension-priv.h: Revert. * expprint.c: Revert. * exec.h: Revert. * exec.c: Revert. * exceptions.c: Revert. * event-top.c: Revert. * event-loop.c: Revert. * eval.c: Revert. * elfread.c: Revert. * dwarf2read.h: Revert. * dwarf2read.c: Revert. * dwarf2loc.c: Revert. * dwarf2expr.h: Revert. * dwarf2expr.c: Revert. * dwarf2-frame.c: Revert. * dwarf2-frame-tailcall.c: Revert. * dwarf-index-write.h: Revert. * dwarf-index-write.c: Revert. * dwarf-index-common.c: Revert. * dwarf-index-cache.h: Revert. * dwarf-index-cache.c: Revert. * dummy-frame.c: Revert. * dtrace-probe.c: Revert. * disasm.h: Revert. * disasm.c: Revert. * disasm-selftests.c: Revert. * dictionary.c: Revert. * dicos-tdep.c: Revert. * demangle.c: Revert. * dcache.h: Revert. * dcache.c: Revert. * darwin-nat.h: Revert. * darwin-nat.c: Revert. * darwin-nat-info.c: Revert. * d-valprint.c: Revert. * d-namespace.c: Revert. * d-lang.c: Revert. * ctf.c: Revert. * csky-tdep.c: Revert. * csky-linux-tdep.c: Revert. * cris-tdep.c: Revert. * cris-linux-tdep.c: Revert. * cp-valprint.c: Revert. * cp-support.c: Revert. * cp-namespace.c: Revert. * cp-abi.c: Revert. * corelow.c: Revert. * corefile.c: Revert. * continuations.c: Revert. * completer.h: Revert. * completer.c: Revert. * complaints.c: Revert. * coffread.c: Revert. * coff-pe-read.c: Revert. * cli-out.h: Revert. * cli-out.c: Revert. * charset.c: Revert. * c-varobj.c: Revert. * c-valprint.c: Revert. * c-typeprint.c: Revert. * c-lang.c: Revert. * buildsym.c: Revert. * buildsym-legacy.c: Revert. * build-id.h: Revert. * build-id.c: Revert. * btrace.c: Revert. * bsd-uthread.c: Revert. * breakpoint.h: Revert. * breakpoint.c: Revert. * break-catch-throw.c: Revert. * break-catch-syscall.c: Revert. * break-catch-sig.c: Revert. * blockframe.c: Revert. * block.c: Revert. * bfin-tdep.c: Revert. * bfin-linux-tdep.c: Revert. * bfd-target.c: Revert. * bcache.c: Revert. * ax-general.c: Revert. * ax-gdb.h: Revert. * ax-gdb.c: Revert. * avr-tdep.c: Revert. * auxv.c: Revert. * auto-load.c: Revert. * arm-wince-tdep.c: Revert. * arm-tdep.c: Revert. * arm-symbian-tdep.c: Revert. * arm-pikeos-tdep.c: Revert. * arm-obsd-tdep.c: Revert. * arm-nbsd-tdep.c: Revert. * arm-nbsd-nat.c: Revert. * arm-linux-tdep.c: Revert. * arm-linux-nat.c: Revert. * arm-fbsd-tdep.c: Revert. * arm-fbsd-nat.c: Revert. * arm-bsd-tdep.c: Revert. * arch-utils.c: Revert. * arc-tdep.c: Revert. * arc-newlib-tdep.c: Revert. * annotate.h: Revert. * annotate.c: Revert. * amd64-windows-tdep.c: Revert. * amd64-windows-nat.c: Revert. * amd64-tdep.c: Revert. * amd64-sol2-tdep.c: Revert. * amd64-obsd-tdep.c: Revert. * amd64-obsd-nat.c: Revert. * amd64-nbsd-tdep.c: Revert. * amd64-nbsd-nat.c: Revert. * amd64-nat.c: Revert. * amd64-linux-tdep.c: Revert. * amd64-linux-nat.c: Revert. * amd64-fbsd-tdep.c: Revert. * amd64-fbsd-nat.c: Revert. * amd64-dicos-tdep.c: Revert. * amd64-darwin-tdep.c: Revert. * amd64-bsd-nat.c: Revert. * alpha-tdep.c: Revert. * alpha-obsd-tdep.c: Revert. * alpha-nbsd-tdep.c: Revert. * alpha-mdebug-tdep.c: Revert. * alpha-linux-tdep.c: Revert. * alpha-linux-nat.c: Revert. * alpha-bsd-tdep.c: Revert. * alpha-bsd-nat.c: Revert. * aix-thread.c: Revert. * agent.c: Revert. * addrmap.c: Revert. * ada-varobj.c: Revert. * ada-valprint.c: Revert. * ada-typeprint.c: Revert. * ada-tasks.c: Revert. * ada-lang.c: Revert. * aarch64-tdep.c: Revert. * aarch64-ravenscar-thread.c: Revert. * aarch64-newlib-tdep.c: Revert. * aarch64-linux-tdep.c: Revert. * aarch64-linux-nat.c: Revert. * aarch64-fbsd-tdep.c: Revert. * aarch64-fbsd-nat.c: Revert. * aarch32-linux-nat.c: Revert.
2019-04-06 21:38:10 +02:00
#include "cp-abi.h"
#include "cp-support.h"
/* A list of access specifiers used for printing. */
enum access_specifier
{
s_none,
s_public,
s_private,
s_protected
};
static void c_type_print_varspec_suffix (struct type *, struct ui_file *, int,
int, int,
enum language,
const struct type_print_options *);
static void c_type_print_varspec_prefix (struct type *,
struct ui_file *,
* ada-lang.c (user_select_syms, ada_print_subexp): Pass flags to type-printing functions. * ada-lang.h (ada_print_type): Add argument. * ada-typeprint.c (print_array_type, print_variant_clauses, print_variant_part, print_selected_record_field_types, print_record_field_types, print_unchecked_union_type, print_func_type, ada_print_type): Add flags argument. (ada_print_typedef): Update. * c-exp.y (OPERATOR conversion_type_id): Update. * c-lang.h (c_print_type, c_type_print_base): Update. * c-typeprint.c (c_print_type, c_type_print_varspec_prefix, c_type_print_modifier, c_type_print_args, c_type_print_varspec_suffix, c_type_print_base): Add flags argument. * cp-valprint.c (cp_print_class_member): Update. * dwarf2read.c (dwarf2_compute_name): Update. * f-lang.h (f_print_type): Add argument. * f-typeprint.c (f_print_type): Add flags argument. * gnu-v3-abi.c (gnuv3_print_method_ptr): Update. * go-lang.h (go_print_type): Add argument. * go-typeprint.c (go_print_type): Add flags argument. * jv-lang.h (java_print_type): Add argument. * jv-typeprint.c (java_type_print_base, java_print_type): Add flags argument. * language.c (unk_lang_print_type): Add flags argument. * language.h (struct language_defn) <la_print_type>: Add flags argument. (LA_PRINT_TYPE): Likewise. * m2-lang.h (m2_print_type): Add argument. * m2-typeprint.c (m2_print_type, m2_range, m2_typedef, m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set, m2_unbounded_array, m2_record_fields): Add flags argument. * p-lang.h (pascal_print_type, pascal_type_print_base, pascal_type_print_varspec_prefix): Add argument. * p-typeprint.c (pascal_print_type, pascal_type_print_varspec_prefix, pascal_print_func_args, pascal_type_print_varspec_suffix, pascal_type_print_base): Add flags argument. * symmisc.c (print_symbol): Update. * typeprint.c (type_print_raw_options, default_ptype_flags): New globals. (type_print): Update. * typeprint.h (struct type_print_options): New. (type_print_raw_options): Declare. (c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 18:14:55 +01:00
int, int, int,
enum language,
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
const struct type_print_options *,
struct print_offset_data *);
/* Print "const", "volatile", or address space modifiers. */
static void c_type_print_modifier (struct type *,
struct ui_file *,
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
int, int, enum language);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
static void c_type_print_base_1 (struct type *type, struct ui_file *stream,
int show, int level, enum language language,
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
const struct type_print_options *flags,
struct print_offset_data *podata);
1999-07-07 22:19:36 +02:00
* 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-12 18:37:38 +01:00
/* A callback function for cp_canonicalize_string_full that uses
C++-ify typedef hash This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
2018-03-14 23:38:02 +01:00
typedef_hash_table::find_typedef. */
* 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-12 18:37:38 +01:00
static const char *
find_typedef_for_canonicalize (struct type *t, void *data)
{
C++-ify typedef hash This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
2018-03-14 23:38:02 +01:00
return typedef_hash_table::find_typedef
((const struct type_print_options *) data, t);
* 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-12 18:37:38 +01:00
}
/* Print NAME on STREAM. If the 'raw' field of FLAGS is not set,
canonicalize NAME using the local typedefs first. */
static void
print_name_maybe_canonical (const char *name,
const struct type_print_options *flags,
struct ui_file *stream)
{
gdb::unique_xmalloc_ptr<char> s;
* 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-12 18:37:38 +01:00
if (!flags->raw)
s = cp_canonicalize_string_full (name,
find_typedef_for_canonicalize,
(void *) flags);
fputs_filtered (s != nullptr ? s.get () : name, stream);
* 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-12 18:37:38 +01:00
}
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
/* Helper function for c_print_type. */
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
static void
c_print_type_1 (struct type *type,
const char *varstring,
struct ui_file *stream,
int show, int level,
enum language language,
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
const struct type_print_options *flags,
struct print_offset_data *podata)
{
enum type_code code;
int demangled_args;
int need_post_space;
* 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-12 18:37:38 +01:00
const char *local_name;
if (show > 0)
Remove CHECK_TYPEDEF, use check_typedef instead I think that the CHECK_TYPEDEF macro is not necessary, and even a bit annoying. It makes unclear the fact that the "type" variables gets overwritten. It has actually bitten me a few times. I think the following, explicit form, is better. type = check_typedef (type); This patches changes all instances of CHECK_TYPEDEF for an equivalent call to check_typedef. The bulk of the change was done with this sed: sed -i 's/CHECK_TYPEDEF (\([^)]*\));/\1 = check_typedef (\1);/' <file>.c The ChangeLog was generated using David Malcom's generate_changelog.py. I manually fixed those places where it gets the wrong function name, hopefully all of them. The patch was built-tested, and I ran a few smoke tests. gdb/ChangeLog: * gdbtypes.h (CHECK_TYPEDEF): Remove. * aarch64-tdep.c (aarch64_return_in_memory): Replace CHECK_TYPEDEF with check_typedef. * ada-lang.c (decode_constrained_packed_array_type): Likewise. (ada_array_length): Likewise. (find_parallel_type_by_descriptive_type): Likewise. (ada_check_typedef): Likewise. * arm-tdep.c (arm_return_in_memory): Likewise. * ax-gdb.c (gen_trace_static_fields): Likewise. (gen_struct_ref_recursive): Likewise. * c-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. (variable: block COLONCOLON name): Likewise. (qualified_name: TYPENAME COLONCOLON name): Likewise. * c-lang.c (classify_type): Likewise. * c-typeprint.c (c_print_type): Likewise. (c_print_typedef): Likewise. (c_type_print_base): Likewise. * c-valprint.c (c_val_print): Likewise. * compile/compile-c-types.c (convert_type): Likewise. * compile/compile-object-load.c (get_out_value_type): Likewise. * completer.c (add_struct_fields): Likewise. (expression_completer): Likewise. * cp-namespace.c (cp_find_type_baseclass_by_name): Likewise. (cp_lookup_nested_symbol_1): Likewise. (cp_lookup_nested_symbol): Likewise. * cp-valprint.c (cp_print_value_fields): Likewise. (cp_print_static_field): Likewise. * d-valprint.c (d_val_print): Likewise. * eval.c (evaluate_subexp_standard): Likewise. (evaluate_subexp_for_sizeof): Likewise. * f-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. * f-typeprint.c (f_type_print_base): Likewise. * f-valprint.c (f_val_print): Likewise. * gdbtypes.c (get_discrete_bounds): Likewise. (create_array_type_with_stride): Likewise. (type_name_no_tag_or_error): Likewise. (lookup_struct_elt_type): Likewise. (get_unsigned_type_max): Likewise. (internal_type_vptr_fieldno): Likewise. (set_type_vptr_fieldno): Likewise. (internal_type_vptr_basetype): Likewise. (set_type_vptr_basetype): Likewise. (get_vptr_fieldno): Likewise. (is_integral_type): Likewise. (is_scalar_type): Likewise. (is_scalar_type_recursive): Likewise. (distance_to_ancestor): Likewise. (is_unique_ancestor_worker): Likewise. (check_types_equal): Likewise. * gnu-v2-abi.c (gnuv2_value_rtti_type): Likewise. * gnu-v3-abi.c (gnuv3_dynamic_class): Likewise. (gnuv3_get_vtable): Likewise. (gnuv3_pass_by_reference): Likewise. * go-exp.y (exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY): Likewise. * go-lang.c (gccgo_string_p): Likewise. (go_classify_struct_type): Likewise. * go-typeprint.c (go_print_type): Likewise. * go-valprint.c (go_val_print): Likewise. * guile/scm-math.c (vlscm_binop): Likewise. * guile/scm-value.c (gdbscm_value_dynamic_type): Likewise. (gdbscm_value_to_bytevector): Likewise. (gdbscm_value_to_bool): Likewise. (gdbscm_value_to_integer): Likewise. (gdbscm_value_to_real): Likewise. * infcall.c (call_function_by_hand_dummy): Likewise. * infcmd.c (get_return_value): Likewise. * jv-lang.c (is_object_type): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_print_value_fields): Likewise. (java_val_print): Likewise. * linespec.c (find_methods): Likewise. (collect_one_symbol): Likewise. * m2-typeprint.c (m2_print_type): Likewise. (m2_print_typedef): Likewise. (m2_get_discrete_bounds): Likewise. * m2-valprint.c (m2_print_long_set): Likewise. (m2_print_unbounded_array): Likewise. (m2_print_array_contents): Likewise. (m2_val_print): Likewise. * opencl-lang.c (opencl_print_type): Likewise. * p-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. * p-typeprint.c (pascal_print_type): Likewise. (pascal_print_typedef): Likewise. (pascal_type_print_base): Likewise. * p-valprint.c (pascal_val_print): Likewise. (pascal_object_print_value_fields): Likewise. (pascal_object_print_static_field): Likewise. * python/py-type.c (typy_fields_items): Likewise. (typy_get_composite): Likewise. * python/py-value.c (valpy_get_dynamic_type): Likewise. (valpy_binop): Likewise. (valpy_long): Likewise. (valpy_float): Likewise. * stack.c (return_command): Likewise. * symtab.c (check_field): Likewise. (lookup_symbol_aux): Likewise. * tic6x-tdep.c (tic6x_return_value): Likewise. * typeprint.c (print_type_scalar): Likewise. * valarith.c (value_vector_widen): Likewise. * valops.c (value_cast): Likewise. (value_assign): Likewise. (do_search_struct_field): Likewise. (search_struct_method): Likewise. (find_method_list): Likewise. * valprint.c (val_print_scalar_type_p): Likewise. (valprint_check_validity): Likewise. (generic_val_print): Likewise. * value.c (unpack_double): Likewise. (value_primitive_field): Likewise. (unpack_bits_as_long): Likewise.
2015-07-06 22:05:06 +02:00
type = check_typedef (type);
C++-ify typedef hash This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
2018-03-14 23:38:02 +01:00
local_name = typedef_hash_table::find_typedef (flags, type);
code = type->code ();
* 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-12 18:37:38 +01:00
if (local_name != NULL)
{
fputs_filtered (local_name, stream);
if (varstring != NULL && *varstring != '\0')
fputs_filtered (" ", stream);
}
else
{
c_type_print_base_1 (type, stream, show, level, language, flags, podata);
* 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-12 18:37:38 +01:00
if ((varstring != NULL && *varstring != '\0')
/* Need a space if going to print stars or brackets;
but not if we will print just a type name. */
|| ((show > 0 || type->name () == 0)
* 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-12 18:37:38 +01:00
&& (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
|| code == TYPE_CODE_METHOD
|| (code == TYPE_CODE_ARRAY
&& !TYPE_VECTOR (type))
|| code == TYPE_CODE_MEMBERPTR
|| code == TYPE_CODE_METHODPTR
|| TYPE_IS_REFERENCE (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-12 18:37:38 +01:00
fputs_filtered (" ", stream);
need_post_space = (varstring != NULL && strcmp (varstring, "") != 0);
c_type_print_varspec_prefix (type, stream, show, 0, need_post_space,
language, flags, podata);
* 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-12 18:37:38 +01:00
}
if (varstring != NULL)
{
if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
fputs_styled (varstring, function_name_style.style (), stream);
else
Style field names in "print" This changes gdb to use the "variable" style when printing field names. I've added new tests for C and Rust, but not other languages. I chose "variable" because that seemed most straightforward. However, another option would be to introduce a new "field" style. Similarly, this patch uses the variable style for enumerator constants -- but again, a new style could be used if that's preferred. gdb/ChangeLog 2020-02-22 Tom Tromey <tom@tromey.com> * valprint.c (generic_val_print_enum_1) (val_print_type_code_flags): Style member names. * rust-lang.c (val_print_struct, rust_print_enum) (rust_print_struct_def, rust_internal_print_type): Style member names. * p-valprint.c (pascal_object_print_value_fields): Style member names. Only call fprintf_symbol_filtered for static members. * m2-typeprint.c (m2_record_fields, m2_enum): Style member names. * f-valprint.c (f_val_print): Style member names. * f-typeprint.c (f_type_print_base): Style member names. * cp-valprint.c (cp_print_value_fields): Style member names. Only call fprintf_symbol_filtered for static members. (cp_print_class_member): Style member names. * c-typeprint.c (c_print_type_1, c_type_print_base_1): Style member names. * ada-valprint.c (ada_print_scalar): Style enum names. (ada_val_print_enum): Likewise. * ada-typeprint.c (print_enum_type): Style enum names. gdb/testsuite/ChangeLog 2020-02-22 Tom Tromey <tom@tromey.com> * gdb.rust/rust-style.rs: New file. * gdb.rust/rust-style.exp: New file. * gdb.base/style.exp: Test structure printing. * gdb.base/style.c (struct some_struct): New type. (enum etype): New type. (struct_value): New global. Change-Id: I070e1293c6cc830c9ea916af8243410aa384e944
2020-02-22 18:02:42 +01:00
fputs_styled (varstring, variable_name_style.style (), stream);
/* For demangled function names, we have the arglist as part of
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
the name, so don't print an additional pair of ()'s. */
* 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-12 18:37:38 +01:00
if (local_name == NULL)
{
demangled_args = strchr (varstring, '(') != NULL;
c_type_print_varspec_suffix (type, stream, show,
0, demangled_args,
language, flags);
* 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-12 18:37:38 +01:00
}
}
}
1999-07-07 22:19:36 +02:00
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
/* LEVEL is the depth to indent lines by. */
void
c_print_type (struct type *type,
const char *varstring,
struct ui_file *stream,
int show, int level,
const struct type_print_options *flags)
{
struct print_offset_data podata;
c_print_type_1 (type, varstring, stream, show, level,
current_language->la_language, flags, &podata);
}
/* See c-lang.h. */
void
c_print_type (struct type *type,
const char *varstring,
struct ui_file *stream,
int show, int level,
enum language language,
const struct type_print_options *flags)
{
struct print_offset_data podata;
c_print_type_1 (type, varstring, stream, show, level, language, flags,
&podata);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
}
/* Print a typedef using C syntax. TYPE is the underlying type.
NEW_SYMBOL is the symbol naming the type. STREAM is the stream on
which to print. */
void
c_print_typedef (struct type *type,
struct symbol *new_symbol,
struct ui_file *stream)
{
Remove CHECK_TYPEDEF, use check_typedef instead I think that the CHECK_TYPEDEF macro is not necessary, and even a bit annoying. It makes unclear the fact that the "type" variables gets overwritten. It has actually bitten me a few times. I think the following, explicit form, is better. type = check_typedef (type); This patches changes all instances of CHECK_TYPEDEF for an equivalent call to check_typedef. The bulk of the change was done with this sed: sed -i 's/CHECK_TYPEDEF (\([^)]*\));/\1 = check_typedef (\1);/' <file>.c The ChangeLog was generated using David Malcom's generate_changelog.py. I manually fixed those places where it gets the wrong function name, hopefully all of them. The patch was built-tested, and I ran a few smoke tests. gdb/ChangeLog: * gdbtypes.h (CHECK_TYPEDEF): Remove. * aarch64-tdep.c (aarch64_return_in_memory): Replace CHECK_TYPEDEF with check_typedef. * ada-lang.c (decode_constrained_packed_array_type): Likewise. (ada_array_length): Likewise. (find_parallel_type_by_descriptive_type): Likewise. (ada_check_typedef): Likewise. * arm-tdep.c (arm_return_in_memory): Likewise. * ax-gdb.c (gen_trace_static_fields): Likewise. (gen_struct_ref_recursive): Likewise. * c-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. (variable: block COLONCOLON name): Likewise. (qualified_name: TYPENAME COLONCOLON name): Likewise. * c-lang.c (classify_type): Likewise. * c-typeprint.c (c_print_type): Likewise. (c_print_typedef): Likewise. (c_type_print_base): Likewise. * c-valprint.c (c_val_print): Likewise. * compile/compile-c-types.c (convert_type): Likewise. * compile/compile-object-load.c (get_out_value_type): Likewise. * completer.c (add_struct_fields): Likewise. (expression_completer): Likewise. * cp-namespace.c (cp_find_type_baseclass_by_name): Likewise. (cp_lookup_nested_symbol_1): Likewise. (cp_lookup_nested_symbol): Likewise. * cp-valprint.c (cp_print_value_fields): Likewise. (cp_print_static_field): Likewise. * d-valprint.c (d_val_print): Likewise. * eval.c (evaluate_subexp_standard): Likewise. (evaluate_subexp_for_sizeof): Likewise. * f-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. * f-typeprint.c (f_type_print_base): Likewise. * f-valprint.c (f_val_print): Likewise. * gdbtypes.c (get_discrete_bounds): Likewise. (create_array_type_with_stride): Likewise. (type_name_no_tag_or_error): Likewise. (lookup_struct_elt_type): Likewise. (get_unsigned_type_max): Likewise. (internal_type_vptr_fieldno): Likewise. (set_type_vptr_fieldno): Likewise. (internal_type_vptr_basetype): Likewise. (set_type_vptr_basetype): Likewise. (get_vptr_fieldno): Likewise. (is_integral_type): Likewise. (is_scalar_type): Likewise. (is_scalar_type_recursive): Likewise. (distance_to_ancestor): Likewise. (is_unique_ancestor_worker): Likewise. (check_types_equal): Likewise. * gnu-v2-abi.c (gnuv2_value_rtti_type): Likewise. * gnu-v3-abi.c (gnuv3_dynamic_class): Likewise. (gnuv3_get_vtable): Likewise. (gnuv3_pass_by_reference): Likewise. * go-exp.y (exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY): Likewise. * go-lang.c (gccgo_string_p): Likewise. (go_classify_struct_type): Likewise. * go-typeprint.c (go_print_type): Likewise. * go-valprint.c (go_val_print): Likewise. * guile/scm-math.c (vlscm_binop): Likewise. * guile/scm-value.c (gdbscm_value_dynamic_type): Likewise. (gdbscm_value_to_bytevector): Likewise. (gdbscm_value_to_bool): Likewise. (gdbscm_value_to_integer): Likewise. (gdbscm_value_to_real): Likewise. * infcall.c (call_function_by_hand_dummy): Likewise. * infcmd.c (get_return_value): Likewise. * jv-lang.c (is_object_type): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_print_value_fields): Likewise. (java_val_print): Likewise. * linespec.c (find_methods): Likewise. (collect_one_symbol): Likewise. * m2-typeprint.c (m2_print_type): Likewise. (m2_print_typedef): Likewise. (m2_get_discrete_bounds): Likewise. * m2-valprint.c (m2_print_long_set): Likewise. (m2_print_unbounded_array): Likewise. (m2_print_array_contents): Likewise. (m2_val_print): Likewise. * opencl-lang.c (opencl_print_type): Likewise. * p-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. * p-typeprint.c (pascal_print_type): Likewise. (pascal_print_typedef): Likewise. (pascal_type_print_base): Likewise. * p-valprint.c (pascal_val_print): Likewise. (pascal_object_print_value_fields): Likewise. (pascal_object_print_static_field): Likewise. * python/py-type.c (typy_fields_items): Likewise. (typy_get_composite): Likewise. * python/py-value.c (valpy_get_dynamic_type): Likewise. (valpy_binop): Likewise. (valpy_long): Likewise. (valpy_float): Likewise. * stack.c (return_command): Likewise. * symtab.c (check_field): Likewise. (lookup_symbol_aux): Likewise. * tic6x-tdep.c (tic6x_return_value): Likewise. * typeprint.c (print_type_scalar): Likewise. * valarith.c (value_vector_widen): Likewise. * valops.c (value_cast): Likewise. (value_assign): Likewise. (do_search_struct_field): Likewise. (search_struct_method): Likewise. (find_method_list): Likewise. * valprint.c (val_print_scalar_type_p): Likewise. (valprint_check_validity): Likewise. (generic_val_print): Likewise. * value.c (unpack_double): Likewise. (value_primitive_field): Likewise. (unpack_bits_as_long): Likewise.
2015-07-06 22:05:06 +02:00
type = check_typedef (type);
fprintf_filtered (stream, "typedef ");
gdb: Show type summary for anonymous structures from c_print_typedef Currently each language has a la_print_typedef method, this is only used for the "info types" command. The documentation for "info types" says: Print a brief description of all types whose names match the regular expression @var{regexp} (or all types in your program, if you supply no argument). However, if we consider this C code: typedef struct { int a; } my_type; Then currently with "info types" this will be printed like this: 3: typedef struct { int a; } my_type; I see two problems with this, first the indentation is clearly broken, second, if the struct contained more fields then it feels like the actual type names could easily get lost in the noise. Given that "info types" is about discovering type names, I think there is an argument to be made that we should focus on giving _only_ the briefest summary for "info types", and if the user wants to know more they can take the type name and plug it into "ptype". As such, I propose that a better output would be: 3: typedef struct {...} my_type; The user understands that there is a type called `my_type`, and that it's an alias for an anonymous structure type. The change to achieve this turns out to be pretty simple, but only effects languages that make use of c_print_typedef, which are C, C++, asm, minimal, d, go, objc, and opencl. Other languages will for now do whatever they used to do. The patch to change how anonymous structs are displayed also changes the display of anonymous enums, consider this code sample: typedef enum { AA, BB, CC } anon_enum_t; This used to be displayed like this: 3: typedef enum {AA, BB, CC} anon_enum_t; Which will quickly become cluttered for enums with a large number of values. The modified output looks like this: 3: typedef enum {...} anon_enum_t; Again, the user can always make use of ptype if they want to see the details of the anon_enum_t type. It is worth pointing out that this change (to use {...}) only effects anonymous structs and enums, named types don't change with this patch, consider this code: struct struct_t { int i; }; enum enum_t { AA, BB, CC }; The output from 'info types' remains unchanged, like this: 4: enum enum_t; 1: struct struct_t; An additional area of interest is how C++ handles anonymous types used within a typedef; enums are handled basically inline with how C handles them, but structs (and classes) are slightly different. The behaviour before the patch is different, and is unchanged by this patch. Consider this code compiled for C++: typedef struct { int i; } struct_t; Both before and after this patch, this is show by 'info types' as: 3: typedef struct_t struct_t; Unions are displayed similarly to structs in both C and C++, the handling of anonymous unions changes for C in the same way that it changes for anonymous structs. I did look at ada, as this is the only language to actually have some tests for "info types", however, as I understand it ada doesn't really support typedefs, however, by forcing the language we can see what ada would print. So, if we 'set language ada', then originally we printed this: 3: record a: int; end record Again the indentation is clearly broken, but we also have no mention of the type name at all, which is odd, but understandable given the lack of typedefs. If I make a similar change as I'm proposing for C, then we now get this output: 3: record ... end record Which is even less informative I think. However, the original output _is_ tested for in gdb.ada/info_auto_lang.exp, and its not clear to me if the change is a good one or not, so for now I have left this out. gdb/ChangeLog: * c-typeprint.c (c_print_typedef): Pass -1 instead of 0 to type_print. gdb/testsuite/ChangeLog: * gdb.ada/info_auto_lang.exp: Update expected results. * gdb.base/info-types.c: Add additional types to check. * gdb.base/info-types.exp: Update expected results.
2019-07-12 12:26:32 +02:00
type_print (type, "", stream, -1);
if ((SYMBOL_TYPE (new_symbol))->name () == 0
|| strcmp ((SYMBOL_TYPE (new_symbol))->name (),
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
new_symbol->linkage_name ()) != 0
|| SYMBOL_TYPE (new_symbol)->code () == TYPE_CODE_TYPEDEF)
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
fprintf_filtered (stream, " %s", new_symbol->print_name ());
fprintf_filtered (stream, ";");
}
/* If TYPE is a derived type, then print out derivation information.
Print only the actual base classes of this type, not the base
classes of the base classes. I.e. for the derivation hierarchy:
1999-07-07 22:19:36 +02:00
class A { int a; };
class B : public A {int b; };
class C : public B {int c; };
Print the type of class C as:
1999-07-07 22:19:36 +02:00
class C : public B {
int c;
}
Not as the following (like gdb used to), which is not legal C++
syntax for derived types and may be confused with the multiple
inheritance form:
1999-07-07 22:19:36 +02:00
class C : public B : public A {
int c;
}
In general, gdb should try to print the types as closely as
possible to the form that they appear in the source code. */
static void
cp_type_print_derivation_info (struct ui_file *stream,
* 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-12 18:37:38 +01:00
struct type *type,
const struct type_print_options *flags)
{
* 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 05:48:23 +01:00
const char *name;
int i;
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
{
* 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-12 18:37:38 +01:00
wrap_here (" ");
fputs_filtered (i == 0 ? ": " : ", ", stream);
fprintf_filtered (stream, "%s%s ",
BASETYPE_VIA_PUBLIC (type, i)
? "public" : (TYPE_FIELD_PROTECTED (type, i)
? "protected" : "private"),
1999-07-07 22:19:36 +02:00
BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : "");
name = TYPE_BASECLASS (type, i)->name ();
* 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-12 18:37:38 +01:00
if (name)
print_name_maybe_canonical (name, flags, stream);
else
fprintf_filtered (stream, "(null)");
}
if (i > 0)
{
fputs_filtered (" ", stream);
}
}
2002-06-14 Daniel Jacobowitz <drow@mvista.com> * gdbtypes.h (TYPE_FLAG_VARARGS): Update comment. (struct main_type): Remove arg_types member. Update comments for struct field. (TYPE_ARG_TYPES): Remove. (TYPE_FN_FIELD_ARGS): Update. (smash_to_method_type): Update prototype. * c-typeprint.c (cp_type_print_method_args): Take method type instead of argument list. Use new argument layout. Simplify. (c_type_print_args): Use new argument layout. Simplify. (c_type_print_base): Update call to cp_type_print_method_args. * dwarf2read.c (dwarf2_add_member_fn): Remove unneeded type argument; use die->type instead. Update call to smash_to_method_type. (read_structure_scope): Update call to dwarf2_add_member_fn. * gdbtypes.c (allocate_stub_method): Update comment. (smash_to_method_type): Take new NARGS and VARARGS arguments. Use new argument layout. (check_stub_method): Use new argument layout. Don't count void as an argument. (print_arg_types): Update comments. Use new argument layout. (recursive_dump_type): Don't print arg_types member. * hpread.c (hpread_read_struct_type): Use new argument layout. (fixup_class_method_type): Likewise. (hpread_type_lookup): Likewise. * stabsread.c (read_type): Update calls to read_args and smash_to_method_type. (read_args): Use new argument layout. Simplify. * valops.c (typecmp): Use new argument layout. Update parameters and comments. Simplify. (hand_function_call): Use new argument layout. (search_struct_method): Update call to typecmp. (find_overload_match): Use new argument layout.
2002-06-14 16:34:26 +02:00
/* Print the C++ method arguments ARGS to the file STREAM. */
1999-07-07 22:19:36 +02:00
1999-05-25 20:09:09 +02:00
static void
* 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 05:48:23 +01:00
cp_type_print_method_args (struct type *mtype, const char *prefix,
const char *varstring, int staticp,
struct ui_file *stream,
enum language language,
const struct type_print_options *flags)
{
struct field *args = mtype->fields ();
int nargs = mtype->num_fields ();
2002-06-14 Daniel Jacobowitz <drow@mvista.com> * gdbtypes.h (TYPE_FLAG_VARARGS): Update comment. (struct main_type): Remove arg_types member. Update comments for struct field. (TYPE_ARG_TYPES): Remove. (TYPE_FN_FIELD_ARGS): Update. (smash_to_method_type): Update prototype. * c-typeprint.c (cp_type_print_method_args): Take method type instead of argument list. Use new argument layout. Simplify. (c_type_print_args): Use new argument layout. Simplify. (c_type_print_base): Update call to cp_type_print_method_args. * dwarf2read.c (dwarf2_add_member_fn): Remove unneeded type argument; use die->type instead. Update call to smash_to_method_type. (read_structure_scope): Update call to dwarf2_add_member_fn. * gdbtypes.c (allocate_stub_method): Update comment. (smash_to_method_type): Take new NARGS and VARARGS arguments. Use new argument layout. (check_stub_method): Use new argument layout. Don't count void as an argument. (print_arg_types): Update comments. Use new argument layout. (recursive_dump_type): Don't print arg_types member. * hpread.c (hpread_read_struct_type): Use new argument layout. (fixup_class_method_type): Likewise. (hpread_type_lookup): Likewise. * stabsread.c (read_type): Update calls to read_args and smash_to_method_type. (read_args): Use new argument layout. Simplify. * valops.c (typecmp): Use new argument layout. Update parameters and comments. Simplify. (hand_function_call): Use new argument layout. (search_struct_method): Update call to typecmp. (find_overload_match): Use new argument layout.
2002-06-14 16:34:26 +02:00
int varargs = TYPE_VARARGS (mtype);
int i;
1999-07-07 22:19:36 +02:00
fprintf_symbol_filtered (stream, prefix,
language_cplus, DMGL_ANSI);
fprintf_symbol_filtered (stream, varstring,
language_cplus, DMGL_ANSI);
fputs_filtered ("(", stream);
2002-06-14 Daniel Jacobowitz <drow@mvista.com> * gdbtypes.h (TYPE_FLAG_VARARGS): Update comment. (struct main_type): Remove arg_types member. Update comments for struct field. (TYPE_ARG_TYPES): Remove. (TYPE_FN_FIELD_ARGS): Update. (smash_to_method_type): Update prototype. * c-typeprint.c (cp_type_print_method_args): Take method type instead of argument list. Use new argument layout. Simplify. (c_type_print_args): Use new argument layout. Simplify. (c_type_print_base): Update call to cp_type_print_method_args. * dwarf2read.c (dwarf2_add_member_fn): Remove unneeded type argument; use die->type instead. Update call to smash_to_method_type. (read_structure_scope): Update call to dwarf2_add_member_fn. * gdbtypes.c (allocate_stub_method): Update comment. (smash_to_method_type): Take new NARGS and VARARGS arguments. Use new argument layout. (check_stub_method): Use new argument layout. Don't count void as an argument. (print_arg_types): Update comments. Use new argument layout. (recursive_dump_type): Don't print arg_types member. * hpread.c (hpread_read_struct_type): Use new argument layout. (fixup_class_method_type): Likewise. (hpread_type_lookup): Likewise. * stabsread.c (read_type): Update calls to read_args and smash_to_method_type. (read_args): Use new argument layout. Simplify. * valops.c (typecmp): Use new argument layout. Update parameters and comments. Simplify. (hand_function_call): Use new argument layout. (search_struct_method): Update call to typecmp. (find_overload_match): Use new argument layout.
2002-06-14 16:34:26 +02:00
/* Skip the class variable. We keep this here to accommodate older
compilers and debug formats which may not support artificial
parameters. */
2002-06-14 Daniel Jacobowitz <drow@mvista.com> * gdbtypes.h (TYPE_FLAG_VARARGS): Update comment. (struct main_type): Remove arg_types member. Update comments for struct field. (TYPE_ARG_TYPES): Remove. (TYPE_FN_FIELD_ARGS): Update. (smash_to_method_type): Update prototype. * c-typeprint.c (cp_type_print_method_args): Take method type instead of argument list. Use new argument layout. Simplify. (c_type_print_args): Use new argument layout. Simplify. (c_type_print_base): Update call to cp_type_print_method_args. * dwarf2read.c (dwarf2_add_member_fn): Remove unneeded type argument; use die->type instead. Update call to smash_to_method_type. (read_structure_scope): Update call to dwarf2_add_member_fn. * gdbtypes.c (allocate_stub_method): Update comment. (smash_to_method_type): Take new NARGS and VARARGS arguments. Use new argument layout. (check_stub_method): Use new argument layout. Don't count void as an argument. (print_arg_types): Update comments. Use new argument layout. (recursive_dump_type): Don't print arg_types member. * hpread.c (hpread_read_struct_type): Use new argument layout. (fixup_class_method_type): Likewise. (hpread_type_lookup): Likewise. * stabsread.c (read_type): Update calls to read_args and smash_to_method_type. (read_args): Use new argument layout. Simplify. * valops.c (typecmp): Use new argument layout. Update parameters and comments. Simplify. (hand_function_call): Use new argument layout. (search_struct_method): Update call to typecmp. (find_overload_match): Use new argument layout.
2002-06-14 16:34:26 +02:00
i = staticp ? 0 : 1;
if (nargs > i)
{
2002-06-14 Daniel Jacobowitz <drow@mvista.com> * gdbtypes.h (TYPE_FLAG_VARARGS): Update comment. (struct main_type): Remove arg_types member. Update comments for struct field. (TYPE_ARG_TYPES): Remove. (TYPE_FN_FIELD_ARGS): Update. (smash_to_method_type): Update prototype. * c-typeprint.c (cp_type_print_method_args): Take method type instead of argument list. Use new argument layout. Simplify. (c_type_print_args): Use new argument layout. Simplify. (c_type_print_base): Update call to cp_type_print_method_args. * dwarf2read.c (dwarf2_add_member_fn): Remove unneeded type argument; use die->type instead. Update call to smash_to_method_type. (read_structure_scope): Update call to dwarf2_add_member_fn. * gdbtypes.c (allocate_stub_method): Update comment. (smash_to_method_type): Take new NARGS and VARARGS arguments. Use new argument layout. (check_stub_method): Use new argument layout. Don't count void as an argument. (print_arg_types): Update comments. Use new argument layout. (recursive_dump_type): Don't print arg_types member. * hpread.c (hpread_read_struct_type): Use new argument layout. (fixup_class_method_type): Likewise. (hpread_type_lookup): Likewise. * stabsread.c (read_type): Update calls to read_args and smash_to_method_type. (read_args): Use new argument layout. Simplify. * valops.c (typecmp): Use new argument layout. Update parameters and comments. Simplify. (hand_function_call): Use new argument layout. (search_struct_method): Update call to typecmp. (find_overload_match): Use new argument layout.
2002-06-14 16:34:26 +02:00
while (i < nargs)
1999-07-07 22:19:36 +02:00
{
struct field arg = args[i++];
/* Skip any artificial arguments. */
if (FIELD_ARTIFICIAL (arg))
continue;
c_print_type (arg.type (), "", stream, 0, 0, flags);
2002-06-14 Daniel Jacobowitz <drow@mvista.com> * gdbtypes.h (TYPE_FLAG_VARARGS): Update comment. (struct main_type): Remove arg_types member. Update comments for struct field. (TYPE_ARG_TYPES): Remove. (TYPE_FN_FIELD_ARGS): Update. (smash_to_method_type): Update prototype. * c-typeprint.c (cp_type_print_method_args): Take method type instead of argument list. Use new argument layout. Simplify. (c_type_print_args): Use new argument layout. Simplify. (c_type_print_base): Update call to cp_type_print_method_args. * dwarf2read.c (dwarf2_add_member_fn): Remove unneeded type argument; use die->type instead. Update call to smash_to_method_type. (read_structure_scope): Update call to dwarf2_add_member_fn. * gdbtypes.c (allocate_stub_method): Update comment. (smash_to_method_type): Take new NARGS and VARARGS arguments. Use new argument layout. (check_stub_method): Use new argument layout. Don't count void as an argument. (print_arg_types): Update comments. Use new argument layout. (recursive_dump_type): Don't print arg_types member. * hpread.c (hpread_read_struct_type): Use new argument layout. (fixup_class_method_type): Likewise. (hpread_type_lookup): Likewise. * stabsread.c (read_type): Update calls to read_args and smash_to_method_type. (read_args): Use new argument layout. Simplify. * valops.c (typecmp): Use new argument layout. Update parameters and comments. Simplify. (hand_function_call): Use new argument layout. (search_struct_method): Update call to typecmp. (find_overload_match): Use new argument layout.
2002-06-14 16:34:26 +02:00
if (i == nargs && varargs)
fprintf_filtered (stream, ", ...");
else if (i < nargs)
* 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-12 18:37:38 +01:00
{
fprintf_filtered (stream, ", ");
wrap_here (" ");
}
1999-07-07 22:19:36 +02:00
}
}
2002-06-14 Daniel Jacobowitz <drow@mvista.com> * gdbtypes.h (TYPE_FLAG_VARARGS): Update comment. (struct main_type): Remove arg_types member. Update comments for struct field. (TYPE_ARG_TYPES): Remove. (TYPE_FN_FIELD_ARGS): Update. (smash_to_method_type): Update prototype. * c-typeprint.c (cp_type_print_method_args): Take method type instead of argument list. Use new argument layout. Simplify. (c_type_print_args): Use new argument layout. Simplify. (c_type_print_base): Update call to cp_type_print_method_args. * dwarf2read.c (dwarf2_add_member_fn): Remove unneeded type argument; use die->type instead. Update call to smash_to_method_type. (read_structure_scope): Update call to dwarf2_add_member_fn. * gdbtypes.c (allocate_stub_method): Update comment. (smash_to_method_type): Take new NARGS and VARARGS arguments. Use new argument layout. (check_stub_method): Use new argument layout. Don't count void as an argument. (print_arg_types): Update comments. Use new argument layout. (recursive_dump_type): Don't print arg_types member. * hpread.c (hpread_read_struct_type): Use new argument layout. (fixup_class_method_type): Likewise. (hpread_type_lookup): Likewise. * stabsread.c (read_type): Update calls to read_args and smash_to_method_type. (read_args): Use new argument layout. Simplify. * valops.c (typecmp): Use new argument layout. Update parameters and comments. Simplify. (hand_function_call): Use new argument layout. (search_struct_method): Update call to typecmp. (find_overload_match): Use new argument layout.
2002-06-14 16:34:26 +02:00
else if (varargs)
fprintf_filtered (stream, "...");
else if (language == language_cplus)
2002-06-14 Daniel Jacobowitz <drow@mvista.com> * gdbtypes.h (TYPE_FLAG_VARARGS): Update comment. (struct main_type): Remove arg_types member. Update comments for struct field. (TYPE_ARG_TYPES): Remove. (TYPE_FN_FIELD_ARGS): Update. (smash_to_method_type): Update prototype. * c-typeprint.c (cp_type_print_method_args): Take method type instead of argument list. Use new argument layout. Simplify. (c_type_print_args): Use new argument layout. Simplify. (c_type_print_base): Update call to cp_type_print_method_args. * dwarf2read.c (dwarf2_add_member_fn): Remove unneeded type argument; use die->type instead. Update call to smash_to_method_type. (read_structure_scope): Update call to dwarf2_add_member_fn. * gdbtypes.c (allocate_stub_method): Update comment. (smash_to_method_type): Take new NARGS and VARARGS arguments. Use new argument layout. (check_stub_method): Use new argument layout. Don't count void as an argument. (print_arg_types): Update comments. Use new argument layout. (recursive_dump_type): Don't print arg_types member. * hpread.c (hpread_read_struct_type): Use new argument layout. (fixup_class_method_type): Likewise. (hpread_type_lookup): Likewise. * stabsread.c (read_type): Update calls to read_args and smash_to_method_type. (read_args): Use new argument layout. Simplify. * valops.c (typecmp): Use new argument layout. Update parameters and comments. Simplify. (hand_function_call): Use new argument layout. (search_struct_method): Update call to typecmp. (find_overload_match): Use new argument layout.
2002-06-14 16:34:26 +02:00
fprintf_filtered (stream, "void");
1999-07-07 22:19:36 +02:00
fprintf_filtered (stream, ")");
dwarf2_physname patchset: Based on work from Daniel Jacobowitz <dan@codesourcery.com> * c-typeprint.c (cp_type_print_method_args): For non-static methods, print out const or volatile qualifiers, too. (c_type_print_args): Add parameters show_artificial and language. Skip artificial parameters when requested. Use the appropriate language printer. (c_type_print_varspec): Tell c_type_print_args to skip artificial parameters and pass language_c. * dwarf2read.c (die_list): New file global. (struct partial_die_info): Update comments for name field. (pdi_needs_namespace): Renamed to ... (die_needs_namespace): ... this. Rewrite. (dwarf2_linkage_name): Remove. (add_partial_symbol): Do not predicate the call to partial_die_full_name based on pdi_needs_namespace. Remove call to cp_check_possible_namespace_symbols and associated outdated comments. (guess_structure_name): Do not inspect child subprogram DIEs. (dwarf2_fullname): Update comments. Use die_needs_namespace to assist in computing the name. (read_func_scope): Use dwarf2_name to get the DIE's name. Use dwarf2_physname to get the "linkage name" of the DIE. (dwarf2_add_member_field): Use dwarf2_physname instead of dwarf2_linkage_name. (read_structure_type): For structs and classes, set TYPE_NAME, too. (determine_class): Remove. (read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages except Ada. (new_symbol): Unconditionally call dwarf2_name. Compute the "linkage name" using dwarf2_physname. Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs. When determining to scan for anonymous C++ namespaces, ignore the linkage name. (dwarf2_physname): New function. (dwarf2_full_name): Move content to new function and call that. (dwarf2_compute_name): "New" function. (_initialize_dwarf2_read): Initialize die_list. * gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable physname. (gnu_v3_print_method_ptr): Use the physname for virtual methods without a demangled name. Print out type information for non-virtual methods. * linespec.c (decode_line_1): Force ANY string using "::" (or "." for java) to use decode_compound, and clean up any stray quoting. If we found a file symtab, re-evaluate whether the remainder is_quoted. (decode_compound): Stop consuming at an open parenthesis. Keep template parameters. Keep any overload information. Keep keywords like "const". Remove paren_pointer. Move is_quoted check from set_flags to here. Remove #if 0 code from 2000. Ten years is long enough. (find_method): Before comparing symbol names, canonicalize the string from the user. If a specific overload is requested, find it. Otherwise throw an error. (find_method_overload_end): New function. (set_flags): Remove. (decode_compound): Assume that parentheses are matched. It's a lot easier. * symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag to cplus_demangle. * linespec.c (decode_line_1): Keep important keywords like "const" and "volatile". * symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove. * typeprint.h (c_type_print_args): Add declaration. * ui-file.c (do_ui_file_obsavestring): New function. (ui_file_obsavestring): New function. * ui-file.h (ui_file_obsavestring): Add declaration. * valops.c (find_overload_match): Resolve the object to a non-pointer type. If the object is a data member, search the object for the member and return with staticp set. Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME. Do not attempt to extract a function name from non-function types. If the extracted function name and the original name are the same, we don't have a C++ method. From Jan Kratochvil <jan.kratochvil@redhat.com>: * dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name. * ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters and arguments from symbol lookups. * ax-gdb.c (gen_expr): Likewise. * cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope, cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type, lookup_possible_namespace_symbol): Likewise. * cp-support.c (read_in_psymtabs): Likewise. * cp-support.h (cp_lookup_symbol_nonlocal): Likewise. * language.h (la_lookup_symbol_nonlocal): Likewise. * scm-valprint.c (scm_inferior_print): Likewise. * solib-darwin.c (darwin_relocate_section_addresses): Likewise. * solib-svr.c (elf_lookup_lib): Likewise. * solib.c (show_auto_solib_add): Likewise. * solist.h (lookup_lib_global, solib_global_lookup): Likewise. * symmisc.c (maintenance_check_symtabs): Likewise. * symtab.c (lookup_symbol_in_language, lookup_symbol_aux, lookup_symbol_aux_local, lookup_symbol_aux_block, lookup_symbol_from_objfile, lookup_symbol_aux_symtabs, lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal, lookup_symbol_static, lookup_symbol_global, symbol_matches_domain, basic_lookup_transparent_type, find_main_psymtab, lookup_block_symbol): Likewise. * symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static, lookup_symbol_global, lookup_symbol_aux_block, lookup_symbol_partial_symbol, lookup_block_symbol, lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
/* For non-static methods, read qualifiers from the type of
THIS. */
if (!staticp)
{
struct type *domain;
gdb_assert (nargs > 0);
gdb_assert (args[0].type ()->code () == TYPE_CODE_PTR);
domain = TYPE_TARGET_TYPE (args[0].type ());
dwarf2_physname patchset: Based on work from Daniel Jacobowitz <dan@codesourcery.com> * c-typeprint.c (cp_type_print_method_args): For non-static methods, print out const or volatile qualifiers, too. (c_type_print_args): Add parameters show_artificial and language. Skip artificial parameters when requested. Use the appropriate language printer. (c_type_print_varspec): Tell c_type_print_args to skip artificial parameters and pass language_c. * dwarf2read.c (die_list): New file global. (struct partial_die_info): Update comments for name field. (pdi_needs_namespace): Renamed to ... (die_needs_namespace): ... this. Rewrite. (dwarf2_linkage_name): Remove. (add_partial_symbol): Do not predicate the call to partial_die_full_name based on pdi_needs_namespace. Remove call to cp_check_possible_namespace_symbols and associated outdated comments. (guess_structure_name): Do not inspect child subprogram DIEs. (dwarf2_fullname): Update comments. Use die_needs_namespace to assist in computing the name. (read_func_scope): Use dwarf2_name to get the DIE's name. Use dwarf2_physname to get the "linkage name" of the DIE. (dwarf2_add_member_field): Use dwarf2_physname instead of dwarf2_linkage_name. (read_structure_type): For structs and classes, set TYPE_NAME, too. (determine_class): Remove. (read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages except Ada. (new_symbol): Unconditionally call dwarf2_name. Compute the "linkage name" using dwarf2_physname. Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs. When determining to scan for anonymous C++ namespaces, ignore the linkage name. (dwarf2_physname): New function. (dwarf2_full_name): Move content to new function and call that. (dwarf2_compute_name): "New" function. (_initialize_dwarf2_read): Initialize die_list. * gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable physname. (gnu_v3_print_method_ptr): Use the physname for virtual methods without a demangled name. Print out type information for non-virtual methods. * linespec.c (decode_line_1): Force ANY string using "::" (or "." for java) to use decode_compound, and clean up any stray quoting. If we found a file symtab, re-evaluate whether the remainder is_quoted. (decode_compound): Stop consuming at an open parenthesis. Keep template parameters. Keep any overload information. Keep keywords like "const". Remove paren_pointer. Move is_quoted check from set_flags to here. Remove #if 0 code from 2000. Ten years is long enough. (find_method): Before comparing symbol names, canonicalize the string from the user. If a specific overload is requested, find it. Otherwise throw an error. (find_method_overload_end): New function. (set_flags): Remove. (decode_compound): Assume that parentheses are matched. It's a lot easier. * symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag to cplus_demangle. * linespec.c (decode_line_1): Keep important keywords like "const" and "volatile". * symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove. * typeprint.h (c_type_print_args): Add declaration. * ui-file.c (do_ui_file_obsavestring): New function. (ui_file_obsavestring): New function. * ui-file.h (ui_file_obsavestring): Add declaration. * valops.c (find_overload_match): Resolve the object to a non-pointer type. If the object is a data member, search the object for the member and return with staticp set. Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME. Do not attempt to extract a function name from non-function types. If the extracted function name and the original name are the same, we don't have a C++ method. From Jan Kratochvil <jan.kratochvil@redhat.com>: * dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name. * ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters and arguments from symbol lookups. * ax-gdb.c (gen_expr): Likewise. * cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope, cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type, lookup_possible_namespace_symbol): Likewise. * cp-support.c (read_in_psymtabs): Likewise. * cp-support.h (cp_lookup_symbol_nonlocal): Likewise. * language.h (la_lookup_symbol_nonlocal): Likewise. * scm-valprint.c (scm_inferior_print): Likewise. * solib-darwin.c (darwin_relocate_section_addresses): Likewise. * solib-svr.c (elf_lookup_lib): Likewise. * solib.c (show_auto_solib_add): Likewise. * solist.h (lookup_lib_global, solib_global_lookup): Likewise. * symmisc.c (maintenance_check_symtabs): Likewise. * symtab.c (lookup_symbol_in_language, lookup_symbol_aux, lookup_symbol_aux_local, lookup_symbol_aux_block, lookup_symbol_from_objfile, lookup_symbol_aux_symtabs, lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal, lookup_symbol_static, lookup_symbol_global, symbol_matches_domain, basic_lookup_transparent_type, find_main_psymtab, lookup_block_symbol): Likewise. * symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static, lookup_symbol_global, lookup_symbol_aux_block, lookup_symbol_partial_symbol, lookup_block_symbol, lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
if (TYPE_CONST (domain))
fprintf_filtered (stream, " const");
if (TYPE_VOLATILE (domain))
fprintf_filtered (stream, " volatile");
if (TYPE_RESTRICT (domain))
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
fprintf_filtered (stream, (language == language_cplus
? " __restrict__"
: " restrict"));
if (TYPE_ATOMIC (domain))
fprintf_filtered (stream, " _Atomic");
dwarf2_physname patchset: Based on work from Daniel Jacobowitz <dan@codesourcery.com> * c-typeprint.c (cp_type_print_method_args): For non-static methods, print out const or volatile qualifiers, too. (c_type_print_args): Add parameters show_artificial and language. Skip artificial parameters when requested. Use the appropriate language printer. (c_type_print_varspec): Tell c_type_print_args to skip artificial parameters and pass language_c. * dwarf2read.c (die_list): New file global. (struct partial_die_info): Update comments for name field. (pdi_needs_namespace): Renamed to ... (die_needs_namespace): ... this. Rewrite. (dwarf2_linkage_name): Remove. (add_partial_symbol): Do not predicate the call to partial_die_full_name based on pdi_needs_namespace. Remove call to cp_check_possible_namespace_symbols and associated outdated comments. (guess_structure_name): Do not inspect child subprogram DIEs. (dwarf2_fullname): Update comments. Use die_needs_namespace to assist in computing the name. (read_func_scope): Use dwarf2_name to get the DIE's name. Use dwarf2_physname to get the "linkage name" of the DIE. (dwarf2_add_member_field): Use dwarf2_physname instead of dwarf2_linkage_name. (read_structure_type): For structs and classes, set TYPE_NAME, too. (determine_class): Remove. (read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages except Ada. (new_symbol): Unconditionally call dwarf2_name. Compute the "linkage name" using dwarf2_physname. Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs. When determining to scan for anonymous C++ namespaces, ignore the linkage name. (dwarf2_physname): New function. (dwarf2_full_name): Move content to new function and call that. (dwarf2_compute_name): "New" function. (_initialize_dwarf2_read): Initialize die_list. * gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable physname. (gnu_v3_print_method_ptr): Use the physname for virtual methods without a demangled name. Print out type information for non-virtual methods. * linespec.c (decode_line_1): Force ANY string using "::" (or "." for java) to use decode_compound, and clean up any stray quoting. If we found a file symtab, re-evaluate whether the remainder is_quoted. (decode_compound): Stop consuming at an open parenthesis. Keep template parameters. Keep any overload information. Keep keywords like "const". Remove paren_pointer. Move is_quoted check from set_flags to here. Remove #if 0 code from 2000. Ten years is long enough. (find_method): Before comparing symbol names, canonicalize the string from the user. If a specific overload is requested, find it. Otherwise throw an error. (find_method_overload_end): New function. (set_flags): Remove. (decode_compound): Assume that parentheses are matched. It's a lot easier. * symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag to cplus_demangle. * linespec.c (decode_line_1): Keep important keywords like "const" and "volatile". * symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove. * typeprint.h (c_type_print_args): Add declaration. * ui-file.c (do_ui_file_obsavestring): New function. (ui_file_obsavestring): New function. * ui-file.h (ui_file_obsavestring): Add declaration. * valops.c (find_overload_match): Resolve the object to a non-pointer type. If the object is a data member, search the object for the member and return with staticp set. Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME. Do not attempt to extract a function name from non-function types. If the extracted function name and the original name are the same, we don't have a C++ method. From Jan Kratochvil <jan.kratochvil@redhat.com>: * dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name. * ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters and arguments from symbol lookups. * ax-gdb.c (gen_expr): Likewise. * cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope, cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type, lookup_possible_namespace_symbol): Likewise. * cp-support.c (read_in_psymtabs): Likewise. * cp-support.h (cp_lookup_symbol_nonlocal): Likewise. * language.h (la_lookup_symbol_nonlocal): Likewise. * scm-valprint.c (scm_inferior_print): Likewise. * solib-darwin.c (darwin_relocate_section_addresses): Likewise. * solib-svr.c (elf_lookup_lib): Likewise. * solib.c (show_auto_solib_add): Likewise. * solist.h (lookup_lib_global, solib_global_lookup): Likewise. * symmisc.c (maintenance_check_symtabs): Likewise. * symtab.c (lookup_symbol_in_language, lookup_symbol_aux, lookup_symbol_aux_local, lookup_symbol_aux_block, lookup_symbol_from_objfile, lookup_symbol_aux_symtabs, lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal, lookup_symbol_static, lookup_symbol_global, symbol_matches_domain, basic_lookup_transparent_type, find_main_psymtab, lookup_block_symbol): Likewise. * symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static, lookup_symbol_global, lookup_symbol_aux_block, lookup_symbol_partial_symbol, lookup_block_symbol, lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
}
}
/* Print any asterisks or open-parentheses needed before the
variable name (to describe its type).
On outermost call, pass 0 for PASSED_A_PTR.
On outermost call, SHOW > 0 means should ignore
any typename for TYPE and show its details.
SHOW is always zero on recursive calls.
NEED_POST_SPACE is non-zero when a space will be be needed
between a trailing qualifier and a field, variable, or function
name. */
static void
c_type_print_varspec_prefix (struct type *type,
struct ui_file *stream,
int show, int passed_a_ptr,
* ada-lang.c (user_select_syms, ada_print_subexp): Pass flags to type-printing functions. * ada-lang.h (ada_print_type): Add argument. * ada-typeprint.c (print_array_type, print_variant_clauses, print_variant_part, print_selected_record_field_types, print_record_field_types, print_unchecked_union_type, print_func_type, ada_print_type): Add flags argument. (ada_print_typedef): Update. * c-exp.y (OPERATOR conversion_type_id): Update. * c-lang.h (c_print_type, c_type_print_base): Update. * c-typeprint.c (c_print_type, c_type_print_varspec_prefix, c_type_print_modifier, c_type_print_args, c_type_print_varspec_suffix, c_type_print_base): Add flags argument. * cp-valprint.c (cp_print_class_member): Update. * dwarf2read.c (dwarf2_compute_name): Update. * f-lang.h (f_print_type): Add argument. * f-typeprint.c (f_print_type): Add flags argument. * gnu-v3-abi.c (gnuv3_print_method_ptr): Update. * go-lang.h (go_print_type): Add argument. * go-typeprint.c (go_print_type): Add flags argument. * jv-lang.h (java_print_type): Add argument. * jv-typeprint.c (java_type_print_base, java_print_type): Add flags argument. * language.c (unk_lang_print_type): Add flags argument. * language.h (struct language_defn) <la_print_type>: Add flags argument. (LA_PRINT_TYPE): Likewise. * m2-lang.h (m2_print_type): Add argument. * m2-typeprint.c (m2_print_type, m2_range, m2_typedef, m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set, m2_unbounded_array, m2_record_fields): Add flags argument. * p-lang.h (pascal_print_type, pascal_type_print_base, pascal_type_print_varspec_prefix): Add argument. * p-typeprint.c (pascal_print_type, pascal_type_print_varspec_prefix, pascal_print_func_args, pascal_type_print_varspec_suffix, pascal_type_print_base): Add flags argument. * symmisc.c (print_symbol): Update. * typeprint.c (type_print_raw_options, default_ptype_flags): New globals. (type_print): Update. * typeprint.h (struct type_print_options): New. (type_print_raw_options): Declare. (c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 18:14:55 +01:00
int need_post_space,
enum language language,
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
const struct type_print_options *flags,
struct print_offset_data *podata)
{
* 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 05:48:23 +01:00
const char *name;
if (type == 0)
return;
if (type->name () && show <= 0)
return;
QUIT;
switch (type->code ())
{
case TYPE_CODE_PTR:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
stream, show, 1, 1, language, flags,
podata);
fprintf_filtered (stream, "*");
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
c_type_print_modifier (type, stream, 1, need_post_space, language);
break;
* 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-03 19:05:45 +01:00
case TYPE_CODE_MEMBERPTR:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (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-17 21:51:25 +02:00
stream, show, 0, 0, language, flags, podata);
name = TYPE_SELF_TYPE (type)->name ();
if (name)
* 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-12 18:37:38 +01:00
print_name_maybe_canonical (name, flags, stream);
else
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
c_type_print_base_1 (TYPE_SELF_TYPE (type),
stream, -1, passed_a_ptr, language, flags,
podata);
* 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-03 19:05:45 +01:00
fprintf_filtered (stream, "::*");
break;
* 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-03 19:05:45 +01:00
case TYPE_CODE_METHODPTR:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
stream, show, 0, 0, language, flags,
podata);
* 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-03 19:05:45 +01:00
fprintf_filtered (stream, "(");
name = TYPE_SELF_TYPE (type)->name ();
* 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-03 19:05:45 +01:00
if (name)
* 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-12 18:37:38 +01:00
print_name_maybe_canonical (name, flags, stream);
* 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-03 19:05:45 +01:00
else
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
c_type_print_base_1 (TYPE_SELF_TYPE (type),
stream, -1, passed_a_ptr, language, flags,
podata);
* 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-03 19:05:45 +01:00
fprintf_filtered (stream, "::*");
break;
case TYPE_CODE_REF:
case TYPE_CODE_RVALUE_REF:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
stream, show, 1, 0, language, flags,
podata);
fprintf_filtered (stream, type->code () == TYPE_CODE_REF ? "&" : "&&");
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
c_type_print_modifier (type, stream, 1, need_post_space, language);
break;
* 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-03 19:05:45 +01:00
case TYPE_CODE_METHOD:
case TYPE_CODE_FUNC:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
stream, show, 0, 0, language, flags,
podata);
if (passed_a_ptr)
fprintf_filtered (stream, "(");
break;
case TYPE_CODE_ARRAY:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
stream, show, 0, 0, language, flags,
podata);
if (passed_a_ptr)
fprintf_filtered (stream, "(");
break;
case TYPE_CODE_TYPEDEF:
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
stream, show, passed_a_ptr, 0,
language, flags, podata);
break;
case TYPE_CODE_UNDEF:
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
case TYPE_CODE_ENUM:
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
case TYPE_CODE_FLAGS:
case TYPE_CODE_INT:
case TYPE_CODE_FLT:
case TYPE_CODE_VOID:
case TYPE_CODE_ERROR:
case TYPE_CODE_CHAR:
case TYPE_CODE_BOOL:
case TYPE_CODE_SET:
case TYPE_CODE_RANGE:
case TYPE_CODE_STRING:
case TYPE_CODE_COMPLEX:
2003-09-11 David Carlton <carlton@kealia.com> * gdbtypes.h: Add TYPE_CODE_NAMESPACE. * gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE. (recursive_dump_type): Ditto. * printcmd.c (print_formatted): Ditto. * typeprint.c (print_type_scalar): Ditto. * c-typeprint.c (c_type_print_varspec_prefix): Ditto. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * cp-support.h: Declare cp_check_possible_namespace_symbols, maint_cplus_cmd_list. * cp-support.c: Make maint_cplus_cmd_list extern. * cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h, command.h. (lookup_symbol_file): Look in possible namespace blocks when appropriate. (initialize_namespace_symtab): New. (get_possible_namespace_block, free_namespace_block) (check_possible_namespace_symbols) (check_possible_namespace_symbols_loop) (check_one_possible_namespace_symbol) (lookup_possible_namespace_symbol, maintenance_cplus_namespace) (_initialize_cp_namespace): Ditto. * block.h: Declare allocate_block. * block.c (allocate_block): New. * jv-lang.c (get_java_class_symtab): Allocate blocks via allocate_block. * symfile.h: Update declaration of add_psymbol_to_list. * symfile.c (add_psymbol_to_list): Return the partial symbol in question. * dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to scan_partial_symbols_call. (scan_partial_symbols): Add NAMESPACE argument; update calls to helper functions. (add_partial_symbol): If necessary, scan mangled names for names of namespaces. (add_partial_namespace): Add NAMESPACE argument; generate partial symbols associated to namespaces. (add_partial_enumeration): Add NAMESPACE argument. (new_symbol): Allow namespace syms. (read_namespace): Generate namespace syms. * objfiles.h: Add opaque declaration of struct symtab. (struct objfile): Add cp_namespace_symtab member. * objfiles.c (allocate_objfile): Set objfile->cp_namespace_symtab. * Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h, dictionary_h, command_h. 2003-09-11 David Carlton <carlton@kealia.com> * gdb.c++/namespace.exp: Add tests for namespace types. * gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'. (test_namespace): New.
2003-09-11 21:49:20 +02:00
case TYPE_CODE_NAMESPACE:
case TYPE_CODE_DECFLOAT:
/* These types need no prefix. They are listed here so that
1999-07-07 22:19:36 +02:00
gcc -Wall will reveal any types that haven't been handled. */
break;
1999-12-14 02:06:04 +01:00
default:
error (_("type not handled in c_type_print_varspec_prefix()"));
1999-12-14 02:06:04 +01:00
break;
}
}
/* Print out "const" and "volatile" attributes,
and address space id if present.
TYPE is a pointer to the type being printed out.
STREAM is the output destination.
NEED_PRE_SPACE = 1 indicates an initial white space is needed.
NEED_POST_SPACE = 1 indicates a final white space is needed. */
static void
c_type_print_modifier (struct type *type, struct ui_file *stream,
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
int need_pre_space, int need_post_space,
enum language language)
{
int did_print_modifier = 0;
const char *address_space_id;
1999-07-07 22:19:36 +02:00
/* We don't print `const' qualifiers for references --- since all
operators affect the thing referenced, not the reference itself,
every reference is `const'. */
if (TYPE_CONST (type) && !TYPE_IS_REFERENCE (type))
{
if (need_pre_space)
1999-07-07 22:19:36 +02:00
fprintf_filtered (stream, " ");
fprintf_filtered (stream, "const");
did_print_modifier = 1;
}
1999-07-07 22:19:36 +02:00
if (TYPE_VOLATILE (type))
{
if (did_print_modifier || need_pre_space)
1999-07-07 22:19:36 +02:00
fprintf_filtered (stream, " ");
fprintf_filtered (stream, "volatile");
did_print_modifier = 1;
}
if (TYPE_RESTRICT (type))
{
if (did_print_modifier || need_pre_space)
fprintf_filtered (stream, " ");
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
fprintf_filtered (stream, (language == language_cplus
? "__restrict__"
: "restrict"));
did_print_modifier = 1;
}
if (TYPE_ATOMIC (type))
{
if (did_print_modifier || need_pre_space)
fprintf_filtered (stream, " ");
fprintf_filtered (stream, "_Atomic");
did_print_modifier = 1;
}
* gdbtypes.c (make_pointer_type, make_reference_type, smash_to_memberptr_type, lookup_array_range_type, check_stub_method): Use type architecture instead of current_gdbarch. * gdbtypes.h (address_space_name_to_int, address_space_int_to_name): Add GDBARCH paramter. * gdbtypes.c (address_space_name_to_int, address_space_int_to_name): Add GDBARCH parameter. Use it instead of current_gdbarch. * c-typeprint.c (c_type_print_modifier): Update call. * parse.c (push_type_address_space): Likewise. * findvar.c (extract_typed_address, store_typed_address): Use type architecture instead of current_gdbarch. * value.c (value_as_address, unpack_field_as_long): Use type architecture instead of current_gdbarch. * doublest.c (floatformat_from_length): Add GDBARCH argument. Use it instead of current_gdbarch. (floatformat_from_type): Pass type architecture. * infcall.c (find_function_addr): Use type architecture instead of current_gdbarch. * valarith.c (value_bitstring_subscript, value_x_binop, value_neg, value_bit_index): Use type architecture instead of current_gdbarch. * valops.c (value_cast, value_slice): Likewise. * value.h (modify_field): Add TYPE argument. * value.c (modify_field): Add TYPE argument. Use type architecture instead of current_gdbarch. (set_internalvar_component): Likewise. * eval.c (evaluate_struct_tuple): Update call. * valops.c (value_assign): Likewise. * ada-lang.c (modify_general_field): Likewise. Add TYPE argument. (make_array_descriptor): Update calls. (move_bits): Add BITS_BIG_ENDIAN_P argument. Use it instead of current_gdbarch. (ada_value_assign, value_assign_to_component): Update calls. (decode_packed_array, ada_value_primitive_packed_val, ada_value_assign, value_assign_to_component): Use type arch instead of current_gdbarch. * printcmd.c (float_type_from_length): Remove GDBARCH argument, use type architecture instead. (print_scalar_formatted, printf_command): Update calls. Use type architecture instead of current_gdbarch. * valprint.c (val_print_type_code_int): Use type architecture instead of current_gdbarch. * varobj.c (value_get_print_value): Likewise. * python/python-prettyprint.c (print_string_repr): Add GDBARCH argument. Use it instead of current_gdbarch. (apply_val_pretty_printer): Update call. * ada-valprint.c (ada_val_print_1): Use type architecture instead of current_gdbarch. * c-valprint.c (print_function_pointer_address): Add GDBARCH argument. Use it instead of current_gdbarch. (c_val_print): Update calls passing type architecture. * f-valprint.c (f_val_print): Use type architecture instead of current_gdbarch. * jv-valprint (java_value_print): Likewise. * m2-valprint.c (print_function_pointer_address): Add GDBARCH argument. Use it instead of current_gdbarch. (print_unpacked_pointer): Update calls passing type architecture. * scm-valprint.c (scm_scmval_print): Use type architecture instead of current_gdbarch. * gnu-v3-abi.c (get_class_arch): Remove. (gnuv3_rtti_type): Use get_type_arch instead of get_class_arch. Remove special-case check for Java classes. (gnuv3_virtual_fn_field, gnuv3_baseclass_offset, gnuv3_print_method_ptr, gnuv3_method_ptr_size, gnuv3_make_method_ptr, gnuv3_method_ptr_to_value): Use get_type_arch instead of get_class_arch.
2009-07-02 14:57:14 +02:00
address_space_id = address_space_int_to_name (get_type_arch (type),
TYPE_INSTANCE_FLAGS (type));
if (address_space_id)
{
if (did_print_modifier || need_pre_space)
fprintf_filtered (stream, " ");
fprintf_filtered (stream, "@%s", address_space_id);
did_print_modifier = 1;
}
if (did_print_modifier && need_post_space)
fprintf_filtered (stream, " ");
}
* 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-03 19:05:45 +01:00
/* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD
or TYPE_CODE_FUNC, to STREAM. Artificial arguments, such as "this"
in non-static methods, are displayed if LINKAGE_NAME is zero. If
LINKAGE_NAME is non-zero and LANGUAGE is language_cplus the topmost
parameter types get removed their possible const and volatile qualifiers to
match demangled linkage name parameters part of such function type.
LANGUAGE is the language in which TYPE was defined. This is a necessary
Remove Java support This patch removes the Java support from gdb. gcj has not seen much development or use for years now, and was recently removed from GCC. This patch changes gdb to follow; in the unlikely event that there are still users using gcj, they can continue to use an older gdb to debug. Or, they can debug in C++ mode. Built and regtested on x86-64 Fedora 24. 2016-10-06 Tom Tromey <tom@tromey.com> * MAINTAINERS: Remove Java test maintainer. * varobj.h (java_varobj_ops): Don't declare. * valprint.h (struct value_print_options) <pascal_static_field_print>: Update comment. * utils.c (producer_is_gcc): Remove java reference. * symtab.h (struct general_symbol_info): Remove java references. (SYMBOL_SEARCH_NAME): Likewise. * objfiles.c (allocate_objfile): Update comment. * linespec.c (find_linespec_symbols): Remove java references. * gnu-v3-abi.c (gnuv3_rtti_type, gnuv3_baseclass_offset): Remove java references. * gdbtypes.h (struct cplus_struct_type) <is_java>: Remove. (TYPE_CPLUS_REALLY_JAVA): Remove. * c-varobj.c (enum vsections): Update comment. * symtab.c (symbol_set_language, symbol_set_names) (symbol_natural_name, symbol_demangled_name) (demangle_for_lookup, symbol_matches_domain) (default_make_symbol_completion_list_break_on_1): Remove java references. (JAVA_PREFIX, JAVA_PREFIX_LEN): Remove. * psymtab.c (match_partial_symbol, psymtab_search_name) (lookup_partial_symbol): Remove java references. * dwarf2read.c (find_slot_in_mapped_hash): Remove java references. (add_partial_symbol, dwarf2_compute_name, dwarf2_physname) (dwarf2_add_member_fn, is_vtable_name, read_structure_type) (process_structure_scope, read_subroutine_type) (read_subrange_type, load_partial_dies) (new_symbol_full, determine_prefix, typename_concat) (dwarf2_name): Remove java references. (set_cu_language): Treat Java as C++. * c-typeprint.c (c_type_print_args): Remove java reference. * defs.h (enum language) <language_java>: Remove. * Makefile.in (SFILES, HFILES_NO_SRCDIR, COMMON_OBS, YYFILES) (YYOBJ, local-maintainer-clean): Don't mention java files. * jv-exp.y, jv-lang.c, jv-lang.h, jv-typeprint.c, jv-valprint.c, jv-varobj.c: Remove. 2016-10-06 Tom Tromey <tom@tromey.com> * guile.texi (Types In Guile): Remove Java mentions. * python.texi (Types In Python): Remove Java mentions. * gdb.texinfo (Address Locations, Supported Languages) (Index Section Format): Remove Java mentions. 2016-10-06 Tom Tromey <tom@tromey.com> * gdb.compile/compile.exp: Change java tests to rust. * gdb.base/setshow.exp: Change java tests to rust. * gdb.base/default.exp: Remove java from language list. * README (Examples): Update language example. * gdb.python/py-lookup-type.exp (test_lookup_type): Remove java test. * lib/gdb.exp (skip_java_tests): Remove. * lib/java.exp: Remove. * gdb.java: Remove.
2016-10-05 16:44:34 +02:00
evil since this code is used by the C and C++. */
dwarf2_physname patchset: Based on work from Daniel Jacobowitz <dan@codesourcery.com> * c-typeprint.c (cp_type_print_method_args): For non-static methods, print out const or volatile qualifiers, too. (c_type_print_args): Add parameters show_artificial and language. Skip artificial parameters when requested. Use the appropriate language printer. (c_type_print_varspec): Tell c_type_print_args to skip artificial parameters and pass language_c. * dwarf2read.c (die_list): New file global. (struct partial_die_info): Update comments for name field. (pdi_needs_namespace): Renamed to ... (die_needs_namespace): ... this. Rewrite. (dwarf2_linkage_name): Remove. (add_partial_symbol): Do not predicate the call to partial_die_full_name based on pdi_needs_namespace. Remove call to cp_check_possible_namespace_symbols and associated outdated comments. (guess_structure_name): Do not inspect child subprogram DIEs. (dwarf2_fullname): Update comments. Use die_needs_namespace to assist in computing the name. (read_func_scope): Use dwarf2_name to get the DIE's name. Use dwarf2_physname to get the "linkage name" of the DIE. (dwarf2_add_member_field): Use dwarf2_physname instead of dwarf2_linkage_name. (read_structure_type): For structs and classes, set TYPE_NAME, too. (determine_class): Remove. (read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages except Ada. (new_symbol): Unconditionally call dwarf2_name. Compute the "linkage name" using dwarf2_physname. Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs. When determining to scan for anonymous C++ namespaces, ignore the linkage name. (dwarf2_physname): New function. (dwarf2_full_name): Move content to new function and call that. (dwarf2_compute_name): "New" function. (_initialize_dwarf2_read): Initialize die_list. * gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable physname. (gnu_v3_print_method_ptr): Use the physname for virtual methods without a demangled name. Print out type information for non-virtual methods. * linespec.c (decode_line_1): Force ANY string using "::" (or "." for java) to use decode_compound, and clean up any stray quoting. If we found a file symtab, re-evaluate whether the remainder is_quoted. (decode_compound): Stop consuming at an open parenthesis. Keep template parameters. Keep any overload information. Keep keywords like "const". Remove paren_pointer. Move is_quoted check from set_flags to here. Remove #if 0 code from 2000. Ten years is long enough. (find_method): Before comparing symbol names, canonicalize the string from the user. If a specific overload is requested, find it. Otherwise throw an error. (find_method_overload_end): New function. (set_flags): Remove. (decode_compound): Assume that parentheses are matched. It's a lot easier. * symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag to cplus_demangle. * linespec.c (decode_line_1): Keep important keywords like "const" and "volatile". * symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove. * typeprint.h (c_type_print_args): Add declaration. * ui-file.c (do_ui_file_obsavestring): New function. (ui_file_obsavestring): New function. * ui-file.h (ui_file_obsavestring): Add declaration. * valops.c (find_overload_match): Resolve the object to a non-pointer type. If the object is a data member, search the object for the member and return with staticp set. Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME. Do not attempt to extract a function name from non-function types. If the extracted function name and the original name are the same, we don't have a C++ method. From Jan Kratochvil <jan.kratochvil@redhat.com>: * dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name. * ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters and arguments from symbol lookups. * ax-gdb.c (gen_expr): Likewise. * cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope, cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type, lookup_possible_namespace_symbol): Likewise. * cp-support.c (read_in_psymtabs): Likewise. * cp-support.h (cp_lookup_symbol_nonlocal): Likewise. * language.h (la_lookup_symbol_nonlocal): Likewise. * scm-valprint.c (scm_inferior_print): Likewise. * solib-darwin.c (darwin_relocate_section_addresses): Likewise. * solib-svr.c (elf_lookup_lib): Likewise. * solib.c (show_auto_solib_add): Likewise. * solist.h (lookup_lib_global, solib_global_lookup): Likewise. * symmisc.c (maintenance_check_symtabs): Likewise. * symtab.c (lookup_symbol_in_language, lookup_symbol_aux, lookup_symbol_aux_local, lookup_symbol_aux_block, lookup_symbol_from_objfile, lookup_symbol_aux_symtabs, lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal, lookup_symbol_static, lookup_symbol_global, symbol_matches_domain, basic_lookup_transparent_type, find_main_psymtab, lookup_block_symbol): Likewise. * symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static, lookup_symbol_global, lookup_symbol_aux_block, lookup_symbol_partial_symbol, lookup_block_symbol, lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
void
c_type_print_args (struct type *type, struct ui_file *stream,
* ada-lang.c (user_select_syms, ada_print_subexp): Pass flags to type-printing functions. * ada-lang.h (ada_print_type): Add argument. * ada-typeprint.c (print_array_type, print_variant_clauses, print_variant_part, print_selected_record_field_types, print_record_field_types, print_unchecked_union_type, print_func_type, ada_print_type): Add flags argument. (ada_print_typedef): Update. * c-exp.y (OPERATOR conversion_type_id): Update. * c-lang.h (c_print_type, c_type_print_base): Update. * c-typeprint.c (c_print_type, c_type_print_varspec_prefix, c_type_print_modifier, c_type_print_args, c_type_print_varspec_suffix, c_type_print_base): Add flags argument. * cp-valprint.c (cp_print_class_member): Update. * dwarf2read.c (dwarf2_compute_name): Update. * f-lang.h (f_print_type): Add argument. * f-typeprint.c (f_print_type): Add flags argument. * gnu-v3-abi.c (gnuv3_print_method_ptr): Update. * go-lang.h (go_print_type): Add argument. * go-typeprint.c (go_print_type): Add flags argument. * jv-lang.h (java_print_type): Add argument. * jv-typeprint.c (java_type_print_base, java_print_type): Add flags argument. * language.c (unk_lang_print_type): Add flags argument. * language.h (struct language_defn) <la_print_type>: Add flags argument. (LA_PRINT_TYPE): Likewise. * m2-lang.h (m2_print_type): Add argument. * m2-typeprint.c (m2_print_type, m2_range, m2_typedef, m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set, m2_unbounded_array, m2_record_fields): Add flags argument. * p-lang.h (pascal_print_type, pascal_type_print_base, pascal_type_print_varspec_prefix): Add argument. * p-typeprint.c (pascal_print_type, pascal_type_print_varspec_prefix, pascal_print_func_args, pascal_type_print_varspec_suffix, pascal_type_print_base): Add flags argument. * symmisc.c (print_symbol): Update. * typeprint.c (type_print_raw_options, default_ptype_flags): New globals. (type_print): Update. * typeprint.h (struct type_print_options): New. (type_print_raw_options): Declare. (c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 18:14:55 +01:00
int linkage_name, enum language language,
const struct type_print_options *flags)
{
int i;
* 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-03 19:05:45 +01:00
int printed_any = 0;
fprintf_filtered (stream, "(");
2002-06-14 Daniel Jacobowitz <drow@mvista.com> * gdbtypes.h (TYPE_FLAG_VARARGS): Update comment. (struct main_type): Remove arg_types member. Update comments for struct field. (TYPE_ARG_TYPES): Remove. (TYPE_FN_FIELD_ARGS): Update. (smash_to_method_type): Update prototype. * c-typeprint.c (cp_type_print_method_args): Take method type instead of argument list. Use new argument layout. Simplify. (c_type_print_args): Use new argument layout. Simplify. (c_type_print_base): Update call to cp_type_print_method_args. * dwarf2read.c (dwarf2_add_member_fn): Remove unneeded type argument; use die->type instead. Update call to smash_to_method_type. (read_structure_scope): Update call to dwarf2_add_member_fn. * gdbtypes.c (allocate_stub_method): Update comment. (smash_to_method_type): Take new NARGS and VARARGS arguments. Use new argument layout. (check_stub_method): Use new argument layout. Don't count void as an argument. (print_arg_types): Update comments. Use new argument layout. (recursive_dump_type): Don't print arg_types member. * hpread.c (hpread_read_struct_type): Use new argument layout. (fixup_class_method_type): Likewise. (hpread_type_lookup): Likewise. * stabsread.c (read_type): Update calls to read_args and smash_to_method_type. (read_args): Use new argument layout. Simplify. * valops.c (typecmp): Use new argument layout. Update parameters and comments. Simplify. (hand_function_call): Use new argument layout. (search_struct_method): Update call to typecmp. (find_overload_match): Use new argument layout.
2002-06-14 16:34:26 +02:00
for (i = 0; i < type->num_fields (); i++)
* 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-03 19:05:45 +01:00
{
struct type *param_type;
if (TYPE_FIELD_ARTIFICIAL (type, i) && linkage_name)
dwarf2_physname patchset: Based on work from Daniel Jacobowitz <dan@codesourcery.com> * c-typeprint.c (cp_type_print_method_args): For non-static methods, print out const or volatile qualifiers, too. (c_type_print_args): Add parameters show_artificial and language. Skip artificial parameters when requested. Use the appropriate language printer. (c_type_print_varspec): Tell c_type_print_args to skip artificial parameters and pass language_c. * dwarf2read.c (die_list): New file global. (struct partial_die_info): Update comments for name field. (pdi_needs_namespace): Renamed to ... (die_needs_namespace): ... this. Rewrite. (dwarf2_linkage_name): Remove. (add_partial_symbol): Do not predicate the call to partial_die_full_name based on pdi_needs_namespace. Remove call to cp_check_possible_namespace_symbols and associated outdated comments. (guess_structure_name): Do not inspect child subprogram DIEs. (dwarf2_fullname): Update comments. Use die_needs_namespace to assist in computing the name. (read_func_scope): Use dwarf2_name to get the DIE's name. Use dwarf2_physname to get the "linkage name" of the DIE. (dwarf2_add_member_field): Use dwarf2_physname instead of dwarf2_linkage_name. (read_structure_type): For structs and classes, set TYPE_NAME, too. (determine_class): Remove. (read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages except Ada. (new_symbol): Unconditionally call dwarf2_name. Compute the "linkage name" using dwarf2_physname. Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs. When determining to scan for anonymous C++ namespaces, ignore the linkage name. (dwarf2_physname): New function. (dwarf2_full_name): Move content to new function and call that. (dwarf2_compute_name): "New" function. (_initialize_dwarf2_read): Initialize die_list. * gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable physname. (gnu_v3_print_method_ptr): Use the physname for virtual methods without a demangled name. Print out type information for non-virtual methods. * linespec.c (decode_line_1): Force ANY string using "::" (or "." for java) to use decode_compound, and clean up any stray quoting. If we found a file symtab, re-evaluate whether the remainder is_quoted. (decode_compound): Stop consuming at an open parenthesis. Keep template parameters. Keep any overload information. Keep keywords like "const". Remove paren_pointer. Move is_quoted check from set_flags to here. Remove #if 0 code from 2000. Ten years is long enough. (find_method): Before comparing symbol names, canonicalize the string from the user. If a specific overload is requested, find it. Otherwise throw an error. (find_method_overload_end): New function. (set_flags): Remove. (decode_compound): Assume that parentheses are matched. It's a lot easier. * symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag to cplus_demangle. * linespec.c (decode_line_1): Keep important keywords like "const" and "volatile". * symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove. * typeprint.h (c_type_print_args): Add declaration. * ui-file.c (do_ui_file_obsavestring): New function. (ui_file_obsavestring): New function. * ui-file.h (ui_file_obsavestring): Add declaration. * valops.c (find_overload_match): Resolve the object to a non-pointer type. If the object is a data member, search the object for the member and return with staticp set. Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME. Do not attempt to extract a function name from non-function types. If the extracted function name and the original name are the same, we don't have a C++ method. From Jan Kratochvil <jan.kratochvil@redhat.com>: * dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name. * ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters and arguments from symbol lookups. * ax-gdb.c (gen_expr): Likewise. * cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope, cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type, lookup_possible_namespace_symbol): Likewise. * cp-support.c (read_in_psymtabs): Likewise. * cp-support.h (cp_lookup_symbol_nonlocal): Likewise. * language.h (la_lookup_symbol_nonlocal): Likewise. * scm-valprint.c (scm_inferior_print): Likewise. * solib-darwin.c (darwin_relocate_section_addresses): Likewise. * solib-svr.c (elf_lookup_lib): Likewise. * solib.c (show_auto_solib_add): Likewise. * solist.h (lookup_lib_global, solib_global_lookup): Likewise. * symmisc.c (maintenance_check_symtabs): Likewise. * symtab.c (lookup_symbol_in_language, lookup_symbol_aux, lookup_symbol_aux_local, lookup_symbol_aux_block, lookup_symbol_from_objfile, lookup_symbol_aux_symtabs, lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal, lookup_symbol_static, lookup_symbol_global, symbol_matches_domain, basic_lookup_transparent_type, find_main_psymtab, lookup_block_symbol): Likewise. * symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static, lookup_symbol_global, lookup_symbol_aux_block, lookup_symbol_partial_symbol, lookup_block_symbol, lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
continue;
* 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-03 19:05:45 +01:00
if (printed_any)
{
* 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-03 19:05:45 +01:00
fprintf_filtered (stream, ", ");
wrap_here (" ");
}
* 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-03 19:05:45 +01:00
param_type = type->field (i).type ();
if (language == language_cplus && linkage_name)
{
/* C++ standard, 13.1 Overloadable declarations, point 3, item:
- Parameter declarations that differ only in the presence or
absence of const and/or volatile are equivalent.
And the const/volatile qualifiers are not present in the mangled
names as produced by GCC. */
param_type = make_cv_type (0, 0, param_type, NULL);
}
c_print_type (param_type, "", stream, -1, 0, language, flags);
* 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-03 19:05:45 +01:00
printed_any = 1;
}
* 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-03 19:05:45 +01:00
if (printed_any && TYPE_VARARGS (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-03 19:05:45 +01:00
/* Print out a trailing ellipsis for varargs functions. Ignore
TYPE_VARARGS if the function has no named arguments; that
represents unprototyped (K&R style) C functions. */
if (printed_any && TYPE_VARARGS (type))
{
fprintf_filtered (stream, ", ");
wrap_here (" ");
fprintf_filtered (stream, "...");
}
}
* 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-03 19:05:45 +01:00
else if (!printed_any
Remove Java support This patch removes the Java support from gdb. gcj has not seen much development or use for years now, and was recently removed from GCC. This patch changes gdb to follow; in the unlikely event that there are still users using gcj, they can continue to use an older gdb to debug. Or, they can debug in C++ mode. Built and regtested on x86-64 Fedora 24. 2016-10-06 Tom Tromey <tom@tromey.com> * MAINTAINERS: Remove Java test maintainer. * varobj.h (java_varobj_ops): Don't declare. * valprint.h (struct value_print_options) <pascal_static_field_print>: Update comment. * utils.c (producer_is_gcc): Remove java reference. * symtab.h (struct general_symbol_info): Remove java references. (SYMBOL_SEARCH_NAME): Likewise. * objfiles.c (allocate_objfile): Update comment. * linespec.c (find_linespec_symbols): Remove java references. * gnu-v3-abi.c (gnuv3_rtti_type, gnuv3_baseclass_offset): Remove java references. * gdbtypes.h (struct cplus_struct_type) <is_java>: Remove. (TYPE_CPLUS_REALLY_JAVA): Remove. * c-varobj.c (enum vsections): Update comment. * symtab.c (symbol_set_language, symbol_set_names) (symbol_natural_name, symbol_demangled_name) (demangle_for_lookup, symbol_matches_domain) (default_make_symbol_completion_list_break_on_1): Remove java references. (JAVA_PREFIX, JAVA_PREFIX_LEN): Remove. * psymtab.c (match_partial_symbol, psymtab_search_name) (lookup_partial_symbol): Remove java references. * dwarf2read.c (find_slot_in_mapped_hash): Remove java references. (add_partial_symbol, dwarf2_compute_name, dwarf2_physname) (dwarf2_add_member_fn, is_vtable_name, read_structure_type) (process_structure_scope, read_subroutine_type) (read_subrange_type, load_partial_dies) (new_symbol_full, determine_prefix, typename_concat) (dwarf2_name): Remove java references. (set_cu_language): Treat Java as C++. * c-typeprint.c (c_type_print_args): Remove java reference. * defs.h (enum language) <language_java>: Remove. * Makefile.in (SFILES, HFILES_NO_SRCDIR, COMMON_OBS, YYFILES) (YYOBJ, local-maintainer-clean): Don't mention java files. * jv-exp.y, jv-lang.c, jv-lang.h, jv-typeprint.c, jv-valprint.c, jv-varobj.c: Remove. 2016-10-06 Tom Tromey <tom@tromey.com> * guile.texi (Types In Guile): Remove Java mentions. * python.texi (Types In Python): Remove Java mentions. * gdb.texinfo (Address Locations, Supported Languages) (Index Section Format): Remove Java mentions. 2016-10-06 Tom Tromey <tom@tromey.com> * gdb.compile/compile.exp: Change java tests to rust. * gdb.base/setshow.exp: Change java tests to rust. * gdb.base/default.exp: Remove java from language list. * README (Examples): Update language example. * gdb.python/py-lookup-type.exp (test_lookup_type): Remove java test. * lib/gdb.exp (skip_java_tests): Remove. * lib/java.exp: Remove. * gdb.java: Remove.
2016-10-05 16:44:34 +02:00
&& (TYPE_PROTOTYPED (type) || language == language_cplus))
* 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-03 19:05:45 +01:00
fprintf_filtered (stream, "void");
1999-07-07 22:19:36 +02:00
fprintf_filtered (stream, ")");
}
2000-02-05 08:30:26 +01:00
/* Return true iff the j'th overloading of the i'th method of TYPE
is a type conversion operator, like `operator int () { ... }'.
When listing a class's methods, we don't print the return type of
such operators. */
2000-02-05 08:30:26 +01:00
static int
is_type_conversion_operator (struct type *type, int i, int j)
{
/* I think the whole idea of recognizing type conversion operators
by their name is pretty terrible. But I don't think our present
data structure gives us any other way to tell. If you know of
some other way, feel free to rewrite this function. */
* 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 05:48:23 +01:00
const char *name = TYPE_FN_FIELDLIST_NAME (type, i);
2000-02-05 08:30:26 +01:00
if (!startswith (name, CP_OPERATOR_STR))
2000-02-05 08:30:26 +01:00
return 0;
name += 8;
if (! strchr (" \t\f\n\r", *name))
return 0;
while (strchr (" \t\f\n\r", *name))
name++;
if (!('a' <= *name && *name <= 'z')
&& !('A' <= *name && *name <= 'Z')
&& *name != '_')
/* If this doesn't look like the start of an identifier, then it
isn't a type conversion operator. */
return 0;
else if (startswith (name, "new"))
2000-02-05 08:30:26 +01:00
name += 3;
else if (startswith (name, "delete"))
2000-02-05 08:30:26 +01:00
name += 6;
else
/* If it doesn't look like new or delete, it's a type conversion
operator. */
return 1;
2000-02-05 08:30:26 +01:00
/* Is that really the end of the name? */
if (('a' <= *name && *name <= 'z')
|| ('A' <= *name && *name <= 'Z')
|| ('0' <= *name && *name <= '9')
|| *name == '_')
/* No, so the identifier following "operator" must be a type name,
and this is a type conversion operator. */
return 1;
/* That was indeed the end of the name, so it was `operator new' or
`operator delete', neither of which are type conversion
operators. */
2000-02-05 08:30:26 +01:00
return 0;
}
/* Given a C++ qualified identifier QID, strip off the qualifiers,
yielding the unqualified name. The return value is a pointer into
the original string.
It's a pity we don't have this information in some more structured
form. Even the author of this function feels that writing little
parsers like this everywhere is stupid. */
2000-02-05 08:30:26 +01:00
static char *
remove_qualifiers (char *qid)
{
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
int quoted = 0; /* Zero if we're not in quotes;
'"' if we're in a double-quoted string;
'\'' if we're in a single-quoted string. */
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
int depth = 0; /* Number of unclosed parens we've seen. */
2000-02-05 08:30:26 +01:00
char *parenstack = (char *) alloca (strlen (qid));
char *scan;
char *last = 0; /* The character after the rightmost
`::' token we've seen so far. */
2000-02-05 08:30:26 +01:00
for (scan = qid; *scan; scan++)
{
if (quoted)
{
if (*scan == quoted)
quoted = 0;
else if (*scan == '\\' && *(scan + 1))
scan++;
}
else if (scan[0] == ':' && scan[1] == ':')
{
/* If we're inside parenthesis (i.e., an argument list) or
angle brackets (i.e., a list of template arguments), then
we don't record the position of this :: token, since it's
not relevant to the top-level structure we're trying to
operate on. */
2000-02-05 08:30:26 +01:00
if (depth == 0)
{
last = scan + 2;
scan++;
}
}
else if (*scan == '"' || *scan == '\'')
quoted = *scan;
else if (*scan == '(')
parenstack[depth++] = ')';
else if (*scan == '[')
parenstack[depth++] = ']';
/* We're going to treat <> as a pair of matching characters,
since we're more likely to see those in template id's than
real less-than characters. What a crock. */
else if (*scan == '<')
parenstack[depth++] = '>';
else if (*scan == ')' || *scan == ']' || *scan == '>')
{
if (depth > 0 && parenstack[depth - 1] == *scan)
depth--;
else
{
/* We're going to do a little error recovery here. If
we don't find a match for *scan on the paren stack,
but there is something lower on the stack that does
match, we pop the stack to that point. */
2000-02-05 08:30:26 +01:00
int i;
for (i = depth - 1; i >= 0; i--)
if (parenstack[i] == *scan)
{
depth = i;
break;
}
}
}
}
if (last)
return last;
else
/* We didn't find any :: tokens at the top level, so declare the
whole thing an unqualified identifier. */
return qid;
}
/* Print any array sizes, function arguments or close parentheses
needed after the variable name (to describe its type).
Args work like c_type_print_varspec_prefix. */
static void
c_type_print_varspec_suffix (struct type *type,
struct ui_file *stream,
int show, int passed_a_ptr,
* ada-lang.c (user_select_syms, ada_print_subexp): Pass flags to type-printing functions. * ada-lang.h (ada_print_type): Add argument. * ada-typeprint.c (print_array_type, print_variant_clauses, print_variant_part, print_selected_record_field_types, print_record_field_types, print_unchecked_union_type, print_func_type, ada_print_type): Add flags argument. (ada_print_typedef): Update. * c-exp.y (OPERATOR conversion_type_id): Update. * c-lang.h (c_print_type, c_type_print_base): Update. * c-typeprint.c (c_print_type, c_type_print_varspec_prefix, c_type_print_modifier, c_type_print_args, c_type_print_varspec_suffix, c_type_print_base): Add flags argument. * cp-valprint.c (cp_print_class_member): Update. * dwarf2read.c (dwarf2_compute_name): Update. * f-lang.h (f_print_type): Add argument. * f-typeprint.c (f_print_type): Add flags argument. * gnu-v3-abi.c (gnuv3_print_method_ptr): Update. * go-lang.h (go_print_type): Add argument. * go-typeprint.c (go_print_type): Add flags argument. * jv-lang.h (java_print_type): Add argument. * jv-typeprint.c (java_type_print_base, java_print_type): Add flags argument. * language.c (unk_lang_print_type): Add flags argument. * language.h (struct language_defn) <la_print_type>: Add flags argument. (LA_PRINT_TYPE): Likewise. * m2-lang.h (m2_print_type): Add argument. * m2-typeprint.c (m2_print_type, m2_range, m2_typedef, m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set, m2_unbounded_array, m2_record_fields): Add flags argument. * p-lang.h (pascal_print_type, pascal_type_print_base, pascal_type_print_varspec_prefix): Add argument. * p-typeprint.c (pascal_print_type, pascal_type_print_varspec_prefix, pascal_print_func_args, pascal_type_print_varspec_suffix, pascal_type_print_base): Add flags argument. * symmisc.c (print_symbol): Update. * typeprint.c (type_print_raw_options, default_ptype_flags): New globals. (type_print): Update. * typeprint.h (struct type_print_options): New. (type_print_raw_options): Declare. (c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 18:14:55 +01:00
int demangled_args,
enum language language,
* ada-lang.c (user_select_syms, ada_print_subexp): Pass flags to type-printing functions. * ada-lang.h (ada_print_type): Add argument. * ada-typeprint.c (print_array_type, print_variant_clauses, print_variant_part, print_selected_record_field_types, print_record_field_types, print_unchecked_union_type, print_func_type, ada_print_type): Add flags argument. (ada_print_typedef): Update. * c-exp.y (OPERATOR conversion_type_id): Update. * c-lang.h (c_print_type, c_type_print_base): Update. * c-typeprint.c (c_print_type, c_type_print_varspec_prefix, c_type_print_modifier, c_type_print_args, c_type_print_varspec_suffix, c_type_print_base): Add flags argument. * cp-valprint.c (cp_print_class_member): Update. * dwarf2read.c (dwarf2_compute_name): Update. * f-lang.h (f_print_type): Add argument. * f-typeprint.c (f_print_type): Add flags argument. * gnu-v3-abi.c (gnuv3_print_method_ptr): Update. * go-lang.h (go_print_type): Add argument. * go-typeprint.c (go_print_type): Add flags argument. * jv-lang.h (java_print_type): Add argument. * jv-typeprint.c (java_type_print_base, java_print_type): Add flags argument. * language.c (unk_lang_print_type): Add flags argument. * language.h (struct language_defn) <la_print_type>: Add flags argument. (LA_PRINT_TYPE): Likewise. * m2-lang.h (m2_print_type): Add argument. * m2-typeprint.c (m2_print_type, m2_range, m2_typedef, m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set, m2_unbounded_array, m2_record_fields): Add flags argument. * p-lang.h (pascal_print_type, pascal_type_print_base, pascal_type_print_varspec_prefix): Add argument. * p-typeprint.c (pascal_print_type, pascal_type_print_varspec_prefix, pascal_print_func_args, pascal_type_print_varspec_suffix, pascal_type_print_base): Add flags argument. * symmisc.c (print_symbol): Update. * typeprint.c (type_print_raw_options, default_ptype_flags): New globals. (type_print): Update. * typeprint.h (struct type_print_options): New. (type_print_raw_options): Declare. (c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 18:14:55 +01:00
const struct type_print_options *flags)
{
if (type == 0)
return;
if (type->name () && show <= 0)
return;
QUIT;
switch (type->code ())
{
case TYPE_CODE_ARRAY:
{
LONGEST low_bound, high_bound;
int is_vector = TYPE_VECTOR (type);
1999-07-07 22:19:36 +02:00
if (passed_a_ptr)
fprintf_filtered (stream, ")");
1999-07-07 22:19:36 +02:00
fprintf_filtered (stream, (is_vector ?
" __attribute__ ((vector_size(" : "["));
/* Bounds are not yet resolved, print a bounds placeholder instead. */
if (TYPE_HIGH_BOUND_KIND (type->index_type ()) == PROP_LOCEXPR
|| TYPE_HIGH_BOUND_KIND (type->index_type ()) == PROP_LOCLIST)
fprintf_filtered (stream, "variable length");
else if (get_array_bounds (type, &low_bound, &high_bound))
fprintf_filtered (stream, "%s",
plongest (high_bound - low_bound + 1));
fprintf_filtered (stream, (is_vector ? ")))" : "]"));
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
show, 0, 0, language, flags);
}
break;
* 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-03 19:05:45 +01:00
case TYPE_CODE_MEMBERPTR:
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
show, 0, 0, language, flags);
break;
* 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-03 19:05:45 +01:00
case TYPE_CODE_METHODPTR:
fprintf_filtered (stream, ")");
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
show, 0, 0, language, flags);
break;
case TYPE_CODE_PTR:
case TYPE_CODE_REF:
case TYPE_CODE_RVALUE_REF:
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
show, 1, 0, language, flags);
break;
* 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-03 19:05:45 +01:00
case TYPE_CODE_METHOD:
case TYPE_CODE_FUNC:
if (passed_a_ptr)
fprintf_filtered (stream, ")");
if (!demangled_args)
c_type_print_args (type, stream, 0, language, flags);
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
show, passed_a_ptr, 0, language, flags);
break;
case TYPE_CODE_TYPEDEF:
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
show, passed_a_ptr, 0, language, flags);
break;
case TYPE_CODE_UNDEF:
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
case TYPE_CODE_FLAGS:
case TYPE_CODE_ENUM:
case TYPE_CODE_INT:
case TYPE_CODE_FLT:
case TYPE_CODE_VOID:
case TYPE_CODE_ERROR:
case TYPE_CODE_CHAR:
case TYPE_CODE_BOOL:
case TYPE_CODE_SET:
case TYPE_CODE_RANGE:
case TYPE_CODE_STRING:
case TYPE_CODE_COMPLEX:
2003-09-11 David Carlton <carlton@kealia.com> * gdbtypes.h: Add TYPE_CODE_NAMESPACE. * gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE. (recursive_dump_type): Ditto. * printcmd.c (print_formatted): Ditto. * typeprint.c (print_type_scalar): Ditto. * c-typeprint.c (c_type_print_varspec_prefix): Ditto. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * cp-support.h: Declare cp_check_possible_namespace_symbols, maint_cplus_cmd_list. * cp-support.c: Make maint_cplus_cmd_list extern. * cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h, command.h. (lookup_symbol_file): Look in possible namespace blocks when appropriate. (initialize_namespace_symtab): New. (get_possible_namespace_block, free_namespace_block) (check_possible_namespace_symbols) (check_possible_namespace_symbols_loop) (check_one_possible_namespace_symbol) (lookup_possible_namespace_symbol, maintenance_cplus_namespace) (_initialize_cp_namespace): Ditto. * block.h: Declare allocate_block. * block.c (allocate_block): New. * jv-lang.c (get_java_class_symtab): Allocate blocks via allocate_block. * symfile.h: Update declaration of add_psymbol_to_list. * symfile.c (add_psymbol_to_list): Return the partial symbol in question. * dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to scan_partial_symbols_call. (scan_partial_symbols): Add NAMESPACE argument; update calls to helper functions. (add_partial_symbol): If necessary, scan mangled names for names of namespaces. (add_partial_namespace): Add NAMESPACE argument; generate partial symbols associated to namespaces. (add_partial_enumeration): Add NAMESPACE argument. (new_symbol): Allow namespace syms. (read_namespace): Generate namespace syms. * objfiles.h: Add opaque declaration of struct symtab. (struct objfile): Add cp_namespace_symtab member. * objfiles.c (allocate_objfile): Set objfile->cp_namespace_symtab. * Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h, dictionary_h, command_h. 2003-09-11 David Carlton <carlton@kealia.com> * gdb.c++/namespace.exp: Add tests for namespace types. * gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'. (test_namespace): New.
2003-09-11 21:49:20 +02:00
case TYPE_CODE_NAMESPACE:
case TYPE_CODE_DECFLOAT:
/* These types do not need a suffix. They are listed so that
gcc -Wall will report types that may not have been
considered. */
break;
1999-12-14 02:06:04 +01:00
default:
error (_("type not handled in c_type_print_varspec_suffix()"));
1999-12-14 02:06:04 +01:00
break;
}
}
* 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-12 18:37:38 +01:00
/* A helper for c_type_print_base that displays template
parameters and their bindings, if needed.
TABLE is the local bindings table to use. If NULL, no printing is
done. Note that, at this point, TABLE won't have any useful
information in it -- but it is also used as a flag to
print_name_maybe_canonical to activate searching the global typedef
table.
TYPE is the type whose template arguments are being displayed.
STREAM is the stream on which to print. */
static void
c_type_print_template_args (const struct type_print_options *flags,
struct type *type, struct ui_file *stream)
{
int first = 1, i;
if (flags->raw)
return;
for (i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (type); ++i)
{
struct symbol *sym = TYPE_TEMPLATE_ARGUMENT (type, i);
if (SYMBOL_CLASS (sym) != LOC_TYPEDEF)
continue;
if (first)
{
wrap_here (" ");
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
fprintf_filtered (stream, _("[with %s = "), sym->linkage_name ());
* 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-12 18:37:38 +01:00
first = 0;
}
else
{
fputs_filtered (", ", stream);
wrap_here (" ");
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
fprintf_filtered (stream, "%s = ", sym->linkage_name ());
* 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-12 18:37:38 +01:00
}
c_print_type (SYMBOL_TYPE (sym), "", stream, -1, 0, flags);
}
if (!first)
fputs_filtered (_("] "), stream);
}
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
/* Use 'print_spaces_filtered', but take into consideration the
type_print_options FLAGS in order to determine how many whitespaces
will be printed. */
static void
print_spaces_filtered_with_print_options
(int level, struct ui_file *stream, const struct type_print_options *flags)
{
if (!flags->print_offsets)
print_spaces_filtered (level, stream);
else
print_spaces_filtered (level + print_offset_data::indentation, stream);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
}
/* Output an access specifier to STREAM, if needed. LAST_ACCESS is the
last access specifier output (typically returned by this function). */
static enum access_specifier
output_access_specifier (struct ui_file *stream,
enum access_specifier last_access,
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
int level, bool is_protected, bool is_private,
const struct type_print_options *flags)
{
if (is_protected)
{
if (last_access != s_protected)
{
last_access = s_protected;
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
print_spaces_filtered_with_print_options (level + 2, stream, flags);
fprintf_filtered (stream, "protected:\n");
}
}
else if (is_private)
{
if (last_access != s_private)
{
last_access = s_private;
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
print_spaces_filtered_with_print_options (level + 2, stream, flags);
fprintf_filtered (stream, "private:\n");
}
}
else
{
if (last_access != s_public)
{
last_access = s_public;
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
print_spaces_filtered_with_print_options (level + 2, stream, flags);
fprintf_filtered (stream, "public:\n");
}
}
return last_access;
}
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
/* Return true if an access label (i.e., "public:", "private:",
"protected:") needs to be printed for TYPE. */
static bool
need_access_label_p (struct type *type)
{
if (TYPE_DECLARED_CLASS (type))
{
QUIT;
for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++)
if (!TYPE_FIELD_PRIVATE (type, i))
return true;
QUIT;
for (int j = 0; j < TYPE_NFN_FIELDS (type); j++)
for (int i = 0; i < TYPE_FN_FIELDLIST_LENGTH (type, j); i++)
if (!TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type,
j), i))
return true;
QUIT;
for (int i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); ++i)
if (!TYPE_TYPEDEF_FIELD_PRIVATE (type, i))
return true;
}
else
{
QUIT;
for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++)
if (TYPE_FIELD_PRIVATE (type, i) || TYPE_FIELD_PROTECTED (type, i))
return true;
QUIT;
for (int j = 0; j < TYPE_NFN_FIELDS (type); j++)
{
QUIT;
for (int i = 0; i < TYPE_FN_FIELDLIST_LENGTH (type, j); i++)
if (TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type,
j), i)
|| TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type,
j),
i))
return true;
}
QUIT;
for (int i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); ++i)
if (TYPE_TYPEDEF_FIELD_PROTECTED (type, i)
|| TYPE_TYPEDEF_FIELD_PRIVATE (type, i))
return true;
}
return false;
}
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
/* Helper function that temporarily disables FLAGS->PRINT_OFFSETS,
calls 'c_print_type_1', and then reenables FLAGS->PRINT_OFFSETS if
applicable. */
static void
c_print_type_no_offsets (struct type *type,
const char *varstring,
struct ui_file *stream,
int show, int level,
enum language language,
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
struct type_print_options *flags,
struct print_offset_data *podata)
{
unsigned int old_po = flags->print_offsets;
/* Temporarily disable print_offsets, because it would mess with
indentation. */
flags->print_offsets = 0;
c_print_type_1 (type, varstring, stream, show, level, language, flags,
podata);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
flags->print_offsets = old_po;
}
/* Helper for 'c_type_print_base' that handles structs and unions.
For a description of the arguments, see 'c_type_print_base'. */
static void
c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
int show, int level,
enum language language,
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
const struct type_print_options *flags,
struct print_offset_data *podata)
{
struct type_print_options local_flags = *flags;
local_flags.local_typedefs = NULL;
C++-ify typedef hash This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
2018-03-14 23:38:02 +01:00
std::unique_ptr<typedef_hash_table> hash_holder;
if (!flags->raw)
{
if (flags->local_typedefs)
local_flags.local_typedefs
C++-ify typedef hash This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
2018-03-14 23:38:02 +01:00
= new typedef_hash_table (*flags->local_typedefs);
else
C++-ify typedef hash This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
2018-03-14 23:38:02 +01:00
local_flags.local_typedefs = new typedef_hash_table ();
C++-ify typedef hash This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
2018-03-14 23:38:02 +01:00
hash_holder.reset (local_flags.local_typedefs);
}
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
c_type_print_modifier (type, stream, 0, 1, language);
if (type->code () == TYPE_CODE_UNION)
fprintf_filtered (stream, "union ");
else if (TYPE_DECLARED_CLASS (type))
fprintf_filtered (stream, "class ");
else
fprintf_filtered (stream, "struct ");
/* Print the tag if it exists. The HP aCC compiler emits a
spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed
enum}" tag for unnamed struct/union/enum's, which we don't
want to print. */
if (type->name () != NULL
&& !startswith (type->name (), "{unnamed"))
{
/* When printing the tag name, we are still effectively
printing in the outer context, hence the use of FLAGS
here. */
print_name_maybe_canonical (type->name (), flags, stream);
if (show > 0)
fputs_filtered (" ", stream);
}
if (show < 0)
{
/* If we just printed a tag name, no need to print anything
else. */
if (type->name () == NULL)
fprintf_filtered (stream, "{...}");
}
else if (show > 0 || type->name () == NULL)
{
struct type *basetype;
int vptr_fieldno;
c_type_print_template_args (&local_flags, type, stream);
/* Add in template parameters when printing derivation info. */
C++-ify typedef hash This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
2018-03-14 23:38:02 +01:00
if (local_flags.local_typedefs != NULL)
local_flags.local_typedefs->add_template_parameters (type);
cp_type_print_derivation_info (stream, type, &local_flags);
/* This holds just the global typedefs and the template
parameters. */
C++-ify typedef hash This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
2018-03-14 23:38:02 +01:00
struct type_print_options semi_local_flags = *flags;
semi_local_flags.local_typedefs = NULL;
C++-ify typedef hash This changes the typedef_hash_table structure to be a C++ class. It adds constructors and destructors and changes some functions to be methods of the class. Then it changes the various users of this class to adapt. This allows for the removal of some cleanups. Regression tested by the buildbot. gdb/ChangeLog 2018-03-27 Tom Tromey <tom@tromey.com> * typeprint.h (struct type_print_options) <local_typedefs, global_typedefs>: Remove "struct" keyword. (class typedef_hash_table): New class. (recursively_update_typedef_hash, add_template_parameters) (create_typedef_hash, free_typedef_hash, copy_typedef_hash) (find_typedef_in_hash): Don't declare. * typeprint.c (struct typedef_hash_table): Move to typeprint.h. (typedef_hash_table::recursively_update): Rename from recursively_update_typedef_hash. Now a member. (typedef_hash_table::add_template_parameters): Rename from add_template_parameters. Now a member. (typedef_hash_table::typedef_hash_table): Now a constructor; rename from create_typedef_hash. (typedef_hash_table::~typedef_hash_table): Now a destructor; rename from free_typedef_hash. (do_free_typedef_hash, make_cleanup_free_typedef_hash) (do_free_global_table): Remove. (typedef_hash_table::typedef_hash_table): New constructor; renamed from copy_type_recursive. (create_global_typedef_table): Remove. (typedef_hash_table::find_global_typedef): Now a member of typedef_hash_table. (typedef_hash_table::find_typedef): Rename from find_typedef_in_hash; now a member. (whatis_exp): Update. * extension.h (struct ext_lang_type_printers): Add constructor and destructor. (start_ext_lang_type_printers, free_ext_lang_type_printers): Don't declare. * extension.c (ext_lang_type_printers::ext_lang_type_printers): Now a constructor; rename from start_ext_lang_type_printers. (ext_lang_type_printers): Now a destructor; rename from free_ext_lang_type_printers. * c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1): Update. (c_type_print_base_struct_union): Update. Remove cleanups.
2018-03-14 23:38:02 +01:00
std::unique_ptr<typedef_hash_table> semi_holder;
if (local_flags.local_typedefs != nullptr)
{
semi_local_flags.local_typedefs
= new typedef_hash_table (*local_flags.local_typedefs);
semi_holder.reset (semi_local_flags.local_typedefs);
/* Now add in the local typedefs. */
local_flags.local_typedefs->recursively_update (type);
}
fprintf_filtered (stream, "{\n");
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
if (type->num_fields () == 0 && TYPE_NFN_FIELDS (type) == 0
&& TYPE_TYPEDEF_FIELD_COUNT (type) == 0)
{
if (TYPE_STUB (type))
fprintfi_filtered (level + 4, stream,
Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
2019-04-03 04:00:18 +02:00
_("%p[<incomplete type>%p]\n"),
metadata_style.style ().ptr (), nullptr);
else
fprintfi_filtered (level + 4, stream,
Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
2019-04-03 04:00:18 +02:00
_("%p[<no data fields>%p]\n"),
metadata_style.style ().ptr (), nullptr);
}
/* Start off with no specific section type, so we can print
one for the first field we find, and use that section type
thereafter until we find another type. */
enum access_specifier section_type = s_none;
/* For a class, if all members are private, there's no need
for a "private:" label; similarly, for a struct or union
masquerading as a class, if all members are public, there's
no need for a "public:" label. */
bool need_access_label = need_access_label_p (type);
/* If there is a base class for this type,
do not print the field that it occupies. */
int len = type->num_fields ();
vptr_fieldno = get_vptr_fieldno (type, &basetype);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
struct print_offset_data local_podata;
for (int i = TYPE_N_BASECLASSES (type); i < len; i++)
{
QUIT;
/* If we have a virtual table pointer, omit it. Even if
virtual table pointers are not specifically marked in
the debug info, they should be artificial. */
if ((i == vptr_fieldno && type == basetype)
|| TYPE_FIELD_ARTIFICIAL (type, i))
continue;
if (need_access_label)
{
section_type = output_access_specifier
(stream, section_type, level,
TYPE_FIELD_PROTECTED (type, i),
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
TYPE_FIELD_PRIVATE (type, i), flags);
}
bool is_static = field_is_static (&type->field (i));
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
if (flags->print_offsets)
podata->update (type, i, stream);
print_spaces_filtered (level + 4, stream);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
if (is_static)
fprintf_filtered (stream, "static ");
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
int newshow = show - 1;
Fix PR c++/23373: GDB hangs when printing a struct with a static member of itself This patch fixes a failure that happens when a structure has a static member whose type is the same as itself. From the bug report: Example code: struct A { static A Empty; int a; }; int main(void) { A a; return 0; } Output: (gdb) ptype/o A /* offset | size */ type = struct A { static struct A { static struct A { static struct A { static struct A { static struct A { static struct A { ... # infinite loop The problem here is that GDB is not taking into account the fact that static members inside a class/struct are not stored in the class/struct, and therefore they should not be accounted for during the display of the offsets/sizes. The fix is simple: we just check if the field we're dealing with (on c-typeprint.c:c_type_print_base_struct_union) is static, and if it is then we don't iterate over it. This patch also adds a new test for this case, and doesn't introduce any regressions. I believe it is important enough to be included in the 8.2 branch. OK? gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> PR c++/23373 * c-typeprint.c (c_type_print_base_struct_union): Don't print offsets/sizes for static members of a class/struct. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> PR c++/23373 * gdb.base/ptype-offsets.cc (struct static_member): New struct. (main) <stmember>: New variable. * gdb.base/ptype-offsets.exp: Add test for printing a struct with a static member in it.
2018-07-07 23:16:55 +02:00
if (!is_static && flags->print_offsets
&& (type->field (i).type ()->code () == TYPE_CODE_STRUCT
|| type->field (i).type ()->code () == TYPE_CODE_UNION))
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
{
/* If we're printing offsets and this field's type is
either a struct or an union, then we're interested in
expanding it. */
++newshow;
/* Make sure we carry our offset when we expand the
struct/union. */
local_podata.offset_bitpos
= podata->offset_bitpos + TYPE_FIELD_BITPOS (type, i);
/* We're entering a struct/union. Right now,
PODATA->END_BITPOS points right *after* the
struct/union. However, when printing the first field
of this inner struct/union, the end_bitpos we're
expecting is exactly at the beginning of the
struct/union. Therefore, we subtract the length of
the whole struct/union. */
local_podata.end_bitpos
= podata->end_bitpos
- TYPE_LENGTH (type->field (i).type ()) * TARGET_CHAR_BIT;
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
}
c_print_type_1 (type->field (i).type (),
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
TYPE_FIELD_NAME (type, i),
stream, newshow, level + 4,
language, &local_flags, &local_podata);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
if (!is_static && TYPE_FIELD_PACKED (type, i))
{
/* It is a bitfield. This code does not attempt
to look at the bitpos and reconstruct filler,
unnamed fields. This would lead to misleading
results if the compiler does not put out fields
for such things (I don't know what it does). */
fprintf_filtered (stream, " : %d",
TYPE_FIELD_BITSIZE (type, i));
}
fprintf_filtered (stream, ";\n");
}
/* If there are both fields and methods, put a blank line
between them. Make sure to count only method that we
will display; artificial methods will be hidden. */
len = TYPE_NFN_FIELDS (type);
if (!flags->print_methods)
len = 0;
int real_len = 0;
for (int i = 0; i < len; i++)
{
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
int len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
int j;
for (j = 0; j < len2; j++)
if (!TYPE_FN_FIELD_ARTIFICIAL (f, j))
real_len++;
}
if (real_len > 0 && section_type != s_none)
fprintf_filtered (stream, "\n");
/* C++: print out the methods. */
for (int i = 0; i < len; i++)
{
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
const char *name = type->name ();
int is_constructor = name && strcmp (method_name,
name) == 0;
for (j = 0; j < len2; j++)
{
const char *mangled_name;
gdb::unique_xmalloc_ptr<char> mangled_name_holder;
char *demangled_name;
const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
int is_full_physname_constructor =
TYPE_FN_FIELD_CONSTRUCTOR (f, j)
|| is_constructor_name (physname)
|| is_destructor_name (physname)
|| method_name[0] == '~';
/* Do not print out artificial methods. */
if (TYPE_FN_FIELD_ARTIFICIAL (f, j))
continue;
QUIT;
section_type = output_access_specifier
(stream, section_type, level,
TYPE_FN_FIELD_PROTECTED (f, j),
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
TYPE_FN_FIELD_PRIVATE (f, j), flags);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
print_spaces_filtered_with_print_options (level + 4, stream,
flags);
if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
fprintf_filtered (stream, "virtual ");
else if (TYPE_FN_FIELD_STATIC_P (f, j))
fprintf_filtered (stream, "static ");
if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)
{
/* Keep GDB from crashing here. */
fprintf_filtered (stream,
Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
2019-04-03 04:00:18 +02:00
_("%p[<undefined type>%p] %s;\n"),
metadata_style.style ().ptr (), nullptr,
TYPE_FN_FIELD_PHYSNAME (f, j));
break;
}
else if (!is_constructor /* Constructors don't
have declared
types. */
&& !is_full_physname_constructor /* " " */
&& !is_type_conversion_operator (type, i, j))
{
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
c_print_type_no_offsets
(TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
"", stream, -1, 0, language, &local_flags, podata);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
fputs_filtered (" ", stream);
}
if (TYPE_FN_FIELD_STUB (f, j))
{
/* Build something we can demangle. */
mangled_name_holder.reset (gdb_mangle_name (type, i, j));
mangled_name = mangled_name_holder.get ();
}
else
mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
demangled_name =
gdb_demangle (mangled_name,
DMGL_ANSI | DMGL_PARAMS);
if (demangled_name == NULL)
{
/* In some cases (for instance with the HP
demangling), if a function has more than 10
arguments, the demangling will fail.
Let's try to reconstruct the function
signature from the symbol information. */
if (!TYPE_FN_FIELD_STUB (f, j))
{
int staticp = TYPE_FN_FIELD_STATIC_P (f, j);
struct type *mtype = TYPE_FN_FIELD_TYPE (f, j);
cp_type_print_method_args (mtype,
"",
method_name,
staticp,
stream, language,
&local_flags);
}
else
Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
2019-04-03 04:00:18 +02:00
fprintf_styled (stream, metadata_style.style (),
_("<badly mangled name '%s'>"),
mangled_name);
}
else
{
char *p;
char *demangled_no_class
= remove_qualifiers (demangled_name);
/* Get rid of the `static' appended by the
demangler. */
p = strstr (demangled_no_class, " static");
if (p != NULL)
{
int length = p - demangled_no_class;
char *demangled_no_static;
demangled_no_static
= (char *) xmalloc (length + 1);
strncpy (demangled_no_static,
demangled_no_class, length);
*(demangled_no_static + length) = '\0';
fputs_filtered (demangled_no_static, stream);
xfree (demangled_no_static);
}
else
fputs_filtered (demangled_no_class, stream);
xfree (demangled_name);
}
fprintf_filtered (stream, ";\n");
}
}
/* Print out nested types. */
if (TYPE_NESTED_TYPES_COUNT (type) != 0
&& semi_local_flags.print_nested_type_limit != 0)
{
if (semi_local_flags.print_nested_type_limit > 0)
--semi_local_flags.print_nested_type_limit;
if (type->num_fields () != 0 || TYPE_NFN_FIELDS (type) != 0)
fprintf_filtered (stream, "\n");
for (int i = 0; i < TYPE_NESTED_TYPES_COUNT (type); ++i)
{
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
print_spaces_filtered_with_print_options (level + 4, stream,
flags);
c_print_type_no_offsets (TYPE_NESTED_TYPES_FIELD_TYPE (type, i),
"", stream, show, level + 4,
language, &semi_local_flags, podata);
fprintf_filtered (stream, ";\n");
}
}
/* Print typedefs defined in this class. */
if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0 && flags->print_typedefs)
{
if (type->num_fields () != 0 || TYPE_NFN_FIELDS (type) != 0
|| TYPE_NESTED_TYPES_COUNT (type) != 0)
fprintf_filtered (stream, "\n");
for (int i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++)
{
struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i);
/* Dereference the typedef declaration itself. */
gdb_assert (target->code () == TYPE_CODE_TYPEDEF);
target = TYPE_TARGET_TYPE (target);
if (need_access_label)
{
section_type = output_access_specifier
(stream, section_type, level,
TYPE_TYPEDEF_FIELD_PROTECTED (type, i),
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
TYPE_TYPEDEF_FIELD_PRIVATE (type, i), flags);
}
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
print_spaces_filtered_with_print_options (level + 4, stream,
flags);
fprintf_filtered (stream, "typedef ");
/* We want to print typedefs with substitutions
from the template parameters or globally-known
typedefs but not local typedefs. */
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
c_print_type_no_offsets (target,
TYPE_TYPEDEF_FIELD_NAME (type, i),
stream, show - 1, level + 4,
language, &semi_local_flags, podata);
fprintf_filtered (stream, ";\n");
}
}
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
if (flags->print_offsets)
{
if (show > 0)
podata->finish (type, level, stream);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
print_spaces_filtered (print_offset_data::indentation, stream);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
if (level == 0)
print_spaces_filtered (2, stream);
}
fprintfi_filtered (level, stream, "}");
}
}
/* Print the name of the type (or the ultimate pointer target,
function value or array element), or the description of a structure
or union.
SHOW positive means print details about the type (e.g. enum
values), and print structure elements passing SHOW - 1 for show.
SHOW negative means just print the type name or struct tag if there
is one. If there is no name, print something sensible but concise
like "struct {...}".
SHOW zero means just print the type name or struct tag if there is
one. If there is no name, print something sensible but not as
concise like "struct {int x; int y;}".
LEVEL is the number of spaces to indent by.
We increase it for some recursive calls. */
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
static void
c_type_print_base_1 (struct type *type, struct ui_file *stream,
int show, int level,
enum language language,
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
const struct type_print_options *flags,
struct print_offset_data *podata)
{
int i;
int len;
QUIT;
if (type == NULL)
{
Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
2019-04-03 04:00:18 +02:00
fputs_styled (_("<type unknown>"), metadata_style.style (), stream);
return;
}
/* When SHOW is zero or less, and there is a valid type name, then
always just print the type name directly from the type. */
if (show <= 0
&& type->name () != NULL)
{
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
c_type_print_modifier (type, stream, 0, 1, language);
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-17 21:51:24 +02:00
/* If we have "typedef struct foo {. . .} bar;" do we want to
print it as "struct foo" or as "bar"? Pick the latter for
C++, because C++ folk tend to expect things like "class5
*foo" rather than "struct class5 *foo". We rather
arbitrarily choose to make language_minimal work in a C-like
way. */
if (language == language_c || language == language_minimal)
{
if (type->code () == TYPE_CODE_UNION)
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-17 21:51:24 +02:00
fprintf_filtered (stream, "union ");
else if (type->code () == TYPE_CODE_STRUCT)
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-17 21:51:24 +02:00
{
if (TYPE_DECLARED_CLASS (type))
fprintf_filtered (stream, "class ");
else
fprintf_filtered (stream, "struct ");
}
else if (type->code () == TYPE_CODE_ENUM)
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-17 21:51:24 +02:00
fprintf_filtered (stream, "enum ");
}
print_name_maybe_canonical (type->name (), flags, stream);
return;
}
Remove CHECK_TYPEDEF, use check_typedef instead I think that the CHECK_TYPEDEF macro is not necessary, and even a bit annoying. It makes unclear the fact that the "type" variables gets overwritten. It has actually bitten me a few times. I think the following, explicit form, is better. type = check_typedef (type); This patches changes all instances of CHECK_TYPEDEF for an equivalent call to check_typedef. The bulk of the change was done with this sed: sed -i 's/CHECK_TYPEDEF (\([^)]*\));/\1 = check_typedef (\1);/' <file>.c The ChangeLog was generated using David Malcom's generate_changelog.py. I manually fixed those places where it gets the wrong function name, hopefully all of them. The patch was built-tested, and I ran a few smoke tests. gdb/ChangeLog: * gdbtypes.h (CHECK_TYPEDEF): Remove. * aarch64-tdep.c (aarch64_return_in_memory): Replace CHECK_TYPEDEF with check_typedef. * ada-lang.c (decode_constrained_packed_array_type): Likewise. (ada_array_length): Likewise. (find_parallel_type_by_descriptive_type): Likewise. (ada_check_typedef): Likewise. * arm-tdep.c (arm_return_in_memory): Likewise. * ax-gdb.c (gen_trace_static_fields): Likewise. (gen_struct_ref_recursive): Likewise. * c-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. (variable: block COLONCOLON name): Likewise. (qualified_name: TYPENAME COLONCOLON name): Likewise. * c-lang.c (classify_type): Likewise. * c-typeprint.c (c_print_type): Likewise. (c_print_typedef): Likewise. (c_type_print_base): Likewise. * c-valprint.c (c_val_print): Likewise. * compile/compile-c-types.c (convert_type): Likewise. * compile/compile-object-load.c (get_out_value_type): Likewise. * completer.c (add_struct_fields): Likewise. (expression_completer): Likewise. * cp-namespace.c (cp_find_type_baseclass_by_name): Likewise. (cp_lookup_nested_symbol_1): Likewise. (cp_lookup_nested_symbol): Likewise. * cp-valprint.c (cp_print_value_fields): Likewise. (cp_print_static_field): Likewise. * d-valprint.c (d_val_print): Likewise. * eval.c (evaluate_subexp_standard): Likewise. (evaluate_subexp_for_sizeof): Likewise. * f-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. * f-typeprint.c (f_type_print_base): Likewise. * f-valprint.c (f_val_print): Likewise. * gdbtypes.c (get_discrete_bounds): Likewise. (create_array_type_with_stride): Likewise. (type_name_no_tag_or_error): Likewise. (lookup_struct_elt_type): Likewise. (get_unsigned_type_max): Likewise. (internal_type_vptr_fieldno): Likewise. (set_type_vptr_fieldno): Likewise. (internal_type_vptr_basetype): Likewise. (set_type_vptr_basetype): Likewise. (get_vptr_fieldno): Likewise. (is_integral_type): Likewise. (is_scalar_type): Likewise. (is_scalar_type_recursive): Likewise. (distance_to_ancestor): Likewise. (is_unique_ancestor_worker): Likewise. (check_types_equal): Likewise. * gnu-v2-abi.c (gnuv2_value_rtti_type): Likewise. * gnu-v3-abi.c (gnuv3_dynamic_class): Likewise. (gnuv3_get_vtable): Likewise. (gnuv3_pass_by_reference): Likewise. * go-exp.y (exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY): Likewise. * go-lang.c (gccgo_string_p): Likewise. (go_classify_struct_type): Likewise. * go-typeprint.c (go_print_type): Likewise. * go-valprint.c (go_val_print): Likewise. * guile/scm-math.c (vlscm_binop): Likewise. * guile/scm-value.c (gdbscm_value_dynamic_type): Likewise. (gdbscm_value_to_bytevector): Likewise. (gdbscm_value_to_bool): Likewise. (gdbscm_value_to_integer): Likewise. (gdbscm_value_to_real): Likewise. * infcall.c (call_function_by_hand_dummy): Likewise. * infcmd.c (get_return_value): Likewise. * jv-lang.c (is_object_type): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_print_value_fields): Likewise. (java_val_print): Likewise. * linespec.c (find_methods): Likewise. (collect_one_symbol): Likewise. * m2-typeprint.c (m2_print_type): Likewise. (m2_print_typedef): Likewise. (m2_get_discrete_bounds): Likewise. * m2-valprint.c (m2_print_long_set): Likewise. (m2_print_unbounded_array): Likewise. (m2_print_array_contents): Likewise. (m2_val_print): Likewise. * opencl-lang.c (opencl_print_type): Likewise. * p-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise. * p-typeprint.c (pascal_print_type): Likewise. (pascal_print_typedef): Likewise. (pascal_type_print_base): Likewise. * p-valprint.c (pascal_val_print): Likewise. (pascal_object_print_value_fields): Likewise. (pascal_object_print_static_field): Likewise. * python/py-type.c (typy_fields_items): Likewise. (typy_get_composite): Likewise. * python/py-value.c (valpy_get_dynamic_type): Likewise. (valpy_binop): Likewise. (valpy_long): Likewise. (valpy_float): Likewise. * stack.c (return_command): Likewise. * symtab.c (check_field): Likewise. (lookup_symbol_aux): Likewise. * tic6x-tdep.c (tic6x_return_value): Likewise. * typeprint.c (print_type_scalar): Likewise. * valarith.c (value_vector_widen): Likewise. * valops.c (value_cast): Likewise. (value_assign): Likewise. (do_search_struct_field): Likewise. (search_struct_method): Likewise. (find_method_list): Likewise. * valprint.c (val_print_scalar_type_p): Likewise. (valprint_check_validity): Likewise. (generic_val_print): Likewise. * value.c (unpack_double): Likewise. (value_primitive_field): Likewise. (unpack_bits_as_long): Likewise.
2015-07-06 22:05:06 +02:00
type = check_typedef (type);
1999-07-07 22:19:36 +02:00
switch (type->code ())
{
case TYPE_CODE_TYPEDEF:
/* If we get here, the typedef doesn't have a name, and we
couldn't resolve TYPE_TARGET_TYPE. Not much we can do. */
gdb_assert (type->name () == NULL);
gdb_assert (TYPE_TARGET_TYPE (type) == NULL);
Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
2019-04-03 04:00:18 +02:00
fprintf_styled (stream, metadata_style.style (),
_("<unnamed typedef>"));
break;
Stop assuming no-debug-info functions return int The fact that GDB defaults to assuming that functions return int, when it has no debug info for the function has been a recurring source of user confusion. Recently this came up on the errno pretty printer discussions. Shortly after, it came up again on IRC, with someone wondering why does getenv() in GDB return a negative int: (gdb) p getenv("PATH") $1 = -6185 This question (with s/getenv/random-other-C-runtime-function) is a FAQ on IRC. The reason for the above is: (gdb) p getenv $2 = {<text variable, no debug info>} 0x7ffff7751d80 <getenv> (gdb) ptype getenv type = int () ... which means that GDB truncated the 64-bit pointer that is actually returned from getent to 32-bit, and then sign-extended it: (gdb) p /x -6185 $6 = 0xffffe7d7 The workaround is to cast the function to the right type, like: (gdb) p ((char *(*) (const char *)) getenv) ("PATH") $3 = 0x7fffffffe7d7 "/usr/local/bin:/"... IMO, we should do better than this. I see the "assume-int" issue the same way I see printing bogus values for optimized-out variables instead of "<optimized out>" -- I'd much rather that the debugger tells me "I don't know" and tells me how to fix it than showing me bogus misleading results, making me go around tilting at windmills. If GDB prints a signed integer when you're expecting a pointer or aggregate, you at least have some sense that something is off, but consider the case of the function actually returning a 64-bit integer. For example, compile this without debug info: unsigned long long function () { return 0x7fffffffffffffff; } Currently, with pristine GDB, you get: (gdb) p function () $1 = -1 # incorrect (gdb) p /x function () $2 = 0xffffffff # incorrect maybe after spending a few hours debugging you suspect something is wrong with that -1, and do: (gdb) ptype function type = int () and maybe, just maybe, you realize that the function actually returns unsigned long long. And you try to fix it with: (gdb) p /x (unsigned long long) function () $3 = 0xffffffffffffffff # incorrect ... which still produces the wrong result, because GDB simply applied int to unsigned long long conversion. Meaning, it sign-extended the integer that it extracted from the return of the function, to 64-bits. and then maybe, after asking around on IRC, you realize you have to cast the function to a pointer of the right type, and call that. It won't be easy, but after a few missteps, you'll get to it: ..... (gdb) p /x ((unsigned long long(*) ()) function) () $666 = 0x7fffffffffffffff # finally! :-) So to improve on the user experience, this patch does the following (interrelated) things: - makes no-debug-info functions no longer default to "int" as return type. Instead, they're left with NULL/"<unknown return type>" return type. (gdb) ptype getenv type = <unknown return type> () - makes calling a function with unknown return type an error. (gdb) p getenv ("PATH") 'getenv' has unknown return type; cast the call to its declared return type - and then to make it easier to call the function, makes it possible to _only_ cast the return of the function to the right type, instead of having to cast the function to a function pointer: (gdb) p (char *) getenv ("PATH") # now Just Works $3 = 0x7fffffffe7d7 "/usr/local/bin:/"... (gdb) p ((char *(*) (const char *)) getenv) ("PATH") # continues working $4 = 0x7fffffffe7d7 "/usr/local/bin:/"... I.e., it makes GDB default the function's return type to the type of the cast, and the function's parameters to the type of the arguments passed down. After this patch, here's what you'll get for the "unsigned long long" example above: (gdb) p function () 'function' has unknown return type; cast the call to its declared return type (gdb) p /x (unsigned long long) function () $4 = 0x7fffffffffffffff # correct! Note that while with "print" GDB shows the name of the function that has the problem: (gdb) p getenv ("PATH") 'getenv' has unknown return type; cast the call to its declared return type which can by handy in more complicated expressions, "ptype" does not: (gdb) ptype getenv ("PATH") function has unknown return type; cast the call to its declared return type This will be fixed in the next patch. gdb/ChangeLog: 2017-09-04 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_evaluate_subexp) <TYPE_CODE_FUNC>: Don't handle TYPE_GNU_IFUNC specially here. Throw error if return type is unknown. * ada-typeprint.c (print_func_type): Handle functions with unknown return type. * c-typeprint.c (c_type_print_base): Handle functions and methods with unknown return type. * compile/compile-c-symbols.c (convert_symbol_bmsym) <mst_text_gnu_ifunc>: Use nodebug_text_gnu_ifunc_symbol. * compile/compile-c-types.c: Include "objfiles.h". (convert_func): For functions with unknown return type, warn and default to int. * compile/compile-object-run.c (compile_object_run): Adjust call to call_function_by_hand_dummy. * elfread.c (elf_gnu_ifunc_resolve_addr): Adjust call to call_function_by_hand. * eval.c (evaluate_subexp_standard): Adjust calls to call_function_by_hand. Handle functions and methods with unknown return type. Pass expect_type to call_function_by_hand. * f-typeprint.c (f_type_print_base): Handle functions with unknown return type. * gcore.c (call_target_sbrk): Adjust call to call_function_by_hand. * gdbtypes.c (objfile_type): Leave nodebug text symbol with NULL return type instead of int. Make nodebug_text_gnu_ifunc_symbol be an integer address type instead of nodebug. * guile/scm-value.c (gdbscm_value_call): Adjust call to call_function_by_hand. * infcall.c (error_call_unknown_return_type): New function. (call_function_by_hand): New "default_return_type" parameter. Pass it down. (call_function_by_hand_dummy): New "default_return_type" parameter. Use it instead of defaulting to int. If there's no default and the return type is unknown, throw an error. If there's a default return type, and the called function has no debug info, then assume the function is prototyped. * infcall.h (call_function_by_hand, call_function_by_hand_dummy): New "default_return_type" parameter. (error_call_unknown_return_type): New declaration. * linux-fork.c (call_lseek): Cast return type of lseek. (inferior_call_waitpid, checkpoint_command): Adjust calls to call_function_by_hand. * linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap): Adjust calls to call_function_by_hand. * m2-typeprint.c (m2_procedure): Handle functions with unknown return type. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, print_object_command): Adjust calls to call_function_by_hand. * p-typeprint.c (pascal_type_print_varspec_prefix): Handle functions with unknown return type. (pascal_type_print_func_varspec_suffix): New function. (pascal_type_print_varspec_suffix) <TYPE_CODE_FUNC, TYPE_CODE_METHOD>: Use it. * python/py-value.c (valpy_call): Adjust call to call_function_by_hand. * rust-lang.c (rust_evaluate_funcall): Adjust call to call_function_by_hand. * valarith.c (value_x_binop, value_x_unop): Adjust calls to call_function_by_hand. * valops.c (value_allocate_space_in_inferior): Adjust call to call_function_by_hand. * typeprint.c (type_print_unknown_return_type): New function. * typeprint.h (type_print_unknown_return_type): New declaration. gdb/testsuite/ChangeLog: 2017-09-04 Pedro Alves <palves@redhat.com> * gdb.base/break-main-file-remove-fail.exp (test_remove_bp): Cast return type of munmap in infcall. * gdb.base/break-probes.exp: Cast return type of foo in infcall. * gdb.base/checkpoint.exp: Simplify using for loop. Cast return type of ftell in infcall. * gdb.base/dprintf-detach.exp (dprintf_detach_test): Cast return type of getpid in infcall. * gdb.base/infcall-exec.exp: Cast return type of execlp in infcall. * gdb.base/info-os.exp: Cast return type of getpid in infcall. Bail on failure to extract the pid. * gdb.base/nodebug.c: #include <stdint.h>. (multf, multf_noproto, mult, mult_noproto, add8, add8_noproto): New functions. * gdb.base/nodebug.exp (test_call_promotion): New procedure. Change expected output of print/whatis/ptype with functions with no debug info. Test all supported languages. Call test_call_promotion. * gdb.compile/compile.exp: Adjust expected output to expect warning. * gdb.threads/siginfo-threads.exp: Likewise.
2017-09-04 21:21:13 +02:00
case TYPE_CODE_FUNC:
case TYPE_CODE_METHOD:
if (TYPE_TARGET_TYPE (type) == NULL)
type_print_unknown_return_type (stream);
else
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
c_type_print_base_1 (TYPE_TARGET_TYPE (type),
stream, show, level, language, flags, podata);
Stop assuming no-debug-info functions return int The fact that GDB defaults to assuming that functions return int, when it has no debug info for the function has been a recurring source of user confusion. Recently this came up on the errno pretty printer discussions. Shortly after, it came up again on IRC, with someone wondering why does getenv() in GDB return a negative int: (gdb) p getenv("PATH") $1 = -6185 This question (with s/getenv/random-other-C-runtime-function) is a FAQ on IRC. The reason for the above is: (gdb) p getenv $2 = {<text variable, no debug info>} 0x7ffff7751d80 <getenv> (gdb) ptype getenv type = int () ... which means that GDB truncated the 64-bit pointer that is actually returned from getent to 32-bit, and then sign-extended it: (gdb) p /x -6185 $6 = 0xffffe7d7 The workaround is to cast the function to the right type, like: (gdb) p ((char *(*) (const char *)) getenv) ("PATH") $3 = 0x7fffffffe7d7 "/usr/local/bin:/"... IMO, we should do better than this. I see the "assume-int" issue the same way I see printing bogus values for optimized-out variables instead of "<optimized out>" -- I'd much rather that the debugger tells me "I don't know" and tells me how to fix it than showing me bogus misleading results, making me go around tilting at windmills. If GDB prints a signed integer when you're expecting a pointer or aggregate, you at least have some sense that something is off, but consider the case of the function actually returning a 64-bit integer. For example, compile this without debug info: unsigned long long function () { return 0x7fffffffffffffff; } Currently, with pristine GDB, you get: (gdb) p function () $1 = -1 # incorrect (gdb) p /x function () $2 = 0xffffffff # incorrect maybe after spending a few hours debugging you suspect something is wrong with that -1, and do: (gdb) ptype function type = int () and maybe, just maybe, you realize that the function actually returns unsigned long long. And you try to fix it with: (gdb) p /x (unsigned long long) function () $3 = 0xffffffffffffffff # incorrect ... which still produces the wrong result, because GDB simply applied int to unsigned long long conversion. Meaning, it sign-extended the integer that it extracted from the return of the function, to 64-bits. and then maybe, after asking around on IRC, you realize you have to cast the function to a pointer of the right type, and call that. It won't be easy, but after a few missteps, you'll get to it: ..... (gdb) p /x ((unsigned long long(*) ()) function) () $666 = 0x7fffffffffffffff # finally! :-) So to improve on the user experience, this patch does the following (interrelated) things: - makes no-debug-info functions no longer default to "int" as return type. Instead, they're left with NULL/"<unknown return type>" return type. (gdb) ptype getenv type = <unknown return type> () - makes calling a function with unknown return type an error. (gdb) p getenv ("PATH") 'getenv' has unknown return type; cast the call to its declared return type - and then to make it easier to call the function, makes it possible to _only_ cast the return of the function to the right type, instead of having to cast the function to a function pointer: (gdb) p (char *) getenv ("PATH") # now Just Works $3 = 0x7fffffffe7d7 "/usr/local/bin:/"... (gdb) p ((char *(*) (const char *)) getenv) ("PATH") # continues working $4 = 0x7fffffffe7d7 "/usr/local/bin:/"... I.e., it makes GDB default the function's return type to the type of the cast, and the function's parameters to the type of the arguments passed down. After this patch, here's what you'll get for the "unsigned long long" example above: (gdb) p function () 'function' has unknown return type; cast the call to its declared return type (gdb) p /x (unsigned long long) function () $4 = 0x7fffffffffffffff # correct! Note that while with "print" GDB shows the name of the function that has the problem: (gdb) p getenv ("PATH") 'getenv' has unknown return type; cast the call to its declared return type which can by handy in more complicated expressions, "ptype" does not: (gdb) ptype getenv ("PATH") function has unknown return type; cast the call to its declared return type This will be fixed in the next patch. gdb/ChangeLog: 2017-09-04 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_evaluate_subexp) <TYPE_CODE_FUNC>: Don't handle TYPE_GNU_IFUNC specially here. Throw error if return type is unknown. * ada-typeprint.c (print_func_type): Handle functions with unknown return type. * c-typeprint.c (c_type_print_base): Handle functions and methods with unknown return type. * compile/compile-c-symbols.c (convert_symbol_bmsym) <mst_text_gnu_ifunc>: Use nodebug_text_gnu_ifunc_symbol. * compile/compile-c-types.c: Include "objfiles.h". (convert_func): For functions with unknown return type, warn and default to int. * compile/compile-object-run.c (compile_object_run): Adjust call to call_function_by_hand_dummy. * elfread.c (elf_gnu_ifunc_resolve_addr): Adjust call to call_function_by_hand. * eval.c (evaluate_subexp_standard): Adjust calls to call_function_by_hand. Handle functions and methods with unknown return type. Pass expect_type to call_function_by_hand. * f-typeprint.c (f_type_print_base): Handle functions with unknown return type. * gcore.c (call_target_sbrk): Adjust call to call_function_by_hand. * gdbtypes.c (objfile_type): Leave nodebug text symbol with NULL return type instead of int. Make nodebug_text_gnu_ifunc_symbol be an integer address type instead of nodebug. * guile/scm-value.c (gdbscm_value_call): Adjust call to call_function_by_hand. * infcall.c (error_call_unknown_return_type): New function. (call_function_by_hand): New "default_return_type" parameter. Pass it down. (call_function_by_hand_dummy): New "default_return_type" parameter. Use it instead of defaulting to int. If there's no default and the return type is unknown, throw an error. If there's a default return type, and the called function has no debug info, then assume the function is prototyped. * infcall.h (call_function_by_hand, call_function_by_hand_dummy): New "default_return_type" parameter. (error_call_unknown_return_type): New declaration. * linux-fork.c (call_lseek): Cast return type of lseek. (inferior_call_waitpid, checkpoint_command): Adjust calls to call_function_by_hand. * linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap): Adjust calls to call_function_by_hand. * m2-typeprint.c (m2_procedure): Handle functions with unknown return type. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, print_object_command): Adjust calls to call_function_by_hand. * p-typeprint.c (pascal_type_print_varspec_prefix): Handle functions with unknown return type. (pascal_type_print_func_varspec_suffix): New function. (pascal_type_print_varspec_suffix) <TYPE_CODE_FUNC, TYPE_CODE_METHOD>: Use it. * python/py-value.c (valpy_call): Adjust call to call_function_by_hand. * rust-lang.c (rust_evaluate_funcall): Adjust call to call_function_by_hand. * valarith.c (value_x_binop, value_x_unop): Adjust calls to call_function_by_hand. * valops.c (value_allocate_space_in_inferior): Adjust call to call_function_by_hand. * typeprint.c (type_print_unknown_return_type): New function. * typeprint.h (type_print_unknown_return_type): New declaration. gdb/testsuite/ChangeLog: 2017-09-04 Pedro Alves <palves@redhat.com> * gdb.base/break-main-file-remove-fail.exp (test_remove_bp): Cast return type of munmap in infcall. * gdb.base/break-probes.exp: Cast return type of foo in infcall. * gdb.base/checkpoint.exp: Simplify using for loop. Cast return type of ftell in infcall. * gdb.base/dprintf-detach.exp (dprintf_detach_test): Cast return type of getpid in infcall. * gdb.base/infcall-exec.exp: Cast return type of execlp in infcall. * gdb.base/info-os.exp: Cast return type of getpid in infcall. Bail on failure to extract the pid. * gdb.base/nodebug.c: #include <stdint.h>. (multf, multf_noproto, mult, mult_noproto, add8, add8_noproto): New functions. * gdb.base/nodebug.exp (test_call_promotion): New procedure. Change expected output of print/whatis/ptype with functions with no debug info. Test all supported languages. Call test_call_promotion. * gdb.compile/compile.exp: Adjust expected output to expect warning. * gdb.threads/siginfo-threads.exp: Likewise.
2017-09-04 21:21:13 +02:00
break;
case TYPE_CODE_ARRAY:
case TYPE_CODE_PTR:
* 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-03 19:05:45 +01:00
case TYPE_CODE_MEMBERPTR:
case TYPE_CODE_REF:
case TYPE_CODE_RVALUE_REF:
* 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-03 19:05:45 +01:00
case TYPE_CODE_METHODPTR:
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
c_type_print_base_1 (TYPE_TARGET_TYPE (type),
stream, show, level, language, flags, podata);
break;
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
c_type_print_base_struct_union (type, stream, show, level,
language, flags, podata);
break;
case TYPE_CODE_ENUM:
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
c_type_print_modifier (type, stream, 0, 1, language);
1999-07-07 22:19:36 +02:00
fprintf_filtered (stream, "enum ");
if (TYPE_DECLARED_CLASS (type))
fprintf_filtered (stream, "class ");
/* Print the tag name if it exists.
The aCC compiler emits a spurious
"{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
tag for unnamed struct/union/enum's, which we don't
want to print. */
if (type->name () != NULL
&& !startswith (type->name (), "{unnamed"))
{
print_name_maybe_canonical (type->name (), flags, stream);
if (show > 0)
fputs_filtered (" ", stream);
}
wrap_here (" ");
if (show < 0)
{
/* If we just printed a tag name, no need to print anything
else. */
if (type->name () == NULL)
fprintf_filtered (stream, "{...}");
}
else if (show > 0 || type->name () == NULL)
{
gdb/ PR symtab/7259: * ada-exp.y (convert_char_literal): Use TYPE_FIELD_ENUMVAL. * ada-lang.c (ada_discrete_type_high_bound) (ada_discrete_type_low_bound): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (ada_identical_enum_types_p): Use TYPE_FIELD_ENUMVAL. (pos_atr, value_val_atr): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * ada-typeprint.c (print_enum_type): Change variable lastval to LONGEST. Use TYPE_FIELD_ENUMVAL. * ada-valprint.c (print_optional_low_bound, ada_print_scalar) (ada_val_print_1): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * c-typeprint.c (c_type_print_base): Move variable lastval to inner block, change it to LONGEST. Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * coffread.c (coff_read_enum_type): Use SET_FIELD_ENUMVAL. * dwarf2read.c (process_enumeration_scope): Likewise. * gdb-gdb.py (TypeFlagsPrinter): Use field.enumval instead of field.bitpos. (class StructMainTypePrettyPrinter): Support also FIELD_LOC_KIND_ENUMVAL. * gdbtypes.c (get_discrete_bounds): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (recursive_dump_type): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (copy_type_recursive): Support also FIELD_LOC_KIND_ENUMVAL. * gdbtypes.h (enum field_loc_kind): New FIELD_LOC_KIND_ENUMVAL. (struct main_type.flds_bnds.fields.loc): Adjust bitpos comment. New field enumval. (struct main_type.flds_bnds.bields): Adjust loc_kind and bitsize to accommodate enumval. (struct call_site): Adjust loc_kind to accommodate enumval. (FIELD_ENUMVAL, FIELD_ENUMVAL_LVAL, SET_FIELD_ENUMVAL) (TYPE_FIELD_ENUMVAL): New macros. * m2-typeprint.c (m2_enum): Use TYPE_FIELD_ENUMVAL. * mdebugread.c (parse_symbol): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * p-typeprint.c (pascal_type_print_base): Likewise. * python/lib/gdb/printing.py (class FlagEnumerationPrinter): Use enumval. * python/lib/gdb/types.py (make_enum_dict): Likewise. * python/py-type.c (convert_field): New variable addrstring. Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (check_types_equal): Support also FIELD_LOC_KIND_ENUMVAL. * stabsread.c (read_enum_type): Use SET_FIELD_ENUMVAL. * typepint.c (print_type_scalar): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * valprint.c (generic_val_print): Likewise. gdb/testsuite/ PR symtab/7259: * gdb.base/enumval.c: New test case. * gdb.base/enumval.exp: New test case. * gdb.python/py-type.exp (test_enums): Use field.enumval instead of field.bitpos.
2012-04-18 08:46:47 +02:00
LONGEST lastval = 0;
/* We can't handle this case perfectly, as DWARF does not
tell us whether or not the underlying type was specified
in the source (and other debug formats don't provide this
at all). We choose to print the underlying type, if it
has a name, when in C++ on the theory that it's better to
print too much than too little; but conversely not to
print something egregiously outside the current
language's syntax. */
if (language == language_cplus && TYPE_TARGET_TYPE (type) != NULL)
{
struct type *underlying = check_typedef (TYPE_TARGET_TYPE (type));
if (underlying->name () != NULL)
fprintf_filtered (stream, ": %s ", underlying->name ());
}
fprintf_filtered (stream, "{");
len = type->num_fields ();
for (i = 0; i < len; i++)
{
QUIT;
1999-07-07 22:19:36 +02:00
if (i)
fprintf_filtered (stream, ", ");
wrap_here (" ");
Style field names in "print" This changes gdb to use the "variable" style when printing field names. I've added new tests for C and Rust, but not other languages. I chose "variable" because that seemed most straightforward. However, another option would be to introduce a new "field" style. Similarly, this patch uses the variable style for enumerator constants -- but again, a new style could be used if that's preferred. gdb/ChangeLog 2020-02-22 Tom Tromey <tom@tromey.com> * valprint.c (generic_val_print_enum_1) (val_print_type_code_flags): Style member names. * rust-lang.c (val_print_struct, rust_print_enum) (rust_print_struct_def, rust_internal_print_type): Style member names. * p-valprint.c (pascal_object_print_value_fields): Style member names. Only call fprintf_symbol_filtered for static members. * m2-typeprint.c (m2_record_fields, m2_enum): Style member names. * f-valprint.c (f_val_print): Style member names. * f-typeprint.c (f_type_print_base): Style member names. * cp-valprint.c (cp_print_value_fields): Style member names. Only call fprintf_symbol_filtered for static members. (cp_print_class_member): Style member names. * c-typeprint.c (c_print_type_1, c_type_print_base_1): Style member names. * ada-valprint.c (ada_print_scalar): Style enum names. (ada_val_print_enum): Likewise. * ada-typeprint.c (print_enum_type): Style enum names. gdb/testsuite/ChangeLog 2020-02-22 Tom Tromey <tom@tromey.com> * gdb.rust/rust-style.rs: New file. * gdb.rust/rust-style.exp: New file. * gdb.base/style.exp: Test structure printing. * gdb.base/style.c (struct some_struct): New type. (enum etype): New type. (struct_value): New global. Change-Id: I070e1293c6cc830c9ea916af8243410aa384e944
2020-02-22 18:02:42 +01:00
fputs_styled (TYPE_FIELD_NAME (type, i),
variable_name_style.style (), stream);
gdb/ PR symtab/7259: * ada-exp.y (convert_char_literal): Use TYPE_FIELD_ENUMVAL. * ada-lang.c (ada_discrete_type_high_bound) (ada_discrete_type_low_bound): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (ada_identical_enum_types_p): Use TYPE_FIELD_ENUMVAL. (pos_atr, value_val_atr): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * ada-typeprint.c (print_enum_type): Change variable lastval to LONGEST. Use TYPE_FIELD_ENUMVAL. * ada-valprint.c (print_optional_low_bound, ada_print_scalar) (ada_val_print_1): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * c-typeprint.c (c_type_print_base): Move variable lastval to inner block, change it to LONGEST. Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * coffread.c (coff_read_enum_type): Use SET_FIELD_ENUMVAL. * dwarf2read.c (process_enumeration_scope): Likewise. * gdb-gdb.py (TypeFlagsPrinter): Use field.enumval instead of field.bitpos. (class StructMainTypePrettyPrinter): Support also FIELD_LOC_KIND_ENUMVAL. * gdbtypes.c (get_discrete_bounds): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (recursive_dump_type): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (copy_type_recursive): Support also FIELD_LOC_KIND_ENUMVAL. * gdbtypes.h (enum field_loc_kind): New FIELD_LOC_KIND_ENUMVAL. (struct main_type.flds_bnds.fields.loc): Adjust bitpos comment. New field enumval. (struct main_type.flds_bnds.bields): Adjust loc_kind and bitsize to accommodate enumval. (struct call_site): Adjust loc_kind to accommodate enumval. (FIELD_ENUMVAL, FIELD_ENUMVAL_LVAL, SET_FIELD_ENUMVAL) (TYPE_FIELD_ENUMVAL): New macros. * m2-typeprint.c (m2_enum): Use TYPE_FIELD_ENUMVAL. * mdebugread.c (parse_symbol): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * p-typeprint.c (pascal_type_print_base): Likewise. * python/lib/gdb/printing.py (class FlagEnumerationPrinter): Use enumval. * python/lib/gdb/types.py (make_enum_dict): Likewise. * python/py-type.c (convert_field): New variable addrstring. Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (check_types_equal): Support also FIELD_LOC_KIND_ENUMVAL. * stabsread.c (read_enum_type): Use SET_FIELD_ENUMVAL. * typepint.c (print_type_scalar): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * valprint.c (generic_val_print): Likewise. gdb/testsuite/ PR symtab/7259: * gdb.base/enumval.c: New test case. * gdb.base/enumval.exp: New test case. * gdb.python/py-type.exp (test_enums): Use field.enumval instead of field.bitpos.
2012-04-18 08:46:47 +02:00
if (lastval != TYPE_FIELD_ENUMVAL (type, i))
{
gdb/ PR symtab/7259: * ada-exp.y (convert_char_literal): Use TYPE_FIELD_ENUMVAL. * ada-lang.c (ada_discrete_type_high_bound) (ada_discrete_type_low_bound): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (ada_identical_enum_types_p): Use TYPE_FIELD_ENUMVAL. (pos_atr, value_val_atr): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * ada-typeprint.c (print_enum_type): Change variable lastval to LONGEST. Use TYPE_FIELD_ENUMVAL. * ada-valprint.c (print_optional_low_bound, ada_print_scalar) (ada_val_print_1): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * c-typeprint.c (c_type_print_base): Move variable lastval to inner block, change it to LONGEST. Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * coffread.c (coff_read_enum_type): Use SET_FIELD_ENUMVAL. * dwarf2read.c (process_enumeration_scope): Likewise. * gdb-gdb.py (TypeFlagsPrinter): Use field.enumval instead of field.bitpos. (class StructMainTypePrettyPrinter): Support also FIELD_LOC_KIND_ENUMVAL. * gdbtypes.c (get_discrete_bounds): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (recursive_dump_type): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (copy_type_recursive): Support also FIELD_LOC_KIND_ENUMVAL. * gdbtypes.h (enum field_loc_kind): New FIELD_LOC_KIND_ENUMVAL. (struct main_type.flds_bnds.fields.loc): Adjust bitpos comment. New field enumval. (struct main_type.flds_bnds.bields): Adjust loc_kind and bitsize to accommodate enumval. (struct call_site): Adjust loc_kind to accommodate enumval. (FIELD_ENUMVAL, FIELD_ENUMVAL_LVAL, SET_FIELD_ENUMVAL) (TYPE_FIELD_ENUMVAL): New macros. * m2-typeprint.c (m2_enum): Use TYPE_FIELD_ENUMVAL. * mdebugread.c (parse_symbol): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * p-typeprint.c (pascal_type_print_base): Likewise. * python/lib/gdb/printing.py (class FlagEnumerationPrinter): Use enumval. * python/lib/gdb/types.py (make_enum_dict): Likewise. * python/py-type.c (convert_field): New variable addrstring. Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. (check_types_equal): Support also FIELD_LOC_KIND_ENUMVAL. * stabsread.c (read_enum_type): Use SET_FIELD_ENUMVAL. * typepint.c (print_type_scalar): Use TYPE_FIELD_ENUMVAL for TYPE_CODE_ENUM. * valprint.c (generic_val_print): Likewise. gdb/testsuite/ PR symtab/7259: * gdb.base/enumval.c: New test case. * gdb.base/enumval.exp: New test case. * gdb.python/py-type.exp (test_enums): Use field.enumval instead of field.bitpos.
2012-04-18 08:46:47 +02:00
fprintf_filtered (stream, " = %s",
plongest (TYPE_FIELD_ENUMVAL (type, i)));
lastval = TYPE_FIELD_ENUMVAL (type, i);
}
lastval++;
}
fprintf_filtered (stream, "}");
}
break;
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
case TYPE_CODE_FLAGS:
{
struct type_print_options local_flags = *flags;
local_flags.local_typedefs = NULL;
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
c_type_print_modifier (type, stream, 0, 1, language);
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
fprintf_filtered (stream, "flag ");
print_name_maybe_canonical (type->name (), flags, stream);
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
if (show > 0)
{
fputs_filtered (" ", stream);
fprintf_filtered (stream, "{\n");
if (type->num_fields () == 0)
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
{
if (TYPE_STUB (type))
fprintfi_filtered (level + 4, stream,
Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
2019-04-03 04:00:18 +02:00
_("%p[<incomplete type>%p]\n"),
metadata_style.style ().ptr (), nullptr);
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
else
fprintfi_filtered (level + 4, stream,
Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
2019-04-03 04:00:18 +02:00
_("%p[<no data fields>%p]\n"),
metadata_style.style ().ptr (), nullptr);
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
}
len = type->num_fields ();
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
for (i = 0; i < len; i++)
{
QUIT;
print_spaces_filtered (level + 4, stream);
/* We pass "show" here and not "show - 1" to get enum types
printed. There's no other way to see them. */
c_print_type_1 (type->field (i).type (),
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
TYPE_FIELD_NAME (type, i),
stream, show, level + 4,
language, &local_flags, podata);
fprintf_filtered (stream, " @%s",
plongest (TYPE_FIELD_BITPOS (type, i)));
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
if (TYPE_FIELD_BITSIZE (type, i) > 1)
{
fprintf_filtered (stream, "-%s",
plongest (TYPE_FIELD_BITPOS (type, i)
+ TYPE_FIELD_BITSIZE (type, i)
- 1));
Extend flags to support multibit and enum bitfields. gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
2016-03-15 22:37:29 +01:00
}
fprintf_filtered (stream, ";\n");
}
fprintfi_filtered (level, stream, "}");
}
}
break;
case TYPE_CODE_VOID:
fprintf_filtered (stream, "void");
break;
case TYPE_CODE_UNDEF:
fprintf_filtered (stream, _("struct <unknown>"));
break;
case TYPE_CODE_ERROR:
fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type));
break;
case TYPE_CODE_RANGE:
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* This should not occur. */
Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
2019-04-03 04:00:18 +02:00
fprintf_styled (stream, metadata_style.style (), _("<range type>"));
break;
2003-09-11 David Carlton <carlton@kealia.com> * gdbtypes.h: Add TYPE_CODE_NAMESPACE. * gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE. (recursive_dump_type): Ditto. * printcmd.c (print_formatted): Ditto. * typeprint.c (print_type_scalar): Ditto. * c-typeprint.c (c_type_print_varspec_prefix): Ditto. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * cp-support.h: Declare cp_check_possible_namespace_symbols, maint_cplus_cmd_list. * cp-support.c: Make maint_cplus_cmd_list extern. * cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h, command.h. (lookup_symbol_file): Look in possible namespace blocks when appropriate. (initialize_namespace_symtab): New. (get_possible_namespace_block, free_namespace_block) (check_possible_namespace_symbols) (check_possible_namespace_symbols_loop) (check_one_possible_namespace_symbol) (lookup_possible_namespace_symbol, maintenance_cplus_namespace) (_initialize_cp_namespace): Ditto. * block.h: Declare allocate_block. * block.c (allocate_block): New. * jv-lang.c (get_java_class_symtab): Allocate blocks via allocate_block. * symfile.h: Update declaration of add_psymbol_to_list. * symfile.c (add_psymbol_to_list): Return the partial symbol in question. * dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to scan_partial_symbols_call. (scan_partial_symbols): Add NAMESPACE argument; update calls to helper functions. (add_partial_symbol): If necessary, scan mangled names for names of namespaces. (add_partial_namespace): Add NAMESPACE argument; generate partial symbols associated to namespaces. (add_partial_enumeration): Add NAMESPACE argument. (new_symbol): Allow namespace syms. (read_namespace): Generate namespace syms. * objfiles.h: Add opaque declaration of struct symtab. (struct objfile): Add cp_namespace_symtab member. * objfiles.c (allocate_objfile): Set objfile->cp_namespace_symtab. * Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h, dictionary_h, command_h. 2003-09-11 David Carlton <carlton@kealia.com> * gdb.c++/namespace.exp: Add tests for namespace types. * gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'. (test_namespace): New.
2003-09-11 21:49:20 +02:00
case TYPE_CODE_NAMESPACE:
fputs_filtered ("namespace ", stream);
fputs_filtered (type->name (), stream);
2003-09-11 David Carlton <carlton@kealia.com> * gdbtypes.h: Add TYPE_CODE_NAMESPACE. * gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE. (recursive_dump_type): Ditto. * printcmd.c (print_formatted): Ditto. * typeprint.c (print_type_scalar): Ditto. * c-typeprint.c (c_type_print_varspec_prefix): Ditto. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * cp-support.h: Declare cp_check_possible_namespace_symbols, maint_cplus_cmd_list. * cp-support.c: Make maint_cplus_cmd_list extern. * cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h, command.h. (lookup_symbol_file): Look in possible namespace blocks when appropriate. (initialize_namespace_symtab): New. (get_possible_namespace_block, free_namespace_block) (check_possible_namespace_symbols) (check_possible_namespace_symbols_loop) (check_one_possible_namespace_symbol) (lookup_possible_namespace_symbol, maintenance_cplus_namespace) (_initialize_cp_namespace): Ditto. * block.h: Declare allocate_block. * block.c (allocate_block): New. * jv-lang.c (get_java_class_symtab): Allocate blocks via allocate_block. * symfile.h: Update declaration of add_psymbol_to_list. * symfile.c (add_psymbol_to_list): Return the partial symbol in question. * dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to scan_partial_symbols_call. (scan_partial_symbols): Add NAMESPACE argument; update calls to helper functions. (add_partial_symbol): If necessary, scan mangled names for names of namespaces. (add_partial_namespace): Add NAMESPACE argument; generate partial symbols associated to namespaces. (add_partial_enumeration): Add NAMESPACE argument. (new_symbol): Allow namespace syms. (read_namespace): Generate namespace syms. * objfiles.h: Add opaque declaration of struct symtab. (struct objfile): Add cp_namespace_symtab member. * objfiles.c (allocate_objfile): Set objfile->cp_namespace_symtab. * Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h, dictionary_h, command_h. 2003-09-11 David Carlton <carlton@kealia.com> * gdb.c++/namespace.exp: Add tests for namespace types. * gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'. (test_namespace): New.
2003-09-11 21:49:20 +02:00
break;
default:
/* Handle types not explicitly handled by the other cases, such
as fundamental types. For these, just print whatever the
type name is, as recorded in the type itself. If there is no
type name, then complain. */
if (type->name () != NULL)
{
Add C parser support for "restrict" and "_Atomic" A user noticed that "watch -location" would fail with a "restrict" pointer. The issue here is that if the DWARF mentions "restrict", gdb will put this into the type name -- but then the C parser will not be able to parse this type. This patch adds support for "restrict" and "_Atomic" to the C parser. C++ doesn't have "restrict", but does have some GCC extensions. The type printer is changed to handle this difference as well, so that watch expressions will work properly. gdb/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * c-typeprint.c (cp_type_print_method_args): Print "__restrict__" for C++. (c_type_print_modifier): Likewise. Add "language" parameter. (c_type_print_varspec_prefix, c_type_print_base_struct_union) (c_type_print_base_1): Update. * type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New constants. * type-stack.c (type_stack::insert): Handle tp_atomic and tp_restrict. (type_stack::follow_type_instance_flags): Likewise. (type_stack::follow_types): Likewise. Merge type-following code. * c-exp.y (RESTRICT, ATOMIC): New tokens. (space_identifier, cv_with_space_id) (const_or_volatile_or_space_identifier_noopt) (const_or_volatile_or_space_identifier): Remove. (single_qualifier, qualifier_seq_noopt, qualifier_seq): New rules. (ptr_operator, typebase): Update. (enum token_flag) <FLAG_C>: New constant. (ident_tokens): Add "restrict", "__restrict__", "__restrict", and "_Atomic". (lex_one_token): Handle FLAG_C. gdb/testsuite/ChangeLog 2020-03-14 Tom Tromey <tom@tromey.com> * gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 19:11:42 +01:00
c_type_print_modifier (type, stream, 0, 1, language);
print_name_maybe_canonical (type->name (), flags, stream);
}
else
{
/* At least for dump_symtab, it is important that this not
be an error (). */
Introduce metadata style This introduces a new "metadata" style and changes many places in gdb to use it. The idea here is to let the user distinguish gdb output from output that (conceptually at least) comes directly from the inferior. The newly-styled category includes text that gdb traditionally surrounds in "<...>", like "<unavailable>". I only added a single test for this. In many cases this output is difficult to test. Also, while developing this errors in the implementation of the new printf formats showed up as regressions. gdb/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * p-lang.c (pascal_printstr): Use metadata style. * value.c (show_convenience): Use metadata style. * valprint.c (valprint_check_validity, val_print_optimized_out) (val_print_not_saved, val_print_unavailable) (val_print_invalid_address, generic_val_print, val_print) (value_check_printable, val_print_array_elements): Use metadata style. * ui-out.h (class ui_out) <field_fmt>: New overload. <do_field_fmt>: Add style parameter. * ui-out.c (ui_out::field_fmt): New overload. * typeprint.c (type_print_unknown_return_type) (val_print_not_allocated, val_print_not_associated): Use metadata style. * tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style parameter. * tui/tui-out.c (tui_ui_out::do_field_fmt): Update. * tracepoint.c (tvariables_info_1): Use metadata style. * stack.c (print_frame_arg, print_frame_info, print_frame) (info_frame_command_core): Use metadata style. * skip.c (info_skip_command): Use metadata style. * rust-lang.c (rust_print_enum): Use metadata style. * python/py-prettyprint.c (print_stack_unless_memory_error): Use metadata style. * python/py-framefilter.c (py_print_single_arg): Use metadata style. * printcmd.c (do_one_display, print_variable_and_value): Use metadata style. * p-valprint.c (pascal_val_print) (pascal_object_print_value_fields): Use metadata style. * p-typeprint.c (pascal_type_print_base): Use metadata style. * mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style parameter. * mi/mi-out.c (mi_ui_out::do_field_fmt): Update. * m2-valprint.c (m2_print_long_set): Use metadata style. * m2-typeprint.c (m2_print_type): Use metadata style. * infcmd.c (print_return_value_1): Use metadata style. * gnu-v3-abi.c (print_one_vtable): Use metadata style. * f-valprint.c (info_common_command_for_block): Use metadata style. * f-typeprint.c (f_type_print_base): Use metadata style. * expprint.c (print_subexp_standard): Use metadata style. * cp-valprint.c (cp_print_value_fields): Use metadata style. * cli/cli-style.h (class cli_style_option): Add constructor. (metadata_style): Declare. * cli/cli-style.c (metadata_style): New global. (_initialize_cli_style): Register metadata style. * cli-out.h (class cli_ui_out) <do_field_fmt>: Add style parameter. * cli-out.c (cli_ui_out::do_field_fmt): Update. * c-typeprint.c (c_type_print_base_struct_union) (c_type_print_base_1): Use metadata style. * breakpoint.c (watchpoint_value_print) (print_one_breakpoint_location): Use metadata style. * break-catch-syscall.c (print_one_catch_syscall): Use metadata style. * break-catch-sig.c (signal_catchpoint_print_one): Use metadata style. * ada-valprint.c (val_print_packed_array_elements, printstr) (print_field_values, ada_val_print_ref, ada_val_print): Use metadata style. * ada-typeprint.c (print_array_type, ada_print_type): Use metadata style. * ada-tasks.c (print_ada_task_info, info_task): Use metadata style. * ada-lang.c (user_select_syms): Use metadata style. gdb/testsuite/ChangeLog 2019-10-01 Tom Tromey <tom@tromey.com> * lib/gdb-utils.exp (style): Handle "metadata" argument. * gdb.base/style.exp: Add metadata style test.
2019-04-03 04:00:18 +02:00
fprintf_styled (stream, metadata_style.style (),
_("<invalid type code %d>"), type->code ());
}
break;
}
}
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
/* See c_type_print_base_1. */
void
c_type_print_base (struct type *type, struct ui_file *stream,
int show, int level,
const struct type_print_options *flags)
{
struct print_offset_data podata;
c_type_print_base_1 (type, stream, show, level,
current_language->la_language, flags, &podata);
Implement pahole-like 'ptype /o' option This commit implements the pahole-like '/o' option for 'ptype', which prints the offsets and sizes of struct fields, reporting whenever there is a hole found. The output is heavily based on pahole(1), with a few modifications here and there to adjust it to our reality. Here's an example: /* offset | size */ type = struct wer : public tuv { public: /* 32 | 24 */ struct tyu { /* 32:31 | 4 */ int a1 : 1; /* 32:28 | 4 */ int a2 : 3; /* 32: 5 | 4 */ int a3 : 23; /* 35: 3 | 1 */ char a4 : 2; /* XXX 3-bit hole */ /* XXX 4-byte hole */ /* 40 | 8 */ int64_t a5; /* 48:27 | 4 */ int a6 : 5; /* 48:56 | 8 */ int64_t a7 : 3; /* total size (bytes): 24 */ } a1; /* total size (bytes): 56 */ } A big part of this patch handles the formatting logic of 'ptype', which is a bit messy. The code to handle bitfield offsets, however, took some time to craft. My thanks to Pedro Alves for figuring things out and pointing me to the right direction, as well as coming up with a way to inspect the layout of structs with bitfields (see testcase for comments). After many discussions both on IRC and at the mailing list, I tried to implement printing vtables and inherited classes. Unfortunately the code grew too complex and there were still a few corner cases failing so I had to drop the attempt. This should be implemented in a future patch. This patch is the start of a long-term work I'll do to flush the local patches we carry for Fedora GDB. In this specific case, I'm aiming at upstreaming the feature implemented by the 'pahole.py' script that is shipped with Fedora GDB: <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311> This has been regression-tested on the BuildBot. There's a new testcase for it, along with an update to the documentation. I also thought it was worth mentioning this feature in the NEWS file. gdb/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/16224 * NEWS (Changes since GDB 8.0): Mention new '/o' flag. * c-typeprint.c (OFFSET_SPC_LEN): New define. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. (c_type_print_base_1): New function and prototype. (c_print_type_1): New function, with code from 'c_print_type'. (c_print_type): Use 'c_print_type_1'. (c_type_print_varspec_prefix): New argument 'struct print_offset_data *'. Use it. Call 'c_type_print_base_1' instead of 'c_print_type_base'. (print_spaces_filtered_with_print_options): New function. (output_access_specifier): Take new argument FLAGS. Modify function to call 'print_spaces_filtered_with_print_options'. (c_print_type_vtable_offset_marker): New function. (c_print_type_union_field_offset): New function. (c_print_type_struct_field_offset): New function. (c_print_type_no_offsets): New function. (c_type_print_base_struct_union): New argument 'struct print_offset_data *'. Print offsets and sizes for struct/union/class fields. * typeprint.c (const struct type_print_options type_print_raw_options): Initialize 'print_offsets'. (static struct type_print_options default_ptype_flags): Likewise. (struct print_offset_data print_offset_default_data): New variable. (whatis_exp): Handle '/o' option. (_initialize_typeprint): Add '/o' flag to ptype's help. * typeprint.h (struct print_offset_data): New struct. (struct type_print_options) <print_offsets>: New field. gdb/testsuite/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.base/ptype-offsets.cc: New file. * gdb.base/ptype-offsets.exp: New file. gdb/doc/ChangeLog: 2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/16224 * gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
}