From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23856 invoked by alias); 16 Dec 2018 05:14:47 -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 23842 invoked by uid 89); 16 Dec 2018 05:14:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Wno-narrowing, wno-narrowing, wnonarrowing, target.h X-HELO: mail-lf1-f65.google.com Received: from mail-lf1-f65.google.com (HELO mail-lf1-f65.google.com) (209.85.167.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 16 Dec 2018 05:14:43 +0000 Received: by mail-lf1-f65.google.com with SMTP id a16so7117399lfg.3 for ; Sat, 15 Dec 2018 21:14:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:reply-to:to:cc:date:in-reply-to:references :organization:user-agent:mime-version:content-transfer-encoding; bh=1wO2dc6ttXyAtUFG1ynZ5UhlJpbFTo54QIWyYyReQaA=; b=mQGHSthgqz+GpgbZSBx9pgyNwFG0wLNPoG/qo6iMXuRnqAdBZeYbPoS7HlNEeR+sAW BLgakukS4bCTub8gepjkn9I3L+fQarVdxtCm5ERTykQIFTsBOYbn0MuEcAV6fCL6/RIJ Qupp0vH1WKn27oeHDEX0H8AFQFh+z42CLm0xDZaP1MJjFUt4g6QzqGB40Ln5K/PTAVYN W+9E9pdPgA2XY9EJlbHMjpXmYMGOtS3aA8Zj8huX8mJtyWigdYXqMSYtT8WmfzVTv8oQ vFpVhCaFBR8qjrNjWsd999KZujJv5GP2HUQVsUBpEbva3CA0353mMUkfjgZ+BkYhC269 7a6g== Return-Path: Received: from G3620.lan (178-78-231-178.customers.ownit.se. [178.78.231.178]) by smtp.gmail.com with ESMTPSA id j18-v6sm1717990ljc.52.2018.12.15.21.14.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Dec 2018 21:14:39 -0800 (PST) Message-ID: <07b12fd403ec2442d90ec3f73bb9a0b99a8899e3.camel@gmail.com> Subject: Re: [PATCH] Please define thread_info as struct thread_info (and other stuff) From: Svante Signell Reply-To: svante.signell@gmail.com To: Simon Marchi , Tom Tromey Cc: gdb-patches@sourceware.org Date: Sun, 16 Dec 2018 05:14:00 -0000 In-Reply-To: References: <87tvje5rvh.fsf@tromey.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.0-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-SW-Source: 2018-12/txt/msg00179.txt.bz2 On Sat, 2018-12-15 at 23:31 -0500, Simon Marchi wrote: > On 2018-12-15 6:01 p.m., Svante Signell wrote: > > A typical error output: > > CXX target.o > > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.c: In function ‘int > > dispose_inferior(inferior*, void*)’: > > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.c:2028:16: error: ‘thread’ was not > > declared > > in this scope > > thread_info *thread = any_thread_of_inferior (inf); > > ^~~~~~ > > /home/srs/DEBs/gdb/gdb-8.2/gdb/target.c:2028:16: note: suggested > > alternative: > > ‘myread’ > > thread_info *thread = any_thread_of_inferior (inf); > > ^~~~~~ > > myread > > > > Sorry, but the compiler directive is hidden from the output (by libtool??). > > You can do "make V=1" to show the compiler invocation (same as if we would use > automake). 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;