From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8320 invoked by alias); 16 Dec 2018 06:02:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 8281 invoked by uid 89); 16 Dec 2018 06:02:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 16 Dec 2018 06:02:06 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 670141E093; Sun, 16 Dec 2018 01:02:04 -0500 (EST) Subject: Re: [PATCH] Please define thread_info as struct thread_info (and other stuff) To: svante.signell@gmail.com, Tom Tromey Cc: gdb-patches@sourceware.org References: <87tvje5rvh.fsf@tromey.com> <07b12fd403ec2442d90ec3f73bb9a0b99a8899e3.camel@gmail.com> From: Simon Marchi Message-ID: <4a6c6720-8c39-6d36-773d-2973798f134e@simark.ca> Date: Sun, 16 Dec 2018 06:02:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: <07b12fd403ec2442d90ec3f73bb9a0b99a8899e3.camel@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2018-12/txt/msg00180.txt.bz2 On 2018-12-16 12:15 a.m., Svante Signell wrote: > Here is an example output with make make V=1 -C build/objdir/gdb/ elfread.o > > i686-gnu-g++ -x c++ -g -O2 -fdebug-prefix-map=/home/srs/DEBs/gdb/gdb-8.2=. > -fstack-protector-strong -Wformat -Werror=format-security -D_GNU_SOURCE -I. > -I/home/srs/DEBs/gdb/gdb-8.2/gdb -I/home/srs/DEBs/gdb/gdb-8.2/gdb/common > -I/home/srs/DEBs/gdb/gdb-8.2/gdb/config -DLOCALEDIR="\"/usr/share/locale\"" > -DHAVE_CONFIG_H -I/home/srs/DEBs/gdb/gdb-8.2/gdb/../include/opcode > -I/home/srs/DEBs/gdb/gdb-8.2/gdb/../opcodes/.. -I../bfd > -I/home/srs/DEBs/gdb/gdb-8.2/gdb/../bfd -I/home/srs/DEBs/gdb/gdb- > 8.2/gdb/../include -I../libdecnumber -I/home/srs/DEBs/gdb/gdb- > 8.2/gdb/../libdecnumber -I/home/srs/DEBs/gdb/gdb-8.2/gdb/gnulib/import -Ibuild- > gnulib/import -DTUI=1 -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC - > I/usr/include/python3.7m -I/usr/include/python3.7m -Wall -Wpointer-arith -Wno- > unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts > -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign- > compare -Wno-narrowing -Wno-error=maybe-uninitialized -Wsuggest-override > -Wimplicit-fallthrough=3 -Wduplicated-cond -Wformat-nonliteral -c -o elfread.o > -MT elfread.o -MMD -MP -MF ./.deps/elfread.Tpo /home/srs/DEBs/gdb/gdb- > 8.2/gdb/elfread.c > In file included from ./nm.h:25, > from /home/srs/DEBs/gdb/gdb-8.2/gdb/defs.h:420, > from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:22: > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:46: warning: ‘get_thread_regcache’ > initialized and declared ‘extern’ > extern struct regcache *get_thread_regcache (thread_info *thread); > ^~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:46: error: ‘regcache* > get_thread_regcache’ redeclared as different kind of symbol > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:32:25: note: previous declaration > ‘regcache* get_thread_regcache(ptid_t)’ > extern struct regcache *get_thread_regcache (ptid_t ptid); > ^~~~~~~~~~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:59: error: ‘thread’ was not > declared in this scope > extern struct regcache *get_thread_regcache (thread_info *thread); > ^~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:35:59: note: suggested alternative: > ‘thread_t’ > extern struct regcache *get_thread_regcache (thread_info *thread); > ^~~~~~ > thread_t > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:144:14: error: ‘function_view’ in > namespace ‘gdb’ does not name a template type > typedef gdb::function_view > ^~~~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:228:14: error: ‘register_read_ftype’ > has not been declared > void save (register_read_ftype cooked_read); > ^~~~~~~~~~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:422:49: error: ‘register_read_ftype’ > has not been declared > readonly_detached_regcache (gdbarch *gdbarch, register_read_ftype > cooked_read) > ^~~~~~~~~~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:439:39: error: variable or field > ‘registers_changed_thread’ declared void > extern void registers_changed_thread (thread_info *thread); > ^~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:439:52: error: ‘thread’ was not > declared in this scope > extern void registers_changed_thread (thread_info *thread); > ^~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/regcache.h:439:52: note: suggested alternative: > ‘thread_t’ > extern void registers_changed_thread (thread_info *thread); > ^~~~~~ > thread_t > In file included from /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:44, > from /home/srs/DEBs/gdb/gdb-8.2/gdb/progspace.h:24, > from /home/srs/DEBs/gdb/gdb-8.2/gdb/objfiles.h:27, > from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:30: > /home/srs/DEBs/gdb/gdb-8.2/gdb/breakpoint.h:950:21: error: ‘thread_info’ is not > a type > CORE_ADDR pc, thread_info *thread, > ^~~~~~~~~~~ > In file included from /home/srs/DEBs/gdb/gdb-8.2/gdb/progspace.h:24, > from /home/srs/DEBs/gdb/gdb-8.2/gdb/objfiles.h:27, > from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:30: > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:652:44: error: ‘extra_thread_info’ > declared as a ‘virtual’ field > virtual const char *extra_thread_info (thread_info *) > ^~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:652:25: error: expected ‘;’ at end of > member declaration > virtual const char *extra_thread_info (thread_info *) > ^~~~~~~~~~~~~~~~~ > ; > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:652:55: error: expected ‘)’ before ‘*’ > token > virtual const char *extra_thread_info (thread_info *) > ~ ^~ > ) > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:654:38: error: ‘thread_name’ declared as > a ‘virtual’ field > virtual const char *thread_name (thread_info *) > ^~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:654:25: error: expected ‘;’ at end of > member declaration > virtual const char *thread_name (thread_info *) > ^~~~~~~~~~~ > ; > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:654:49: error: expected ‘)’ before ‘*’ > token > virtual const char *thread_name (thread_info *) > ~ ^~ > ) > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.h:656:13: error: ‘thread_info’ does not > name a type > virtual thread_info *thread_handle_to_thread_info (const gdb_byte *, > ^~~~~~~~~~~ > In file included from /home/srs/DEBs/gdb/gdb-8.2/gdb/infcall.h:23, > from /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:42: > /home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:38:10: error: ‘thread_info’ is not > a type > thread_info *thread); > ^~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:49:49: error: ‘thread_info’ is not > a type > extern void dummy_frame_pop (frame_id dummy_id, thread_info *thread); > ^~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:51:53: error: ‘thread_info’ is not > a type > extern void dummy_frame_discard (frame_id dummy_id, thread_info *thread); > ^~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/dummy-frame.h:67:12: error: ‘thread_info’ is not > a type > thread_info *thread, > ^~~~~~~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c: In function ‘void > elf_gnu_ifunc_resolver_return_stop(breakpoint*)’: > /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:975:16: error: ‘thread’ was not > declared in this scope > thread_info *thread = inferior_thread (); > ^~~~~~ > /home/srs/DEBs/gdb/gdb-8.2/gdb/elfread.c:975:16: note: suggested alternative: > ‘myread’ > thread_info *thread = inferior_thread (); > ^~~~~~ > myread > Makefile:1651: recipe for target 'elfread.o' failed > make: *** [elfread.o] Error 1 > > In gdb/regcache.h we have: > extern struct regcache *get_thread_regcache (ptid_t ptid); > extern struct regcache *get_thread_regcache (struct thread_info *thread); > >> What you compiler is doing is very strange, as Tom mentioned the use of the >> "struct" or "class" keyword when declaring a variable in C++ is >> optional. What does your >> compiler say when compiling the following code (g++ -c foo.cpp)? >> >> struct Foo >> { >> int a; >> }; >> >> void func() >> { >> Foo f2; >> } > > g++ -c -Wall foo.cpp > foo.cpp: In function ‘void func()’: > foo.cpp:8:13: warning: unused variable ‘f2’ [-Wunused-variable] > Foo f2; > > Sorry, I don't have anything to add, except that it looks like a compiler problem. I'm compiling the same code with the same compiler version (gcc 8.2), so I'm at lost here. I'd try to reduce to a minimal reproducer to try to understand the problem better... Simon