Bug 11613 - hardware watchpoint missed for -O2 -g inferior
Summary: hardware watchpoint missed for -O2 -g inferior
Status: UNCONFIRMED
Alias: None
Product: gdb
Classification: Unclassified
Component: breakpoints (show other bugs)
Version: unknown
: P2 normal
Target Milestone: 7.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-19 19:51 UTC by Jan Kratochvil
Modified: 2011-05-16 20:55 UTC (History)
3 users (show)

See Also:
Host:
Target: i386-unknown-linux-gnu
Build:
Last reconfirmed:


Attachments
2.s precompiled code. (1.46 KB, text/plain)
2010-05-19 19:52 UTC, Jan Kratochvil
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2010-05-19 19:51:06 UTC
==> 1.c <==
int
g (int j)
{
  int l = j + 2;
  return l;
}
extern int f (int i);
int
main (int argc, char **argv)
{
  f (1);
  return 0;
}

==> 2.c <==
extern int g (int j);
int
f (int i)
{
  i++;
  g (2);
  return g (i);
}


gcc 1.c 2.s -Wall -o 1 -m32
# Tested with gcc-4.4.3-4.fc12.x86_64 but 1.c -> 2.s is attached precompiled.

Works using 'set can-use-hw-watchpoints 0' workaround:

$ gdb -nx -ex 'set can-use-hw-watchpoints 0' -ex 'b f' -ex r -ex 'p i' -ex
'watch i' -ex 'adv 7' -ex 'p i' ./1
$1 = 1
Watchpoint 2: i
Watchpoint 2: i

Old value = 1
New value = 2
f (i=2) at 2.c:6
6	  g (2);
$2 = 2


Does not work without the workaround:
$ gdb -nx -ex 'b f' -ex r -ex 'p i' -ex 'watch i' -ex 'adv 7' -ex 'p i' ./1
$1 = 1
Hardware watchpoint 2: i
f (i=2) at 2.c:7
7	  return g (i);
$2 = 2
The value has changed but the breakpoint has not triggered.

 <2><3e>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <3f>   DW_AT_name        : i
    <43>   DW_AT_type        : <0x4c>
    <47>   DW_AT_location    : 0x0      (location list)
Contents of the .debug_loc section:
    Offset   Begin    End      Expression
    00000000 080483d0 080483da (DW_OP_fbreg: 0)
    00000000 080483da 080483f1 (DW_OP_breg3: 1; DW_OP_stack_value)
    00000000 <End of list>
Comment 1 Jan Kratochvil 2010-05-19 19:52:52 UTC
Created attachment 4802 [details]
2.s precompiled code.
Comment 2 Tom Tromey 2011-05-16 20:55:33 UTC
Maybe location lists could refine the bounds of the scope
used to decide when a watchpoint expression should be
reparsed.