This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Problems with hardware watchpoint on ia32.


I don't like the hardware watchpoint support on ia32. That is one
reason I started hacking gdb. Here are some examples:

# cat y.c
int a1;
int a2;
int a3;
int a4;
int a5;
int a6;

main ()
{

  a1 = 11;
  a2 = 12;
  a3 = 13;
  a4 = 14;
  a5 = 15;
  a6 = 16;
  return 0;
}
# gcc -g -o y y.c
# /work/build/gnu/bin/gdb.orig/gdb/gdb y
(gdb) watch a1
Hardware watchpoint 1: a1
(gdb) watch a2
Hardware watchpoint 2: a2
(gdb) watch a3
Hardware watchpoint 3: a3
(gdb) watch a4 
Hardware watchpoint 4: a4
(gdb) watch a5
Hardware watchpoint 5: a5
(gdb) r
Starting program: /home/hjl/bugs/gdb/hw/y 
warning: Could not insert hardware watchpoint 5.
ptrace: Unknown error 4294967295.
Cannot insert breakpoints.
The same program may be running in another process.
(gdb) del 5
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/hjl/bugs/gdb/hw/y 
warning: Could not insert hardware watchpoint 1.
warning: Could not insert hardware watchpoint 3.
ptrace: Unknown error 4294967295.
Cannot insert breakpoints.
The same program may be running in another process.
(gdb)

ia32 only has 4 hardware debug registers. But gdb shouldn't crash. Even
worse, after  deleted one hardware watchpoint, gdb still refused to
work.

One more annoying thing:

# cat ll.c
unsigned long long a1 = 0;
double a2 = 0;

main ()
{

  a1 = 0x00000000ffffffffL;
  a2 = 12;
  a1 = 0xffffffff00000000L;
  return 0;
}
# gcc -g -o ll ll.c
# /work/build/gnu/bin/gdb.orig/gdb/gdb ll
(gdb) watch a1
Watchpoint 1: a1
(gdb) watch a2
Watchpoint 2: a2
(gdb)

gdb won't set hardware watchpoints on long long nor double.

I put some kludegs in gdb 4.17. They work for me the way I prefer. F
r
the first one, I got

# /work/build/gnu/bin/gdb/gdb/gdb  y
(gdb) watch a1
Hardware watchpoint 1: a1
(gdb) watch a2
Hardware watchpoint 2: a2
(gdb) watch a3
Hardware watchpoint 3: a3
(gdb) watch a4
Hardware watchpoint 4: a4
(gdb) watch a5
Hardware watchpoint 5: a5
(gdb) r
Starting program: /home/hjl/bugs/gdb/hw/y 
warning: Could not insert hardware watchpoint 5.
warning: Could not insert hardware watchpoint 5.
Hardware watchpoint 1: a1
Hardware watchpoint 2: a2
Hardware watchpoint 3: a3
Hardware watchpoint 4: a4
Hardware watchpoint 5: a5
Hardware watchpoint 1: a1
Hardware watchpoint 2: a2
Hardware watchpoint 3: a3
Hardware watchpoint 4: a4
Hardware watchpoint 5: a5
warning: Could not insert hardware watchpoint 5.
warning: Could not insert hardware watchpoint 5.
Hardware watchpoint 1: a1
Hardware watchpoint 2: a2
Hardware watchpoint 3: a3
Hardware watchpoint 4: a4
Hardware watchpoint 5: a5
warning: Could not insert hardware watchpoint 5.
Hardware watchpoint 1: a1

Old value = 0
New value = 11
main () at y.c:12
12        a2 = 12;
(gdb) del 1
(gdb) del 1
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/hjl/bugs/gdb/hw/y 
Hardware watchpoint 2: a2
Hardware watchpoint 3: a3
Hardware watchpoint 4: a4
Hardware watchpoint 5: a5
Hardware watchpoint 2: a2
Hardware watchpoint 3: a3
Hardware watchpoint 4: a4
Hardware watchpoint 5: a5
Hardware watchpoint 2: a2
Hardware watchpoint 3: a3
Hardware watchpoint 4: a4
Hardware watchpoint 5: a5
Hardware watchpoint 2: a2

Old value = 0
New value = 12
main () at y.c:13
13        a3 = 13;
(gdb)

For the second one,

# /work/build/gnu/bin/gdb/gdb/gdb  ll
(gdb) watch a1
Hardware watchpoint 1: a1
(gdb) watch a2
Hardware watchpoint 2: a2
(gdb) r
Starting program: /home/hjl/bugs/gdb/hw/ll 
Hardware watchpoint 1: a1
Hardware watchpoint 2: a2
Hardware watchpoint 1: a1
Hardware watchpoint 2: a2
Hardware watchpoint 1: a1
Hardware watchpoint 2: a2
Hardware watchpoint 1: a1

Old value = 0
New value = 4294967295
0x80483d3 in main () at ll.c:7
7         a1 = 0x00000000ffffffffL;
(gdb) c
Continuing.
Hardware watchpoint 2: a2

Old value = 0
New value = 12
main () at ll.c:9
9         a1 = 0xffffffff00000000L;

I know the support for long long and double is not perfect. But I
much prefer it than none at all.

I will send in a patch in another email.

H.J.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]