임베디드 환경에서 디버깅
임베디드 개발자는 아닙니다만 이것 저것 하고 있습니다;;;
디버깅에 대한 질문을 드립니다.
임베디드 arm linux(2.4) 환경인데 프로그램이 잘 돌다가 어쩌다 죽습니다.
Makefile은 대충 이런식이구요(-g는 디버깅용). -g 옵션 컴파일에 no strip입니다.
CC = arm-linux-g++
OBJS = test.o
CFLAGS = -march=armv4 -mtune=arm9tdmi
CFLAGS += -I.. -I$(INCLUDEDIR)
CFLAGS += -D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64
.
.
.
test.o: test.c test.h
$(CC) $(CFLAGS) -g -c -o test.o test.c
prj : $(OBJS)
$(CC) -g -o prj $(OBJS) -lpthread -lc_nonshared
테스트로 아래 강제 SIGSEGV 코드를 넣어서 해당 시점의 스택이나 변수를 보려합니다.
CInfo * c;
cout << c->what;
printf 신공은 논외로 하고,
테스트용으로 간단한 소스를 이용한 bug trap은 gdbserver, core dump 모두가 잘 되었습니다.
문제는 프로젝트 어플리케이션인데...
1. gdbserver를 arm 컴파일해서 타겟보드에 올려놓고 호스트 gdb로 디버깅(호스트 및 타겟 configure는 제대로 했음)
아래처럼 gdb 디버깅이 되는데 디버깅 정보가 제대로 삽입되지 않은 것 처럼 나오네요. Makefile 설정에 문제가 있나요?
[root@test]# gdb ./prj
GNU gdb Red Hat Linux (6.1post-1.20040607.52rh)
Copyright 2004 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"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) target remote x.x.x.x:7777
Remote debugging using x.x.x.x:7777
0x00000000 in ?? ()
(gdb) break CTest::Test()
Breakpoint 1 at 0x386ac: file test.cpp, line 2098.
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x2ad53940 in ?? ()
(gdb) list
1 in C++-namespaces
(gdb) bt
#0 0x2ad53940 in ?? ()
#1 0x00000000 in ?? ()
2. Core dump(보드 ulimit -c 65536)
덤프(Core.52, 524288byte)가 나오긴 하는데 이걸 호스트로 가져와서 실행해(gdb ./prj ./core.52) 보면
이런식으로 메세지를 뿌립니다.
[root@test]# gdb ./prj ./core.52
GNU gdb Red Hat Linux (6.1post-1.20040607.52rh)
Copyright 2004 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"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
Core was generated by `./prj'.
warning: Couldn't find general-purpose registers in core file.
Cannot access memory at address 0x2aac7aa4
warning: Couldn't find general-purpose registers in core file.
#0 0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
#1 0x00000000 in ?? ()
(gdb) list
1 C++-namespaces: 그런 파일이
나 디렉토리가 없음.
in C++-namespaces
4. 간단한 테스트 프로그램에서는 잘 됩니다만, 뭔가 개발 어플 컴파일 설정을 잘못한건지 잡힐 듯 안잡히네요.
보드 메모리도 한정적이고 모든 상황이 압박입니다. 참고가 될 만한 답변을 부탁드립니다.
아니면 위 디버깅 방법을 제외한 좀 더 희망적인 방법 제시라도 좋습니다.
일단 디버거를...
대부분 Multi ICE 환경으로 디버깅하시던데, 일부러 gdb로 하시나요?
위의 메시지가 제일 맘에 걸리는데, gdb 는 configure 하실 때 대상 플랫폼에 대해 컴파일 하신 것이죠? 이에 대한 binutils 는 설정하셨나요?
gdb 에 대한 설정부터 올바르게 만드시는 것이 좋을듯 싶습니다.
====
( - -)a 이제는 학생으로 가장한 백수가 아닌 진짜 백수가 되어야겠다.
댓글 달기