CnUnix

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ CnUnix ] in KIDS
글 쓴 이(By): akira (Park_S_J_)
날 짜 (Date): 2004년 12월 22일 수요일 오전 09시 31분 22초
제 목(Title): Re: 기초적인 gdb 질문


% cat aaa.c
#define CHAR_SIZE 256
char print_chars[CHAR_SIZE];

main() {
  strcpy(print_chars, "Test");
  exit(0);
}
% gcc -g -o aaa aaa.c
% gdb aaa
GNU gdb 6.2.1
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 "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) b 6
Breakpoint 1 at 0x8048381: file aaa.c, line 6.
(gdb) run
Starting program: /home/^_^/tmp/aaa 

Breakpoint 1, main () at aaa.c:6
6         exit(0);
(gdb) p print_chars
$1 = "Test", '\0' <repeats 251 times>
(gdb) 

------------------------
잘 되는데요? ㅎㅎ

뭔가 print_chars가 정의된 화일 컴파일할때 -g가 빠졌다던지, 기타 등등...

설마 로컬변수인데 함수밖에서 print 해본건 아니겠죠?

로컬 변수는 stack frame을 맞춰줘야 보입니다.

[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.