what is the difference between break *main
and break main()
in essence?
for example:
#include <iostream>
using namespace std;
int main()
{
int x=30;
int y=40;
x=y;
return 0;
}
when I use break *main
and watch x
, it is this:
(gdb) b *main
Breakpoint 1 at 0x400674: file aa.cpp, line 4.
(gdb) r
Starting program: /root/dd/aa.out
Breakpoint 1, main () at aa.cpp:4
4 {
(gdb) n
5 int x=30;
(gdb) watch x
Hardware watchpoint 2: x
(gdb) c
Continuing.
Hardware watchpoint 2: x
Old value = 0
New value = 30
main () at aa.cpp:6
6 int y=40;
(gdb) c
Continuing.
Hardware watchpoint 2: x
Old value = 30
New value = 40
main () at aa.cpp:8
8 return 0;
(gdb)
but when I use break main()
and watch x
, it is this:
(gdb) b main()
Breakpoint 1 at 0x400678: file aa.cpp, line 5.
(gdb) r
Starting program: /root/dd/aa.out
Breakpoint 1, main () at aa.cpp:5
5 int x=30;
(gdb) watch x
Hardware watchpoint 2: x
(gdb) c
Continuing.
Hardware watchpoint 2: x
Old value = 0
New value = 40
main () at aa.cpp:8
8 return 0;
(gdb)
why are they different? And what is the difference in essence?
And when I watch an array, if I use break main()
, it will appear:
Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
but if I use break *main
, it will not appear, why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…