eteran / edb-debugger

edb is a cross-platform AArch32/x86/x86-64 debugger.
GNU General Public License v2.0
2.68k stars 322 forks source link

x86-generic/PlatformThread.cpp: avoid non-constant offsetof for gcc-11 #776

Closed trofi closed 3 years ago

trofi commented 4 years ago

On gcc-11 edb-debugger build fails as:

.../x86-generic/PlatformThread.cpp:332:79: error: 'n' is not a constant expression
  332 |         return ptrace(PTRACE_POKEUSER, tid_, offsetof(struct user, u_debugreg[n]), value);
      |                                                                               ^

It's a regression of gcc-11 compared to gcc-10, but it's not clear if non-constant expressions are guaranteed to work in general: https://gcc.gnu.org/PR95942. gcc used to accept simple expressions, but nothing complex.

The change workarounds build failure by avoiding non-constant expression.