This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[03/03] Make breakpoint_address_match gdbarch_addr_bit-aware
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Sun, 10 Jan 2010 21:16:31 +0100
- Subject: [03/03] Make breakpoint_address_match gdbarch_addr_bit-aware
Hi,
this is a re-post of:
[patch 03/15] PIE: breakpoint_address_match gdbarch_addr_bit workaround
http://sourceware.org/ml/gdb-patches/2009-11/msg00170.html
I went the more correct way of making breakpoint_address_match dependent just
on address_space without requiring new gdbarch parameter(s); which may be IMO
even removed in the future according to [00/03].
Regression tested with [01/03] and [02/03] on
{x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
Thanks,
Jan
2010-01-10 Jan Kratochvil <jan.kratochvil@redhat.com>
* breakpoint.c (breakpoint_address_match): New variables addr1_bit,
addr2_bit, addr1_mask and addr2_mask, initialize them. New assertions
on aspace1 and aspace2. Mask addresses by ADDR1_MASK and ADDR2_MASK.
* defs.h (CORE_ADDR): Extend the comment.
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4715,9 +4715,23 @@ static int
breakpoint_address_match (struct address_space *aspace1, CORE_ADDR addr1,
struct address_space *aspace2, CORE_ADDR addr2)
{
+ int addr1_bit, addr2_bit;
+ CORE_ADDR addr1_mask = CORE_ADDR_MAX;
+ CORE_ADDR addr2_mask = CORE_ADDR_MAX;
+
+ gdb_assert (aspace1 != NULL);
+ gdb_assert (aspace2 != NULL);
+
+ addr1_bit = gdbarch_addr_bit (address_space_gdbarch (aspace1));
+ if (addr1_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
+ addr1_mask = ((CORE_ADDR) 1 << addr1_bit) - 1;
+ addr2_bit = gdbarch_addr_bit (address_space_gdbarch (aspace2));
+ if (addr2_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
+ addr2_mask = ((CORE_ADDR) 1 << addr2_bit) - 1;
+
return ((gdbarch_has_global_breakpoints (target_gdbarch)
|| aspace1 == aspace2)
- && addr1 == addr2);
+ && (addr1 & addr1_mask) == (addr2 & addr2_mask));
}
/* Assuming LOC1 and LOC2's types' have meaningful target addresses
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -98,7 +98,17 @@
/* A byte from the program being debugged. */
typedef bfd_byte gdb_byte;
-/* An address in the program being debugged. Host byte order. */
+/* An address in the program being debugged. Host byte order.
+
+ Its width is the maximum width of all the supported targets. That means
+ 32-bit target will run on such GDB using 64-bit CORE_ADDR cluttering the
+ bits 32...63 with random data from internal GDB calculations. GDB currently
+ in general truncates the address width only when it is being presented/used
+ externally (such as by the paddress function).
+
+ FIXME: This is still not right as any GDB internal comparisons (such as >=)
+ of CORE_ADDR do not use the properly truncated width. */
+
typedef bfd_vma CORE_ADDR;
/* The largest CORE_ADDR value. */