This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Does hardware watchpoint work on Linux/x86-64?
Not even very simple one works:
[hjl@gnu-27 gdb]$ cat x.c
int foo;
main ()
{
foo =1;
}
[hjl@gnu-27 gdb]$ gcc -g x.c
[hjl@gnu-27 gdb]$ gdb a.out
GNU gdb 6.6.50.20061121-cvs
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu"...
Using host libthread_db library "/lib64/tls/libthread_db.so.1".
Setting up the environment for debugging gdb.
Function "internal_error" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
Function "info_command" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
/export/build/gnu/gdb/build-x86_64-linux/gdb/.gdbinit:8: Error in
sourced command file:
No breakpoint number 0.
(gdb) watch foo
Hardware watchpoint 1: foo
(gdb) q
[hjl@gnu-27 gdb]$ ./gdb a.out
GNU gdb 6.8.50.20080416-cvs
Copyright (C) 2008 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-unknown-linux-gnu"...
Setting up the environment for debugging gdb.
Function "internal_error" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
Function "info_command" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
/export/build/gnu/gdb/build-x86_64-linux/gdb/.gdbinit:8: Error in
sourced command file:
No breakpoint number 0.
(gdb) watch foo
Watchpoint 1: foo
(gdb) q
[hjl@gnu-27 gdb]$
[hjl@gnu-27 gdb]$ readelf -w a.out
The section .debug_aranges contains:
Length: 44
Version: 2
Offset into .debug_info: 0x0
Pointer Size: 8
Segment Size: 0
Address Length
0000000000400428 0000000000000010
0000000000000000 0000000000000000
Contents of the .debug_pubnames section:
Length: 31
Version: 2
Offset into .debug_info section: 0x0
Size of area in .debug_info section: 184
Offset Name
121 main
161 foo
The section .debug_info contains:
Compilation Unit @ offset 0x0:
Length: 0xb4 (32-bit)
Version: 2
Abbrev Offset: 0
Pointer Size: 8
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
< c> DW_AT_stmt_list : 0x0
<10> DW_AT_high_pc : 0x400438
<18> DW_AT_low_pc : 0x400428
<20> DW_AT_producer : GNU C 3.4.6 20060404 (Red Hat 3.4.6-9)
<47> DW_AT_language : 1 (ANSI C)
<48> DW_AT_name : x.c
<4c> DW_AT_comp_dir : /export/build/gnu/gdb/build-x86_64-linux/gdb
<1><79>: Abbrev Number: 2 (DW_TAG_subprogram)
<7a> DW_AT_external : 1
<7b> DW_AT_name : main
<80> DW_AT_decl_file : 1
<81> DW_AT_decl_line : 3
<82> DW_AT_type : <0x9a>
<86> DW_AT_low_pc : 0x400428
<8e> DW_AT_high_pc : 0x400438
<96> DW_AT_frame_base : 0x0 (location list)
<1><9a>: Abbrev Number: 3 (DW_TAG_base_type)
<9b> DW_AT_name : int
<9f> DW_AT_byte_size : 4
<a0> DW_AT_encoding : 5 (signed)
<1><a1>: Abbrev Number: 4 (DW_TAG_variable)
<a2> DW_AT_name : foo
<a6> DW_AT_decl_file : 1
<a7> DW_AT_decl_line : 1
<a8> DW_AT_type : <0x9a>
<ac> DW_AT_external : 1
<ad> DW_AT_location : 9 byte block: 3 e4 7 60 0 0 0 0 0
(DW_OP_addr: 6007e4)
Contents of the .debug_abbrev section:
Number TAG
1 DW_TAG_compile_unit [has children]
DW_AT_stmt_list DW_FORM_data4
DW_AT_high_pc DW_FORM_addr
DW_AT_low_pc DW_FORM_addr
DW_AT_producer DW_FORM_string
DW_AT_language DW_FORM_data1
DW_AT_name DW_FORM_string
DW_AT_comp_dir DW_FORM_string
2 DW_TAG_subprogram [no children]
DW_AT_external DW_FORM_flag
DW_AT_name DW_FORM_string
DW_AT_decl_file DW_FORM_data1
DW_AT_decl_line DW_FORM_data1
DW_AT_type DW_FORM_ref4
DW_AT_low_pc DW_FORM_addr
DW_AT_high_pc DW_FORM_addr
DW_AT_frame_base DW_FORM_data4
3 DW_TAG_base_type [no children]
DW_AT_name DW_FORM_string
DW_AT_byte_size DW_FORM_data1
DW_AT_encoding DW_FORM_data1
4 DW_TAG_variable [no children]
DW_AT_name DW_FORM_string
DW_AT_decl_file DW_FORM_data1
DW_AT_decl_line DW_FORM_data1
DW_AT_type DW_FORM_ref4
DW_AT_external DW_FORM_flag
DW_AT_location DW_FORM_block1
The section .debug_frame contains:
00000000 00000014 ffffffff CIE
Version: 1
Augmentation: ""
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
DW_CFA_def_cfa: r7 (rsp) ofs 8
DW_CFA_offset: r16 (rip) at cfa-8
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
00000018 0000001c 00000000 FDE cie=00000000 pc=00400428..00400438
DW_CFA_advance_loc: 1 to 00400429
DW_CFA_def_cfa_offset: 16
DW_CFA_offset: r6 (rbp) at cfa-16
DW_CFA_advance_loc: 3 to 0040042c
DW_CFA_def_cfa_register: r6 (rbp)
Contents of the .debug_loc section:
Offset Begin End Expression
00000000 0000000000400428 0000000000400429 (DW_OP_breg7: 8)
00000000 0000000000400429 000000000040042c (DW_OP_breg7: 16)
00000000 000000000040042c 0000000000400438 (DW_OP_breg6: 16)
00000000 <End of list>
[hjl@gnu-27 gdb]$
H.J.
On Wed, Apr 16, 2008 at 3:19 PM, Daniel Jacobowitz <drow@false.org> wrote:
> Yes, hardware watchpoints work on x86-64.
>
>
> On Wed, Apr 16, 2008 at 03:05:23PM -0700, H.J. Lu wrote:
> > (gdb) watch section_headers
> > During symbol reading, DW_AT_type missing from DW_TAG_subrange_type.
> > Watchpoint 1: section_headers
>
> Figure out what sort of symbol GDB thinks this is. It thinks it's too
> complicated to use a hardware watchpoint for. Does it have a location
> list (odd for a global variable)?
>
> --
> Daniel Jacobowitz
> CodeSourcery
>