• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Enabling AGBPrintf Debugging

55
Posts
14
Years
    • Seen Feb 1, 2023
    I'm trying to debug an issue I'm facing, but it's extremely difficult just to tweak code and run/check the results. I know that pokeemerald supports console logging via the AGBPrintf function. In config.h there's the following message:
    Code:
    #define NDEBUG
    
    // To enable print debugging, comment out "#define NDEBUG". This allows
    // the various AGBPrint functions to be used. (See include/gba/isagbprint.h).
    // Some emulators support a debug console window: uncomment NoCashGBAPrint()
    // and NoCashGBAPrintf() in libisagbprn.c to use no$gba's own proprietary
    // printing system. Use NoCashGBAPrint() and NoCashGBAPrintf() like you
    // would normally use AGBPrint() and AGBPrintf().

    When I comment out that line (and build via make), however, the linker spits out a bunch of errors about things in optimized-out sections that are now being accessed:
    Spoiler:


    My question: how do I get AGBPrintf to compile into the ROM without getting the linker errors? Alternately, is there another way I can debug my features without AGBPrintf -- and how do I do it? I'm currently using VBA-M (v2.1.4) on Windows and building in WSL. I also have an old version of the pokeemerald repo, if that's relevant. Further, it seems like VBA supports connecting to a debugger, but idk how I'd even go about that; I've found the console window in the emulator, and have turned on AGBPrintf logging.



    Note: I'm intentionally not describing the details of the specific problem I'm facing because they aren't actually relevant to debugging. If you need/want more details of the problem(s) I'm trying to solve, feel free to PM me directly.


    Thanks in advance :)
     

    Lunos

    Random Uruguayan User
    3,114
    Posts
    15
    Years
  • I'm trying to debug an issue I'm facing, but it's extremely difficult just to tweak code and run/check the results. I know that pokeemerald supports console logging via the AGBPrintf function. In config.h there's the following message:
    Code:
    #define NDEBUG
    
    // To enable print debugging, comment out "#define NDEBUG". This allows
    // the various AGBPrint functions to be used. (See include/gba/isagbprint.h).
    // Some emulators support a debug console window: uncomment NoCashGBAPrint()
    // and NoCashGBAPrintf() in libisagbprn.c to use no$gba's own proprietary
    // printing system. Use NoCashGBAPrint() and NoCashGBAPrintf() like you
    // would normally use AGBPrint() and AGBPrintf().

    When I comment out that line (and build via make), however, the linker spits out a bunch of errors about things in optimized-out sections that are now being accessed:
    Spoiler:


    My question: how do I get AGBPrintf to compile into the ROM without getting the linker errors? Alternately, is there another way I can debug my features without AGBPrintf -- and how do I do it? I'm currently using VBA-M (v2.1.4) on Windows and building in WSL. I also have an old version of the pokeemerald repo, if that's relevant. Further, it seems like VBA supports connecting to a debugger, but idk how I'd even go about that; I've found the console window in the emulator, and have turned on AGBPrintf logging.



    Note: I'm intentionally not describing the details of the specific problem I'm facing because they aren't actually relevant to debugging. If you need/want more details of the problem(s) I'm trying to solve, feel free to PM me directly.


    Thanks in advance :)
    I encourage you to use mGBA as your GBA emulator instead of VBA-M. On mGBA, you can use its printf which there's a tutorial about in the Pokeemerald wiki.
    https://github.com/pret/pokeemerald/wiki/printf-in-mGBA

    Alternatively, try asking about AGBPrintf in Pret's Discord server.
     
    55
    Posts
    14
    Years
    • Seen Feb 1, 2023
    I encourage you to use mGBA as your GBA emulator instead of VBA-M. On mGBA, you can use its printf which there's a tutorial about in the Pokeemerald wiki.
    https://github.com/pret/pokeemerald/wiki/printf-in-mGBA

    Alternatively, try asking about AGBPrintf in Pret's Discord server.

    This was an excellent suggestion! Got logging up and working via the tutorial, and was able to fix a bunch of my issues based on the logs :D

    Thanks!!
     

    Lunos

    Random Uruguayan User
    3,114
    Posts
    15
    Years
  • It's worth mentioning that the code that allows to perform debugging via mGBA's printf was PR'd and merged into the main repositories in the last few months of 2022, so in up-to-date projects, one simply needs to comment out #define NDEBUG and then make use of the DebugPrintf and/or DebugPrintfLevel functions.
     
    Back
    Top