From owner-svn-src-head@FreeBSD.ORG Wed Dec 19 16:23:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6ADD2D9F; Wed, 19 Dec 2012 16:23:22 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4F1158FC1D; Wed, 19 Dec 2012 16:23:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qBJGNMgc035527; Wed, 19 Dec 2012 16:23:22 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBJGNLrm035520; Wed, 19 Dec 2012 16:23:21 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201212191623.qBJGNLrm035520@svn.freebsd.org> From: Ed Maste Date: Wed, 19 Dec 2012 16:23:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244437 - head/contrib/gdb/gdb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2012 16:23:22 -0000 Author: emaste Date: Wed Dec 19 16:23:20 2012 New Revision: 244437 URL: http://svnweb.freebsd.org/changeset/base/244437 Log: Support restrict qualifier in dwarf debug info Newer clang/llvm emit DW_TAG_restrict_type, which wasn't handled by gdb. Import support from Apple's gdb-1822: | 2009-03-24 Jason Molenda (jmolenda@apple.com) | | * gdbtypes.c (make_cv_type): Rename this function to make_cvr_type to | also handle restrict qualifiers. | (check_typedef): Handle TYPE_RESTRICT. | * gdbtypes.h (TYPE_FLAG_RESTRICT, TYPE_RESTRICT): New. | * hpread.c (hpread_type_lookup): Update to use make_cvr_type. | * stabsread.c (read_type): Pass the restrict qualifiers along. | * parse.c (follow_types): Pass the restrict qualifiers along. | * dwarf2read.c (read_tag_const_type): Call make_cvr_type. | (read_tag_volatile_type): Same. | (read_tag_restrict_type): New function. | (read_type_die): Handle DW_TAG_restrict_type. Obtained from: Apple Sponsored by: ADARA Networks Modified: head/contrib/gdb/gdb/dwarf2read.c head/contrib/gdb/gdb/gdbtypes.c head/contrib/gdb/gdb/gdbtypes.h head/contrib/gdb/gdb/hpread.c head/contrib/gdb/gdb/parse.c head/contrib/gdb/gdb/stabsread.c Modified: head/contrib/gdb/gdb/dwarf2read.c ============================================================================== --- head/contrib/gdb/gdb/dwarf2read.c Wed Dec 19 16:22:46 2012 (r244436) +++ head/contrib/gdb/gdb/dwarf2read.c Wed Dec 19 16:23:20 2012 (r244437) @@ -834,6 +834,8 @@ static void read_tag_const_type (struct static void read_tag_volatile_type (struct die_info *, struct dwarf2_cu *); +static void read_tag_restrict_type (struct die_info *, struct dwarf2_cu *); + static void read_tag_string_type (struct die_info *, struct dwarf2_cu *); static void read_subroutine_type (struct die_info *, struct dwarf2_cu *); @@ -3729,7 +3731,8 @@ read_tag_const_type (struct die_info *di } base_type = die_type (die, cu); - die->type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0); + die->type = make_cvr_type (1, TYPE_VOLATILE (base_type), + TYPE_RESTRICT (base_type), base_type, 0); } static void @@ -3743,7 +3746,23 @@ read_tag_volatile_type (struct die_info } base_type = die_type (die, cu); - die->type = make_cv_type (TYPE_CONST (base_type), 1, base_type, 0); + die->type = make_cvr_type (TYPE_CONST (base_type), 1, + TYPE_RESTRICT (base_type), base_type, 0); +} + +static void +read_tag_restrict_type (struct die_info *die, struct dwarf2_cu *cu) +{ + struct type *base_type; + + if (die->type) + { + return; + } + + base_type = die_type (die, cu); + die->type = make_cvr_type (TYPE_CONST (base_type), TYPE_VOLATILE (base_type), + 1, base_type, 0); } /* Extract all information from a DW_TAG_string_type DIE and add to @@ -6086,6 +6105,9 @@ read_type_die (struct die_info *die, str case DW_TAG_volatile_type: read_tag_volatile_type (die, cu); break; + case DW_TAG_restrict_type: + read_tag_restrict_type (die, cu); + break; case DW_TAG_string_type: read_tag_string_type (die, cu); break; Modified: head/contrib/gdb/gdb/gdbtypes.c ============================================================================== --- head/contrib/gdb/gdb/gdbtypes.c Wed Dec 19 16:22:46 2012 (r244436) +++ head/contrib/gdb/gdb/gdbtypes.c Wed Dec 19 16:23:20 2012 (r244437) @@ -502,7 +502,8 @@ make_type_with_address_space (struct typ We allocate new memory if needed. */ struct type * -make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr) +make_cvr_type (int cnst, int voltl, int restrct, struct type *type, + struct type **typeptr) { struct type *ntype; /* New type */ struct type *tmp_type = type; /* tmp type */ @@ -517,6 +518,9 @@ make_cv_type (int cnst, int voltl, struc if (voltl) new_flags |= TYPE_FLAG_VOLATILE; + if (restrct) + new_flags |= TYPE_FLAG_RESTRICT; + if (typeptr && *typeptr != NULL) { /* Objfile is per-core-type. This const-qualified type had best @@ -1371,7 +1375,7 @@ struct type * check_typedef (struct type *type) { struct type *orig_type = type; - int is_const, is_volatile; + int is_const, is_volatile, is_restrict; while (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) { @@ -1407,6 +1411,7 @@ check_typedef (struct type *type) is_const = TYPE_CONST (type); is_volatile = TYPE_VOLATILE (type); + is_restrict = TYPE_RESTRICT (type); /* If this is a struct/class/union with no fields, then check whether a full definition exists somewhere else. This is for systems where a @@ -1424,7 +1429,7 @@ check_typedef (struct type *type) } newtype = lookup_transparent_type (name); if (newtype) - make_cv_type (is_const, is_volatile, newtype, &type); + make_cvr_type (is_const, is_volatile, is_restrict, newtype, &type); } /* Otherwise, rely on the stub flag being set for opaque/stubbed types */ else if (TYPE_STUB (type) && !currently_reading_symtab) @@ -1442,7 +1447,8 @@ check_typedef (struct type *type) } sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL); if (sym) - make_cv_type (is_const, is_volatile, SYMBOL_TYPE (sym), &type); + make_cvr_type (is_const, is_volatile, is_restrict, SYMBOL_TYPE (sym), + &type); } if (TYPE_TARGET_STUB (type)) Modified: head/contrib/gdb/gdb/gdbtypes.h ============================================================================== --- head/contrib/gdb/gdb/gdbtypes.h Wed Dec 19 16:22:46 2012 (r244436) +++ head/contrib/gdb/gdb/gdbtypes.h Wed Dec 19 16:23:20 2012 (r244437) @@ -273,6 +273,13 @@ enum type_code #define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \ & TYPE_FLAG_ADDRESS_CLASS_ALL) +/* Restrict type. If this is set, the corresponding type has a + * restrict modifier. + */ + +#define TYPE_FLAG_RESTRICT (1 << 17) +#define TYPE_RESTRICT(t) (TYPE_INSTANCE_FLAGS (t) & TYPE_FLAG_RESTRICT) + /* Array bound type. */ enum array_bound_type { @@ -1099,7 +1106,8 @@ extern struct type *lookup_reference_typ extern struct type *make_reference_type (struct type *, struct type **); -extern struct type *make_cv_type (int, int, struct type *, struct type **); +extern struct type *make_cvr_type (int, int, int, struct type *, + struct type **); extern void replace_type (struct type *, struct type *); Modified: head/contrib/gdb/gdb/hpread.c ============================================================================== --- head/contrib/gdb/gdb/hpread.c Wed Dec 19 16:22:46 2012 (r244436) +++ head/contrib/gdb/gdb/hpread.c Wed Dec 19 16:23:20 2012 (r244437) @@ -4939,8 +4939,9 @@ hpread_type_lookup (dnttpointer hp_type, * "m_void" modifiers? Is static_flag really needed here? * (m_static used for methods of classes, elsewhere). */ - tmp_type = make_cv_type (dn_bufp->dmodifier.m_const, + tmp_type = make_cvr_type (dn_bufp->dmodifier.m_const, dn_bufp->dmodifier.m_volatile, + 0, hpread_type_lookup (dn_bufp->dmodifier.type, objfile), 0); return tmp_type; Modified: head/contrib/gdb/gdb/parse.c ============================================================================== --- head/contrib/gdb/gdb/parse.c Wed Dec 19 16:22:46 2012 (r244436) +++ head/contrib/gdb/gdb/parse.c Wed Dec 19 16:23:20 2012 (r244437) @@ -1167,13 +1167,15 @@ follow_types (struct type *follow_type) case tp_end: done = 1; if (make_const) - follow_type = make_cv_type (make_const, - TYPE_VOLATILE (follow_type), - follow_type, 0); + follow_type = make_cvr_type (make_const, + TYPE_VOLATILE (follow_type), + TYPE_RESTRICT (follow_type), + follow_type, 0); if (make_volatile) - follow_type = make_cv_type (TYPE_CONST (follow_type), - make_volatile, - follow_type, 0); + follow_type = make_cvr_type (TYPE_CONST (follow_type), + make_volatile, + TYPE_RESTRICT (follow_type), + follow_type, 0); if (make_addr_space) follow_type = make_type_with_address_space (follow_type, make_addr_space); @@ -1192,13 +1194,15 @@ follow_types (struct type *follow_type) case tp_pointer: follow_type = lookup_pointer_type (follow_type); if (make_const) - follow_type = make_cv_type (make_const, - TYPE_VOLATILE (follow_type), - follow_type, 0); + follow_type = make_cvr_type (make_const, + TYPE_VOLATILE (follow_type), + TYPE_RESTRICT (follow_type), + follow_type, 0); if (make_volatile) - follow_type = make_cv_type (TYPE_CONST (follow_type), - make_volatile, - follow_type, 0); + follow_type = make_cvr_type (TYPE_CONST (follow_type), + make_volatile, + TYPE_RESTRICT (follow_type), + follow_type, 0); if (make_addr_space) follow_type = make_type_with_address_space (follow_type, make_addr_space); @@ -1208,13 +1212,15 @@ follow_types (struct type *follow_type) case tp_reference: follow_type = lookup_reference_type (follow_type); if (make_const) - follow_type = make_cv_type (make_const, - TYPE_VOLATILE (follow_type), - follow_type, 0); + follow_type = make_cvr_type (make_const, + TYPE_VOLATILE (follow_type), + TYPE_RESTRICT (follow_type), + follow_type, 0); if (make_volatile) - follow_type = make_cv_type (TYPE_CONST (follow_type), - make_volatile, - follow_type, 0); + follow_type = make_cvr_type (TYPE_CONST (follow_type), + make_volatile, + TYPE_RESTRICT (follow_type), + follow_type, 0); if (make_addr_space) follow_type = make_type_with_address_space (follow_type, make_addr_space); Modified: head/contrib/gdb/gdb/stabsread.c ============================================================================== --- head/contrib/gdb/gdb/stabsread.c Wed Dec 19 16:22:46 2012 (r244436) +++ head/contrib/gdb/gdb/stabsread.c Wed Dec 19 16:23:20 2012 (r244437) @@ -1750,13 +1750,13 @@ again: case 'k': /* Const qualifier on some type (Sun) */ type = read_type (pp, objfile); - type = make_cv_type (1, TYPE_VOLATILE (type), type, + type = make_cvr_type (1, TYPE_VOLATILE (type), TYPE_RESTRICT(type), type, dbx_lookup_type (typenums)); break; case 'B': /* Volatile qual on some type (Sun) */ type = read_type (pp, objfile); - type = make_cv_type (TYPE_CONST (type), 1, type, + type = make_cvr_type (TYPE_CONST (type), 1, TYPE_RESTRICT(type), type, dbx_lookup_type (typenums)); break;