From patchwork Fri May 15 08:21:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: asmwarrior X-Patchwork-Id: 6733 Received: (qmail 130217 invoked by alias); 15 May 2015 08:13:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 130205 invoked by uid 89); 15 May 2015 08:13:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f174.google.com Received: from mail-ob0-f174.google.com (HELO mail-ob0-f174.google.com) (209.85.214.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 15 May 2015 08:13:41 +0000 Received: by obfe9 with SMTP id e9so72822560obf.1 for ; Fri, 15 May 2015 01:13:39 -0700 (PDT) X-Received: by 10.202.74.71 with SMTP id x68mr5881196oia.93.1431677619118; Fri, 15 May 2015 01:13:39 -0700 (PDT) Received: from [0.0.0.0] (li925-193.members.linode.com. [45.56.75.193]) by mx.google.com with ESMTPSA id sj5sm485035oeb.13.2015.05.15.01.13.35 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 May 2015 01:13:38 -0700 (PDT) Message-ID: <5555AC9F.7020206@gmail.com> Date: Fri, 15 May 2015 16:21:51 +0800 From: asmwarrior User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Pedro Alves , GDB Patches Subject: Re: [all pushed] Re: [PATCH 00/36] Support building GDB as a C++ program References: <1423524046-20605-1-git-send-email-palves@redhat.com> <54F0B52F.1050909@redhat.com> <54FB20E2.2040403@redhat.com> <54FB3C58.6050702@redhat.com> <550660C5.2060009@gmail.com> <5506661C.1040103@gmail.com> <5506C18C.9080408@redhat.com> In-Reply-To: <5506C18C.9080408@redhat.com> Hi, Pedro, I just found another build issue when building gdb under g++. Building mingw GDB with --enable-build-with-cxx shows: ../../binutils-gdb/gdb/python/py-unwind.c:500:45: error: cannot convert 'cached_frame_info::reg_info*' to 'pyuw_prev_register(frame_info*, void**, int)::reg_info*' in initialization struct reg_info *reg_info = cached_frame->reg; ^ ../../binutils-gdb/gdb/python/py-unwind.c:501:60: error: invalid use of incomplete type 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info' struct reg_info *reg_info_end = reg_info + cached_frame->reg_count; ^ ../../binutils-gdb/gdb/python/py-unwind.c:500:10: error: forward declaration of 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info' struct reg_info *reg_info = cached_frame->reg; ^ ../../binutils-gdb/gdb/python/py-unwind.c:505:37: error: cannot increment a pointer to incomplete type 'pyuw_prev_register(frame_info*, void**, int)::reg_info' for (; reg_info < reg_info_end; ++reg_info) ^ ../../binutils-gdb/gdb/python/py-unwind.c:507:29: error: invalid use of incomplete type 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info' if (regnum == reg_info->number) ^ ../../binutils-gdb/gdb/python/py-unwind.c:500:10: error: forward declaration of 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info' struct reg_info *reg_info = cached_frame->reg; ^ ../../binutils-gdb/gdb/python/py-unwind.c:508:68: error: invalid use of incomplete type 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info' return frame_unwind_got_bytes (this_frame, regnum, reg_info->data); ^ ../../binutils-gdb/gdb/python/py-unwind.c:500:10: error: forward declaration of 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info' struct reg_info *reg_info = cached_frame->reg; ^ ../../binutils-gdb/gdb/python/py-unwind.c: In function 'int pyuw_sniffer(const frame_unwind*, frame_info*, void**)': ../../binutils-gdb/gdb/python/py-unwind.c:574:70: warning: invalid conversion from 'void*' to 'cached_frame_info*' [-fpermissive] reg_count * sizeof (cached_frame->reg[0])); ^ ../../binutils-gdb/gdb/python/py-unwind.c: In function 'void pyuw_on_new_gdbarch(gdbarch*)': ../../binutils-gdb/gdb/python/py-unwind.c:636:47: warning: invalid conversion from 'void*' to 'pyuw_gdbarch_data_type*' [-fpermissive] gdbarch_data (newarch, pyuw_gdbarch_data); ^ ../../binutils-gdb/gdb/python/py-unwind.c:647:29: warning: invalid conversion from 'void*' to 'const frame_data*' [-fpermissive] unwinder->unwind_data = (void *) newarch; ^ ../../binutils-gdb/gdb/python/py-unwind.c: At global scope: ../../binutils-gdb/gdb/python/py-unwind.c:699:21: error: redefinition of 'PyTypeObject pending_frame_object_type' static PyTypeObject pending_frame_object_type = ^ ../../binutils-gdb/gdb/python/py-unwind.c:96:21: error: 'PyTypeObject pending_frame_object_type' previously declared here static PyTypeObject pending_frame_object_type ^ ../../binutils-gdb/gdb/python/py-unwind.c:749:21: error: redefinition of 'PyTypeObject unwind_info_object_type' static PyTypeObject unwind_info_object_type = ^ ../../binutils-gdb/gdb/python/py-unwind.c:99:21: error: 'PyTypeObject unwind_info_object_type' previously declared here static PyTypeObject unwind_info_object_type ^ The first kind of error is caused by embedded struct definition, so I moved it out of the parent struct. The second kind of error is caused by using static keyword on a CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF decoreated variable, I see that all other files use extern, so I changed to extern. Here is the patch: 43f2422c2dea00287eff57bd2b3aaa478e6de88d gdb/python/py-unwind.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index bcfea4b..10b5731 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -72,6 +72,15 @@ typedef struct /* The data we keep for a frame we can unwind: frame ID and an array of (register_number, register_value) pairs. */ +struct reg_info +{ + /* Register number. */ + int number; + + /* Register data bytes pointer. */ + gdb_byte data[MAX_REGISTER_SIZE]; +}; + typedef struct { /* Frame ID. */ @@ -83,20 +92,13 @@ typedef struct /* Length of the `reg' array below. */ int reg_count; - struct reg_info - { - /* Register number. */ - int number; - - /* Register data bytes pointer. */ - gdb_byte data[MAX_REGISTER_SIZE]; - } reg[]; + struct reg_info reg[]; } cached_frame_info; -static PyTypeObject pending_frame_object_type +extern PyTypeObject pending_frame_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pending_frame_object"); -static PyTypeObject unwind_info_object_type +extern PyTypeObject unwind_info_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("unwind_info_object"); static unsigned int pyuw_debug = 0;