{"id":16140891,"url":"https://github.com/networkfusion/ed64-gdb","last_synced_at":"2025-06-25T23:05:13.941Z","repository":{"id":109730806,"uuid":"185793650","full_name":"networkfusion/ed64-gdb","owner":"networkfusion","description":"A basic project for learning how to debug using GDB on an ED64 V3","archived":false,"fork":false,"pushed_at":"2019-05-09T12:35:15.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T18:39:43.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/networkfusion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-05-09T12:21:44.000Z","updated_at":"2023-05-06T05:35:38.000Z","dependencies_parsed_at":"2023-06-11T06:15:47.503Z","dependency_job_id":null,"html_url":"https://github.com/networkfusion/ed64-gdb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/networkfusion/ed64-gdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networkfusion%2Fed64-gdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networkfusion%2Fed64-gdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networkfusion%2Fed64-gdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networkfusion%2Fed64-gdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/networkfusion","download_url":"https://codeload.github.com/networkfusion/ed64-gdb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networkfusion%2Fed64-gdb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261967131,"owners_count":23237663,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T23:54:02.611Z","updated_at":"2025-06-25T23:05:13.886Z","avatar_url":"https://github.com/networkfusion.png","language":"C","funding_links":[],"categories":["Tools and Libraries"],"sub_categories":["Debugging"],"readme":"A GDBstub for Nintendo 64 + EverDrive-64 V3.\n\n# Build (with sample)\nDownload the toolchain from [https://github.com/N64-tools/mips64-gcc-toolchain](https://github.com/N64-tools/mips64-gcc-toolchain) and extract it to the toolchain directory\nNote: Although gdbstub does not depends any libraries (maybe), sample program requires [libdragon](https://github.com/n64-tools/libdragon). In this case, it should also be extracted into the toolchain directory.\n\n```\n\u003e build\n```\n\n# Testrun\n\nTurn on Nintendo 64 with EverDrive-64, and connect USB cable with it.\n\nOn some terminal:\n\n```\n$ ruby ./loader64.rb /dev/ttyUSB0 sample.z64 \u0026\u0026 ruby ./com64.rb /dev/ttyUSB0 23946\n```\n\n(tested with `ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]`)\n\nOn another terminal:\n\n```\n$ gdb -q sample.elf\n(gdb) target remote localhost:23946\n```\n\nYou'll see `__asm(\"syscall\")` that invokes gdbstub.\n\nContinue with stub by skipping `syscall` and `jal stub_uninstall`:\n\n```\n(gdb) set $pc=$pc+8\n```\n\nThen break\u0026continue, step, ...\n\n## Nintendo 64 hangs before getting stub?\n\nMaybe libdragon's link script is broken...\n\nDisassemble or `nm` your ELF file and check `_start` is at 0x80000400 (default libdragon entry point address).\n\nIf not, some non-code section are on the entry point. It crash ofcourse!\n\nModify your `$N64_INST/mips64-elf/lib/n64ld.x` to fix it.\n\nOn my some environment, `.MIPS.abiflags` and `.eh_frame` does. I modified as...\n\n```\n/* snip */\n         *(.sdata)\n         *(.sdata.*)\n\t\t\t\t *(.eh_frame)   /* add this in .data */\n      __data_end = . ;\n\n/* snip */\n\t__bss_end = . ;\n\tend = . ;\n   }\n\n\t/DISCARD/ : {\n\t\t*(.MIPS.abiflags)  /* simply discard this section */\n\t}\n/* snip */\n```\n\nAlso, check `__data_end`, `__bss_start` and `__bss_end` is aligned at 4-bytes boundary.\n\nI hope this helps you.\n\n## Stub breaks at non-problem instruction\n\nSee `cause` and last 8 bit is 0x00? That's interrupt!\n\n`set $sr=$sr\u0026~1` (disable interrupt) will help you... until program enables interrupt again.\n\n## Can't stop with Ctrl-C\n\nUnsupported! Reset and redo from start...\n\n# Integrate stub with your (homebrew) program\n\nJust implant the following code where you want to break:\n\n```\nextern void stub(void); stub();\n```\n\nAnd link with `gdbstub.o`, `gdbstubl.o` and `cache.o`.\n\nTested with O64 and O32 ABI. Other ABIs are untested...\n\nIt will initialize TLB and install starting stub code to vectors (80000000, 80000080, 80000100(meaningless :-), 80000180) then invoke stub with a dummy `syscall`.\n\n# TODO\n\n* accept longer packet? (com64.rb/gdbstub.c)\n* TLB co-operate support (gdbstubl.S)\n  * currently it assuming that stub is a ONLY user of TLB... or TLB-shutdown will happen in worst case\n  * should tlbp before tlbwr, and use tlbwi if found\n* support stepping eret (gdbstub.c)\n* support skipping interrupt exception (or filtering some exception)\n  * how to run the (first 2 instructions of) original handler?\n* stepping into exception handler\n  * currently you need to set pc to the handler...\n\t* EPC can't be restored... how to??\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworkfusion%2Fed64-gdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetworkfusion%2Fed64-gdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworkfusion%2Fed64-gdb/lists"}