aboutsummaryrefslogtreecommitdiffstats
path: root/dev/c/system.html
diff options
context:
space:
mode:
authorpunk <punk@libernaut>2021-04-21 15:26:19 +0100
committerpunk <punk@libernaut>2021-04-21 15:26:19 +0100
commiteac48b5a8d709135a95abcc2243b369095f074f4 (patch)
treea2e34d995cef5ac8068ec7047e93b1125c80d175 /dev/c/system.html
parent3bd43803fc8cb7a39a87394cb7c491ddc151e06b (diff)
parent452477a2635d85ecf772a5242ce97d9479503bb3 (diff)
downloaddoc-eac48b5a8d709135a95abcc2243b369095f074f4.tar.gz
release 0.7.0
Diffstat (limited to 'dev/c/system.html')
-rw-r--r--dev/c/system.html107
1 files changed, 88 insertions, 19 deletions
diff --git a/dev/c/system.html b/dev/c/system.html
index de9dab5..d1d6558 100644
--- a/dev/c/system.html
+++ b/dev/c/system.html
@@ -15,35 +15,87 @@
will run on and GDB will connect to it to help us
understand how things tick.</p>
- <h2>Kernel Build</h2>
+ <h2>Build Kernel</h2>
<pre>
- $ tar xf linux-4.9.48.tar.xz
- $ cd linux-4.9.48
+ $ tar xf linux-4.9.258.tar.xz
+ $ cd linux-4.9.258
</pre>
<p>Default configuration disable some security
configurations that allow us to debug (random memory
- layout).</p>
+ layout KALSR), CONFIG_COMPAT_BRK don't randomize
+ position of the programs (randomize_va_space) useful when
+ debugging a program (<a href="tracing.html">tracing</a>).
+ Configuration flags to enable;</p>
+
+ <ul>
+ <li>CONFIG_64BIT</li>
+ <li>CONFIG_DEBUG_KERNEL</li>
+ <li>CONFIG_HAVE_ARCH_KGDB</li>
+ <li>CONFIG_FTRACE</li>
+ <li>CONFIG_PRINTK</li>
+ <li>CONFIG_BLK_DEV_INITRD</li>
+ <li>CONFIG_BINFMT_ELF</li>
+ <li>CONFIG_TTY</li>
+ <li>CONFIG_DEBUG_INFO</li>
+ <li>CONFIG_DEBUG_INFO_DWARF4</li>
+ <li>CONFIG_GDB_SCRIPTS</li>
+ <li>CONFIG_READABLE_ASM</li>
+ <li>CONFIG_FRAME_POINTER</li>
+ <li>CONFIG_KGDB</li>
+ <li>CONFIG_KGDB_LOW_LEVEL_TRAP</li>
+ <li>CONFIG_EARLY_PRINTK</li>
+ <li>CONFIG_COMPAT_BRK</li>
+ </ul>
+
+ <p>And to disable;</p>
+
+ <ul>
+ <li>CONFIG_CC_OPTIMIZE_FOR_SIZE</li>
+ </ul>
+
+
+ <p>This changes can be achieved by creating a config-fragment and then
+ merge it with the configuration.</p>
<pre>
- $ make x86_64_defconfig
+ $ cat &lt;&lt;EOF &gt;.config-fragment
+ CONFIG_64BIT=y
+ CONFIG_DEBUG_KERNEL=y
+ CONFIG_HAVE_ARCH_KGDB=y
+ CONFIG_COMPAT_BRK=y
+ CONFIG_FTRACE=y
+ CONFIG_PRINTK=y
+ CONFIG_BLK_DEV_INITRD=y
+ CONFIG_BINFMT_ELF=y
+ CONFIG_TTY=y
+ CONFIG_DEBUG_INFO=y
+ CONFIG_DEBUG_INFO_DWARF4=y
+ CONFIG_GDB_SCRIPTS=y
+ CONFIG_READABLE_ASM=y
+ CONFIG_FRAME_POINTER=y
+ CONFIG_KGDB=y
+ CONFIG_KGDB_LOW_LEVEL_TRAP=y
+ CONFIG_EARLY_PRINTK=y
+ CONFIG_CC_OPTIMIZE_FOR_SIZE=n
+ EOF
</pre>
- <p>Enable CONFIG_DEBUG_INFO, CONFIG_DEBUG_INFO_DWARF4
- and CONFIG_GDB_SCRIPTS in the kernel;</p>
+ <p>Create a tiny config;</p>
<pre>
- make x86_64_defconfig
- cat &lt;&lt;EOF &gt;.config-fragment
- CONFIG_DEBUG_INFO=y
- CONFIG_DEBUG_KERNEL=y
- CONFIG_GDB_SCRIPTS=y
- EOF
- ./scripts/kconfig/merge_config.sh .config .config-fragment
+ $ make ARCH=x86_64 tinyconfig
</pre>
- <p>Check or change to your needs the configuration;</p>
+ <p>Merge config with the following script;</p>
+
+ <pre>
+ $ ./scripts/kconfig/merge_config.sh .config .config-fragment
+ </pre>
+
+ <p>Check or change the configuration according to your needs;</p>
+
<pre>
$ make nconfig
</pre>
@@ -138,7 +190,7 @@
-ex "file vmlinux" \
-ex 'set arch i386:x86-64:intel' \
-ex 'target remote localhost:1234' \
- -ex 'break start_kernel' \
+ -ex 'hbreak start_kernel' \
-ex 'continue' \
-ex 'disconnect' \
-ex 'set arch i386:x86-64' \
@@ -169,11 +221,28 @@
(gdb)
</pre>
+ <p>lx-symbols allows to debug kernel modules, after starting the vm and loading
+ the module use lx-symbols to load the symbols from all the modules loaded in
+ the kernel.</p>
+
+ <pre>
+ (gdb) apropos lx
+ (gdb) lx-symbols
+ </pre>
+
+ <p>It's useful to set conditional breakpoints or a break point can be trigger
+ by unrelated tasks, example of a break point on do_exit function but only by
+ the process with pid 1;</p>
+
+ <pre>
+ (gdb) br do_exit if $lx_current()->pid == 1
+ </pre>
+
<a href="index.html">C Index</a>
<p>
- This is part of the Tribu System Documentation.
- Copyright (C) 2020
- Tribu Team.
+ This is part of the LeetIO System Documentation.
+ Copyright (C) 2021
+ LeetIO Team.
See the file <a href="../../fdl-1.3-standalone.html">Gnu Free Documentation License</a>
for copying conditions.</p>