gdbserver 질문입니다.
gdbserver와 gdb사용법에 대해 의문이 들어 질문 올립니다.
gdbserver를 이용하지 않고 gdb a.out을 하면 모든 명령이 잘 먹습니다.
그런데 gdbserver로 실행을 시키고
gdb로 원격접속을 하니 제대로 명령이 먹지 않네요.
하다못해 브레이크 포인트라도 걸어야 하는데 브레이크포인터 설정도 안대고, 무엇이 잘못인지 모르겟습니다.
gnu에서 5.3버전을 받아서 제컴에서 컴파일해서 나온 gdb,gdbserver로 사용을 햇습니다.
아래는 제 화면입니다.
---서버쪽 화면
[root@localhost aaa]# ./gdbserver 192.168.1.20:5000 ts
Process ts created; pid = 26231
Remote debugging from host 192.168.1.20
input:1234567
1073828704
---클라이언트화면
[root@localhost test]# gdb ts
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 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 "i386-redhat-linux-gnu"...ts: 그런 파일이나 디렉토리?
?없음.
(gdb) target remote 192.168.1.20:5000
Remote debugging using 192.168.1.20:5000
0x40000be0 in ?? ()
(gdb) l
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) n
Program not restarted.
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x4000c6a0 in ?? ()
(gdb) l
No symbol table is loaded. Use the "file" command.
(gdb) bt
#0 0x4000c6a0 in ?? ()
#1 0x42029c20 in ?? ()
#2 0x420155d8 in ?? ()
(gdb) file ts
A program is being debugged already. Kill it? (y or n) n
Program not killed.
--실험코드
#include <stdio.h> int main( int argc, char *argv[] ) { int i; scanf("%d",i); printf("%d\n",i): return 0; }
바이너리를 컴파일
바이너리를 컴파일 하실때 -g 옵션을 주셨나요? 혹은 -g 옵션을 주셨는데 strip 을 하신 건 아닐까요?
이건 gdb 가 실행파일
이건 gdb 가 실행파일 아키텍쳐를 잘못파악했을때 발생하는 문제 같습니다.
-- 아쉬운 하루 되세요 --
-- 아쉬운 하루 되세요 --
윗분
윗분 말씀대로입니다.
target하고 host machine 다른 모양이군요.
cross compiler 만들 듯이 cross gdb로 컴파일하세요.
___________________________________
Less is More (Robert Browning)
___________________________________
Less is More (Robert Browning)
타겟은 동일합니다.
왜냐하면 gnu에서 5.3버전으로 받아서
컴파일후에
제 컴에서 서버 돌리고
원격접속을 했습니다.
타켓이 다를 이유가 없다고 봅니다.
혹시 컴파일할때 타켓을 지정해야 하는가요?
그냥 ./configure하고 메이크 했습니다.
댓글 달기