index.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <!DOCTYPE html>
  2. <html lang="en" class="h-full">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <meta name="color-scheme" content="light dark">
  7. <meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="4.1.0.825921057143">
  8. <!-- See retype.com -->
  9. <meta name="generator" content="Retype 4.1.0">
  10. <!-- Primary Meta Tags -->
  11. <title>Debugging | Portable Python 3.x Interpreter in Modern C</title>
  12. <meta name="title" content="Debugging | Portable Python 3.x Interpreter in Modern C">
  13. <meta name="description" content="To debug a pocketpy program, you need to install our VSCode extension first:">
  14. <!-- Canonical -->
  15. <link rel="canonical" href="https://pocketpy.dev/features/debugging/">
  16. <!-- Open Graph -->
  17. <meta property="og:type" content="website">
  18. <meta property="og:url" content="https://pocketpy.dev/features/debugging/">
  19. <meta property="og:title" content="Debugging | Portable Python 3.x Interpreter in Modern C">
  20. <meta property="og:description" content="To debug a pocketpy program, you need to install our VSCode extension first:">
  21. <meta property="og:image" content="https://pocketpy.dev/static/debugger/launch_json.png">
  22. <meta property="og:image:width" content="1200">
  23. <meta property="og:image:height" content="630">
  24. <meta property="og:image:alt" content="Debugging | Portable Python 3.x Interpreter in Modern C">
  25. <meta property="og:site_name" content="pocketpy">
  26. <meta property="og:locale" content="en_US">
  27. <script data-cfasync="false">(function(){var cl=document.documentElement.classList,ls=localStorage.getItem("retype_scheme"),hd=cl.contains("dark"),hl=cl.contains("light"),wm=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(ls==="dark"||(!ls&&wm&&!hd&&!hl)){cl.remove("light");cl.add("dark")}else if(ls==="light"||(!ls&&!wm&&!hd&&!hl)){cl.remove("dark");cl.add("light")}})();</script>
  28. <link id="retype-favicon" rel="icon" href="../../static/logo.png" />
  29. <link href="../../resources/css/retype.css?v=4.1.0.825921057143" rel="stylesheet">
  30. <script data-cfasync="false" src="../../resources/js/config.js?v=4.1.0.825921057143" data-turbo-eval="false" defer></script>
  31. <script data-cfasync="false" src="../../resources/js/retype.js?v=4.1.0" data-turbo-eval="false" defer></script>
  32. <script id="lunr-js" data-cfasync="false" src="../../resources/js/lunr.js?v=4.1.0.825921057143" data-turbo-eval="false" defer></script>
  33. <script id="prism-js" data-cfasync="false" src="../../resources/js/prism.js?v=4.1.0.825921057143" defer></script>
  34. </head>
  35. <body>
  36. <div id="retype-app" class="relative text-base antialiased text-base-text bg-base-bg font-body">
  37. <div class="absolute bottom-0 left-0" style="top: 5rem; right: 50%"></div>
  38. <header id="retype-header" class="sticky top-0 z-30 flex w-full h-16 bg-header-bg border-b border-header-border md:h-20">
  39. <div class="container relative flex items-center justify-between pr-6 grow md:justify-start">
  40. <!-- Mobile menu button skeleton -->
  41. <button v-cloak class="skeleton retype-mobile-menu-button flex items-center justify-center shrink-0 overflow-hidden dark:text-white focus:outline-hidden rounded-full w-10 h-10 ml-3.5 md:hidden"><svg xmlns="http://www.w3.org/2000/svg" class="mb-px shrink-0" width="24" height="24" viewBox="0 0 24 24" role="presentation" style="margin-bottom: 0px;"><g fill="currentColor"><path d="M2 4h20v2H2zM2 11h20v2H2zM2 18h20v2H2z"></path></g></svg></button>
  42. <div v-cloak id="retype-sidebar-left-toggle-button"></div>
  43. <!-- Logo -->
  44. <div class="flex items-center justify-between h-full py-2 md:w-75">
  45. <div class="flex items-center px-2 md:px-6">
  46. <a id="retype-branding-logo" href="../../" class="flex items-center leading-snug text-2xl">
  47. <span class="w-10 mr-2 grow-0 shrink-0 overflow-hidden">
  48. <img class="max-h-10 dark:hidden md:inline-block" src="../../static/logo.png">
  49. <img class="max-h-10 hidden dark:inline-block" src="../../static/logo.png">
  50. </span>
  51. <span class="dark:text-white font-bold line-clamp-1 md:line-clamp-2">pocketpy</span>
  52. </a><span id="retype-branding-label" class="inline-flex mt-1 px-2 py-1 ml-4 text-xs font-medium leading-none items-center rounded-md bg-branding-label-bg text-branding-label-text ring-1 ring-branding-label-border ring-inset md:inline-block">v2.1.8</span>
  53. </div>
  54. <span class="hidden h-8 border-r md:inline-block border-base-border"></span>
  55. </div>
  56. <div class="flex justify-between md:grow">
  57. <!-- Top Nav -->
  58. <nav id="retype-header-nav" class="hidden md:flex">
  59. <ul class="flex flex-col mb-4 md:pl-16 md:mb-0 md:flex-row md:items-center">
  60. <li class="mr-6">
  61. <a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="">
  62. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
  63. <g fill="currentColor">
  64. <path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
  65. </g>
  66. </svg>
  67. <span>Home</span>
  68. </a>
  69. </li>
  70. <li class="mr-6">
  71. <a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
  72. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
  73. <g fill="currentColor">
  74. <path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
  75. </g>
  76. </svg>
  77. <span>Live Demo</span>
  78. </a>
  79. </li>
  80. <li class="mr-6">
  81. <a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
  82. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
  83. <g fill="currentColor">
  84. <path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
  85. </g>
  86. </svg>
  87. <span>Live Examples</span>
  88. </a>
  89. </li>
  90. <li class="mr-6">
  91. <a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
  92. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
  93. <g fill="currentColor">
  94. <path d="M10.303 16.652c-2.837-.344-4.835-2.385-4.835-5.028 0-1.074.387-2.235 1.031-3.008-.279-.709-.236-2.214.086-2.837.86-.107 2.02.344 2.708.967.816-.258 1.676-.386 2.728-.386 1.053 0 1.913.128 2.686.365.666-.602 1.848-1.053 2.708-.946.3.581.344 2.085.064 2.815.688.817 1.053 1.913 1.053 3.03 0 2.643-1.998 4.641-4.877 5.006.73.473 1.224 1.504 1.224 2.686v2.235c0 .644.537 1.01 1.182.752 3.889-1.483 6.94-5.372 6.94-10.185 0-6.081-4.942-11.044-11.022-11.044-6.081 0-10.98 4.963-10.98 11.044a10.84 10.84 0 0 0 7.112 10.206c.58.215 1.139-.172 1.139-.752v-1.719a2.768 2.768 0 0 1-1.032.215c-1.418 0-2.256-.773-2.857-2.213-.237-.58-.495-.924-.989-.988-.258-.022-.344-.129-.344-.258 0-.258.43-.451.86-.451.623 0 1.16.386 1.719 1.181.43.623.881.903 1.418.903.537 0 .881-.194 1.375-.688.365-.365.645-.687.903-.902Z"/>
  95. </g>
  96. </svg>
  97. <span>Github</span>
  98. </a>
  99. </li>
  100. <li class="mr-6">
  101. <a class="py-2 md:mb-0 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
  102. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
  103. <g fill="currentColor">
  104. <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
  105. </g>
  106. </svg>
  107. <span>Discord</span>
  108. </a>
  109. </li>
  110. </ul>
  111. </nav>
  112. <div v-cloak class="flex justify-end grow">
  113. <div id="retype-mobile-search-button"></div>
  114. <doc-search-desktop></doc-search-desktop>
  115. <doc-theme-switch class="lg:ml-2"></doc-theme-switch>
  116. <doc-history></doc-history>
  117. </div>
  118. </div>
  119. </div>
  120. </header>
  121. <div id="retype-container" class="container relative flex bg-white">
  122. <!-- Sidebar Skeleton -->
  123. <div v-cloak class="fixed flex flex-col shrink-0 duration-300 ease-in-out bg-sidebar-left-bg border-sidebar-left-border sidebar top-20 w-75 border-r h-screen md:sticky transition-transform skeleton">
  124. <div class="flex items-center h-16 px-6">
  125. <input id="retype-filter-input-mock" class="w-full h-10 pl-8 px-3 py-2 transition-colors duration-200 ease-linear bg-filter-bg border border-filter-border rounded-lg shadow-none md:text-sm hover:border-filter-border-hover focus:outline-hidden focus:border-filter-border-focus placeholder-filter-placeholder" type="text">
  126. </div>
  127. <div class="pl-6 mt-1 mb-4">
  128. <div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  129. <div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  130. <div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  131. <div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  132. <div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  133. <div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  134. </div>
  135. <div class="shrink-0 mt-auto bg-transparent dark:border-base-border">
  136. <a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
  137. <span class="text-xs whitespace-nowrap">Powered by</span>
  138. <svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
  139. </a>
  140. </div>
  141. </div>
  142. <!-- Sidebar component -->
  143. <doc-sidebar v-cloak>
  144. <template #sidebar-footer>
  145. <div class="shrink-0 mt-auto border-t md:bg-transparent md:border-none dark:border-base-border">
  146. <div class="py-3 px-6 md:hidden border-b dark:border-base-border">
  147. <nav>
  148. <ul class="flex flex-wrap justify-center items-center">
  149. <li class="mr-6">
  150. <a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="">
  151. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
  152. <g fill="currentColor">
  153. <path d="M11.03 2.59a1.501 1.501 0 0 1 1.94 0l7.5 6.363a1.5 1.5 0 0 1 .53 1.144V19.5a1.5 1.5 0 0 1-1.5 1.5h-5.75a.75.75 0 0 1-.75-.75V14h-2v6.25a.75.75 0 0 1-.75.75H4.5A1.5 1.5 0 0 1 3 19.5v-9.403c0-.44.194-.859.53-1.144ZM12 3.734l-7.5 6.363V19.5h5v-6.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v6.25h5v-9.403Z"/>
  154. </g>
  155. </svg>
  156. <span>Home</span>
  157. </a>
  158. </li>
  159. <li class="mr-6">
  160. <a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://pocketpy.dev/static/web/" target="_blank">
  161. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
  162. <g fill="currentColor">
  163. <path d="M9.5 15.584V8.416a.5.5 0 0 1 .77-.42l5.576 3.583a.5.5 0 0 1 0 .842l-5.576 3.584a.5.5 0 0 1-.77-.42Z"/><path d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11-9.5A9.5 9.5 0 0 0 2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5Z"/>
  164. </g>
  165. </svg>
  166. <span>Live Demo</span>
  167. </a>
  168. </li>
  169. <li class="mr-6">
  170. <a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://pocketpy.github.io/examples/" target="_blank">
  171. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
  172. <g fill="currentColor">
  173. <path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/>
  174. </g>
  175. </svg>
  176. <span>Live Examples</span>
  177. </a>
  178. </li>
  179. <li class="mr-6">
  180. <a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://github.com/blueloveth/pocketpy" target="_blank">
  181. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
  182. <g fill="currentColor">
  183. <path d="M10.303 16.652c-2.837-.344-4.835-2.385-4.835-5.028 0-1.074.387-2.235 1.031-3.008-.279-.709-.236-2.214.086-2.837.86-.107 2.02.344 2.708.967.816-.258 1.676-.386 2.728-.386 1.053 0 1.913.128 2.686.365.666-.602 1.848-1.053 2.708-.946.3.581.344 2.085.064 2.815.688.817 1.053 1.913 1.053 3.03 0 2.643-1.998 4.641-4.877 5.006.73.473 1.224 1.504 1.224 2.686v2.235c0 .644.537 1.01 1.182.752 3.889-1.483 6.94-5.372 6.94-10.185 0-6.081-4.942-11.044-11.022-11.044-6.081 0-10.98 4.963-10.98 11.044a10.84 10.84 0 0 0 7.112 10.206c.58.215 1.139-.172 1.139-.752v-1.719a2.768 2.768 0 0 1-1.032.215c-1.418 0-2.256-.773-2.857-2.213-.237-.58-.495-.924-.989-.988-.258-.022-.344-.129-.344-.258 0-.258.43-.451.86-.451.623 0 1.16.386 1.719 1.181.43.623.881.903 1.418.903.537 0 .881-.194 1.375-.688.365-.365.645-.687.903-.902Z"/>
  184. </g>
  185. </svg>
  186. <span>Github</span>
  187. </a>
  188. </li>
  189. <li class="mr-6">
  190. <a class="block py-1 inline-flex items-center text-sm whitespace-nowrap transition-colors duration-200 ease-linear md:text-header-text font-header-text hover:text-header-text-hover" href="https://discord.gg/WWaq72GzXv" target="_blank">
  191. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px mr-1" width="18" height="18" viewBox="0 0 24 24" role="presentation">
  192. <g fill="currentColor">
  193. <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"/><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"/>
  194. </g>
  195. </svg>
  196. <span>Discord</span>
  197. </a>
  198. </li>
  199. </ul>
  200. </nav>
  201. </div>
  202. <a class="flex items-center justify-center flex-nowrap h-16 text-gray-350 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-300 transition-colors duration-150 ease-in docs-powered-by" target="_blank" href="https://retype.com/" rel="noopener">
  203. <span class="text-xs whitespace-nowrap">Powered by</span>
  204. <svg xmlns="http://www.w3.org/2000/svg" class="ml-2" fill="currentColor" width="96" height="20" overflow="visible"><path d="M0 0v20h13.59V0H0zm11.15 17.54H2.44V2.46h8.71v15.08zM15.8 20h2.44V4.67L15.8 2.22zM20.45 6.89V20h2.44V9.34z"/><g><path d="M40.16 8.44c0 1.49-.59 2.45-1.75 2.88l2.34 3.32h-2.53l-2.04-2.96h-1.43v2.96h-2.06V5.36h3.5c1.43 0 2.46.24 3.07.73s.9 1.27.9 2.35zm-2.48 1.1c.26-.23.38-.59.38-1.09 0-.5-.13-.84-.4-1.03s-.73-.28-1.39-.28h-1.54v2.75h1.5c.72 0 1.2-.12 1.45-.35zM51.56 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92h4.74v1.83h-6.79V5.36h6.64zM60.09 7.15v7.48h-2.06V7.15h-2.61V5.36h7.28v1.79h-2.61zM70.81 14.64h-2.06v-3.66l-3.19-5.61h2.23l1.99 3.45 1.99-3.45H74l-3.19 5.61v3.66zM83.99 6.19c.65.55.97 1.4.97 2.55s-.33 1.98-1 2.51-1.68.8-3.04.8h-1.23v2.59h-2.06V5.36h3.26c1.42 0 2.45.28 3.1.83zm-1.51 3.65c.25-.28.37-.69.37-1.22s-.16-.92-.48-1.14c-.32-.23-.82-.34-1.5-.34H79.7v3.12h1.38c.68 0 1.15-.14 1.4-.42zM95.85 5.36V7.2h-4.59v1.91h4.13v1.76h-4.13v1.92H96v1.83h-6.79V5.36h6.64z"/></g></svg>
  205. </a>
  206. </div>
  207. </template>
  208. </doc-sidebar>
  209. <div class="grow min-w-0 bg-body-bg">
  210. <!-- Render "toolbar" template here on api pages --><!-- Render page content -->
  211. <div class="flex">
  212. <div id="retype-main" class="min-w-0 p-4 grow md:px-16">
  213. <main class="relative pb-12 lg:pt-2">
  214. <div class="retype-markdown" id="retype-content">
  215. <!-- Rendered if sidebar right is enabled -->
  216. <div id="retype-sidebar-right-toggle"></div>
  217. <!-- Page content -->
  218. <doc-anchor-target id="debugging" class="break-words">
  219. <h1>
  220. <doc-anchor-trigger class="header-anchor-trigger" to="#debugging">#</doc-anchor-trigger>
  221. <span>Debugging</span>
  222. </h1>
  223. </doc-anchor-target>
  224. <doc-anchor-target id="install-vscode-extension">
  225. <h2>
  226. <doc-anchor-trigger class="header-anchor-trigger" to="#install-vscode-extension">#</doc-anchor-trigger>
  227. <span>Install VSCode Extension</span>
  228. </h2>
  229. </doc-anchor-target>
  230. <p>To debug a pocketpy program, you need to install our VSCode extension first:</p>
  231. <p><a href="https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy">https://marketplace.visualstudio.com/items?itemName=pocketpy.pocketpy</a></p>
  232. <div class="flex mb-6">
  233. <div class="shrink-0 w-1.5 rounded-tl-lg rounded-bl-lg bg-callout-primary"></div>
  234. <div class="flex w-full py-4 border border-l-0 rounded-tr-lg rounded-br-lg doc-callout bg-callout-base-bg border-callout-base-border" role="alert">
  235. <div class="flex items-center ml-4 h-7">
  236. <svg xmlns="http://www.w3.org/2000/svg" class="mb-px text-callout-primary" width="22" height="22" viewBox="0 0 24 24" role="presentation">
  237. <g fill="currentColor"><g>
  238. <path d="M12 1C5.93 1 1 5.93 1 12s4.93 11 11 11 11-4.93 11-11S18.07 1 12 1zm0 20c-4.96 0-9-4.04-9-9s4.04-9 9-9 9 4.04 9 9-4.04 9-9 9z"></path>
  239. <path d="M12 11c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1zM12.01 7c-.56 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"></path>
  240. <path fill="none" d="M0 0h24v24H0z"></path>
  241. </g></g>
  242. </svg>
  243. </div>
  244. <div class="pr-5 ml-3 w-full">
  245. <p>The VSCode extension requires pocketpy version &gt;= <code translate="no" v-pre>2.1.1</code></p>
  246. </div>
  247. </div>
  248. </div>
  249. <doc-anchor-target id="create-a-launchjson-file">
  250. <h2>
  251. <doc-anchor-trigger class="header-anchor-trigger" to="#create-a-launchjson-file">#</doc-anchor-trigger>
  252. <span>Create a <code translate="no" v-pre>launch.json</code> file</span>
  253. </h2>
  254. </doc-anchor-target>
  255. <p>Navigate to the Debug view in VSCode, and click on &quot;create a launch.json file&quot; link.
  256. In the dropdown menu, select &quot;pocketpy&quot;.</p>
  257. <p><figure class="content-center">
  258. <img src="../../static/debugger/launch_json.png" alt="launch_json" class="rounded-image-rounded border-image-border border-image-border-width" />
  259. <figcaption class="caption">launch_json</figcaption>
  260. </figure>
  261. </p>
  262. <p>Then a default <code translate="no" v-pre>launch.json</code> file will be created in the <code translate="no" v-pre>.vscode</code> folder
  263. with a sample pocketpy debug configuration.</p>
  264. <doc-anchor-target id="how-does-it-work">
  265. <h2>
  266. <doc-anchor-trigger class="header-anchor-trigger" to="#how-does-it-work">#</doc-anchor-trigger>
  267. <span>How does it work?</span>
  268. </h2>
  269. </doc-anchor-target>
  270. <p>pocketpy provides a C-API <code translate="no" v-pre>py_debugger_waitforattach</code>,
  271. which starts a debug server and waits for the VSCode extension to attach.
  272. When the debugger is attached, the program will continue to run.</p>
  273. <ul>
  274. <li>If you are using pocketpy&#x27;s standalone executable <code translate="no" v-pre>main.exe</code>, you can pass <code translate="no" v-pre>--debug</code> flag to it. This will automatically call <code translate="no" v-pre>py_debugger_waitforattach(&quot;127.0.0.1&quot;, 6110)</code> before running your program.</li>
  275. <li>If you are embedding pocketpy as a library, you need to call <code translate="no" v-pre>py_debugger_waitforattach</code> manually in your C/C++ code.</li>
  276. </ul>
  277. <doc-anchor-target id="configuration">
  278. <h2>
  279. <doc-anchor-trigger class="header-anchor-trigger" to="#configuration">#</doc-anchor-trigger>
  280. <span>Configuration</span>
  281. </h2>
  282. </doc-anchor-target>
  283. <ul>
  284. <li><code translate="no" v-pre>type</code>: must be <code translate="no" v-pre>pocketpy</code></li>
  285. <li><code translate="no" v-pre>request</code>: can be <code translate="no" v-pre>attach</code> or <code translate="no" v-pre>launch</code></li>
  286. <li><code translate="no" v-pre>name</code>: the name of this configuration</li>
  287. <li><code translate="no" v-pre>port</code>: the port number of the debug server, must match the one in <code translate="no" v-pre>py_debugger_waitforattach</code></li>
  288. <li><code translate="no" v-pre>host</code>: the host of the debug server, must match the one in <code translate="no" v-pre>py_debugger_waitforattach</code></li>
  289. <li><code translate="no" v-pre>sourceFolder</code>: the root folder of your python source code, default to <code translate="no" v-pre>${workspaceFolder}</code>. However,
  290. sometimes you may run your program from a subfolder, in this case you need to set <code translate="no" v-pre>sourceFolder</code> to the correct path. If this is not set correctly, breakpoints will not be hit.</li>
  291. <li><code translate="no" v-pre>program</code>: (for launch mode only) the path to the executable file which calls <code translate="no" v-pre>py_debugger_waitforattach</code>, e.g. the pocketpy standalone executable <code translate="no" v-pre>main.exe</code>.</li>
  292. <li><code translate="no" v-pre>args</code>: (for launch mode only) the arguments to pass to the executable file, e.g. <code translate="no" v-pre>--debug</code> and the script path if you are using <code translate="no" v-pre>main.exe</code>.</li>
  293. <li><code translate="no" v-pre>cwd</code>: (for launch mode only) the working directory to launch the executable file, default to <code translate="no" v-pre>${workspaceFolder}</code>.</li>
  294. </ul>
  295. <doc-anchor-target id="for-attach-mode">
  296. <h3>
  297. <doc-anchor-trigger class="header-anchor-trigger" to="#for-attach-mode">#</doc-anchor-trigger>
  298. <span>For attach mode</span>
  299. </h3>
  300. </doc-anchor-target>
  301. <p>In this mode, you need to start your pocketpy program manually which must call <code translate="no" v-pre>py_debugger_waitforattach</code> first.
  302. After the program starts, you can let VSCode attach to the debug server.</p>
  303. <div id="for-attach-mode-code-1" class="codeblock-wrapper"><doc-codeblock>
  304. <pre translate="no" class="language-json"><code v-pre class="language-json">{
  305. &quot;type&quot;: &quot;pocketpy&quot;,
  306. &quot;request&quot;: &quot;attach&quot;,
  307. &quot;name&quot;: &quot;Attach to pocketpy program&quot;,
  308. &quot;port&quot;: 6110,
  309. &quot;host&quot;: &quot;localhost&quot;,
  310. &quot;sourceFolder&quot;: &quot;${workspaceFolder}&quot;
  311. }</code></pre>
  312. </doc-codeblock></div>
  313. <doc-anchor-target id="for-launch-mode">
  314. <h3>
  315. <doc-anchor-trigger class="header-anchor-trigger" to="#for-launch-mode">#</doc-anchor-trigger>
  316. <span>For launch mode</span>
  317. </h3>
  318. </doc-anchor-target>
  319. <p>In this mode, VSCode will start your program with the specified <code translate="no" v-pre>program</code>, <code translate="no" v-pre>args</code> and <code translate="no" v-pre>cwd</code>.
  320. After the program starts, VSCode attempts to attach to the debug server automatically.</p>
  321. <div id="for-launch-mode-code-1" class="codeblock-wrapper"><doc-codeblock>
  322. <pre translate="no" class="language-json"><code v-pre class="language-json">{
  323. &quot;type&quot;: &quot;pocketpy&quot;,
  324. &quot;request&quot;: &quot;launch&quot;,
  325. &quot;name&quot;: &quot;Launch pocketpy program&quot;,
  326. &quot;port&quot;: 6110,
  327. &quot;host&quot;: &quot;localhost&quot;,
  328. &quot;sourceFolder&quot;: &quot;${workspaceFolder}&quot;,
  329. &quot;program&quot;: &quot;${workspaceFolder}/pocketpy/main.exe&quot;,
  330. &quot;args&quot;: [
  331. &quot;--debug&quot;
  332. ],
  333. &quot;cwd&quot;: &quot;${workspaceFolder}&quot;
  334. }</code></pre>
  335. </doc-codeblock></div>
  336. <doc-anchor-target id="showcase">
  337. <h2>
  338. <doc-anchor-trigger class="header-anchor-trigger" to="#showcase">#</doc-anchor-trigger>
  339. <span>Showcase</span>
  340. </h2>
  341. </doc-anchor-target>
  342. <p><figure class="content-center">
  343. <img src="../../static/debugger/debugger_demo.png" alt="debugger_demo" class="rounded-image-rounded border-image-border border-image-border-width" />
  344. <figcaption class="caption">debugger_demo</figcaption>
  345. </figure>
  346. </p>
  347. <!-- Required only on API pages -->
  348. <doc-toolbar-member-filter-no-results></doc-toolbar-member-filter-no-results>
  349. </div>
  350. <footer id="retype-content-footer" class="clear-both">
  351. <nav id="retype-nextprev" class="print:hidden flex mt-14">
  352. <div class="w-1/2">
  353. <a class="px-5 py-4 h-full flex items-center break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-l-lg transition-colors duration-150 relative hover:z-5" href="../../features/deploy/">
  354. <svg xmlns="http://www.w3.org/2000/svg" class="mr-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19 11H7.41l5.29-5.29a.996.996 0 10-1.41-1.41l-7 7a1 1 0 000 1.42l7 7a1.024 1.024 0 001.42-.01.996.996 0 000-1.41L7.41 13H19c.55 0 1-.45 1-1s-.45-1-1-1z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
  355. <span>
  356. <span class="block text-xs font-normal text-base-text-muted">Previous</span>
  357. <span class="block mt-1">Deploy Bytecodes</span>
  358. </span>
  359. </a>
  360. </div>
  361. <div class="w-1/2">
  362. <a class="px-5 py-4 -mx-px h-full flex items-center justify-end break-normal font-medium text-body-link border border-base-border hover:border-base-border-hover rounded-r-lg transition-colors duration-150 relative hover:z-5" href="../../features/profiling/">
  363. <span>
  364. <span class="block text-xs font-normal text-right text-base-text-muted">Next</span>
  365. <span class="block mt-1">Profiling</span>
  366. </span>
  367. <svg xmlns="http://www.w3.org/2000/svg" class="ml-3" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" overflow="visible"><path d="M19.92 12.38a1 1 0 00-.22-1.09l-7-7a.996.996 0 10-1.41 1.41l5.3 5.3H5c-.55 0-1 .45-1 1s.45 1 1 1h11.59l-5.29 5.29a.996.996 0 000 1.41c.19.2.44.3.7.3s.51-.1.71-.29l7-7c.09-.09.16-.21.21-.33z" /><path fill="none" d="M0 0h24v24H0z" /></svg>
  368. </a>
  369. </div>
  370. </nav>
  371. </footer>
  372. </main>
  373. <div id="retype-page-footer" class="print:border-none border-t border-base-border pt-6 mb-8">
  374. <footer class="flex flex-wrap items-center justify-between print:justify-center">
  375. <div id="retype-footer-links" class="print:hidden">
  376. <ul class="flex flex-wrap items-center text-sm">
  377. </ul>
  378. </div>
  379. <div id="retype-copyright" class="print:justify-center py-2 text-footer-text font-footer-link text-sm leading-relaxed"><p>© Copyright 2026 - <a href="https://github.com/blueloveTH">blueloveTH</a> - All rights reserved.</p></div>
  380. </footer>
  381. </div>
  382. </div>
  383. <!-- Rendered if sidebar right is enabled -->
  384. <!-- Sidebar right skeleton-->
  385. <div v-cloak class="fixed top-0 bottom-0 right-0 translate-x-full bg-sidebar-right-bg border-sidebar-right-border lg:sticky lg:border-l lg:shrink-0 lg:pt-6 lg:translate-x-0 sm:w-1/2 lg:w-64 lg:z-0 md:w-104 sidebar-right skeleton">
  386. <div class="pl-5">
  387. <div class="w-32 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  388. <div class="w-48 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  389. <div class="w-40 h-3 mb-4 bg-skeleton-bg rounded-full loading"></div>
  390. </div>
  391. </div>
  392. <!-- User should be able to hide sidebar right -->
  393. <doc-sidebar-right v-cloak></doc-sidebar-right>
  394. </div>
  395. </div>
  396. </div>
  397. <doc-search-mobile></doc-search-mobile>
  398. <doc-back-to-top></doc-back-to-top>
  399. </div>
  400. <div id="retype-overlay-target"></div>
  401. <script data-cfasync="false">window.__DOCS__ = { "title": "Debugging", level: 2, icon: "file", hasPrism: true, hasMermaid: false, hasMath: false, tocDepth: 23 }</script>
  402. </body>
  403. </html>