gdb script에서...

armadillo의 이미지

반갑습니다.

gdb에서 script를 실행하는데
source할때 에러가 발생하네요.

소스는 스택을 출력해보려고 인터넷에서 가져온거구요..

그런데 이상한것은 gdb내에서
define stkfrm
...
...
end

입력하고,
아래와 같이 실행하면
(gdb) stkfrm

이상이 없는데,

화일 (gdb.sh)로 만들어두고,
gdb 내에서

(gdb) source ./gdb.sh [enter]

실행하면 아래와 같이 에러가 나네요.

./gdb.sh:7: Error in sourced command file:
This command cannot be used at the top level.

아래는 코드입니다.

define stkfrm
set $pos=0
where $pos < ($ebp-$esp)
x/xw $ebp-$pos
set $pos=$pos+4
end
end

코드를 한줄씩 지워보니
아래와 같이 마지막 end를 지우면 되긴합니다만, 실제로 출력이 제대로 되지 않네요.

define stkfrm
set $pos=0
where $pos < ($ebp-$esp)
x/xw $ebp-$pos
set $pos=$pos+4
end

어떻게 접근해야할지 감을 잡을수 없네요.
환경은 intel linux 입니다.

조언 부탁드립니다.
좋은 휴일 되세요.

armadillo의 이미지

역시 코드가 막힐때는 한박자 쉬고...

script에 오타가 있었네요

where -> while 로 바꾸면...

감사합니다.