This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Please define thread_info as struct thread_info (and other stuff)
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<register_status (int regnum, gdb_byte *buf)>
> ^~~~~~~~~~~~~
> /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