Bug 26029

Summary: GDB build failure on SPARC
Product: gdb Reporter: Joel Brobecker <brobecker>
Component: buildAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: amodra, simark
Priority: P2    
Version: 9.1   
Target Milestone: 9.2   
Host: Target:
Build: Last reconfirmed:

Description Joel Brobecker 2020-05-23 16:18:22 UTC
The following error was reported by a user:

<<
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
>>
Comment 1 Sourceware Commits 2020-05-23 16:23:29 UTC
The gdb-9-branch branch has been updated by Joel Brobecker <brobecke@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c4997f6072e77371faa5a35b7a58c34ccbe290ce

commit c4997f6072e77371faa5a35b7a58c34ccbe290ce
Author: Christian Biesinger <cbiesinger@google.com>
Date:   Wed Feb 5 11:43:22 2020 -0600

    Fix base class function call
    
    This was a typo introduced in f6ac5f3d63e03a81c4ff3749aba234961cc9090e.
    
    Found by looking through NetBSD's GDB patches:
    https://github.com/NetBSD/pkgsrc-wip/blob/master/gdb-netbsd/patches/patch-gdb_sparc-nat.h
    
    This patch can't be tested on Linux because Linux does not use the
    sparc_target template.
    
    gdb/ChangeLog:
    
    2020-05-23  Christian Biesinger  <cbiesinger@google.com>
    
            PR gdb/26029:
            * sparc-nat.h (struct sparc_target) <xfer_partial>: Fix base class
            function call.
    
    Change-Id: I4fa88cbdc365efe89b84cc0619b60db38718d9ce
    (cherry picked from commit c6a42d11acf2d485bf70d76eda76fd005fcd6825)
Comment 2 Joel Brobecker 2020-05-23 16:26:28 UTC
Note that the same patch than the one recorded as being pushed to branch "gdb-9-branch" was actually pushed to branch "master"on Feb 5th, 2020 (before this PR was created):

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c6a42d11acf2d485bf70d76eda76fd005fcd6825
Comment 3 Sourceware Commits 2020-06-03 08:42:26 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0ed18fa177858d67fec42babbca3fef4ae1d939f

commit 0ed18fa177858d67fec42babbca3fef4ae1d939f
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Jun 3 15:33:01 2020 +0930

    PR26069, strip/objcopy memory leaks
    
            PR 26029
            * elf.c (_bfd_elf_close_and_cleanup): Free elf_shstrtab for
            core files as well as objects.
Comment 4 Simon Marchi 2020-06-03 13:44:19 UTC
Alan, there's a typo in the bug number in that ChangeLog entry.