Skip to content

Enable GDB for binutils 2.40 with native AmigaOS debugging fixes - #1

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

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

Conversation

@derfsss

@derfsss derfsss commented Apr 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Enable GDB in both cross and native binutils 2.40 builds (remove --disable-gdb, add --with-python=no)
  • Add gild patch 0002-Fix-GDB-native-debugging-on-AmigaOS-4.patch with fixes for native GDB on AmigaOS 4
  • Add GDB test targets to tests/makefile

GDB Fixes (patch 0002)

Register handling:

  • Fix fetch_registers() GPR loop indexing (used regno instead of loop variable)
  • Fix FPR index offset (subtract base register number)
  • Fix loop bounds: 32 registers not 31
  • Gate AltiVec register access on ECF_VECTOR context flag
  • Implement store_registers() using IDebug->WriteTaskContext()

Trap/signal handling:

  • Replace raw PPC vector numbers with SDK TRAPNUM_* values from exec/interrupts.h
  • Add handling for TRAP_TRAP (breakpoints), TRAP_DATA_BREAKPOINT (DABR), TRAP_TRACE (single-step)
  • Preserve actual signal type in wait() instead of collapsing to GDB_SIGNAL_0

Process control:

  • Implement attach() for connecting to running processes
  • Fix kill() to use Signal(SIGBREAKF_CTRL_C) + RestartTask instead of DeleteTask on Process objects
  • Add message pool safety with NULL checks in debug callback

BFD file path fix:

  • Skip canonicalize_file_name() on AmigaOS in gdb_realpath() — AmigaOS realpath() resolves assigns (e.g. T: becomes RAM Disk:T/) producing paths that fail when BFD's file cache tries to reopen them

Charset fix:

  • Force UTF-8 host charset on AmigaOS — clib4's nl_langinfo(CODESET) returns ISO-8859-1 but its iconv cannot reliably convert to UTF-32

Test plan

  • Cross-GDB builds on Linux host
  • Native GDB tested on AmigaOS 4.1 (Pegasos II via QEMU)
  • info functions — DWARF symbols with source file and line numbers
  • disassemble — correct PPC instruction dump
  • break — breakpoints resolved to source locations
  • ptype — struct, enum, union, function types
  • x/ — memory examination (hex, instructions, strings)
  • maintenance info sections — all sections including .debug_*
  • No locale/charset warnings
  • Patches apply cleanly to fresh gild checkout binutils 2.40

🤖 Generated with Claude Code

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>
@migthymax

Copy link
Copy Markdown

Based on your work i created a PR against the binutils-gdb project containing your changes. There I will comment about it.

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