h8クロスgdbでprintf

PCやフリーソフト関係のTipsと私的備忘録

カテゴリ[h8]

h8クロスgdbのシュミレータ上でprintfを使う

環境は VineLinux4.0 上の binutils-2.16.1, gcc-4.0.3, newlib-1.14.0, gdb-6.5 の組合せ。

$ cat hello.c
#include <stdio.h>

int main()
{
        int i, j;
        for (i = 0; i < 10; i++){
          printf("<%d> Hello World!\n", i);
          j = i + 1;
        }
}

$ h8300-hms-gcc -o hello -g -mh -mn hello.c

$ h8300-hms-gdb hello
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=h8300-hms"...
(gdb) set architecture h8300hn
The target architecture is assumed to be h8300hn
(gdb) target sim
Connected to the simulator.
(gdb) load
Loading section .text, size 0x88e8 vma 0x100
Loading section .data, size 0x462 vma 0x89e8
Loading section .stack, size 0x4 vma 0xfefc
Start address 0x438
Transfer rate: 289392 bits in <1 sec.
(gdb) run
Starting program: /home/kyo/src/h8/hello/hello
<0> Hello World!
<1> Hello World!
<2> Hello World!
<3> Hello World!
<4> Hello World!
<5> Hello World!
<6> Hello World!
<7> Hello World!
<8> Hello World!
<9> Hello World!

Program exited with code 021.
(gdb) q

参照: GNU による AKI-H8 のプログラム開発, 文字列出力(printf)をシミュレータ と実機両方で使えるようにする