Skip to content

Instantly share code, notes, and snippets.

@LiquidFenrir
Last active February 21, 2023 22:06
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LiquidFenrir/d110f3e7755ffbe82672eda49ae21af2 to your computer and use it in GitHub Desktop.
Save LiquidFenrir/d110f3e7755ffbe82672eda49ae21af2 to your computer and use it in GitHub Desktop.
gdb 101 for 3ds, credits to Stary
1. enable debugger in rosalina menu
go to process list
select a process
2. launch arm-none-eabi-gdb <path to elf>
command "target remote ip:port"
3. command "continue" or "c" to resume execution
4.
"b <func | file:line | *address>" to set a breakpoint
"del <breakpoint number>" to remove a breakpoint
"p <expression>" to print something
"x <expression>" to view memory there
like if you have a pointer or something
"c", "continue"
"s", "step"
"bt" for backtrace with errors
@namkazt
Copy link

namkazt commented Aug 13, 2018

should it have some warning about MakeFile ?
CFLAGS += -ggdb -Og
LIBS := -lcitro3dd -lctrud ( replace )

@oreo639
Copy link

oreo639 commented Apr 24, 2020

Make sure you are using the arm-none-eabi-gdb that comes with devkitARM.
$DEVKITARM/bin/arm-none-eabi-gdb. It would probably be easiest to alias this to something easy to type and remember.
(If you get an error about not having libncurses.so.5, make sure you install libncurses5)

@jtothebell
Copy link

A couple notes that may be helpful for others.

First, you can also do this same process to debug from Citra, just modify step 1 to be

  1. Open Citra Configuration (Emulation-> Configure on windows), then in the General section, open the Debug tab. click on Enable GDB stub, and note the port (change it if you need)
    then in step 2 use "localhost" for the IP, and the port from Citra for the port.
    Remember that Citra will wait for the debugger to attach before running any code, so turn off "Enable GDB Stub" when you are done debugging.

Second, if you are using Visual Studio code, you can use the "Native Debug" extension to attach directly from VS Code, letting you set breakpoints, etc all from VS Code. An example configuration would look something like this (change the executable, target, and gdbpath to match your environment):
"configurations": [ { "type": "gdb", "request": "attach", "name": "Attach to gdbserver", "executable": "path-to-your-app.elf", "target": "{{ip address of 3ds or citra}}:{{port}}", "remote": true, "cwd": "${workspaceRoot}", "valuesFormatting": "parseText", "gdbpath": "C:\\devkitPro\\devkitARM\\bin\\arm-none-eabi-gdb.exe" }

@dealmengor
Copy link

Hi, someone have a example code of .vscode folder for launch.json and tasks.json?

@pvpb0t
Copy link

pvpb0t commented Apr 9, 2022

since oreo639 helped me, i will just summerize for noobs like me:
start msys2
do cd to the folder of your .elf of the homebrew application (on pc)
write $DEVKITARM/bin/arm-none-eabi-gdb and then your-apps-name.elf
now go into homebrew menu or where you launch it from
open rosalina menu by L+down+select
go to debugger options->Enable Debugger and Force-debug next application on launch
make note of the port, and check the ip in the right top corner
Go out of rosalina menu
Start your app
Go to your pc and in msys2/terminal do target remote ip:port
it should say something like 0x00100000 in _start ()
then write c and hit enter
write backtrace or bt

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