{"id":132,"date":"2018-02-05T15:45:07","date_gmt":"2018-02-05T23:45:07","guid":{"rendered":"https:\/\/sysprogs.com\/tutorials\/?p=132"},"modified":"2018-02-05T15:51:15","modified_gmt":"2018-02-05T23:51:15","slug":"getting-kernel-symbolssources-on-ubuntu-linux","status":"publish","type":"post","link":"https:\/\/sysprogs.com\/VisualKernel\/tutorials\/setup\/ubuntu\/","title":{"rendered":"Getting Kernel Symbols\/Sources on Ubuntu Linux"},"content":{"rendered":"<p>This tutorial shows how to prepare your a Debian-based (e.g. Ubuntu, Mint) Linux machine for kernel debugging without rebuilding the kernel.<\/p>\n<p>Note that if you are using VisualKernel, this will be done automatically by the VisualKernel project wizard. This page provides instructions on doing it manually in order to help diagnosing common problems.<\/p>\n<p>As the kernel provided by the distribution does not include sources and symbols, we will need to install the corresponding packages manually. This page provides step-by-step instructions on doing that:<\/p>\n<ol>\n<li>Determine the exact\u00a0<strong>release<\/strong>\u00a0and\u00a0<strong>version<\/strong>\u00a0of your kernel by running the following commands:\n<pre class=\"code\">uname -r\r\nuname -v<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/setup\/ubuntu\/img\/01-kernelver.png\" width=\"596\" height=\"374\" \/>In this example the release is\u00a0<strong>3.8.0-19-generic<\/strong>\u00a0and the version number is\u00a0<strong>#29<\/strong>.<\/li>\n<li>Determine the Debian release codename by running the &#8220;lsb_release -c&#8221; command:<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/setup\/ubuntu\/img\/02-codename.png\" width=\"645\" height=\"419\" \/>In this example the release codename is\u00a0<strong>raring<\/strong>.<\/li>\n<li>Add the following line to the\u00a0<strong>\/etc\/apt\/sources.list.d\/ddebs.list<\/strong>\u00a0file (create it if it doesn&#8217;t exist):\n<div>\n<pre class=\"code\">deb http:\/\/ddebs.ubuntu.com\/ &lt;codename&gt; main restricted universe multiverse<\/pre>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/setup\/ubuntu\/img\/03-repo.png\" width=\"645\" height=\"421\" \/>This will add a repository containing debugging symbols to your system&#8217;s repository list.<\/li>\n<li>Run &#8216;sudo apt-get update&#8217; to load the package list from the new repository:<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/setup\/ubuntu\/img\/04-update.png\" width=\"645\" height=\"421\" \/><\/li>\n<li>Now that the repository has been added, you can install the symbol package by running the following command:\n<pre class=\"code\">apt-get install linux-image-&lt;release&gt;-dbgsym=&lt;release&gt;.&lt;version&gt;<\/pre>\n<p>In this example the package name\/version are\u00a0<strong>linux-image-3.8.0-19-generic-dbgsym=3.8.0-19.29<\/strong><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/setup\/ubuntu\/img\/05-install.png\" width=\"645\" height=\"421\" \/><\/li>\n<li>Once the package is installed, go to\u00a0<strong>\/usr\/lib\/debug\/boot<\/strong>, locate the kernel symbol file matching your current version, open it with gdb and ensure that its version matches the version\/release discovered in step 1:<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/setup\/ubuntu\/img\/06-check.png\" width=\"645\" height=\"466\" \/><\/li>\n<li>The symbol file you have installed allows setting breakpoints by function names and viewing local variables, however you won&#8217;t be able to display source file contents unless you install the source package. The sources can be installed using the following command:\n<pre class=\"code\">apt-get install linux-source-&lt;release&gt;-dbgsym=&lt;release&gt;.&lt;version&gt;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/setup\/ubuntu\/img\/07-sources.png\" width=\"645\" height=\"421\" \/><\/li>\n<li>Once the package is installed, go to \/usr\/src\/linux-source-&lt;release&gt; and unpack the source tarball:<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/setup\/ubuntu\/img\/08-unpack.png\" width=\"663\" height=\"466\" \/><\/li>\n<\/ol>\n<p>Now that you have both symbols and sources installed, you can use gdb to successfully debug your kernel.<\/p>\n<p>Note that if you are using VisualKernel, the sources\/symbols will be automatically installed by the new project wizard (see\u00a0<a href=\"http:\/\/sysprogs.com\/VisualKernel\/tutorials\/kgdb\/\">this tutorial<\/a>\u00a0for an example).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to prepare your a Debian-based (e.g. Ubuntu, Mint) Linux machine for kernel debugging without rebuilding the<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41,1],"tags":[],"_links":{"self":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/132"}],"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=132"}],"version-history":[{"count":1,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/132\/revisions"}],"predecessor-version":[{"id":133,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/132\/revisions\/133"}],"wp:attachment":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/media?parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/categories?post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/tags?post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}