Gdbstub for Citra available

Discussion in '3DS - ROM Hacking, Translations and Utilities' started by Nagato, Nov 14, 2015.

  1. Nagato

    Nagato GBAtemp Advanced Fan

    Jul 15, 2011
    United States
    NOTICE: If you don't know what a gdbstub or debugger is or how to debug/reverse engineer, then this post isn't for you. This will not help you play Pokemon or any other game so don't ask, please.

    Kind of a release thread I guess? This may or may not be very useful depending on what game you are working on, but I spent the past 2 and a half months working on a gdbstub for Citra that finally got merged into master 2 days ago. This is what I spent my free time on after releasing Labyrinth no Kanata and Nanashi no Game: Me. :P

    Having a gdbstub was on the list of features the Citra devs wanted since it would make it easier to debug some games, but my personal goal was to be able to reverse engineer 3DS games for fan translations in the same way that I do for DS games (using DeSmuME's gdbstub and IDA Pro). Especially when I was working on Labyrinth no Kanata, something like this would have helped greatly in trying to fix some things (Labyrinth no Kanata wasn't really even playable in Citra while I was making the fan translation, though. It is now, though! Sorta).

    So what can this do?
    - Debug, in real time, a game's code as it is being executed in Citra
    - Breakpoints
    - Step code
    - View, modify memory
    - View, modify registers
    - You can use any gdb client to connect to the gdbserver. That means you can use a plain ol' gdb.exe or something like IDA Pro or anything in between (as long as it supports ARM architecture).


    The above game is Labyrinth no Kanata. I've also tested it with Time Travelers, The Legend of Zelda: Ocarina of Time 3D, and Star Fox 64 3DS.

    Anyway, I just wanted to make everyone who could make use of it here aware that the feature is there and working at the moment in case it might be useful for anyone. As of two days ago, the gdbstub is in all nightly builds which can be found on the official Citra website.

    To enable the Gdbstub, check the "Use Gdbstub" option under the Emulation menu at any time during execution. The gdbstub can be enabled and disabled at any time. The default port is 24689 and can be modified by changing the gdbstub_port setting in the relevant ini file under user/config. Multiple gdbstubs can be run at the same time as long as they have different port numbers (such as multiple glfw and qt instances running at the same time).
    Last edited by Nagato, Nov 14, 2015
  2. Exavold

    Exavold eeh

    Nov 9, 2015
    Nice ! :D
  3. shinyquagsire23

    shinyquagsire23 SALT/Sm4sh Leak Guy

    Nov 18, 2012
    United States
    Las Vegas
    I've been using it with the Smash demo, it's helped immensely in figuring things out in terms of file IO.
    Nagato and Exavold like this.
  4. Nagato

    Nagato GBAtemp Advanced Fan

    Jul 15, 2011
    United States
    I'm really glad to hear that someone else has been able to put it to good use! :D
  5. delete12345

    delete12345 GBAtemp Advanced Fan

    Feb 27, 2010
    United States
    Taipei, Taiwan
    For those who are interested in using Citra GDBStub,

    1. Run GDB in the terminal (WSL Bash, terminal, etc.) You should have "(gdb)" replacing the "$" symbol.
    2. Open Citra emulator.
    3. Check and enable GDB Stub, and set the port number.
    4. Back in Citra emulator, open and execute a game.
    5. Check to see the Citro command prompt/terminal is saying "Debug.GDBStub: Waiting for gdb to connect...."
    6. In your GDB terminal, type:
    target remote localhost:####
    Where #### is your port number you have set earlier.
    7. You will see:
    Remote debugging using localhost:####
    After you pressed Enter key. This means your GDB is connected to Citra emulator GDB Stub.
    8. You can now press and type "si" to run 1 instruction, "n" to step over, and so on.
  6. Amick

    Amick Newbie

    Feb 26, 2017
    Thanks !! It Helped me a lot!!
  7. Hiccup

    Hiccup GBAtemp Advanced Fan

    Nov 21, 2009
    Is there a universal method for using this to track what files a game loads from its RomFS?
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice