1
GDB의 감시 점을 연구 중입니다. 나는 다음과 같은 간단한 테스트 코드를 작성 : 내 테스트 코드에서왜 워치 포인트가 적용되지 않습니까?
int main(int argc, char **argv)
{
int x = 30;
int y = 10;
x = y;
return 0;
}
I build it via gcc -g -o wt watch.c. And then I started gdb and did following experiment:
[email protected]:~/mySrc$ gdb ./wt
GNU gdb (GDB) 7.3
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/lihacker/mySrc/wt...done.
(gdb) b main
Breakpoint 1 at 0x80483a5: file watch.c, line 5.
(gdb) run
Starting program: /home/lihacker/mySrc/wt
Breakpoint 1, main (argc=<optimized out>, argv=<optimized out>) at watch.c:5
5 int x = 30;
(gdb) watch x
Hardware watchpoint 2: x
(gdb) c
Continuing.
Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
0xb7e83775 in __libc_start_main() from /lib/tls/i686/cmov/libc.so.6
(gdb)
는 변수는 "X"로 변경되지만, GDB는 멈추지 않습니다. 왜 워치 포인트가 여기에 영향을 미치지 않습니까? 고마워.
감사합니다 : 주의, 는이 예상대로 작동합니다. 실제로 gcc를 통해 빌드 할 때 최적화 플래그를 설정하지 않았습니다. 비록 당신이 말한 것처럼 -O0을 추가하더라도 결과는 동일합니다. 내 테스트 플랫폼은 가상 머신에서 실행되는 Ubuntu 9.0.4이고 gdb 버전은 최신 7.3입니다. 테스트 환경이 어떻습니까? – mingganz