From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Smid To: gdb-patches@sources.redhat.com Cc: Eli Zaretskii Subject: Re: [RFA]: x86_64 target - multiarch Date: Wed, 12 Sep 2001 02:31:00 -0000 Message-id: References: X-SW-Source: 2001-09/msg00159.html Eli Zaretskii writes: > On 11 Sep 2001, Jiri Smid wrote: > > > *** 466,472 **** > > { > > int retval; > > > > ! if (len == 3 || len > 4 || addr % len != 0) > > retval = i386_handle_nonaligned_watchpoint (WP_INSERT, addr, len, type); > > else > > { > > --- 481,488 ---- > > { > > int retval; > > > > ! if ((len != 1 && len !=2 && len !=4 && (TARGET_HAS_DR_LEN_8 && len !=8)) > > ! || addr % len != 0) > > retval = i386_handle_nonaligned_watchpoint (WP_INSERT, addr, len, type); > > else > > { > > Unless I'm missing something, the new code loses if addr and len both > equal to 3, for a target which does not define TARGET_HAS_DR_LEN_8. I > think this is better: > > if ((len != 1 && len !=2 && len !=4 && !(TARGET_HAS_DR_LEN_8 && len ==8)) > > (There's one more case like this.) > > Other than that, I have no comments. You're right, I only add parentheses to avoid gcc warnings. (also paddr is used instead of %p as recommended by Andrew Cagney) OK to commit now? Index: ChangeLog from Jiri Smid * i386-nat.c (TARGET_HAS_DR_LEN_8, DR_LEN_8): Declare. (i386_length_and_rw_bits, i386_handle_nonaligned_watchpoint, i386_insert_watchpoint, i386_remove_watchpoint): Add support for 8-byte wide watchpoints. (i386_show_dr): Debug message format string change. Index: i386-nat.c =================================================================== RCS file: /cvs/src/src/gdb/i386-nat.c,v retrieving revision 1.3 diff -c -3 -p -r1.3 i386-nat.c *** i386-nat.c 2001/04/18 00:37:49 1.3 --- i386-nat.c 2001/09/12 08:01:19 *************** *** 60,65 **** --- 60,70 ---- #ifdef I386_USE_GENERIC_WATCHPOINTS + /* Support for 8-byte wide hw watchpoints. */ + #ifndef TARGET_HAS_DR_LEN_8 + #define TARGET_HAS_DR_LEN_8 0 + #endif + /* Debug registers' indices. */ #define DR_NADDR 4 /* the number of debug address registers */ #define DR_STATUS 6 /* index of debug status register (DR6) */ *************** *** 89,94 **** --- 94,100 ---- #define DR_LEN_1 (0x0 << 2) /* 1-byte region watch or breakpt */ #define DR_LEN_2 (0x1 << 2) /* 2-byte region watch */ #define DR_LEN_4 (0x3 << 2) /* 4-byte region watch */ + #define DR_LEN_8 (0x2 << 2) /* 8-byte region watch (x86-64) */ /* Local and Global Enable flags in DR7. *************** i386_show_dr (const char *func, CORE_ADD *** 252,260 **** dr_control_mirror, dr_status_mirror); ALL_DEBUG_REGISTERS(i) { ! printf_unfiltered ("\tDR%d: addr=%08lx, ref.count=%d DR%d: addr=%08lx, ref.count=%d\n", ! i, dr_mirror[i], dr_ref_count[i], ! i+1, dr_mirror[i+1], dr_ref_count[i+1]); i++; } } --- 258,266 ---- dr_control_mirror, dr_status_mirror); ALL_DEBUG_REGISTERS(i) { ! printf_unfiltered ("\tDR%d: addr=0x%s, ref.count=%d DR%d: addr=0x%s, ref.count=%d\n", ! i, paddr(dr_mirror[i]), dr_ref_count[i], ! i+1, paddr(dr_mirror[i+1]), dr_ref_count[i+1]); i++; } } *************** Invalid hw breakpoint type %d in i386_le *** 291,302 **** switch (len) { - case 4: - return (DR_LEN_4 | rw); - case 2: - return (DR_LEN_2 | rw); case 1: return (DR_LEN_1 | rw); default: internal_error (__FILE__, __LINE__, "\ Invalid hw breakpoint length %d in i386_length_and_rw_bits.\n", len); --- 297,311 ---- switch (len) { case 1: return (DR_LEN_1 | rw); + case 2: + return (DR_LEN_2 | rw); + case 4: + return (DR_LEN_4 | rw); + case 8: + if (TARGET_HAS_DR_LEN_8) + return (DR_LEN_8 | rw); default: internal_error (__FILE__, __LINE__, "\ Invalid hw breakpoint length %d in i386_length_and_rw_bits.\n", len); *************** i386_handle_nonaligned_watchpoint (i386_ *** 407,426 **** int align; int size; int rv = 0, status = 0; ! static int size_try_array[4][4] = { ! { 1, 1, 1, 1 }, /* trying size one */ ! { 2, 1, 2, 1 }, /* trying size two */ ! { 2, 1, 2, 1 }, /* trying size three */ ! { 4, 1, 2, 1 } /* trying size four */ }; while (len > 0) { ! align = addr % 4; ! /* Four is the maximum length an x86 debug register can watch. */ ! size = size_try_array[len > 4 ? 3 : len - 1][align]; if (what == WP_COUNT) /* size_try_array[] is defined so that each iteration through the loop is guaranteed to produce an address and a size --- 416,441 ---- int align; int size; int rv = 0, status = 0; + int max_wp_len = TARGET_HAS_DR_LEN_8 ? 8 : 4; ! static int size_try_array[8][8] = { ! {1, 1, 1, 1, 1, 1, 1, 1}, /* trying size one */ ! {2, 1, 2, 1, 2, 1, 2, 1}, /* trying size two */ ! {2, 1, 2, 1, 2, 1, 2, 1}, /* trying size three */ ! {4, 1, 2, 1, 4, 1, 2, 1}, /* trying size four */ ! {4, 1, 2, 1, 4, 1, 2, 1}, /* trying size five */ ! {4, 1, 2, 1, 4, 1, 2, 1}, /* trying size six */ ! {4, 1, 2, 1, 4, 1, 2, 1}, /* trying size seven */ ! {8, 1, 2, 1, 4, 1, 2, 1}, /* trying size eight */ }; while (len > 0) { ! align = addr % max_wp_len; ! /* Four(eigth on x86_64) is the maximum length an x86 debug register ! can watch. */ ! size = size_try_array[len > max_wp_len ? (max_wp_len - 1) : len - 1][align]; if (what == WP_COUNT) /* size_try_array[] is defined so that each iteration through the loop is guaranteed to produce an address and a size *************** i386_insert_watchpoint (CORE_ADDR addr, *** 466,472 **** { int retval; ! if (len == 3 || len > 4 || addr % len != 0) retval = i386_handle_nonaligned_watchpoint (WP_INSERT, addr, len, type); else { --- 481,488 ---- { int retval; ! if (((len != 1 && len !=2 && len !=4) && !(TARGET_HAS_DR_LEN_8 && len == 8)) ! || addr % len != 0) retval = i386_handle_nonaligned_watchpoint (WP_INSERT, addr, len, type); else { *************** i386_remove_watchpoint (CORE_ADDR addr, *** 489,495 **** { int retval; ! if (len == 3 || len > 4 || addr % len != 0) retval = i386_handle_nonaligned_watchpoint (WP_REMOVE, addr, len, type); else { --- 505,512 ---- { int retval; ! if (((len != 1 && len !=2 && len !=4) && !(TARGET_HAS_DR_LEN_8 && len == 8)) ! || addr % len != 0) retval = i386_handle_nonaligned_watchpoint (WP_REMOVE, addr, len, type); else { -- Jiri Smid --------------------------------------------------------------------- SuSE CR, s.r.o. e-mail: smid@suse.cz Drahobejlova 27 tel:+420 2 83095 373 190 00 Praha 9 fax:+420 2 83095 374 Ceska republika http://www.suse.cz