{"id":572,"date":"2022-09-13T20:48:50","date_gmt":"2022-09-14T03:48:50","guid":{"rendered":"https:\/\/sysprogs.com\/tutorials\/?p=572"},"modified":"2022-09-13T20:52:06","modified_gmt":"2022-09-14T03:52:06","slug":"linuxkerneldebughelper-module","status":"publish","type":"post","link":"https:\/\/sysprogs.com\/VisualKernel\/documentation\/debughelper\/","title":{"rendered":"LinuxKernelDebugHelper Module"},"content":{"rendered":"<p>VisualKernel can greatly enhance the kernel debugging experience by building and installing <strong>LinuxKernelDebugHelper.ko<\/strong> &#8211; a special kernel module facilitating several debugging tasks.<\/p>\n<h2>Overview<\/h2>\n<p>The module implements the following functionality:<\/p>\n<ul>\n<li>Maintains a list of currently loaded kernel modules and allows VisualKernel to query them instantly. This saves considerable time compared to parsing the kernel module structures manually.<\/li>\n<li>Serves as a back end for Live Watch &#8211; the mechanism for viewing the values of kernel variables in real time without stopping the kernel in debugger.<\/li>\n<\/ul>\n<p>You can configure VisualKernel to build the KernelDebugHelper module via the <strong>VisualKernel Project Properties -&gt; Debug Settings -&gt; Obtain module information via -&gt; Optimized Kernel Module<\/strong>.<br \/>\n<a id=\"troubleshooting\"><\/a><\/p>\n<h2>Troubleshooting<\/h2>\n<p>We normally test <strong>LinuxKernelDebugHelper<\/strong> for compatibility with recent kernel releases, however if you are using a rare (or a very new) kernel version, the module may not build out-of-the-box. If this happens, VisualKernel will display an error message showing the detailed build log:<a href=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2022\/09\/error.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-573\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2022\/09\/error.png\" alt=\"\" width=\"786\" height=\"493\" \/><\/a>You can troubleshoot the build errors as shown below:<\/p>\n<ol>\n<li>Locate the source code of <strong>LinuxKernelDebugHelper<\/strong> under <strong>C:\\Program Files (x86)\\Sysprogs\\VisualKernel\\KernelTools\\Common<\/strong> and copy them to your target. If you have previously attempted building the module with VisualKernel, the source will be already uploaded to <strong>\/tmp\/LinuxKernelDebugHelper-&lt;GUID&gt;<\/strong>.<\/li>\n<li>Run the following command lines:\n<pre class=\"\">sh configure.sh \/lib\/modules\/$(uname -r)\/build\r\nmake -C \/lib\/modules\/$(uname -r)\/build M=$(pwd) modules<\/pre>\n<p>If the build fails due to an error in <strong>LiveMemoryEngine.c<\/strong>, your kernel might be configured without network support:<a href=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2022\/09\/build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-574\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2022\/09\/build.png\" alt=\"\" width=\"1147\" height=\"551\" \/><\/a>If this happens, you can disable the live memory functionality by building the module as shown below:<\/p>\n<pre class=\"\"> make -C \/lib\/modules\/$(uname -r)\/build M=$(pwd) DISABLE_LIVE_MEMORY_ENGINE=1 modules<\/pre>\n<p>If you manually disabled the live memory support, make sure you also disable Live Watch via <strong>VisualKernel Project Properties -&gt; Debug Settings -&gt; Live Watch -&gt; Show live values of variables -&gt; Never<\/strong>. Otherwise, VisualKernel will try to build the module again.<\/li>\n<li>Once the module has been built successfully, run the following command to find out the address of <strong>kallsyms_lookup_name()<\/strong>:\n<pre class=\"\">sudo cat \/proc\/kallsyms | grep kallsyms_lookup_name<\/pre>\n<p>Then load the newly built module passing the address of <strong>kallsyms_lookup_name()<\/strong> to it as a parameter:<\/p>\n<pre class=\"\">sudo insmod .\/LinuxKernelDebugHelper.ko kallsyms_lookup_name_address=0x&lt;...&gt;<\/pre>\n<p><a href=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2022\/09\/insmod.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-575\" src=\"https:\/\/sysprogs.com\/tutorials\/wp-content\/uploads\/2022\/09\/insmod.png\" alt=\"\" width=\"1452\" height=\"271\" \/><\/a><\/li>\n<\/ol>\n<p>You can verify that the module is loaded by running &#8220;sudo dmesg&#8221; or &#8220;cat \/proc\/com_sysprogs_LinuxKernelDebugHelper_DebugBlockAddress_v2&#8221;. If the file in <strong>\/proc<\/strong> is present, VisualKernel will be able to use the functionality provided by the module.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>VisualKernel can greatly enhance the kernel debugging experience by building and installing LinuxKernelDebugHelper.ko &#8211; a special kernel module facilitating several<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[],"_links":{"self":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/572"}],"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=572"}],"version-history":[{"count":3,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/572\/revisions"}],"predecessor-version":[{"id":578,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/572\/revisions\/578"}],"wp:attachment":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/media?parent=572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/categories?post=572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/tags?post=572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}