diff --git a/desmume/configure.ac b/desmume/configure.ac index d8db8179d..d1d004bcd 100644 --- a/desmume/configure.ac +++ b/desmume/configure.ac @@ -155,6 +155,11 @@ AC_SUBST(PO_DIR) AC_SUBST(PO_FILES) AC_SUBST(PO_FILES_IN) +dnl - Gdb stub +AC_ARG_ENABLE(gdb-stub, + [AC_HELP_STRING(--enable-gdb-stub, enable gdb stub)], + [AC_DEFINE(GDB_STUB)]) + dnl - Compiler warnings # for developer use, enable lots of compile warnings, @@ -163,7 +168,7 @@ dnl - Compiler warnings # # NB: must add -Werror after AC_PROG_CC, etc., so do this last AC_ARG_ENABLE(hardcore, - [ --enable-hardcore turn on -W -Wall -Werror], + [AC_HELP_STRING(--enable-hardcore, turn on -W -Wall -Werror)], [case "${enableval}" in yes) ENABLE_HARDCORE=1 ;; no) ENABLE_HARDCORE=0 ;; diff --git a/desmume/src/cli/main.cpp b/desmume/src/cli/main.cpp index 84a15923c..84b97e8a0 100644 --- a/desmume/src/cli/main.cpp +++ b/desmume/src/cli/main.cpp @@ -52,7 +52,9 @@ #include "../sndsdl.h" #include "../ctrlssdl.h" #include "../render3D.h" +#ifdef GDB_STUB #include "../gdbstub.h" +#endif volatile BOOL execute = FALSE; @@ -171,8 +173,10 @@ fill_config( struct my_config *config, printf( " 4 = Italian\n"); printf( " 5 = Spanish\n"); printf( "\n"); +#ifdef GDB_STUB printf( " --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n"); printf( " --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n"); +#endif //printf( " --sticky Enable sticky keys and stylus\n"); printf( "\n"); printf( " --cflash=PATH_TO_DISK_IMAGE\n"); @@ -212,6 +216,7 @@ fill_config( struct my_config *config, good_args = 0; } } +#ifdef GDB_STUB else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) { char *end_char; unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); @@ -236,6 +241,7 @@ fill_config( struct my_config *config, good_args = 0; } } +#endif else if ( strncmp( argv[i], "--cflash=", 9) == 0) { if ( config->cflash_disk_image_file == NULL) { config->cflash_disk_image_file = &argv[i][9]; @@ -271,10 +277,10 @@ fill_config( struct my_config *config, return good_args; } - /* * The thread handling functions needed by the GDB stub code. */ +#ifdef GDB_STUB void * createThread_gdb( void (*thread_function)( void *data), void *thread_data) { @@ -289,6 +295,7 @@ joinThread_gdb( void *thread_handle) { int ignore; SDL_WaitThread( (SDL_Thread*)thread_handle, &ignore); } +#endif @@ -542,12 +549,14 @@ int main(int argc, char ** argv) { static unsigned short keypad = 0; struct my_config my_config; u32 last_cycle = 0; +#ifdef GDB_STUB gdbstub_handle_t arm9_gdb_stub; gdbstub_handle_t arm7_gdb_stub; struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; struct armcpu_ctrl_iface *arm9_ctrl_iface; struct armcpu_ctrl_iface *arm7_ctrl_iface; +#endif int limiter_frame_counter = 0; SDL_sem *fps_limiter_semaphore; @@ -584,6 +593,7 @@ int main(int argc, char ** argv) { fw_config.language = my_config.firmware_language; } +#ifdef GDB_STUB if ( my_config.arm9_gdb_port != 0) { arm9_gdb_stub = createStub_gdb( my_config.arm9_gdb_port, &arm9_memio, @@ -606,6 +616,7 @@ int main(int argc, char ** argv) { exit( 1); } } +#endif #ifdef DEBUG LogStart(); @@ -633,12 +644,14 @@ int main(int argc, char ** argv) { * Activate the GDB stubs * This has to come after the NDS_Init where the cpus are set up. */ +#ifdef GDB_STUB if ( my_config.arm9_gdb_port != 0) { activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); } if ( my_config.arm7_gdb_port != 0) { activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); } +#endif /* // This has to get fixed yet strcpy(szRomPath, dirname(argv[1])); @@ -818,12 +831,14 @@ int main(int argc, char ** argv) { SDL_Quit(); NDS_DeInit(); +#ifdef GDB_STUB if ( my_config.arm9_gdb_port != 0) { destroyStub_gdb( arm9_gdb_stub); } if ( my_config.arm7_gdb_port != 0) { destroyStub_gdb( arm7_gdb_stub); } +#endif #ifdef DEBUG LogStop(); diff --git a/desmume/src/gtk-glade/main.cpp b/desmume/src/gtk-glade/main.cpp index 2466d0bcf..58bbdc2a3 100755 --- a/desmume/src/gtk-glade/main.cpp +++ b/desmume/src/gtk-glade/main.cpp @@ -24,9 +24,12 @@ #include "callbacks_IO.h" #include "dTools/callbacks_dtools.h" #include "globals.h" -#include "../gdbstub.h" #include "keyval_names.h" +#ifdef GDB_STUB +#include "../gdbstub.h" +#endif + #ifdef GTKGLEXT_AVAILABLE #include #include "../OGLRender.h" @@ -122,10 +125,13 @@ fill_configured_features( struct configured_features *config, 2 = French\n\ 3 = German\n\ 4 = Italian\n\ - 5 = Spanish\n\n\ + 5 = Spanish\n\n")); +#ifdef GDB_STUB + g_print( _("\ --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n\ - --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n\ - \n\ + --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n\n")); +#endif + g_print( _("\ --help Display this message\n")); //g_print(" --sticky Enable sticky keys and stylus\n"); good_args = 0; @@ -150,6 +156,7 @@ fill_configured_features( struct configured_features *config, good_args = 0; } } +#ifdef GDB_STUB else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) { char *end_char; unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); @@ -174,6 +181,7 @@ fill_configured_features( struct configured_features *config, good_args = 0; } } +#endif else if ( strcmp( argv[i], "--disable-limiter") == 0) { config->disable_limiter = 1; } @@ -315,6 +323,7 @@ static int Write_ConfigFile() /* * The thread handling functions needed by the GDB stub code. */ +#ifdef GDB_STUB void * createThread_gdb( void (*thread_function)( void *data), void *thread_data) { @@ -330,6 +339,7 @@ void joinThread_gdb( void *thread_handle) { g_thread_join((GThread *) thread_handle); } +#endif @@ -359,8 +369,10 @@ glade_fps_limiter_fn( Uint32 interval, void *param) { static int common_gtk_glade_main( struct configured_features *my_config) { SDL_TimerID limiter_timer; +#ifdef GDB_STUB gdbstub_handle_t arm9_gdb_stub; gdbstub_handle_t arm7_gdb_stub; +#endif struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; struct armcpu_ctrl_iface *arm9_ctrl_iface; @@ -388,6 +400,7 @@ common_gtk_glade_main( struct configured_features *my_config) { #endif init_keyvals(); +#ifdef GDB_STUB if ( my_config->arm9_gdb_port != 0) { arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port, &arm9_memio, @@ -410,7 +423,7 @@ common_gtk_glade_main( struct configured_features *my_config) { return -1; } } - +#endif if(SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO) == -1) { @@ -431,12 +444,14 @@ common_gtk_glade_main( struct configured_features *my_config) { * This has to come after the NDS_Init (called in desmume_init) * where the cpus are set up. */ +#ifdef GDB_STUB if ( my_config->arm9_gdb_port != 0) { activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); } if ( my_config->arm7_gdb_port != 0) { activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); } +#endif /* Initialize joysticks */ if(!init_joy()) return 1; diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index 541e30519..0c1f571f2 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -27,7 +27,9 @@ #include "globals.h" #include "../debug.h" +#ifdef GDB_STUB #include "../gdbstub.h" +#endif #ifdef GTKGLEXT_AVAILABLE #include "../OGLRender.h" @@ -173,8 +175,10 @@ fill_configured_features( struct configured_features *config, printf( " 4 = Italian\n"); printf( " 5 = Spanish\n"); printf( "\n"); +#ifdef GDB_STUB printf( " --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n"); printf( " --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n"); +#endif //printf( " --sticky Enable sticky keys and stylus\n"); printf( "\n"); printf( " --cflash=PATH_TO_DISK_IMAGE\n"); @@ -204,6 +208,7 @@ fill_configured_features( struct configured_features *config, fprintf( stderr, "Firmware language must be set to a value from 0 to 5.\n"); good_args = 0; } +#ifdef GDB_STUB } else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) { char *end_char; unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); @@ -224,6 +229,7 @@ fill_configured_features( struct configured_features *config, fprintf( stderr, "ARM7 GDB stub port must be in the range 1 to 65535\n"); good_args = 0; } +#endif } else if ( strncmp( argv[i], "--cflash=", 9) == 0) { if ( config->cflash_disk_image_file == NULL) { config->cflash_disk_image_file = &argv[i][9]; @@ -260,6 +266,7 @@ fill_configured_features( struct configured_features *config, /* * The thread handling functions needed by the GDB stub code. */ +#ifdef GDB_STUB void * createThread_gdb( void (*thread_function)( void *data), void *thread_data) @@ -276,6 +283,7 @@ void joinThread_gdb( void *thread_handle) { g_thread_join( (GThread *)thread_handle); } +#endif u16 Keypad_Temp[NB_KEYS]; @@ -1522,8 +1530,10 @@ common_gtk_main( struct configured_features *my_config) GdkGLConfig *glconfig; GdkGLContext *glcontext; #endif +#ifdef GDB_STUB gdbstub_handle_t arm9_gdb_stub; gdbstub_handle_t arm7_gdb_stub; +#endif struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; struct armcpu_ctrl_iface *arm9_ctrl_iface; @@ -1546,6 +1556,7 @@ common_gtk_main( struct configured_features *my_config) LogStart(); #endif +#ifdef GDB_STUB if ( my_config->arm9_gdb_port != 0) { arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port, &arm9_memio, @@ -1568,7 +1579,7 @@ common_gtk_main( struct configured_features *my_config) exit( -1); } } - +#endif #ifdef GTKGLEXT_AVAILABLE /* Try double-buffered visual */ @@ -1599,18 +1610,19 @@ common_gtk_main( struct configured_features *my_config) arm7_memio, &arm7_ctrl_iface, my_config->disable_sound); - /* * Activate the GDB stubs * This has to come after the NDS_Init (called in desmume_init) * where the cpus are set up. */ +#ifdef GDB_STUB if ( my_config->arm9_gdb_port != 0) { activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); } if ( my_config->arm7_gdb_port != 0) { activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); } +#endif /* Create the dummy firmware */ NDS_CreateDummyFirmware( &fw_config); @@ -2016,12 +2028,14 @@ common_gtk_main( struct configured_features *my_config) Write_ConfigFile(); +#ifdef GDB_STUB if ( my_config->arm9_gdb_port != 0) { destroyStub_gdb( arm9_gdb_stub); } if ( my_config->arm7_gdb_port != 0) { destroyStub_gdb( arm7_gdb_stub); } +#endif return EXIT_SUCCESS; }