[Converted from Gnats 154] GDB truncates 64 bit enums. http://sources.redhat.com/ml/gdb-patches/2000-06/msg00290.html This is a duplicate of gdb/352 Here is the info: The following program: enum e {I, J=(unsigned)0xffffffff} e = J; void dummy() {} main() { dummy(); } will cause gdb to get confused when asked to print the value of 'e': (gdb) p e $1 = <error type> (gdb) p &e $2 = (<unknown type> *) 0x30ac (gdb) maint print type e type node 0x1bf480 name '<unknown type>' (0x242fc) tagname 'e' (0x2026b0) code 0xe (TYPE_CODE_ERROR) length 0 upper_bound_type 0x0 (BOUND_SIMPLE) lower_bound_type 0x0 (BOUND_SIMPLE) objfile 0x0 target_type 0x0 pointer_type 0x0 reference_type 0x0 cv_type 0x1bf480 as_type 0x1bf480 flags 0x0 nfields 0 0x0 vptr_basetype 0x0 vptr_fieldno -1 type_specific 0x0 See also gdb/779 and the info in there. Release: unknown
From: Kevin Nomura <nomura@netapp.com> To: gdb-gnats@sources.redhat.com Cc: Subject: Re: symtab/154: GDB truncates 64 bit enums. Date: Mon, 13 Sep 2004 15:10:40 -0700 gdb 6.2 with gcc 3.4.1 still has problems with enum values wider than an int. gdb crashes can occur when stabsread.c:read_enum_type returns "error_type" n = read_huge_number (pp, ',', &nbits); if (nbits != 0) return error_type (pp, objfile); which engenders a NULL type field in the symtab. Anyway this is an old problem report so I am sure you are aware of the symptoms. I have tinkered with working around this in 6.2 by expanding "ivalue" to a LONGEST in symtab.h:struct general_symbol_info: union { /* The fact that this is a long not a LONGEST mainly limits the range of a LOC_CONST. Since LOC_CONST_BYTES exists, I'm not sure that is a big deal. */ int ivalue; and expanding "bitpos" to a LONGEST in gdbtypes.h:struct main_type: struct field { union field_location { /* Position of this field, counting in bits from start of containing structure. For BITS_BIG_ENDIAN=1 targets, it is the bit offset to the MSB. For BITS_BIG_ENDIAN=0 targets, it is the bit offset to the LSB. For a range bound or enum value, this is the value itself. */ LONGEST bitpos; and providing a version of stabsread.c:read_huge_number, which allows 64 bit integers, for read_enum_type to call. gdb seems happy with this to a first approximation. The segfault is gone, the values display properly with "p" and "ptype". However I've clearly tweaked some global data structures. Warnings about typecasts of 64-bit ints to 32-bit pointers, and warnings about printfs being passed a 64-bit int to a %d format, pop out here and there, unrelated to enum code. Is this the right approach, and a straightforward cleanup will address the warnings and be internally consistent?
CVSROOT: /cvs/src Module name: src Changes by: jkratoch@sourceware.org 2012-04-18 06:46:47 Modified files: gdb : ChangeLog ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c c-typeprint.c coffread.c dwarf2read.c gdb-gdb.py gdbtypes.c gdbtypes.h m2-typeprint.c mdebugread.c p-typeprint.c stabsread.c typeprint.c valprint.c gdb/python : py-type.c gdb/python/lib/gdb: printing.py types.py gdb/testsuite : ChangeLog gdb/testsuite/gdb.python: py-type.exp Log message: 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. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.14122&r2=1.14123 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ada-exp.y.diff?cvsroot=src&r1=1.49&r2=1.50 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ada-lang.c.diff?cvsroot=src&r1=1.364&r2=1.365 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ada-typeprint.c.diff?cvsroot=src&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ada-valprint.c.diff?cvsroot=src&r1=1.90&r2=1.91 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/c-typeprint.c.diff?cvsroot=src&r1=1.73&r2=1.74 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/coffread.c.diff?cvsroot=src&r1=1.126&r2=1.127 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.635&r2=1.636 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/gdb-gdb.py.diff?cvsroot=src&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/gdbtypes.c.diff?cvsroot=src&r1=1.228&r2=1.229 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/gdbtypes.h.diff?cvsroot=src&r1=1.164&r2=1.165 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/m2-typeprint.c.diff?cvsroot=src&r1=1.29&r2=1.30 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/mdebugread.c.diff?cvsroot=src&r1=1.129&r2=1.130 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/p-typeprint.c.diff?cvsroot=src&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/stabsread.c.diff?cvsroot=src&r1=1.146&r2=1.147 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/typeprint.c.diff?cvsroot=src&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/valprint.c.diff?cvsroot=src&r1=1.122&r2=1.123 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-type.c.diff?cvsroot=src&r1=1.36&r2=1.37 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/lib/gdb/printing.py.diff?cvsroot=src&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/lib/gdb/types.py.diff?cvsroot=src&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3166&r2=1.3167 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-type.exp.diff?cvsroot=src&r1=1.21&r2=1.22
CVSROOT: /cvs/src Module name: src Changes by: jkratoch@sourceware.org 2012-04-18 06:51:05 Added files: gdb/testsuite/gdb.base: enumval.c enumval.exp Log message: Forgotten commit for: gdb/testsuite/ PR symtab/7259: * gdb.base/enumval.c: New test case. * gdb.base/enumval.exp: New test case. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/enumval.c.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/enumval.exp.diff?cvsroot=src&r1=NONE&r2=1.1
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "gdb and binutils". The branch, master has been updated via 0809504b5eca5e73ad721919b6b13d941ffd0a30 (commit) from edef60002fc0c8d1bda6b5deb03c84d2733a32ba (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0809504b5eca5e73ad721919b6b13d941ffd0a30 commit 0809504b5eca5e73ad721919b6b13d941ffd0a30 Author: Joel Brobecker <brobecker@adacore.com> Date: Mon Dec 23 11:15:42 2013 +0400 Fix gdb.Field attributes documentation for enum types. The following patch ... | commit 14e75d8ea4fe9ed4dbf292ae4a9745e33e2ff353 | Date: Wed Apr 18 06:46:47 2012 +0000 | | gdb/ | PR symtab/7259: | [...] ... discussed under ... [PATCH] Allow 64-bit enum values http://www.sourceware.org/ml/gdb-patches/2012-03/msg00772.html ... introduced a change in the gdb.Fields API without documenting it: | I took a separate approach from the one I took in: | | http://sourceware.org/ml/gdb-patches/2012-02/msg00403.html | | and removed the overloaded meaning of the bitpos location variable to | fix PR symtab/7259. In the following patch, I introduce a separate | field_location union member 'enumval' which can accept LONGEST and | hence expand enum values to 64-bit signed values. With this change, | bitpos now only is used for (non-negative) offsets into structures, | since the other overload of bitpos (range bounds) were already | separated into struct range_bound. This patch updates the documentation to reflect that change. gdb/doc/ChangeLog: * gdb.texinfo (Types In Python): Fix the documentation of attribute "bitpos" in class gdb.Field for enum types. Add documentation for attribute "enumval" in that same class. ----------------------------------------------------------------------- Summary of changes: gdb/doc/ChangeLog | 6 ++++++ gdb/doc/gdb.texinfo | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-)
Already checked in.