Skip to content

Enable GDB for binutils 2.40 and fix native AmigaOS debugging - #46

Open
derfsss wants to merge 1 commit into
AmigaLabs:masterfrom
derfsss:add-binutils-240-gdb
Open

Enable GDB for binutils 2.40 and fix native AmigaOS debugging#46
derfsss wants to merge 1 commit into
AmigaLabs:masterfrom
derfsss:add-binutils-240-gdb

Conversation

@derfsss

@derfsss derfsss commented Apr 10, 2026

Copy link
Copy Markdown

Binutils build changes:

  • Enable GDB in both cross and native 2.40 builds (remove --disable-gdb)
  • Add --with-python=no to native build configuration

GDB native debugging fixes (patch 0002):

  • Fix register fetch/store: correct GPR/FPR indexing, implement WriteTaskContext for store_registers, gate AltiVec on ECF_VECTOR
  • Fix trap numbers: use SDK TRAPNUM_* values from exec/interrupts.h instead of raw PPC vector offsets
  • Implement attach() for connecting to running processes
  • Fix kill() to use Signal+RestartTask instead of DeleteTask
  • Add message pool safety with Forbid/Permit and NULL checks
  • Fix BFD file cache: skip realpath on AmigaOS to prevent path mangling (assigns like T: resolve to "RAM Disk:T/" which fails)
  • Fix charset: force UTF-8 host charset on AmigaOS (clib4 iconv)

Test infrastructure:

  • Add GDB test targets to tests/makefile (test-gdb-all, test-gdb-smoke, test-gdb-load, test-gdb-disasm, test-gdb-remote)
  • Add docs/ to .gitignore

Binutils build changes:
- Enable GDB in both cross and native 2.40 builds (remove --disable-gdb)
- Add --with-python=no to native build configuration

GDB native debugging fixes (patch 0002):
- Fix register fetch/store: correct GPR/FPR indexing, implement
  WriteTaskContext for store_registers, gate AltiVec on ECF_VECTOR
- Fix trap numbers: use SDK TRAPNUM_* values from exec/interrupts.h
  instead of raw PPC vector offsets
- Implement attach() for connecting to running processes
- Fix kill() to use Signal+RestartTask instead of DeleteTask
- Add message pool safety with Forbid/Permit and NULL checks
- Fix BFD file cache: skip realpath on AmigaOS to prevent path
  mangling (assigns like T: resolve to "RAM Disk:T/" which fails)
- Fix charset: force UTF-8 host charset on AmigaOS (clib4 iconv)

Test infrastructure:
- Add GDB test targets to tests/makefile (test-gdb-all, test-gdb-smoke,
  test-gdb-load, test-gdb-disasm, test-gdb-remote)
- Add docs/ to .gitignore

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@josefwegner

josefwegner commented Jun 19, 2026

Copy link
Copy Markdown

Sadly does not compile for me because of some GCLIBC includes hack:

make[4]: Entering directory '/opt/code/native-build/binutils-native-build-2.40/gdbsupport'
make  all-am
make[5]: Entering directory '/opt/code/native-build/binutils-native-build-2.40/gdbsupport'
  CXX      agent.o
In file included from ../gnulib/import/stdint.h:584,
                 from /opt/code/binutils/repo/gdbsupport/common-defs.h:95,
                 from /opt/code/binutils/repo/gdbsupport/agent.cc:20:
../gnulib/import/wchar.h:66:11: fatal error: features.h: No such file or directory
   66 | # include <features.h> /* for __GLIBC__ */
      |           ^~~~~~~~~~~~
compilation terminated.

binutils-native-build-2.40/gnulib/import/wchar.h

#if 1
# include <features.h> /* for __GLIBC__ */
#endif

That might be caused by a difference in the CLIB4 headers between the cross-compiler and clib4 repo. The #if 1 is really #if HAVE_FEATURES_H. And newer versions of CLIB4 do have features.h

@josefwegner

Copy link
Copy Markdown

But building a cross compiler with adtools fails because of this:

gcc -c -DHAVE_CONFIG_H -Wno-sign-compare       -I. -I/home/jwegne/Projects/amiga/adtools/binutils/repo/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic  -D_GNU_SOURCE  /home/jwegne/Projects/amiga/adtools/binutils/repo/libiberty/lbasename.c -o lbasename.o
In file included from /home/jwegne/Projects/amiga/adtools/binutils/repo/libiberty/lbasename.c:46:
/home/jwegne/Projects/amiga/adtools/binutils/repo/libiberty/lbasename.c: In function ‘amiga_lbasename’:
/home/jwegne/Projects/amiga/adtools/binutils/repo/libiberty/../include/filenames.h:88:35: error: implicit declaration of function ‘index’ [-Wimplicit-function-declaration]
   88 | #define HAS_AMIGOS_DRIVE_SPEC(f) (index (&(f)[0], ':') != NULL )
      |                                   ^~~~~
