Bug 27219 - remote.c compilation failure on CentOS 7
Summary: remote.c compilation failure on CentOS 7
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: remote (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-20 16:39 UTC by Joel Sherrill
Modified: 2021-01-21 01:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Patch to address naming conflict in remote.c (998 bytes, application/mbox)
2021-01-20 16:39 UTC, Joel Sherrill
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joel Sherrill 2021-01-20 16:39:52 UTC
Created attachment 13140 [details]
Patch to address naming conflict in remote.c

Per https://sourceware.org/pipermail/gdb-patches/2021-January/175167.html, gdb/remote.c fails to compile on CentOS 7. The compilation error is because an enum and method have the same name. Per a suggestion in the thread, I renamed the method resume_state() to get_resume_start(). Hopefully the name is OK. I just went with the most obvious choice to me. This is in the attached patch.

Here is the error as reported by Sebastian Huber:

there could be a problem with this "enum class" on CentOS 7.9:

../../sourceware-mirror-binutils-gdb-edf0f28/gdb/remote.c:1157:38: error: 'resume_state' is not a class, namespace, or enumeration
    enum resume_state m_resume_state = resume_state::NOT_RESUMED;
                                       ^
../../sourceware-mirror-binutils-gdb-edf0f28/gdb/remote.c: In member function 'void remote_thread_info::set_not_resumed()':
../../sourceware-mirror-binutils-gdb-edf0f28/gdb/remote.c:1115:22: error: 'resume_state' is not a class, namespace, or enumeration
      m_resume_state = resume_state::NOT_RESUMED;
                       ^
../../sourceware-mirror-binutils-gdb-edf0f28/gdb/remote.c: In member function 'void remote_thread_info::set_resumed_pending_vcont(bool, gdb_signal)':
../../sourceware-mirror-binutils-gdb-edf0f28/gdb/remote.c:1121:22: error: 'resume_state' is not a class, namespace, or enumeration
      m_resume_state = resume_state::RESUMED_PENDING_VCONT;
                       ^
In file included from ../../sourceware-mirror-binutils-gdb-edf0f28/gdb/../gdbsupport/gdb_string_view.h:49:0,
                  from ../../sourceware-mirror-binutils-gdb-edf0f28/gdb/../gdbsupport/common-utils.h:46,
                  from ../../sourceware-mirror-binutils-gdb-edf0f28/gdb/../gdbsupport/common-defs.h:125,
                  from ../../sourceware-mirror-binutils-gdb-edf0f28/gdb/defs.h:28,
                  from ../../sourceware-mirror-binutils-gdb-edf0f28/gdb/remote.c:22:
../../sourceware-mirror-binutils-gdb-edf0f28/gdb/remote.c: In member function 'const resumed_pending_vcont_info& remote_thread_info::resumed_pending_vcont_info() const':
../../sourceware-mirror-binutils-gdb-edf0f28/gdb/remote.c:1132:35: error: 'resume_state' is not a class, namespace, or enumeration
      gdb_assert (m_resume_state == resume_state::RESUMED_PENDING_VCONT);
                                    ^
../../sourceware-mirror-binutils-gdb-edf0f28/gdb/../gdbsupport/gdb_assert.h:35:13: note: in definition of macro 'gdb_assert'
    ((void) ((expr) ? 0 :                                                       \
              ^
../../sourceware-mirror-binutils-gdb-edf0f28/gdb/remote.c: In member function 'void remote_thread_info::set_resumed()':
../../sourceware-mirror-binutils-gdb-edf0f28/gdb/remote.c:1140:22: error: 'resume_state' is not a class, namespace, or enumeration
      m_resume_state = resume_state::RESUMED;
                       ^
Comment 1 Sourceware Commits 2021-01-21 01:41:05 UTC
The master branch has been updated by Simon Marchi <simark@sourceware.org>:

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

commit a6c11cbb14cea4900a97f8cb20762fefec6fda54
Author: Joel Sherrill <joel@rtems.org>
Date:   Wed Jan 20 20:38:57 2021 -0500

    gdb/remote.c: address conflicting enum and method name
    
    When building with gcc 4.8, we get:
    
          CXX    remote.o
        cc1plus: warning: command line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++ [enabled by default]
        /home/smarchi/src/binutils-gdb/gdb/remote.c:1157:38: error: 'resume_state' is not a class, namespace, or enumeration
           enum resume_state m_resume_state = resume_state::NOT_RESUMED;
                                              ^
    
    It looks like gcc 4.8 doesn't like that there is an enum class named
    resume_state as well as a method.  Since it's an easy fix, rename the method to
    get_remote_state to avoid the clash.
    
    gdb/ChangeLog:
    
            PR gdb/27219
            * remote.c (struct remote_thread_info) <resume_state>: Rename
            to...
            <get_resume_state>: ... this.
            (remote_target::resume): Adjust.
            (remote_target::commit_resume): Adjust.
            (remote_target::select_thread_for_ambiguous_stop_reply): Adjust.
    
    Change-Id: Ib86c877a4c75ee671d69c27ed06cb8f57bc087db
Comment 2 Simon Marchi 2021-01-21 01:44:28 UTC
Fixed.