aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.h
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2014-09-16 17:40:06 +0100
committerPedro Alves <palves@redhat.com>2014-09-16 17:40:06 +0100
commitbb9d5f81c36ecc61e3d4a70ce7e41348c8b12fef (patch)
tree87ce6907cc01910723e151cd42f08414548d7d64 /gdb/breakpoint.h
parentd3d3c6db1a3de87d5df6900f3be0557c33fa23b3 (diff)
downloadgdb-bb9d5f81c36ecc61e3d4a70ce7e41348c8b12fef.zip
gdb-bb9d5f81c36ecc61e3d4a70ce7e41348c8b12fef.tar.gz
gdb-bb9d5f81c36ecc61e3d4a70ce7e41348c8b12fef.tar.bz2
Fix PR12526: -location watchpoints for bitfield arguments
PR 12526 reports that -location watchpoints against bitfield arguments trigger false positives when bits around the bitfield, but not the bitfield itself, are modified. This happens because -location watchpoints naturally operate at the byte level, not at the bit level. When the address of a bitfield lvalue is taken, information about the bitfield (i.e. its offset and size) is lost in the process. This information must first be retained throughout the lifetime of the -location watchpoint. This patch achieves this by adding two new fields to the watchpoint struct: val_bitpos and val_bitsize. These fields are set when a watchpoint is first defined in watch_command_1. They are both equal to zero if the watchpoint is not a -location watchpoint or if the argument is not a bitfield. Then these bitfield parameters are used inside update_watchpoint and watchpoint_check to extract the actual value of the bitfield from the watchpoint address, with the help of a local helper function extract_bitfield_from_watchpoint_value. Finally when creating a HW breakpoint pointing to a bitfield, we optimize the address and length of the breakpoint. By skipping over the bytes that don't cover the bitfield, this step reduces the frequency at which a read watchpoint for the bitfield is triggered. It also reduces the number of times a false-positive call to check_watchpoint is triggered for a write watchpoint. gdb/ PR breakpoints/12526 * breakpoint.h (struct watchpoint): New fields val_bitpos and val_bitsize. * breakpoint.c (watch_command_1): Use these fields to retain bitfield information. (extract_bitfield_from_watchpoint_value): New function. (watchpoint_check): Use it. (update_watchpoint): Use it. Optimize the address and length of a HW watchpoint pointing to a bitfield. * value.h (unpack_value_bitfield): New prototype. * value.c (unpack_value_bitfield): Make extern. gdb/testsuite/ PR breakpoints/12526 * gdb.base/watch-bitfields.exp: New file. * gdb.base/watch-bitfields.c: New file.
Diffstat (limited to 'gdb/breakpoint.h')
-rw-r--r--gdb/breakpoint.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 8abb5ea..00c8802 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -779,6 +779,11 @@ struct watchpoint
then an error occurred reading the value. */
int val_valid;
+ /* When watching the location of a bitfield, contains the offset and size of
+ the bitfield. Otherwise contains 0. */
+ int val_bitpos;
+ int val_bitsize;
+
/* Holds the frame address which identifies the frame this
watchpoint should be evaluated in, or `null' if the watchpoint
should be evaluated on the outermost frame. */