Arria 10 SoC バーチャル・プラットフォーム ユーザーガイド

ID 683326
日付 9/16/2015
Public
ドキュメント目次

1.6.6. ホスト上でのgdbクライアントを使用したデバッグ

  1. ホスト上でgdbクライアントを実行します。
    gdb-multiarch ./factorial.out
    Process ./factorial.out created; pid = 229
    Listening on port 8080
  2. ターゲットへgdbを接続します。
    注: 「ネットワーク接続」の項に記載されたVLANポート・マッピングにあるよう、この例では192.168.0.9:8080ではなくlocalhost:3624が使用されています。
    (gdb) target remote localhost:3624
    Remote debugging using localhost:3624
    warning: Unable to find dynamic linker breakpoint function.
    GDB will be unable to debug shared library initializers
    and track explicitly loaded dynamic code.
    0x76fcfb00 in ?? ()
  3. コードをデバッグするには、次のgdbサンプル・コマンドを使用します。
    • b mainmainファンクションでブレークポイントを設定します
    • c:ブレークポイントに至るまで継続します
    • s:ステップ・ワン・インストラクション
    • b 14:行14にブレークポイントを挿入します
    • c typed multiple times:ループの繰り返しを実行します
    • l:List code

    ホスト・コンソールは以下に類似します。

    <name>@ubuntu-12:~$ gdb-multiarch ./factorial.out
    GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1)7.4-2012.04
    Copyright (C) 2012 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 "x86_64-linux-gnu".
    For bug reporting instructions, please see:
    <http://bugs.launchpad.net/gdb-linaro/>...
    Reading symbols from /home/<name>/factorial.out...done.
    (gdb) target remote localhost:3624
    Remote debugging using localhost:3624
    warning: Unable to find dynamic linker breakpoint function.
    GDB will be unable to debug shared library initializers
    and track explicitly loaded dynamic code.
    0x76fcfb00 in ?? ()
    (gdb) b main
    Cannot access memory at address 0x0
    Breakpoint 1 at 0x83ce: file factorial.c, line 12.
    (gdb) c
    Continuing.
    warning: Could not load shared library symbols for 2 libraries, e.g. 
    /lib/libc.so.6.
    Use the "info sharedlibrary" command to see the complete listing.
    Do you need "set solib-search-path" or "set sysroot"? 
    
    Breakpoint 1, main () at factorial.c:12
    12         for (i = 0; i < 10; ++i) {
    (gdb) l
    7     }
    8     
    9     int main () {
    10         int i;
    11         int n;
    12         for (i = 0; i < 10; ++i) {
    13                n = factorial (i);
    14                printf ("factorial(%d) = %d\n", i, n);
    15         }
    16         return 0;
    (gdb) b 14
    Breakpoint 2 at 0x83de: file factorial.c, line 14.
    (gdb) c
    Continuing. 
    Breakpoint 2, main () at factorial.c:14
    14                printf ("factorial(%d) = %d\n", i, n);
    (gdb) s
    Cannot access memory at address 0x0 
    Breakpoint 2, main () at factorial.c:14
    14                printf ("factorial(%d) = %d\n", i, n);
    (gdb) c
    Continuing. 
    Breakpoint 2, main () at factorial.c:14
    14                printf ("factorial(%d) = %d\n", i, n);
    (gdb) c
    Continuing. 
    Breakpoint 2, main () at factorial.c:14
    14                printf ("factorial(%d) = %d\n", i, n);
    (gdb) c
    Continuing. Breakpoint 2, main () at factorial.c:14
    14                printf ("factorial(%d) = %d\n", i, n);
    (gdb) c
    Continuing. 
    Breakpoint 2, main () at factorial.c:14
    14                printf ("factorial(%d) = %d\n", i, n);
    (gdb) c

    ターゲット・コンソールは以下に類似します。

    root@host:~# gdbserver :8080 ./factorial.out
    Process ./factorial.out created; pid = 229
    Listening on port 8080
    Remote debugging from host 192.168.0.1
    factorial(0) = 1
    factorial(1) = 1
    factorial(2) = 2
    factorial(3) = 6
    factorial(4) = 24
    factorial(5) = 120
    factorial(6) = 720
    factorial(7) = 5040
    factorial(8) = 40320
    factorial(9) = 362880 
    
    Child exited with status 0