ROCm / ROCdbgapi

The AMD Debugger API is a library that provides all the support necessary for a debugger and other tools to perform low level control of the execution and inspection of execution state of AMD's commercially available GPU architectures.
https://rocm.docs.amd.com/projects/ROCdbgapi/en/latest/
MIT License
19 stars 15 forks source link

[build error] numeric limits not a member of std with GCC 11 #3

Closed tpkessler closed 4 months ago

tpkessler commented 2 years ago

When building ROCdbgapi with GCC 11 the following errors occur:

/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp: In constructor ‘amd::dbgapi::watchpoint_t::watchpoint_t(amd_dbgapi_watchpoint_id_t, amd::dbgapi::process_t&, amd_dbgapi_global_address_t, amd_dbgapi_size_t, amd_dbgapi_watchpoint_kind_t)’:
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:101:10: error: ‘numeric_limits’ is not a member of ‘std’
  101 |     std::numeric_limits<decltype (programmable_mask_bits)>::max ()
      |          ^~~~~~~~~~~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:101:25: error: expected primary-expression before ‘decltype’
  101 |     std::numeric_limits<decltype (programmable_mask_bits)>::max ()
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:101:25: error: expected ‘}’ before ‘decltype’
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:100:53: note: to match this ‘{’
  100 |   amd_dbgapi_global_address_t programmable_mask_bits{
      |                                                     ^
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:94:31: error: unused variable ‘stable_bits’ [-Werror=unused-variable]
   94 |   amd_dbgapi_global_address_t stable_bits
      |                               ^~~~~~~~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp: At global scope:
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:103:3: error: expected unqualified-id before ‘for’
  103 |   for (auto &&agent : process.range<agent_t> ())
      |   ^~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:106:41: error: ‘programmable_mask_bits’ was not declared in this scope
  106 |   amd_dbgapi_global_address_t field_B = programmable_mask_bits;
      |                                         ^~~~~~~~~~~~~~~~~~~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:111:3: error: expected unqualified-id before ‘if’
  111 |   if (stable_bits < field_A)
      |   ^~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:125:3: error: ‘m_size’ does not name a type
  125 |   m_size = -(stable_bits & ~field_C);
      |   ^~~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:126:3: error: ‘m_address’ does not name a type
  126 |   m_address = requested_address & -m_size;
      |   ^~~~~~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:130:1: error: ‘watchpoint_t’ has not been declared
  130 | watchpoint_t::get_info (amd_dbgapi_watchpoint_info_t query, size_t value_size,
      | ^~~~~~~~~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:131:38: error: non-member function ‘void get_info(amd_dbgapi_watchpoint_info_t, size_t, void*)’ cannot have cv-qualifier
  131 |                         void *value) const
      |                                      ^~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp: In function ‘void get_info(amd_dbgapi_watchpoint_info_t, size_t, void*)’:
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:136:7: error: ‘utils’ has not been declared
  136 |       utils::get_info (value_size, value, process ().id ());
      |       ^~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:136:43: error: ‘process’ was not declared in this scope
  136 |       utils::get_info (value_size, value, process ().id ());
      |                                           ^~~~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:139:7: error: ‘utils’ has not been declared
  139 |       utils::get_info (value_size, value, address ());
      |       ^~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:139:43: error: ‘address’ was not declared in this scope
  139 |       utils::get_info (value_size, value, address ());
      |                                           ^~~~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:142:7: error: ‘utils’ has not been declared
  142 |       utils::get_info (value_size, value, size ());
      |       ^~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:142:43: error: ‘size’ was not declared in this scope; did you mean ‘std::size’?
  142 |       utils::get_info (value_size, value, size ());
      |                                           ^~~~
      |                                           std::size
In file included from /usr/include/c++/11.1.0/string:54,
                 from /usr/include/c++/11.1.0/stdexcept:39,
                 from /build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/debug.h:26,
                 from /build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/utils.h:25,
                 from /build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/handle_object.h:24,
                 from /build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.h:25,
                 from /build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:21:
/usr/include/c++/11.1.0/bits/range_access.h:254:5: note: ‘std::size’ declared here
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:146:9: error: ‘api_error_t’ was not declared in this scope; did you mean ‘amd::dbgapi::api_error_t’?
  146 |   throw api_error_t (AMD_DBGAPI_STATUS_ERROR_INVALID_ARGUMENT);
      |         ^~~~~~~~~~~
      |         amd::dbgapi::api_error_t
In file included from /build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/utils.h:26,
                 from /build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/handle_object.h:24,
                 from /build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.h:25,
                 from /build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:21:
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/exception.h:63:7: note: ‘amd::dbgapi::api_error_t’ declared here
   63 | class api_error_t : public exception_t
      |       ^~~~~~~~~~~
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp: At global scope:
/build/rocm-dbgapi/src/ROCdbgapi-rocm-5.0.0/src/watchpoint.cpp:149:1: error: expected declaration before ‘}’ token
  149 | } /* namespace amd::dbgapi */
      | ^
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/amd-dbgapi.dir/build.make:328: CMakeFiles/amd-dbgapi.dir/src/watchpoint.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/build/rocm-dbgapi/src/build'
make[1]: *** [CMakeFiles/Makefile2:84: CMakeFiles/amd-dbgapi.dir/all] Error 2
make[1]: Leaving directory '/build/rocm-dbgapi/src/build'
make: *** [Makefile:156: all] Error 2
make: Leaving directory '/build/rocm-dbgapi/src/build'

This is fixed by adding #include <limits> to watchpoint.cpp. See my PR #4