This is the mail archive of the gdb-prs@sourceware.org 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]
Other format: [Raw text]

[Bug gdb/12953] No hardware watchpoints on FreeBSD amd64


http://sourceware.org/bugzilla/show_bug.cgi?id=12953

--- Comment #4 from Valery Khromov <valery.khromov at gmail dot com> 2011-12-05 00:42:48 UTC ---
Created attachment 6089
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6089
Updated patch

Attached updated patch fixes watching local variables.


However, it looks like gdb isn't able to watch uninitialized variables:

$ cat main.c 
#include <string.h>

void ms(char *p) {
  memset(p, 0, 1024);
}

main() {
#ifdef INIT_BUF1
  char buf1[1024] = { 0 };
#else
  char buf1[1024];
#endif
  buf1[256] = 7;
  ms(buf1);
}

$ cc main.c -ggdb -O0 -o main-notinit

$ cc main.c -ggdb -O0 -DINIT_BUF1 -o main-init


$ gdb main-notinit              
GNU gdb (GDB) 7.3.1 [GDB v7.3.1 for FreeBSD]
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 "x86_64-portbld-freebsd8.2".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from
/place/home/qwerty/gdb-freebsd-fixes/tst/main-notinit...done.
(gdb) br main
Breakpoint 1 at 0x4005ab: file main.c, line 13.
(gdb) r
Starting program: /place/home/qwerty/gdb-freebsd-fixes/tst/main-notinit 

Breakpoint 1, main () at main.c:13
13      buf1[256] = 7;
(gdb) wa buf1[256]
Hardware watchpoint 2: buf1[256]
(gdb) c
Continuing.

Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
0x00000000004004ee in _start ()


$ gdb main-init   
GNU gdb (GDB) 7.3.1 [GDB v7.3.1 for FreeBSD]
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 "x86_64-portbld-freebsd8.2".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /place/home/qwerty/gdb-freebsd-fixes/tst/main-init...done.
(gdb) br main
Breakpoint 1 at 0x4005ab: file main.c, line 9.
(gdb) r
Starting program: /place/home/qwerty/gdb-freebsd-fixes/tst/main-init 

Breakpoint 1, main () at main.c:9
9      char buf1[1024] = { 0 };
(gdb) wa buf1[256]
Hardware watchpoint 2: buf1[256]
(gdb) c
Continuing.
Hardware watchpoint 2: buf1[256]

Old value = 0 '\000'
New value = 7 '\a'
main () at main.c:14
14      ms(buf1);
(gdb) 
Continuing.
Hardware watchpoint 2: buf1[256]

Old value = 7 '\a'
New value = 0 '\000'
0x000000003273b1c4 in memset () from /lib/libc.so.7
(gdb) 
Continuing.

Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
0x00000000004004ee in _start ()



I tested it on Linux with the similar result: the watchpoint is triggered on
the second variable change by memset, not on the first assignment:

$ gdb main-notinit
GNU gdb (GDB) 7.0-debian
Copyright (C) 2009 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 "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/ll/main-notinit...done.
(gdb) br main
Breakpoint 1 at 0x400518: file main.c, line 13.
(gdb) r
Starting program: /tmp/ll/main-notinit 

Breakpoint 1, main () at main.c:13
13      buf1[256] = 7;
(gdb) wa buf1[256]
Hardware watchpoint 2: buf1[256]
(gdb) c
Continuing.
Hardware watchpoint 2: buf1[256]

Old value = -16 '\360'
New value = 0 '\000'
memset () at ../sysdeps/x86_64/memset.S:1017
1017    ../sysdeps/x86_64/memset.S: No such file or directory.
    in ../sysdeps/x86_64/memset.S
Current language:  auto
The current source language is "auto; currently asm".

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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