Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jiri Smid <smid@suse.cz>
To: gdb-patches@sources.redhat.com
Cc: Eli Zaretskii <eliz@is.elta.co.il>
Subject: Re: [RFA]: x86_64 target - multiarch
Date: Wed, 12 Sep 2001 02:31:00 -0000	[thread overview]
Message-ID: <s8v3d5skb6m.fsf@naga.suse.cz> (raw)
In-Reply-To: <Pine.SUN.3.91.1010911144046.4452D-100000@is>

Eli Zaretskii <eliz@is.elta.co.il> 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   <smid@suse.cz>
	* 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


  reply	other threads:[~2001-09-12  2:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-05  7:02 Jiri Smid
2001-09-05  7:38 ` Eli Zaretskii
2001-09-05 15:31 ` Mark Kettenis
2001-09-05 18:05   ` Andrew Cagney
2001-09-06  0:30   ` Eli Zaretskii
2001-09-11  5:13     ` Jiri Smid
2001-09-11  5:43       ` Eli Zaretskii
2001-09-12  2:31         ` Jiri Smid [this message]
2001-09-05 17:55 ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s8v3d5skb6m.fsf@naga.suse.cz \
    --to=smid@suse.cz \
    --cc=eliz@is.elta.co.il \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox