Sunday, September 5, 2010

How to use gdb server

디버깅 방식은 원격 디버깅방법을 사용할려고 합니다.

그래서 관련 자료를 찾아보니 다음과 같이 하더군요

호스트 PC <-----------------------> 타겟보드
gdb <-----------------------> gdbserver

GDB-5.3을 사용했습니다.

먼저 호스트PC에는 다음과 같이 설정 및 컴파일 했습니다.

./configure --host=i686-pc-linux-gnu --prefix=/usr/local/gdb-5.3-x86 --norecursion

이렇게 하니 호스트PC의 /usr/local/gdb-5.3-x86 디렉토리에 설치가 되더군요..

그래서 테스트삼아 hello 프로그램을 작성하여 gdb 를 실행하니 잘 됩니다.


이제는 타겟보드에 사용될 GDB는 다음과 같이 설정 및 컴파일했습니다.

./configure --target=arm-linux --host=arm-linux --build=i686-pc-linux-gnu --prefix=/usr/local/gdb-5.3-x86 --norecursion

호스트PC의 /usr/local/gdb-5.3-arm 디렉토리에 설치되더군요...

file 명령어를 사용하여 /usr/local/gdb-5.3-arm/bin 디렉토리에 있는 실행파일들을 살펴보니 ARM 버전으로 잘 나왔습니다.

그래서 타겟보드상의 /usr/local 디렉토리에 nfs 를 이용하여 복사를 했습니다.

즉 호스트 PC의 ARM용 GDB를 타겟보드에 탑재하였습니다.

타겟보드의 /usr/local/gdb-5.3-arm/bin 디렉토리에는 gdb, gdbserver 실행파일이 있습니다.

그래서 먼저 타겟보드에서 다음과 같이 실행했습니다.

(1) # gdbserver 203.253.176.177:8080 hello

Process hello created; pid = 73

그리고 호스트PC에서 다음과 같이 실행했습니다.

(2) # gdb
GNU gdb 5.3
Copyright 2002 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 "i686-pc-linux-gnu".

(3) (gdb) target remote 203.253.176.177:8080 hello
Remote debugging using 203.253.176.177 hello
0x00000000 in ?? ()

출력이 어째 좀 이상합니다. (3)을 호스트PC에서 실행시켰을때 타겟보드에서는 다음과 같이 출력됩니다.

(4) Remote debugging from host 203.253.176.177


그래서 호스트PC에서 gdb의 명령어를 실행하면 다음과 같이 출력됩니다.

(gdb) b hello.c:7
No symbol table is loaded. Use the "file" command.
(gdb) n
Cannot find bounds of current function
(gdb) list
No symbol table is loaded. Use the "file" command.
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program:
No executable file specified.
Use the "file" or "exec-file" command.


그리고 타겟보드에서는 다음과 같이 출력되고 끝나버립니다.

Killing inferior

뭐가 잘못된 건지요...

제가 잘못 설정하고 컴파일했나요?

도움부탁드립니다.

No comments:

Post a Comment