/home/jwegne/Projects/amiga/adtools/binutils/repo/libiberty/lbasename.c:82:7: note: in expansion of macro ‘HAS_AMIGOS_DRIVE_SPEC’
   82 |   if (HAS_AMIGOS_DRIVE_SPEC (name)) {
      |       ^~~~~~~~~~~~~~~~~~~~~
/home/jwegne/Projects/amiga/adtools/binutils/repo/libiberty/../include/filenames.h:88:35: warning: incompatible implicit declaration of built-in function ‘index’ [-Wbuiltin-declaration-mismatch]
   88 | #define HAS_AMIGOS_DRIVE_SPEC(f) (index (&(f)[0], ':') != NULL )
      |                                   ^~~~~
/home/jwegne/Projects/amiga/adtools/binutils/repo/libiberty/lbasename.c:82:7: note: in expansion of macro ‘HAS_AMIGOS_DRIVE_SPEC’
   82 |   if (HAS_AMIGOS_DRIVE_SPEC (name)) {
      |       ^~~~~~~~~~~~~~~~~~~~~
make[4]: *** [Makefile:963: lbasename.o] Fehler 1
make[4]: Verzeichnis „/home/jwegne/Projects/amiga/adtools/native-build/binutils-cross-build-2.40/libiberty“ wird verlassen
make[3]: *** [Makefile:9997: all-libiberty] Fehler 2
make[3]: Verzeichnis „/home/jwegne/Projects/amiga/adtools/native-build/binutils-cross-build-2.40“ wird verlassen
make[2]: *** [Makefile:1004: all] Fehler 2
make[2]: Verzeichnis „/home/jwegne/Projects/amiga/adtools/native-build/binutils-cross-build-2.40“ wird verlassen
make[1]: *** [Makefile:81: cross] Fehler 2
make[1]: Verzeichnis „/home/jwegne/Projects/amiga/adtools/binutils-build“ wird verlassen
make: *** [makefile:163: binutils-cross-build-done-2.40] Fehler 2
make: Verzeichnis „/home/jwegne/Projects/amiga/adtools/native-build“ wird verlassen

@josefwegner

Copy link
Copy Markdown

I was able to build adtools with gcc 13 and binutils 2.40 but without gdb.
It has still the same filename/tmpfile issues:

make
gcc -O2 -Wall -D__USE_INLINE__ -o abi tests/abi.c
T:/ccpjQCkV.s: Assembler messages:
T:/ccpjQCkV.s: Fatal error: can't write 8 bytes to section .text of T:/cceVptoL.o: 'Input/output error'
Work:Cubic IDE/ide/devkits/compilers/gcc/amigaos4/13.4.0/ppc-amigaos/bin/as: BFD (GNU Binutils) 2.40 assertion fail /opt/code/binutils/repo/bfd/elf.c:3108
T:/ccpjQCkV.s: Fatal error: T:/cceVptoL.o: Device busy
make: *** [abi] Error 1
Work:Cubic IDE/ide/devkits/compilers/gcc/amigaos4/13.4.0/ppc-amigaos/bin/as fehlgeschlagen, Rckgabewert 20

@josefwegner

Copy link
Copy Markdown

I was able to build adtools with gcc 13 and binutils 2.40 but without gdb.
It has still the same filename/tmpfile issues:

make
gcc -O2 -Wall -D__USE_INLINE__ -o abi tests/abi.c
T:/ccpjQCkV.s: Assembler messages:
T:/ccpjQCkV.s: Fatal error: can't write 8 bytes to section .text of T:/cceVptoL.o: 'Input/output error'
Work:Cubic IDE/ide/devkits/compilers/gcc/amigaos4/13.4.0/ppc-amigaos/bin/as: BFD (GNU Binutils) 2.40 assertion fail /opt/code/binutils/repo/bfd/elf.c:3108
T:/ccpjQCkV.s: Fatal error: T:/cceVptoL.o: Device busy
make: *** [abi] Error 1
Work:Cubic IDE/ide/devkits/compilers/gcc/amigaos4/13.4.0/ppc-amigaos/bin/as fehlgeschlagen, Rckgabewert 20

Sadly does not compile for me because of some GCLIBC includes hack:

make[4]: Entering directory '/opt/code/native-build/binutils-native-build-2.40/gdbsupport'
make  all-am
make[5]: Entering directory '/opt/code/native-build/binutils-native-build-2.40/gdbsupport'
  CXX      agent.o
In file included from ../gnulib/import/stdint.h:584,
                 from /opt/code/binutils/repo/gdbsupport/common-defs.h:95,
                 from /opt/code/binutils/repo/gdbsupport/agent.cc:20:
../gnulib/import/wchar.h:66:11: fatal error: features.h: No such file or directory
   66 | # include <features.h> /* for __GLIBC__ */
      |           ^~~~~~~~~~~~
compilation terminated.

binutils-native-build-2.40/gnulib/import/wchar.h

#if 1
# include <features.h> /* for __GLIBC__ */
#endif

That might be caused by a difference in the CLIB4 headers between the cross-compiler and clib4 repo. The #if 1 is really #if HAVE_FEATURES_H. And newer versions of CLIB4 do have features.h

No, the issue is that we need to set the CXXFLAGS=-mcrt=clib4 in binutils-build/Makefile.

But then the compilation fails with:

  CXX    ppc-amigaos-nat.o
virtual memory exhausted: Cannot allocate memory
make[4]: *** [Makefile:1899: ppc-amigaos-nat.o] Error 1
make[4]: Leaving directory '/opt/code/native-build/binutils-native-build-2.40/gdb'
make[3]: *** [Makefile:12856: all-gdb] Error 2
make[3]: Leaving directory '/opt/code/native-build/binutils-native-build-2.40'
make[2]: *** [Makefile:1004: all] Error 2
make[2]: Leaving directory '/opt/code/native-build/binutils-native-build-2.40'
make[1]: *** [Makefile:94: native] Error 2
make[1]: Leaving directory '/opt/code/binutils-build'
make: *** [makefile:331: binutils-native-done-2.40] Error 2
make: Leaving directory '/opt/code/native-build'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants