Re: gdb-9.1 Fails to build: "invalid cast to abstract class type"

Simon Marchi <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On 2020-05-20 2:24 p.m., Chris Nicol wrote:
> Hello,
> 
> I am trying to build a new version of the debugger on a SunBlade 100 running FreeBSD 12.1. This build fails with the following complaint:
> 
>   CXX    sparc64-fbsd-nat.o
> In file included from ../../gdb/sparc64-fbsd-nat.c:26:
> ../../gdb/sparc-nat.h: In instantiation of 'target_xfer_status sparc_target<BaseTarget>::xfer_partial(target_object, const char*, gdb_byte*, const gdb_byte*, ULONGEST, ULONGEST, ULONGEST*) [with BaseTarget = fbsd_nat_target; gdb_byte = unsigned char; ULONGEST = long unsigned int]':
> ../../gdb/sparc-nat.h:67:27:   required from here
> ../../gdb/sparc-nat.h:78:12: error: invalid cast to abstract class type 'fbsd_nat_target'
>    78 |     return BaseTarget (object, annex, readbuf, writebuf,
>       |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    79 |          offset, len, xfered_len);
>       |          ~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from ../../gdb/sparc64-fbsd-nat.c:24:
> ../../gdb/fbsd-nat.h:36:7: note:   because the following virtual functions are pure within 'fbsd_nat_target':
>    36 | class fbsd_nat_target : public inf_ptrace_target
>       |       ^~~~~~~~~~~~~~~
> In file included from ../../gdb/inf-ptrace.h:23,
>                  from ../../gdb/fbsd-nat.h:23,
>                  from ../../gdb/sparc64-fbsd-nat.c:24:
> ../../gdb/inf-child.h:42:8: note:     'virtual void inf_child_target::fetch_registers(regcache*, int)'
>    42 |   void fetch_registers (struct regcache *, int) override = 0;
>       |        ^~~~~~~~~~~~~~~
> ../../gdb/inf-child.h:43:8: note:     'virtual void inf_child_target::store_registers(regcache*, int)'
>    43 |   void store_registers (struct regcache *, int) override = 0;
>       |        ^~~~~~~~~~~~~~~
> gmake[2]: *** [Makefile:1656: sparc64-fbsd-nat.o] Error 1
> gmake[2]: Leaving directory '/usr/home/nicolc/gdb/gdb-9.1/build/gdb'
> gmake[1]: *** [Makefile:9563: all-gdb] Error 2
> gmake[1]: Leaving directory '/usr/home/nicolc/gdb/gdb-9.1/build'
> gmake: *** [Makefile:851: all] Error 2
> 
> 
> Can anyone provide insight into what is going on here, please? Thank you.
> 
> Chris.
> -- 
> ______________________________________________________________________
> 

This has been fixed by this commit:

  https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c6a42d11acf2d485bf70d76eda76fd005fcd6825

So if you use the master branch, you shouldn't see this error.

GDB 9.2 (the bugfix release of 9.1) will be out soon, we could probably
cherry-pick that commit in that branch if that helps you.

Simon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.