http://sourceware.org/ml/gdb-patches/2012-09/msg00629.html Subject: [PATCH 3/4] Expand watchpoint lengths to LONGEST --MP_/6HRlH6vpyqtSy4CYyMrX6b2 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, This is part three of the bitpos expansion change. Some architectures allow arbitrary length watchpoints and combined with the fact that type lengths could be large enough, we need LONGEST for watchpoint lengths. It is architecture dependent however, whether the LONGEST is needed or not. This patch updates the signatures of watchpoint insertion and removal functions of all architectures (to comply with the function signatures in the callback struct), but expands types only in architectures that need it. Tested on Fedora 16 x86_64. Regards, Siddhesh --MP_/6HRlH6vpyqtSy4CYyMrX6b2 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=ChangeLog-wp gdb/ChangeLog: * arm-linux-nat.c (arm_linux_insert_watchpoint): Expand parameter LEN to LONGEST. (arm_linux_remove_watchpoint): Likewise. (arm_linux_watchpoint_addr_within_range): Expand parameter LENGTH to LONGEST. * i386-nat.c (i386_insert_watchpoint): Expand parameter LEN to LONGEST. (i386_remove_watchpoint): Likewise. * ia64-linux-nat.c (ia64_linux_insert_watchpoint): Likewise. (ia64_linux_remove_watchpoint): Likewise. * inf-ttrace.c (inf_ttrace_insert_watchpoint): Likewise. Expand NUM_PAGES, PAGE to LONGEST. (inf_ttrace_remove_watchpoint): Likewise. * mips-linux-nat.c (mips_linux_insert_watchpoint): Expand parameter LEN to LONGEST. (mips_linux_remove_watchpoint): Likewise. * nto-procfs.c (procfs_remove_hw_watchpoint): Likewise. (procfs_insert_hw_watchpoint): Likewise. * ppc-linux-nat.c (calculate_dvc): Likewise. Expand I, NUM_BYTE_ENABLE to LONGEST. (check_condition): Expand parameter LEN to point to LONGEST. (ppc_linux_can_accel_watchpoint_condition): Expand parameter LEN to LONGEST. (create_watchpoint_request): Likewise. (ppc_linux_insert_watchpoint): Likewise. (ppc_linux_remove_watchpoint): Likewise. (ppc_linux_watchpoint_addr_within_range): Expand parameter LENGTH to LONGEST. * procfs.c (proc_set_watchpoint): Expand parameter LEN to LONGEST. (procfs_set_watchpoint): Likewise. (procfs_insert_watchpoint): Likewise. (procfs_remove_watchpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_watchpoint): Likewise. Use plongest to format print LEN. (m32r_remove_watchpoint): Likewise. * remote-mips.c (mips_insert_watchpoint): Expand parameter LEN to LONGEST. (mips_remove_watchpoint): Likewise. * remote.c (remote_insert_watchpoint): Likewise. Use phex_nz to format print LEN. (remote_remove_watchpoint): Likewise. (remote_watchpoint_addr_within_range): Expand parameter LENGTH to LONGEST. * s390-linux-nat.c (s390_insert_watchpoint): Expand parameter LEN to LONGEST. (s390_remove_watchpoint): Likewise. * target.c (update_current_target): Expand parameter LEN for callbacks to TO_INSERT_WATCHPOINT, TO_REMOVE_WATCHPOINT, TO_CAN_ACCEL_WATCHPOINT_CONDITION, to LONGEST. (default_watchpoint_addr_within_range): Expand parameter LENGTH to LONGEST. (debug_to_can_accel_watchpoint_condition): Expand parameter LEN to LONGEST. Use plongest to format print LEN. (debug_to_watchpoint_addr_within_range): Expand parameter LENGTH to LONGEST. Use plongest to format print LENGTH. (debug_to_insert_watchpoint): Expand parameter LEN to LONGEST. Use plongest to format print LEN. (debug_to_remove_watchpoint): Likewise. * target.h (struct target_ops): Expand parameter LEN of TO_REMOVE_WATCHPOINT, TO_INSERT_WATCHPOINT, TO_WATCHPOINT_ADDR_WITHIN_RANGE and TO_CAN_ACCEL_WATCHPOINT_CONDITION to LONGEST. --MP_/6HRlH6vpyqtSy4CYyMrX6b2 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=bitpos-wp.patch Index: gdb-7.7.90.20140613/gdb/arm-linux-nat.c =================================================================== --- gdb-7.7.90.20140613.orig/gdb/arm-linux-nat.c 2014-06-13 22:23:09.630440699 +0200 +++ gdb-7.7.90.20140613/gdb/arm-linux-nat.c 2014-06-13 22:23:54.666492199 +0200 @@ -1296,7 +1296,7 @@ arm_linux_stopped_by_watchpoint (struct static int arm_linux_watchpoint_addr_within_range (struct target_ops *target, CORE_ADDR addr, - CORE_ADDR start, int length) + CORE_ADDR start, LONGEST length) { return start <= addr && start + length - 1 >= addr; } Index: gdb-7.7.90.20140613/gdb/ppc-linux-nat.c =================================================================== --- gdb-7.7.90.20140613.orig/gdb/ppc-linux-nat.c 2014-06-13 22:23:09.635440704 +0200 +++ gdb-7.7.90.20140613/gdb/ppc-linux-nat.c 2014-06-13 22:23:54.672492206 +0200 @@ -1857,11 +1857,11 @@ can_use_watchpoint_cond_accel (void) CONDITION_VALUE will hold the value which should be put in the DVC register. */ static void -calculate_dvc (CORE_ADDR addr, int len, CORE_ADDR data_value, +calculate_dvc (CORE_ADDR addr, LONGEST len, CORE_ADDR data_value, uint32_t *condition_mode, uint64_t *condition_value) { - int i, num_byte_enable, align_offset, num_bytes_off_dvc, - rightmost_enabled_byte; + LONGEST i, num_byte_enable; + int align_offset, num_bytes_off_dvc, rightmost_enabled_byte; CORE_ADDR addr_end_data, addr_end_dvc; /* The DVC register compares bytes within fixed-length windows which @@ -1948,7 +1948,7 @@ num_memory_accesses (struct value *v) of the constant. */ static int check_condition (CORE_ADDR watch_addr, struct expression *cond, - CORE_ADDR *data_value, int *len) + CORE_ADDR *data_value, LONGEST *len) { int pc = 1, num_accesses_left, num_accesses_right; struct value *left_val, *right_val, *left_chain, *right_chain; @@ -2033,7 +2033,7 @@ ppc_linux_can_accel_watchpoint_condition static void create_watchpoint_request (struct ppc_hw_breakpoint *p, CORE_ADDR addr, - int len, int rw, struct expression *cond, + LONGEST len, int rw, struct expression *cond, int insert) { if (len == 1 @@ -2299,7 +2299,7 @@ ppc_linux_stopped_by_watchpoint (struct static int ppc_linux_watchpoint_addr_within_range (struct target_ops *target, CORE_ADDR addr, - CORE_ADDR start, int length) + CORE_ADDR start, LONGEST length) { int mask; Index: gdb-7.7.90.20140613/gdb/procfs.c =================================================================== --- gdb-7.7.90.20140613.orig/gdb/procfs.c 2014-06-13 22:23:09.638440708 +0200 +++ gdb-7.7.90.20140613/gdb/procfs.c 2014-06-13 22:23:54.673492207 +0200 @@ -2429,7 +2429,7 @@ procfs_address_to_host_pointer (CORE_ADD #endif static int -proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags) +proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, LONGEST len, int wflags) { #if !defined (PCWATCH) && !defined (PIOCSWATCH) /* If neither or these is defined, we can't support watchpoints. @@ -4762,7 +4762,7 @@ procfs_pid_to_str (struct target_ops *op /* Insert a watchpoint. */ static int -procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag, +procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, LONGEST len, int rwflag, int after) { #ifndef AIX5 Index: gdb-7.7.90.20140613/gdb/remote.c =================================================================== --- gdb-7.7.90.20140613.orig/gdb/remote.c 2014-06-13 22:23:09.643440713 +0200 +++ gdb-7.7.90.20140613/gdb/remote.c 2014-06-13 22:23:54.680492215 +0200 @@ -8199,7 +8199,7 @@ remote_insert_watchpoint (struct target_ p = strchr (rs->buf, '\0'); addr = remote_address_masked (addr); p += hexnumstr (p, (ULONGEST) addr); - xsnprintf (p, endbuf - p, ",%x", len); + xsnprintf (p, endbuf - p, ",%s", phex_nz (len, sizeof (len))); putpkt (rs->buf); getpkt (&rs->buf, &rs->buf_size, 0); @@ -8219,7 +8219,7 @@ remote_insert_watchpoint (struct target_ static int remote_watchpoint_addr_within_range (struct target_ops *target, CORE_ADDR addr, - CORE_ADDR start, int length) + CORE_ADDR start, LONGEST length) { CORE_ADDR diff = remote_address_masked (addr - start); @@ -8249,7 +8249,7 @@ remote_remove_watchpoint (struct target_ p = strchr (rs->buf, '\0'); addr = remote_address_masked (addr); p += hexnumstr (p, (ULONGEST) addr); - xsnprintf (p, endbuf - p, ",%x", len); + xsnprintf (p, endbuf - p, ",%s", phex_nz (len, sizeof (len))); putpkt (rs->buf); getpkt (&rs->buf, &rs->buf_size, 0); Index: gdb-7.7.90.20140613/gdb/target.c =================================================================== --- gdb-7.7.90.20140613.orig/gdb/target.c 2014-06-13 22:23:09.645440716 +0200 +++ gdb-7.7.90.20140613/gdb/target.c 2014-06-13 22:26:24.077661601 +0200 @@ -52,7 +52,7 @@ static void target_info (char *, int); static void default_terminal_info (struct target_ops *, const char *, int); static int default_watchpoint_addr_within_range (struct target_ops *, - CORE_ADDR, CORE_ADDR, int); + CORE_ADDR, CORE_ADDR, LONGEST); static int default_region_ok_for_hw_watchpoint (struct target_ops *, CORE_ADDR, LONGEST); @@ -150,7 +150,7 @@ static int debug_to_remove_watchpoint (s static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *); static int debug_to_watchpoint_addr_within_range (struct target_ops *, - CORE_ADDR, CORE_ADDR, int); + CORE_ADDR, CORE_ADDR, LONGEST); static int debug_to_region_ok_for_hw_watchpoint (struct target_ops *self, CORE_ADDR, LONGEST); @@ -2959,7 +2959,7 @@ default_region_ok_for_hw_watchpoint (str static int default_watchpoint_addr_within_range (struct target_ops *target, CORE_ADDR addr, - CORE_ADDR start, int length) + CORE_ADDR start, LONGEST length) { return addr >= start && addr < start + length; } @@ -3691,8 +3691,8 @@ debug_to_can_accel_watchpoint_condition fprintf_unfiltered (gdb_stdlog, "target_can_accel_watchpoint_condition " - "(%s, %d, %d, %s) = %ld\n", - core_addr_to_string (addr), len, rw, + "(%s, %s, %d, %s) = %ld\n", + core_addr_to_string (addr), plongest (len), rw, host_address_to_string (cond), (unsigned long) retval); return retval; } @@ -3727,7 +3727,7 @@ debug_to_stopped_data_address (struct ta static int debug_to_watchpoint_addr_within_range (struct target_ops *target, CORE_ADDR addr, - CORE_ADDR start, int length) + CORE_ADDR start, LONGEST length) { int retval; @@ -3735,9 +3735,9 @@ debug_to_watchpoint_addr_within_range (s start, length); fprintf_filtered (gdb_stdlog, - "target_watchpoint_addr_within_range (%s, %s, %d) = %d\n", + "target_watchpoint_addr_within_range (%s, %s, %s) = %d\n", core_addr_to_string (addr), core_addr_to_string (start), - length, retval); + plongest (length), retval); return retval; } Index: gdb-7.7.90.20140613/gdb/target.h =================================================================== --- gdb-7.7.90.20140613.orig/gdb/target.h 2014-06-13 22:23:54.683492219 +0200 +++ gdb-7.7.90.20140613/gdb/target.h 2014-06-13 22:25:41.372613039 +0200 @@ -469,7 +469,7 @@ struct target_ops int (*to_stopped_data_address) (struct target_ops *, CORE_ADDR *) TARGET_DEFAULT_RETURN (0); int (*to_watchpoint_addr_within_range) (struct target_ops *, - CORE_ADDR, CORE_ADDR, int) + CORE_ADDR, CORE_ADDR, LONGEST) TARGET_DEFAULT_FUNC (default_watchpoint_addr_within_range); /* Documentation of this routine is provided with the corresponding Index: gdb-7.7.90.20140613/gdb/aarch64-linux-nat.c =================================================================== --- gdb-7.7.90.20140613.orig/gdb/aarch64-linux-nat.c 2014-06-13 22:23:09.647440718 +0200 +++ gdb-7.7.90.20140613/gdb/aarch64-linux-nat.c 2014-06-13 22:23:54.683492219 +0200 @@ -428,14 +428,14 @@ aarch64_notify_debug_reg_change (const s static void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state, const char *func, CORE_ADDR addr, - int len, int type) + LONGEST len, int type) { int i; fprintf_unfiltered (gdb_stdlog, "%s", func); if (addr || len) - fprintf_unfiltered (gdb_stdlog, " (addr=0x%08lx, len=%d, type=%s)", - (unsigned long) addr, len, + fprintf_unfiltered (gdb_stdlog, " (addr=0x%08lx, len=%s, type=%s)", + (unsigned long) addr, plongest (len), type == hw_write ? "hw-write-watchpoint" : (type == hw_read ? "hw-read-watchpoint" : (type == hw_access ? "hw-access-watchpoint" @@ -869,9 +869,10 @@ aarch64_linux_read_description (struct t gdbserver/linux-aarch64-low.c for more information. */ static void -aarch64_align_watchpoint (CORE_ADDR addr, int len, CORE_ADDR *aligned_addr_p, +aarch64_align_watchpoint (CORE_ADDR addr, LONGEST len, + CORE_ADDR *aligned_addr_p, int *aligned_len_p, CORE_ADDR *next_addr_p, - int *next_len_p) + LONGEST *next_len_p) { int aligned_len; unsigned int offset; @@ -1038,7 +1039,7 @@ aarch64_point_encode_ctrl_reg (int type, Return 0 for any non-compliant ADDR and/or LEN; return 1 otherwise. */ static int -aarch64_point_is_aligned (int is_watchpoint, CORE_ADDR addr, int len) +aarch64_point_is_aligned (int is_watchpoint, CORE_ADDR addr, LONGEST len) { unsigned int alignment = is_watchpoint ? AARCH64_HWP_ALIGNMENT : AARCH64_HBP_ALIGNMENT; @@ -1290,7 +1291,7 @@ aarch64_handle_aligned_watchpoint (int t Return 0 if succeed. */ static int -aarch64_handle_unaligned_watchpoint (int type, CORE_ADDR addr, int len, +aarch64_handle_unaligned_watchpoint (int type, CORE_ADDR addr, LONGEST len, int is_insert) { struct aarch64_debug_reg_state *state @@ -1315,8 +1316,8 @@ aarch64_handle_unaligned_watchpoint (int fprintf_unfiltered (gdb_stdlog, "handle_unaligned_watchpoint: is_insert: %d\n" " aligned_addr: 0x%08lx, aligned_len: %d\n" -" next_addr: 0x%08lx, next_len: %d\n", - is_insert, aligned_addr, aligned_len, addr, len); +" next_addr: 0x%08lx, next_len: %s\n", + is_insert, aligned_addr, aligned_len, addr, plongest (len)); if (ret != 0) return ret; @@ -1328,7 +1329,7 @@ aarch64_handle_unaligned_watchpoint (int /* Implements insertion and removal of a single watchpoint. */ static int -aarch64_handle_watchpoint (int type, CORE_ADDR addr, int len, int is_insert) +aarch64_handle_watchpoint (int type, CORE_ADDR addr, LONGEST len, int is_insert) { if (aarch64_point_is_aligned (1 /* is_watchpoint */ , addr, len)) return aarch64_handle_aligned_watchpoint (type, addr, len, is_insert); @@ -1497,7 +1498,7 @@ aarch64_linux_stopped_by_watchpoint (str static int aarch64_linux_watchpoint_addr_within_range (struct target_ops *target, CORE_ADDR addr, - CORE_ADDR start, int length) + CORE_ADDR start, LONGEST length) { return start <= addr && start + length - 1 >= addr; } Index: gdb-7.7.90.20140613/gdb/target-delegates.c =================================================================== --- gdb-7.7.90.20140613.orig/gdb/target-delegates.c 2014-06-13 22:22:37.917404611 +0200 +++ gdb-7.7.90.20140613/gdb/target-delegates.c 2014-06-13 22:26:06.092640924 +0200 @@ -261,7 +261,7 @@ tdefault_stopped_data_address (struct ta } static int -delegate_watchpoint_addr_within_range (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, int arg3) +delegate_watchpoint_addr_within_range (struct target_ops *self, CORE_ADDR arg1, CORE_ADDR arg2, LONGEST arg3) { self = self->beneath; return self->to_watchpoint_addr_within_range (self, arg1, arg2, arg3);