{"id":499,"date":"2022-07-27T12:45:09","date_gmt":"2022-07-27T19:45:09","guid":{"rendered":"https:\/\/sysprogs.com\/tutorials\/?p=499"},"modified":"2022-09-15T18:04:05","modified_gmt":"2022-09-16T01:04:05","slug":"installing-development-builds-of-virtualbox-with-gdb-support","status":"publish","type":"post","link":"https:\/\/sysprogs.com\/VisualKernel\/documentation\/vboxdev\/","title":{"rendered":"Installing Development builds of VirtualBox with GDB Support"},"content":{"rendered":"<p>The recent versions of VirtualBox support debugging the target directly (i.e. without the use of <strong>kgdboe<\/strong> or <strong>kgdboe<\/strong>) with a <a href=\"https:\/\/www.virtualbox.org\/browser\/vbox\/trunk\/src\/VBox\/Debugger\/DBGCGdbRemoteStub.cpp\">built-in GDB stub<\/a>.<\/p>\n<p>However, this functionality is <strong>only available in the development snapshots of VirtualBox<\/strong> and requires disabling the Hyper-V platform on the <strong>host.<\/strong><\/p>\n<p>In order to debug a Linux kernel running inside a VirtualBox VM, follow the steps below:<\/p>\n<ol>\n<li>Download and install the latest <a href=\"https:\/\/www.virtualbox.org\/wiki\/Testbuilds\">development snapshot<\/a> of VirtualBox (not a test build). You can also get the latest version successfully tested with VisualKernel <a href=\"https:\/\/sysprogs.com\/gettool?tool=VirtualBox\">here<\/a>. <a href=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2022\/07\/build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-500 aligncenter\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2022\/07\/build.png\" alt=\"\" width=\"349\" height=\"550\" \/><\/a><\/li>\n<li>When the VM is stopped, run the following commands:\n<pre class=\"\">vboxmanage [.vbox file path] setextradata VBoxInternal\/DBGC\/gdb\/Provider TCP\r\nvboxmanage [.vbox file path] setextradata VBoxInternal\/DBGC\/gdb\/StubType Gdb\r\nvboxmanage [.vbox file path] setextradata VBoxInternal\/DBGC\/gdb\/Port 1234<\/pre>\n<p>Replace 1234 with the port number on the <strong>host<\/strong> that you would like to use for debugging.<\/li>\n<li>Start the VM. Once it loads, start a <strong>gdb<\/strong> executable on the <strong>host<\/strong> and run the following command:\n<pre class=\"\">target remote :1234<\/pre>\n<\/li>\n<\/ol>\n<p>You will now be able to debug the target kernel using VirtualBox.<\/p>\n<h2>Limitations<\/h2>\n<p>The VirtualBox GDB stub has the following known limitations:<\/p>\n<ol>\n<li>It is only supported in the development snapshots of VirtualBox. Stable releases do not include it.<\/li>\n<li>It does not work when the <strong>host<\/strong> has Hyper-V virtualization enabled. If you encounter strange debugging behavior, make sure Hyper-V is disabled:<a href=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2022\/07\/hyperv.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-501\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2022\/07\/hyperv.png\" alt=\"\" width=\"415\" height=\"368\" \/><\/a><\/li>\n<li>The VirtualBox GDB stub has higher latency than the VMWare or QEMU gdb stubs. Expect a ~1 second delay after hitting each breakpoint. If the overall debugging performance is too slow, try disabling the <strong>printk()<\/strong> hook in VisualKernel settings, as it involves setting a breakpoint.<\/li>\n<\/ol>\n<h2>Integration with Visual Studio<\/h2>\n<p>See <a href=\"https:\/\/sysprogs.com\/VisualKernel\/tutorials\/virtualbox\/\">this tutorial<\/a> for detailed steps on debugging a VirtualBox guest kernel with Visual Studio.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The recent versions of VirtualBox support debugging the target directly (i.e. without the use of kgdboe or kgdboe) with a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57],"tags":[25,26],"_links":{"self":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/499"}],"collection":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/comments?post=499"}],"version-history":[{"count":2,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/499\/revisions"}],"predecessor-version":[{"id":579,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/499\/revisions\/579"}],"wp:attachment":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/media?parent=499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/categories?post=499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/tags?post=499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}