- 次のコマンドを実行し、現在ビルド済みの Linux を使用して QEMU を起動します。
petalinux-boot --qemu --kernel
- QEMU のコンソールを確認します。QEMU コマンドの詳細を表示します。-gdb tcp:<TCP_PORT> から GDB TCP を取得します。
- PetaLinux の settings スクリプトが実行済みであることを確認して別のコマンド コンソールを開き、Linux ディレクトリに移動します。
cd "<plnx-proj-root>/images/linux"
- vmlinux カーネル イメージに対してコマンド モードで GDB を起動します。
petalinux-util --gdb vmlinux
GDB プロンプトが表示されます。次に例を示します。
petalinux-util --gdb vmlinux GNU gdb (GDB) 12.1 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-petalinux-linux --target=aarch64-xilinx-linux". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from vmlinux... (No debugging symbols found in vmlinux) (gdb)
- 次の GDB コマンドを実行し、GDB で QEMU ターゲットに接続します。
(gdb) target remote :9000
- QEMU の実行を継続します。
(gdb) continue
-
Ctrl+C
を押すとカーネル実行を中断して GDB プロンプトに戻ることができます。 - ブレークポイントを設定し、ほかの GDB コマンドを実行してカーネルをデバッグできます。
注意:
ポート 9000 がほかのプロセスで使用中の場合、
petalinux-boot
で別のポートの使用が試みられます。petalinux-boot
の出力を見て、どのポートが使用されているかを確認してください。たとえば、「INFO: qemu-system-arm ... -gdb
tcp::9001 ...
」と表示される場合は、ポート 9001 が使用されています。ヒント: カーネル コンフィギュレーション メニューで を選択してカーネル デバッグを有効にし、カーネル デバッグ シンボルをイメージに含めることを推奨します。