gdbstub.pp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. program gdbstub;
  2. {$J+}
  3. {$macro on}
  4. {$mode objfpc}
  5. uses
  6. cmem, ctypes, gctypes, debug, gccore;
  7. var
  8. xfb: pcuint32 = nil;
  9. rmode: PGXRModeObj = nil;
  10. begin
  11. VIDEO_Init();
  12. WPAD_Init();
  13. rmode := VIDEO_GetPreferredMode(nil);
  14. xfb := SYS_AllocateFramebuffer(rmode);
  15. console_init(xfb,20,20,rmode^.fbWidth,rmode^.xfbHeight,rmode^.fbWidth*VI_DISPLAY_PIX_SZ);
  16. VIDEO_Configure(rmode);
  17. VIDEO_SetNextFramebuffer(xfb);
  18. VIDEO_SetBlack(FALSE);
  19. VIDEO_Flush();
  20. VIDEO_WaitVSync();
  21. if(rmode^.viTVMode and VI_NON_INTERLACE) <> 0 then VIDEO_WaitVSync();
  22. // Configure for use with USB on EXI channel 1 (memcard slot B)
  23. // Other option: GDBSTUB_DEVICE_TCP. Note: second parameter acts as port for this type of device
  24. DEBUG_Init(GDBSTUB_DEVICE_USB,1);
  25. printf('Waiting for debugger ...'#10);
  26. // This function call enters the debug stub for the first time
  27. // It's needed to call this if one wants to start debugging.
  28. _break();
  29. printf('debugger connected ...'#10);
  30. while true do
  31. begin
  32. VIDEO_WaitVSync();
  33. WPAD_ScanPads();
  34. if (WPAD_ButtonsDown(0) and WPAD_BUTTON_A) <> 0 then
  35. printf('Button A pressed.'#10);
  36. if (WPAD_ButtonsDown(0) and WPAD_BUTTON_HOME) <> 0 then break;
  37. end;
  38. end.